@@ -629,7 +629,7 @@ func TestHandler_OwnerNodeAdminCanEnabledValidator(t *testing.T) {
629
629
require .False (t , isFound )
630
630
}
631
631
632
- func TestHandler_TrusteeDisabkedValidatorOwnerNodeAdminCanEnableValidator (t * testing.T ) {
632
+ func TestHandler_TrusteeDisabledValidatorOwnerNodeAdminCanEnableValidator (t * testing.T ) {
633
633
setup := Setup (t )
634
634
635
635
// create Trustees
@@ -651,7 +651,7 @@ func TestHandler_TrusteeDisabkedValidatorOwnerNodeAdminCanEnableValidator(t *tes
651
651
valAddress , err := sdk .ValAddressFromBech32 (testconstants .ValidatorAddress1 )
652
652
require .NoError (t , err )
653
653
654
- // create Trustee and NodeAdmin
654
+ // create NodeAdmin
655
655
ba4 := authtypes .NewBaseAccount (sdk .AccAddress (valAddress ), testconstants .PubKey4 , 0 , 0 )
656
656
account4 := dclauthtypes .NewAccount (ba4 ,
657
657
dclauthtypes.AccountRoles {dclauthtypes .NodeAdmin }, nil , testconstants .VendorID4 )
@@ -676,6 +676,88 @@ func TestHandler_TrusteeDisabkedValidatorOwnerNodeAdminCanEnableValidator(t *tes
676
676
require .False (t , isFound )
677
677
}
678
678
679
+ func TestHandler_OwnerNodeAdminDisabledValidatorAndNodeAdminCanNotAddNewValidator (t * testing.T ) {
680
+ setup := Setup (t )
681
+
682
+ valAddress , err := sdk .ValAddressFromBech32 (testconstants .ValidatorAddress1 )
683
+ require .NoError (t , err )
684
+
685
+ // create NodeAdmin
686
+ ba1 := authtypes .NewBaseAccount (sdk .AccAddress (valAddress ), testconstants .PubKey1 , 0 , 0 )
687
+ account1 := dclauthtypes .NewAccount (ba1 ,
688
+ dclauthtypes.AccountRoles {dclauthtypes .NodeAdmin }, nil , testconstants .VendorID1 )
689
+ setup .DclauthKeeper .SetAccount (setup .Ctx , account1 )
690
+
691
+ // node admin disable validator
692
+ msgDisableValidator := types .NewMsgDisableValidator (valAddress )
693
+ _ , err = setup .Handler (setup .Ctx , msgDisableValidator )
694
+ require .NoError (t , err )
695
+
696
+ msgCreateValidator , err := types .NewMsgCreateValidator (
697
+ valAddress ,
698
+ testconstants .ValidatorPubKey2 ,
699
+ & types.Description {Moniker : testconstants .ProductName },
700
+ )
701
+ require .NoError (t , err )
702
+
703
+ // node admin try to add a new validator
704
+ _ , err = setup .Handler (setup .Ctx , msgCreateValidator )
705
+ require .Error (t , err )
706
+ }
707
+
708
+ func TestHandler_TrusteeDisabledValidatorAndOwnerNodeAdminCanNotAddNewValidator (t * testing.T ) {
709
+ setup := Setup (t )
710
+
711
+ // create Trustees
712
+ ba1 := authtypes .NewBaseAccount (testconstants .Address1 , testconstants .PubKey1 , 0 , 0 )
713
+ account1 := dclauthtypes .NewAccount (ba1 ,
714
+ dclauthtypes.AccountRoles {dclauthtypes .Trustee }, nil , testconstants .VendorID1 )
715
+ setup .DclauthKeeper .SetAccount (setup .Ctx , account1 )
716
+
717
+ ba2 := authtypes .NewBaseAccount (testconstants .Address2 , testconstants .PubKey2 , 0 , 0 )
718
+ account2 := dclauthtypes .NewAccount (ba2 ,
719
+ dclauthtypes.AccountRoles {dclauthtypes .Trustee }, nil , testconstants .VendorID2 )
720
+ setup .DclauthKeeper .SetAccount (setup .Ctx , account2 )
721
+
722
+ ba3 := authtypes .NewBaseAccount (testconstants .Address3 , testconstants .PubKey3 , 0 , 0 )
723
+ account3 := dclauthtypes .NewAccount (ba3 ,
724
+ dclauthtypes.AccountRoles {dclauthtypes .Trustee }, nil , testconstants .VendorID3 )
725
+ setup .DclauthKeeper .SetAccount (setup .Ctx , account3 )
726
+
727
+ valAddress , err := sdk .ValAddressFromBech32 (testconstants .ValidatorAddress1 )
728
+ require .NoError (t , err )
729
+
730
+ // create NodeAdmin
731
+ ba4 := authtypes .NewBaseAccount (sdk .AccAddress (valAddress ), testconstants .PubKey4 , 0 , 0 )
732
+ account4 := dclauthtypes .NewAccount (ba4 ,
733
+ dclauthtypes.AccountRoles {dclauthtypes .NodeAdmin }, nil , testconstants .VendorID4 )
734
+ setup .DclauthKeeper .SetAccount (setup .Ctx , account4 )
735
+
736
+ // propose new disable validator
737
+ msgProposeDisableValidator1 := NewMsgProposeDisableValidator (account1 .GetAddress (), valAddress )
738
+ _ , err = setup .Handler (setup .Ctx , msgProposeDisableValidator1 )
739
+ require .NoError (t , err )
740
+
741
+ // approve new disable validator
742
+ msgProposeDisableValidator2 := NewMsgApproveDisableValidator (account2 .GetAddress (), valAddress )
743
+ _ , err = setup .Handler (setup .Ctx , msgProposeDisableValidator2 )
744
+ require .NoError (t , err )
745
+
746
+ _ , isFound := setup .ValidatorKeeper .GetDisabledValidator (setup .Ctx , valAddress .String ())
747
+ require .True (t , isFound )
748
+
749
+ msgCreateValidator , err := types .NewMsgCreateValidator (
750
+ valAddress ,
751
+ testconstants .ValidatorPubKey2 ,
752
+ & types.Description {Moniker : testconstants .ProductName },
753
+ )
754
+ require .NoError (t , err )
755
+
756
+ // node admin try to add a new validator
757
+ _ , err = setup .Handler (setup .Ctx , msgCreateValidator )
758
+ require .Error (t , err )
759
+ }
760
+
679
761
func NewMsgProposeDisableValidator (signer sdk.AccAddress , address sdk.ValAddress ) * types.MsgProposeDisableValidator {
680
762
return & types.MsgProposeDisableValidator {
681
763
Creator : signer .String (),
0 commit comments