Skip to content

Commit

Permalink
test authz
Browse files Browse the repository at this point in the history
  • Loading branch information
mmsqe committed Dec 5, 2024
1 parent 27b91fd commit d4b0367
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions app/legacy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"encoding/base64"
"testing"

banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
evmenc "github.com/evmos/ethermint/encoding"
"github.com/stretchr/testify/require"
)
Expand All @@ -27,3 +28,25 @@ func TestDecodeLegacyTx(t *testing.T) {
_, err = encodingConfig.TxConfig.TxDecoder()(bz)
require.NoError(t, err)
}

func TestDecodeAuthzLegacyTx(t *testing.T) {
// msg url: /cosmos.authz.v1beta1.MsgGrant
tx := "Cr0BCroBCh4vY29zbW9zLmF1dGh6LnYxYmV0YTEuTXNnR3JhbnQSlwEKKmNyYzF4N3g5cGtmeGYzM2w4N2Z0c3BrNWFldHdua3IwbHZsdjMzNDZjZBIqY3JjMTZ6MGhlcno5OTg5NDZ3cjY1OWxyODRjOGM1NTZkYTU1ZGMzNGhoGj0KOwomL2Nvc21vcy5iYW5rLnYxYmV0YTEuU2VuZEF1dGhvcml6YXRpb24SEQoPCghiYXNldGNybxIDMjAwEl8KVwpPCigvZXRoZXJtaW50LmNyeXB0by52MS5ldGhzZWNwMjU2azEuUHViS2V5EiMKIQNg/r8Tea2PYFq2XE07fpnN97ASePg32cuO4HmUkEGpFBIECgIIARIEEMCaDBpBekTx2LtLIFDODLVr1OqMUR9UYjZBv0KAr8eCacs7jTw/szr3jCvtvHGNraifkLfBEDatH3Rp/wqaNvxXgGjH4gA="

bz, err := base64.StdEncoding.DecodeString(tx)
require.NoError(t, err)

encodingConfig := evmenc.MakeConfig()

_, err = encodingConfig.TxConfig.TxDecoder()(bz)
require.Error(t, err, "")
require.Contains(t, err.Error(), "unable to resolve type URL /cosmos.authz.v1beta1.MsgGrant")

RegisterLegacyCodec(encodingConfig.Amino)
RegisterLegacyInterfaces(encodingConfig.InterfaceRegistry)
banktypes.RegisterLegacyAminoCodec(encodingConfig.Amino)
banktypes.RegisterInterfaces(encodingConfig.InterfaceRegistry)

_, err = encodingConfig.TxConfig.TxDecoder()(bz)
require.NoError(t, err)
}

0 comments on commit d4b0367

Please sign in to comment.