From d4f52652ac636336069f60f64235ebdd6b9b93a9 Mon Sep 17 00:00:00 2001 From: mmsqe Date: Mon, 14 Oct 2024 17:13:50 +0800 Subject: [PATCH] fix test --- tests/go.mod | 1 + .../tx/aminojson/aminojson_test.go | 30 ++++++++++++++----- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/tests/go.mod b/tests/go.mod index 78f711884c42..d9c660a2b8f4 100644 --- a/tests/go.mod +++ b/tests/go.mod @@ -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 ) diff --git a/tests/integration/tx/aminojson/aminojson_test.go b/tests/integration/tx/aminojson/aminojson_test.go index eb271308f8d6..6d9859db7ac3 100644 --- a/tests/integration/tx/aminojson/aminojson_test.go +++ b/tests/integration/tx/aminojson/aminojson_test.go @@ -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 @@ -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{}, }, @@ -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) @@ -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