-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add msg for permanent locked vesting accounts #11019
Changes from 4 commits
df23e67
8167c65
347e635
6044190
1bb094f
6abd6f9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -146,3 +146,82 @@ func (s *IntegrationTestSuite) TestNewMsgCreateVestingAccountCmd() { | |||||||||
s.T().Logf("Height now: %d", height) | ||||||||||
} | ||||||||||
} | ||||||||||
|
||||||||||
func (s *IntegrationTestSuite) TestNewMsgCreatePermanentLockedAccountCmd() { | ||||||||||
val := s.network.Validators[0] | ||||||||||
|
||||||||||
testCases := map[string]struct { | ||||||||||
args []string | ||||||||||
expectErr bool | ||||||||||
expectedCode uint32 | ||||||||||
respType proto.Message | ||||||||||
}{ | ||||||||||
"create a permanent locked account": { | ||||||||||
args: []string{ | ||||||||||
sdk.AccAddress("addr4_______________").String(), | ||||||||||
sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String(), | ||||||||||
fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address), | ||||||||||
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), | ||||||||||
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), | ||||||||||
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), | ||||||||||
}, | ||||||||||
expectErr: false, | ||||||||||
expectedCode: 0, | ||||||||||
respType: &sdk.TxResponse{}, | ||||||||||
}, | ||||||||||
"invalid address": { | ||||||||||
args: []string{ | ||||||||||
"addr4", | ||||||||||
sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String(), | ||||||||||
"4070908800", | ||||||||||
fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address), | ||||||||||
}, | ||||||||||
expectErr: true, | ||||||||||
expectedCode: 0, | ||||||||||
respType: &sdk.TxResponse{}, | ||||||||||
}, | ||||||||||
"invalid coins": { | ||||||||||
args: []string{ | ||||||||||
sdk.AccAddress("addr4_______________").String(), | ||||||||||
"fooo", | ||||||||||
"4070908800", | ||||||||||
fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address), | ||||||||||
}, | ||||||||||
expectErr: true, | ||||||||||
expectedCode: 0, | ||||||||||
respType: &sdk.TxResponse{}, | ||||||||||
}, | ||||||||||
} | ||||||||||
|
||||||||||
// Synchronize height between test runs, to ensure sequence numbers are | ||||||||||
// properly updated. | ||||||||||
height, err := s.network.LatestHeight() | ||||||||||
if err != nil { | ||||||||||
s.T().Fatalf("Getting initial latest height: %v", err) | ||||||||||
} | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
s.T().Logf("Initial latest height: %d", height) | ||||||||||
for name, tc := range testCases { | ||||||||||
tc := tc | ||||||||||
|
||||||||||
s.Run(name, func() { | ||||||||||
clientCtx := val.ClientCtx | ||||||||||
|
||||||||||
bw, err := clitestutil.ExecTestCLICmd(clientCtx, cli.NewMsgCreatePermanentLockedAccountCmd(), tc.args) | ||||||||||
if tc.expectErr { | ||||||||||
s.Require().Error(err) | ||||||||||
} else { | ||||||||||
s.Require().NoError(err) | ||||||||||
s.Require().NoError(clientCtx.Codec.UnmarshalJSON(bw.Bytes(), tc.respType), bw.String()) | ||||||||||
|
||||||||||
txResp := tc.respType.(*sdk.TxResponse) | ||||||||||
s.Require().Equal(tc.expectedCode, txResp.Code) | ||||||||||
} | ||||||||||
}) | ||||||||||
next, err := s.network.WaitForHeight(height + 1) | ||||||||||
if err != nil { | ||||||||||
s.T().Fatalf("Waiting for height %d: %v", height+1, err) | ||||||||||
} | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. as above, let's use require |
||||||||||
height = next | ||||||||||
s.T().Logf("Height now: %d", height) | ||||||||||
} | ||||||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,8 @@ func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { | |
cdc.RegisterConcrete(&DelayedVestingAccount{}, "cosmos-sdk/DelayedVestingAccount", nil) | ||
cdc.RegisterConcrete(&PeriodicVestingAccount{}, "cosmos-sdk/PeriodicVestingAccount", nil) | ||
cdc.RegisterConcrete(&PermanentLockedAccount{}, "cosmos-sdk/PermanentLockedAccount", nil) | ||
cdc.RegisterConcrete(&MsgCreateVestingAccount{}, "cosmos-sdk/MsgCreateVestingAccount", nil) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this line mean there is no Amino JSON signing support for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hmm, I think it would still work in 0.44 and 0.45, but be shown without the |
||
cdc.RegisterConcrete(&MsgCreatePermanentLockedAccount{}, "cosmos-sdk/MsgCreatePermLockedAccount", nil) | ||
} | ||
|
||
// RegisterInterface associates protoName with AccountI and VestingAccount | ||
|
@@ -53,6 +55,7 @@ func RegisterInterfaces(registry types.InterfaceRegistry) { | |
registry.RegisterImplementations( | ||
(*sdk.Msg)(nil), | ||
&MsgCreateVestingAccount{}, | ||
&MsgCreatePermanentLockedAccount{}, | ||
) | ||
|
||
msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should also add a state-machine breaking one