feat: Add amino support for x/authz and x/feegrant (#9457)
* add amino for authz * Add amion for feegrant * add cl * Remove protoCdc from simulations * Update x/authz/client/testutil/tx.go Co-authored-by: likhita-809 <78951027+likhita-809@users.noreply.github.com> * Address reviews Co-authored-by: likhita-809 <78951027+likhita-809@users.noreply.github.com>
This commit is contained in:
@@ -59,6 +59,22 @@ func (s *IntegrationTestSuite) SetupSuite() {
|
||||
granter := val.Address
|
||||
grantee := s.network.Validators[1].Address
|
||||
|
||||
s.createGrant(granter, grantee)
|
||||
|
||||
grant, err := feegrant.NewGrant(granter, grantee, &feegrant.BasicAllowance{
|
||||
SpendLimit: sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(100))),
|
||||
})
|
||||
s.Require().NoError(err)
|
||||
|
||||
s.addedGrant = grant
|
||||
s.addedGranter = granter
|
||||
s.addedGrantee = grantee
|
||||
}
|
||||
|
||||
// createGrant creates a new basic allowance fee grant from granter to grantee.
|
||||
func (s *IntegrationTestSuite) createGrant(granter, grantee sdk.Address) {
|
||||
val := s.network.Validators[0]
|
||||
|
||||
clientCtx := val.ClientCtx
|
||||
commonFlags := []string{
|
||||
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
||||
@@ -81,20 +97,10 @@ func (s *IntegrationTestSuite) SetupSuite() {
|
||||
|
||||
cmd := cli.NewCmdFeeGrant()
|
||||
|
||||
_, err = clitestutil.ExecTestCLICmd(clientCtx, cmd, args)
|
||||
_, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, args)
|
||||
s.Require().NoError(err)
|
||||
_, err = s.network.WaitForHeight(1)
|
||||
s.Require().NoError(err)
|
||||
|
||||
s.addedGranter = granter
|
||||
s.addedGrantee = grantee
|
||||
|
||||
grant, err := feegrant.NewGrant(granter, grantee, &feegrant.BasicAllowance{
|
||||
SpendLimit: sdk.NewCoins(fee),
|
||||
})
|
||||
s.Require().NoError(err)
|
||||
|
||||
s.addedGrant = grant
|
||||
}
|
||||
|
||||
func (s *IntegrationTestSuite) TearDownSuite() {
|
||||
@@ -302,6 +308,20 @@ func (s *IntegrationTestSuite) TestNewCmdFeeGrant() {
|
||||
),
|
||||
false, 0, &sdk.TxResponse{},
|
||||
},
|
||||
{
|
||||
"valid basic fee grant with amino",
|
||||
append(
|
||||
[]string{
|
||||
granter.String(),
|
||||
"cosmos1v57fx2l2rt6ehujuu99u2fw05779m5e2ux4z2h",
|
||||
fmt.Sprintf("--%s=%s", cli.FlagSpendLimit, "100stake"),
|
||||
fmt.Sprintf("--%s=%s", flags.FlagFrom, granter),
|
||||
fmt.Sprintf("--%s=%s", flags.FlagSignMode, flags.SignModeLegacyAminoJSON),
|
||||
},
|
||||
commonFlags...,
|
||||
),
|
||||
false, 0, &sdk.TxResponse{},
|
||||
},
|
||||
{
|
||||
"valid basic fee grant without spend limit",
|
||||
append(
|
||||
@@ -507,6 +527,11 @@ func (s *IntegrationTestSuite) TestNewCmdRevokeFeegrant() {
|
||||
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
||||
}
|
||||
|
||||
// Create new fee grant specifically to test amino.
|
||||
aminoGrantee, err := sdk.AccAddressFromBech32("cosmos16ydaqh0fcnh4qt7a3jme4mmztm2qel5axcpw00")
|
||||
s.Require().NoError(err)
|
||||
s.createGrant(granter, aminoGrantee)
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
args []string
|
||||
@@ -562,6 +587,19 @@ func (s *IntegrationTestSuite) TestNewCmdRevokeFeegrant() {
|
||||
),
|
||||
false, 0, &sdk.TxResponse{},
|
||||
},
|
||||
{
|
||||
"Valid revoke with amino",
|
||||
append(
|
||||
[]string{
|
||||
granter.String(),
|
||||
aminoGrantee.String(),
|
||||
fmt.Sprintf("--%s=%s", flags.FlagFrom, granter),
|
||||
fmt.Sprintf("--%s=%s", flags.FlagSignMode, flags.SignModeLegacyAminoJSON),
|
||||
},
|
||||
commonFlags...,
|
||||
),
|
||||
false, 0, &sdk.TxResponse{},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
|
||||
Reference in New Issue
Block a user