diff --git a/CHANGELOG.md b/CHANGELOG.md index 2ec5ae2374..6b0b0fb2df 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -79,6 +79,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (x/fswap) [\#1379](https://github.com/Finschia/finschia-sdk/pull/1379) add missing router registration * (x/fswap, x/fbridge) [\#1380](https://github.com/Finschia/finschia-sdk/pull/1380) Fix bug where amino is not supported in fswap and fbridge (backport #1378) * (x/fswap) [\#1385](https://github.com/Finschia/finschia-sdk/pull/1385) add accidentally deleted event emissions(EventSetSwap, EventAddDenomMetadata) +* (x/fswap) [\#1392](https://github.com/Finschia/finschia-sdk/pull/1392) fix dummy denom coin data for test in fswap ### Removed diff --git a/x/fswap/keeper/grpc_query_test.go b/x/fswap/keeper/grpc_query_test.go index b0c02d7f2e..d947121578 100644 --- a/x/fswap/keeper/grpc_query_test.go +++ b/x/fswap/keeper/grpc_query_test.go @@ -57,13 +57,15 @@ func (s *FSwapQueryTestSuite) SetupTest() { s.toDenomMetadata = bank.Metadata{ Description: "This is metadata for to-coin", DenomUnits: []*bank.DenomUnit{ - {Denom: s.swap.ToDenom, Exponent: 0}, + {Denom: s.toDenom, Exponent: 0}, }, Base: s.toDenom, - Display: "dummycoin", + Display: s.toDenom, Name: "DUMMY", Symbol: "DUM", } + err = s.toDenomMetadata.Validate() + s.Require().NoError(err) fromDenom := bank.Metadata{ Description: "This is metadata for from-coin", @@ -71,10 +73,13 @@ func (s *FSwapQueryTestSuite) SetupTest() { {Denom: s.fromDenom, Exponent: 0}, }, Base: s.fromDenom, - Display: "fromcoin", + Display: s.fromDenom, Name: "FROM", Symbol: "FROM", } + err = fromDenom.Validate() + s.Require().NoError(err) + s.app.BankKeeper.SetDenomMetaData(s.ctx, fromDenom) err = s.keeper.SetSwap(s.ctx, s.swap, s.toDenomMetadata) s.Require().NoError(err) diff --git a/x/fswap/keeper/keeper_test.go b/x/fswap/keeper/keeper_test.go index 4d3b68eb06..1ebffa116a 100644 --- a/x/fswap/keeper/keeper_test.go +++ b/x/fswap/keeper/keeper_test.go @@ -89,21 +89,27 @@ func (s *KeeperTestSuite) SetupTest() { DenomUnits: []*bank.DenomUnit{ {Denom: s.swap.ToDenom, Exponent: 0}, }, - Base: "todenom", - Display: "todenomcoin", + Base: s.swap.ToDenom, + Display: s.swap.ToDenom, Name: "DUMMY", Symbol: "DUM", } + err = s.toDenomMetadata.Validate() + s.Require().NoError(err) + fromDenom := bank.Metadata{ Description: "This is metadata for from-coin", DenomUnits: []*bank.DenomUnit{ - {Denom: "fromdenom", Exponent: 0}, + {Denom: s.swap.FromDenom, Exponent: 0}, }, - Base: "fromdenom", - Display: "fromdenomcoin", - Name: "DUMMY", - Symbol: "DUM", + Base: s.swap.FromDenom, + Display: s.swap.FromDenom, + Name: "FROM", + Symbol: "FROM", } + err = fromDenom.Validate() + s.Require().NoError(err) + app.BankKeeper.SetDenomMetaData(s.ctx, fromDenom) s.createAccountsWithInitBalance(app) app.AccountKeeper.GetModuleAccount(s.ctx, types.ModuleName) @@ -298,7 +304,7 @@ func (s *KeeperTestSuite) TestSetSwap() { Attributes: []abci.EventAttribute{ { Key: []byte("metadata"), - Value: []uint8{0x7b, 0x22, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x3a, 0x22, 0x54, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x74, 0x6f, 0x2d, 0x63, 0x6f, 0x69, 0x6e, 0x22, 0x2c, 0x22, 0x64, 0x65, 0x6e, 0x6f, 0x6d, 0x5f, 0x75, 0x6e, 0x69, 0x74, 0x73, 0x22, 0x3a, 0x5b, 0x7b, 0x22, 0x64, 0x65, 0x6e, 0x6f, 0x6d, 0x22, 0x3a, 0x22, 0x74, 0x6f, 0x64, 0x65, 0x6e, 0x6f, 0x6d, 0x22, 0x2c, 0x22, 0x65, 0x78, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x22, 0x3a, 0x30, 0x2c, 0x22, 0x61, 0x6c, 0x69, 0x61, 0x73, 0x65, 0x73, 0x22, 0x3a, 0x5b, 0x5d, 0x7d, 0x5d, 0x2c, 0x22, 0x62, 0x61, 0x73, 0x65, 0x22, 0x3a, 0x22, 0x74, 0x6f, 0x64, 0x65, 0x6e, 0x6f, 0x6d, 0x22, 0x2c, 0x22, 0x64, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x22, 0x3a, 0x22, 0x74, 0x6f, 0x64, 0x65, 0x6e, 0x6f, 0x6d, 0x63, 0x6f, 0x69, 0x6e, 0x22, 0x2c, 0x22, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x3a, 0x22, 0x44, 0x55, 0x4d, 0x4d, 0x59, 0x22, 0x2c, 0x22, 0x73, 0x79, 0x6d, 0x62, 0x6f, 0x6c, 0x22, 0x3a, 0x22, 0x44, 0x55, 0x4d, 0x22, 0x7d}, + Value: []uint8{0x7b, 0x22, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x3a, 0x22, 0x54, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x74, 0x6f, 0x2d, 0x63, 0x6f, 0x69, 0x6e, 0x22, 0x2c, 0x22, 0x64, 0x65, 0x6e, 0x6f, 0x6d, 0x5f, 0x75, 0x6e, 0x69, 0x74, 0x73, 0x22, 0x3a, 0x5b, 0x7b, 0x22, 0x64, 0x65, 0x6e, 0x6f, 0x6d, 0x22, 0x3a, 0x22, 0x74, 0x6f, 0x64, 0x65, 0x6e, 0x6f, 0x6d, 0x22, 0x2c, 0x22, 0x65, 0x78, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x22, 0x3a, 0x30, 0x2c, 0x22, 0x61, 0x6c, 0x69, 0x61, 0x73, 0x65, 0x73, 0x22, 0x3a, 0x5b, 0x5d, 0x7d, 0x5d, 0x2c, 0x22, 0x62, 0x61, 0x73, 0x65, 0x22, 0x3a, 0x22, 0x74, 0x6f, 0x64, 0x65, 0x6e, 0x6f, 0x6d, 0x22, 0x2c, 0x22, 0x64, 0x69, 0x73, 0x70, 0x6c, 0x61, 0x79, 0x22, 0x3a, 0x22, 0x74, 0x6f, 0x64, 0x65, 0x6e, 0x6f, 0x6d, 0x22, 0x2c, 0x22, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x3a, 0x22, 0x44, 0x55, 0x4d, 0x4d, 0x59, 0x22, 0x2c, 0x22, 0x73, 0x79, 0x6d, 0x62, 0x6f, 0x6c, 0x22, 0x3a, 0x22, 0x44, 0x55, 0x4d, 0x22, 0x7d}, Index: false, }, }, @@ -356,7 +362,7 @@ func (s *KeeperTestSuite) TestSetSwap() { Description: s.toDenomMetadata.Description, DenomUnits: s.toDenomMetadata.DenomUnits, Base: "change", - Display: s.toDenomMetadata.Display, + Display: "change", Name: s.toDenomMetadata.Name, Symbol: s.toDenomMetadata.Symbol, }, diff --git a/x/fswap/types/msgs_test.go b/x/fswap/types/msgs_test.go index eb5611f858..e3dd86b7dd 100644 --- a/x/fswap/types/msgs_test.go +++ b/x/fswap/types/msgs_test.go @@ -65,13 +65,13 @@ func TestAminoJSON(t *testing.T) { }, }, Base: "kaia", - Display: "KAIA", + Display: "kaia", Name: "Kaia", Symbol: "KAIA", }, }, "/lbm.fswap.v1.MsgSetSwap", - "{\"account_number\":\"1\",\"chain_id\":\"foo\",\"fee\":{\"amount\":[],\"gas\":\"0\"},\"memo\":\"memo\",\"msgs\":[{\"type\":\"lbm-sdk/MsgSetSwap\",\"value\":{\"authority\":\"link15sdc7wdajsps42fky3j6mnvr4tj9fv6w3hkqkj\",\"swap\":{\"amount_cap_for_to_denom\":\"1000000000000000\",\"from_denom\":\"cony\",\"swap_rate\":\"148.079656000000000000\",\"to_denom\":\"pdt\"},\"to_denom_metadata\":{\"base\":\"kaia\",\"denom_units\":[{\"denom\":\"kaia\"}],\"description\":\"test\",\"display\":\"KAIA\",\"name\":\"Kaia\",\"symbol\":\"KAIA\"}}}],\"sequence\":\"1\",\"timeout_height\":\"1\"}", + "{\"account_number\":\"1\",\"chain_id\":\"foo\",\"fee\":{\"amount\":[],\"gas\":\"0\"},\"memo\":\"memo\",\"msgs\":[{\"type\":\"lbm-sdk/MsgSetSwap\",\"value\":{\"authority\":\"link15sdc7wdajsps42fky3j6mnvr4tj9fv6w3hkqkj\",\"swap\":{\"amount_cap_for_to_denom\":\"1000000000000000\",\"from_denom\":\"cony\",\"swap_rate\":\"148.079656000000000000\",\"to_denom\":\"pdt\"},\"to_denom_metadata\":{\"base\":\"kaia\",\"denom_units\":[{\"denom\":\"kaia\"}],\"description\":\"test\",\"display\":\"kaia\",\"name\":\"Kaia\",\"symbol\":\"KAIA\"}}}],\"sequence\":\"1\",\"timeout_height\":\"1\"}", }, }