From 6ca08db5f511eba256fad9ae0e61977bb3789365 Mon Sep 17 00:00:00 2001 From: 170210 <85928898+170210@users.noreply.github.com> Date: Thu, 23 May 2024 10:55:34 +0900 Subject: [PATCH] chore: fix dummy denom coin data for test in fswap (#1392) * fix: fix dummy denom coin data for test in fswap Signed-off-by: 170210 * chore: update CHANGLOG.md Signed-off-by: 170210 * fix: fix failed test Signed-off-by: 170210 --------- Signed-off-by: 170210 --- CHANGELOG.md | 1 + x/fswap/keeper/grpc_query_test.go | 11 ++++++++--- x/fswap/keeper/keeper_test.go | 24 +++++++++++++++--------- x/fswap/types/msgs_test.go | 4 ++-- 4 files changed, 26 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2003eab02e..b17d42b3bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -92,6 +92,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (x/fswap, x/fbridge) [\#1378](https://github.com/Finschia/finschia-sdk/pull/1378) Fix bug where amino is not supported in fswap and fbridge * (x/fswap) [\#1379](https://github.com/Finschia/finschia-sdk/pull/1379) add missing router registration * (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\"}", }, }