Skip to content
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

Add MsgRevoke to ICS20 Authz test #2997

Merged
35 changes: 35 additions & 0 deletions e2e/tests/transfer/authz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,41 @@ func (suite *AuthzTransferTestSuite) TestAuthz_MsgTransfer_Succeeds() {

t.Run("granter grant was reinitialized", verifyGrantFn(testvalues.StartingTokenAmount))

t.Run("revoke access", func(t *testing.T) {
msgRevoke := authz.MsgRevoke{
Granter: granterAddress,
Grantee: granteeAddress,
MsgTypeUrl: transfertypes.TransferAuthorization{}.MsgTypeURL(),
}

resp, err := suite.BroadcastMessages(context.TODO(), chainA, granterWallet, &msgRevoke)
suite.AssertValidTxResponse(resp)
suite.Require().NoError(err)
})

t.Run("exec unauthorized MsgTransfer", func(t *testing.T) {
transferMsg := transfertypes.MsgTransfer{
SourcePort: channelA.PortID,
SourceChannel: channelA.ChannelID,
Token: testvalues.DefaultTransferAmount(chainADenom),
Sender: granterAddress,
Receiver: receiverWalletAddress,
TimeoutHeight: suite.GetTimeoutHeight(ctx, chainB),
}

transferAny, err := codectypes.NewAnyWithValue(&transferMsg)
suite.Require().NoError(err)

msgExec := &authz.MsgExec{
Grantee: granteeAddress,
Msgs: []*codectypes.Any{transferAny},
}

resp, err := suite.BroadcastMessages(context.TODO(), chainA, granteeWallet, msgExec)
suite.Require().NotEqual(0, resp.Code)
suite.Require().Contains(resp.RawLog, authz.ErrNoAuthorizationFound.Error())
suite.Require().NoError(err)
})
}

// extractTransferAuthorizationFromGrantAuthorization extracts a TransferAuthorization from the given
Expand Down