Skip to content

Commit

Permalink
chore: fix dummy denom coin data for test in fswap (#1392) (#1398)
Browse files Browse the repository at this point in the history
* fix: fix dummy denom coin data for test in fswap

Signed-off-by: 170210 <[email protected]>

* chore: update CHANGLOG.md

Signed-off-by: 170210 <[email protected]>

* fix: fix failed test

Signed-off-by: 170210 <[email protected]>

---------

Signed-off-by: 170210 <[email protected]>
(cherry picked from commit 6ca08db)

Co-authored-by: 170210 <[email protected]>
  • Loading branch information
mergify[bot] and 170210 authored May 24, 2024
1 parent 98d243f commit ecea330
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 14 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
11 changes: 8 additions & 3 deletions x/fswap/keeper/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,24 +57,29 @@ 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",
DenomUnits: []*bank.DenomUnit{
{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)
Expand Down
24 changes: 15 additions & 9 deletions x/fswap/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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,
},
},
Expand Down Expand Up @@ -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,
},
Expand Down
4 changes: 2 additions & 2 deletions x/fswap/types/msgs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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\"}",
},
}

Expand Down

0 comments on commit ecea330

Please sign in to comment.