Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
mmsqe committed Oct 14, 2024
1 parent 98e9a10 commit d4f5265
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
1 change: 1 addition & 0 deletions tests/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -214,4 +214,5 @@ replace (
// Fix upstream GHSA-h395-qcrw-5vmq and GHSA-3vp4-m3rf-835h vulnerabilities.
// TODO Remove it: https://github.com/cosmos/cosmos-sdk/issues/10409
github.com/gin-gonic/gin => github.com/gin-gonic/gin v1.9.1
cosmossdk.io/x/tx => ../x/tx
)
30 changes: 23 additions & 7 deletions tests/integration/tx/aminojson/aminojson_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,12 @@ func TestAminoJSON_Equivalence(t *testing.T) {

legacyAminoJSON, err := encCfg.Amino.MarshalJSON(gogo)
require.NoError(t, err)
legacyAminoJSON, err = types.SortJSON(legacyAminoJSON)
require.NoError(t, err)
aminoJSON, err := aj.Marshal(msg)
require.NoError(t, err)
aminoJSON, err = types.SortJSON(aminoJSON)
require.NoError(t, err)
require.Equal(t, string(legacyAminoJSON), string(aminoJSON))

// test amino json signer handler equivalence
Expand Down Expand Up @@ -224,7 +228,15 @@ func TestAminoJSON_LegacyParity(t *testing.T) {
protoUnmarshalFails bool
}{
"auth/params": {gogo: &authtypes.Params{TxSigLimit: 10}, pulsar: &authapi.Params{TxSigLimit: 10}},
"auth/module_account": {
"auth/module_account_nil_permissions": {
gogo: &authtypes.ModuleAccount{
BaseAccount: authtypes.NewBaseAccountWithAddress(addr1),
},
pulsar: &authapi.ModuleAccount{
BaseAccount: &authapi.BaseAccount{Address: addr1.String()},
},
},
"auth/module_account_empty_permissions": {
gogo: &authtypes.ModuleAccount{
BaseAccount: authtypes.NewBaseAccountWithAddress(addr1), Permissions: []string{},
},
Expand Down Expand Up @@ -407,16 +419,22 @@ func TestAminoJSON_LegacyParity(t *testing.T) {
t.Run(name, func(t *testing.T) {
gogoBytes, err := encCfg.Amino.MarshalJSON(tc.gogo)
require.NoError(t, err)

gogoBytes, err = types.SortJSON(gogoBytes)
require.NoError(t, err)
pulsarBytes, err := aj.Marshal(tc.pulsar)
if tc.pulsarMarshalFails {
require.Error(t, err)
return
}
require.NoError(t, err)

pulsarBytes, err = types.SortJSON(pulsarBytes)
require.NoError(t, err)
fmt.Printf("pulsar: %s\n", string(pulsarBytes))
fmt.Printf(" gogo: %s\n", string(gogoBytes))
if tc.roundTripUnequal {
require.NotEqual(t, string(gogoBytes), string(pulsarBytes))
return
}
require.Equal(t, string(gogoBytes), string(pulsarBytes))

pulsarProtoBytes, err := proto.Marshal(tc.pulsar)
Expand All @@ -434,10 +452,8 @@ func TestAminoJSON_LegacyParity(t *testing.T) {

newGogoBytes, err := encCfg.Amino.MarshalJSON(newGogo)
require.NoError(t, err)
if tc.roundTripUnequal {
require.NotEqual(t, string(gogoBytes), string(newGogoBytes))
return
}
newGogoBytes, err = types.SortJSON(newGogoBytes)
require.NoError(t, err)
require.Equal(t, string(gogoBytes), string(newGogoBytes))

// test amino json signer handler equivalence
Expand Down

0 comments on commit d4f5265

Please sign in to comment.