Skip to content

Commit

Permalink
fix(x/photon): wrong codec for GetSignBytes
Browse files Browse the repository at this point in the history
  • Loading branch information
tbruyelle committed Jan 10, 2025
1 parent 066d7db commit 309ccbe
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
2 changes: 1 addition & 1 deletion x/photon/types/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func RegisterInterfaces(registry cdctypes.InterfaceRegistry) {

var (
amino = codec.NewLegacyAmino()
ModuleCdc = codec.NewProtoCodec(cdctypes.NewInterfaceRegistry())
ModuleCdc = codec.NewAminoCodec(amino)
)

func init() {
Expand Down
45 changes: 45 additions & 0 deletions x/photon/types/msgs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,48 @@ func TestMsgMintPhoton_ValidateBasic(t *testing.T) {
})
}
}

func TestMsgMintPhoton_GetSignBytes(t *testing.T) {
msg := MsgMintPhoton{
ToAddress: "my_addr",
Amount: sdk.NewInt64Coin("uatone", 1),
}

bz := msg.GetSignBytes()

expectedSignedBytes := `{
"type": "atomone/photon/v1/MsgMintPhoton",
"value": {
"amount": {
"amount":"1",
"denom": "uatone"
},
"to_address": "my_addr"
}
}`
require.JSONEq(t, expectedSignedBytes, string(bz))
}

func TestMsgUpdateParams_GetSignBytes(t *testing.T) {
msg := MsgUpdateParams{
Authority: "authority",
Params: Params{
MintDisabled: true,
TxFeeExceptions: []string{"tx1", "tx2"},
},
}

bz := msg.GetSignBytes()

expectedSignedBytes := `{
"type": "atomone/x/photon/v1/MsgUpdateParams",
"value": {
"authority":"authority",
"params": {
"mint_disabled":true,
"tx_fee_exceptions": ["tx1","tx2"]
}
}
}`
require.JSONEq(t, expectedSignedBytes, string(bz))
}

0 comments on commit 309ccbe

Please sign in to comment.