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

fix(x/tx): fix amino json drift from legacy spec #21825

Merged
merged 20 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix test spec
  • Loading branch information
kocubinski committed Sep 20, 2024
commit 62f47d87652281cbda769dc637014b741efbb322
4 changes: 2 additions & 2 deletions tests/integration/tx/aminojson/aminojson_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -341,8 +341,8 @@ func TestAminoJSON_LegacyParity(t *testing.T) {
dynamicBytes, err := aj.Marshal(fixture.DynamicMessage(t, tc.gogo))
require.NoError(t, err)

fmt.Printf("legacy: %s\n", string(legacyBytes))
fmt.Printf(" sut: %s\n", string(dynamicBytes))
t.Logf("legacy: %s\n", string(legacyBytes))
t.Logf(" sut: %s\n", string(dynamicBytes))
if tc.fails {
require.NotEqual(t, string(legacyBytes), string(dynamicBytes))
return
Expand Down
7 changes: 6 additions & 1 deletion tests/integration/tx/context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"cosmossdk.io/depinject"
"cosmossdk.io/log"
_ "cosmossdk.io/x/accounts"
"cosmossdk.io/x/tx/signing"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/tests/integration/tx/internal"
"github.com/cosmos/cosmos-sdk/tests/integration/tx/internal/pulsar/testpb"
Expand All @@ -14,6 +15,10 @@ import (
"github.com/stretchr/testify/require"
)

func ProvideCustomGetSigner() signing.CustomGetSigner {
return internal.TestRepeatedFieldsSigner
}

func TestDefineCustomGetSigners(t *testing.T) {
var interfaceRegistry codectypes.InterfaceRegistry
_, err := simtestutil.SetupAtGenesis(
Expand All @@ -26,7 +31,7 @@ func TestDefineCustomGetSigners(t *testing.T) {
configurator.ConsensusModule(),
),
depinject.Supply(log.NewNopLogger()),
depinject.Provide(internal.ProvideCustomGetSigner),
depinject.Provide(ProvideCustomGetSigner),
),
&interfaceRegistry,
)
Expand Down
20 changes: 9 additions & 11 deletions tests/integration/tx/internal/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,14 @@ import (
gogoproto "github.com/cosmos/gogoproto/proto"
)

func ProvideCustomGetSigner() signing.CustomGetSigner {
return signing.CustomGetSigner{
MsgType: proto.MessageName(&testpb.TestRepeatedFields{}),
Fn: func(msg proto.Message) ([][]byte, error) {
testMsg := msg.(*testpb.TestRepeatedFields)
// arbitrary logic
signer := testMsg.NullableDontOmitempty[1].Value
return [][]byte{[]byte(signer)}, nil
},
}
var TestRepeatedFieldsSigner = signing.CustomGetSigner{
MsgType: proto.MessageName(&testpb.TestRepeatedFields{}),
Fn: func(msg proto.Message) ([][]byte, error) {
testMsg := msg.(*testpb.TestRepeatedFields)
// arbitrary logic
signer := testMsg.NullableDontOmitempty[1].Value
return [][]byte{[]byte(signer)}, nil
},
}

type noOpAddressCodec struct{}
Expand Down Expand Up @@ -71,7 +69,7 @@ func NewSigningFixture(
t.Helper()
// set up transaction and signing infra
addressCodec, valAddressCodec := noOpAddressCodec{}, noOpAddressCodec{}
customGetSigners := []signing.CustomGetSigner{ProvideCustomGetSigner()}
customGetSigners := []signing.CustomGetSigner{TestRepeatedFieldsSigner}
interfaceRegistry, _, err := codec.ProvideInterfaceRegistry(
addressCodec,
valAddressCodec,
Expand Down
2 changes: 1 addition & 1 deletion x/auth/migrations/legacytx/stdtx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func TestStdSignBytes(t *testing.T) {
Amount: []*basev1beta1.Coin{{Denom: "atom", Amount: "150"}},
GasLimit: 100000,
}
msgStr := fmt.Sprintf(`{"type":"testpb/TestMsg","value":{"decField":"0","signers":["%s"]}}`, addr)
msgStr := fmt.Sprintf(`{"type":"testpb/TestMsg","value":{"decField":"0.000000000000000000","signers":["%s"]}}`, addr)
tests := []struct {
name string
args args
Expand Down
Loading