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

Parse memo before looking up hash #501

Merged
merged 3 commits into from
Jul 13, 2023
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
2 changes: 0 additions & 2 deletions x/interchainstaking/keeper/ibc_packet_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,6 @@ func (k *Keeper) HandleWithdrawForUser(ctx sdk.Context, zone *types.Zone, msg *b
// if we can't burn the coins, fail.
return err
}
k.SetWithdrawalRecord(ctx, withdrawalRecord)
k.Logger(ctx).Info("burned coins post-withdrawal", "coins", withdrawalRecord.BurnAmount)
} else {

Expand All @@ -457,7 +456,6 @@ func (k *Keeper) HandleWithdrawForUser(ctx sdk.Context, zone *types.Zone, msg *b
// if we can't burn the coins, fail.
return err
}
k.SetWithdrawalRecord(ctx, withdrawalRecord)
k.Logger(ctx).Info("burned coins post-withdrawal", "coins", withdrawalRecord.BurnAmount)
}
break
Expand Down
18 changes: 9 additions & 9 deletions x/interchainstaking/keeper/ibc_packet_handlers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ func (suite *KeeperTestSuite) TestHandleWithdrawForUser() {
}
},
message: banktypes.MsgSend{},
memo: "7C8B95EEE82CB63771E02EBEB05E6A80076D70B2E0A1C457F1FD1A0EF2EA961D",
memo: "unbondSend/7C8B95EEE82CB63771E02EBEB05E6A80076D70B2E0A1C457F1FD1A0EF2EA961D",
err: true,
},
{
Expand All @@ -545,7 +545,7 @@ func (suite *KeeperTestSuite) TestHandleWithdrawForUser() {
message: banktypes.MsgSend{
Amount: sdk.NewCoins(sdk.NewCoin("uatom", sdk.NewInt(4000000))),
},
memo: "7C8B95EEE82CB63771E02EBEB05E6A80076D70B2E0A1C457F1FD1A0EF2EA961D",
memo: "unbondSend/7C8B95EEE82CB63771E02EBEB05E6A80076D70B2E0A1C457F1FD1A0EF2EA961D",
err: false,
},
{
Expand Down Expand Up @@ -587,7 +587,7 @@ func (suite *KeeperTestSuite) TestHandleWithdrawForUser() {
message: banktypes.MsgSend{
Amount: sdk.NewCoins(sdk.NewCoin("uatom", sdk.NewInt(15000000))),
},
memo: "d786f7d4c94247625c2882e921a790790eb77a00d0534d5c3154d0a9c5ab68f5",
memo: "unbondSend/d786f7d4c94247625c2882e921a790790eb77a00d0534d5c3154d0a9c5ab68f5",
err: false,
},
}
Expand Down Expand Up @@ -625,14 +625,14 @@ func (suite *KeeperTestSuite) TestHandleWithdrawForUser() {
}

quicksilver.InterchainstakingKeeper.IterateZoneStatusWithdrawalRecords(ctx, zone.ChainId, icstypes.WithdrawStatusSend, func(idx int64, withdrawal icstypes.WithdrawalRecord) bool {
if withdrawal.Txhash == test.memo {
if withdrawal.Txhash == test.memo[11:] {
ajansari95 marked this conversation as resolved.
Show resolved Hide resolved
suite.Require().Fail("unexpected withdrawal record; status should be Completed.")
}
return false
})

quicksilver.InterchainstakingKeeper.IterateZoneStatusWithdrawalRecords(ctx, zone.ChainId, icstypes.WithdrawStatusCompleted, func(idx int64, withdrawal icstypes.WithdrawalRecord) bool {
if withdrawal.Txhash != test.memo {
if withdrawal.Txhash != test.memo[11:] {
suite.Require().Fail("unexpected withdrawal record; status should be Completed.")
}
return false
Expand Down Expand Up @@ -674,7 +674,7 @@ func (suite *KeeperTestSuite) TestHandleWithdrawForUserLSM() {
{Amount: sdk.NewCoins(sdk.NewCoin(v1+"1", sdk.NewInt(1000000)))},
{Amount: sdk.NewCoins(sdk.NewCoin(v2+"2", sdk.NewInt(1000000)))},
},
memo: "7C8B95EEE82CB63771E02EBEB05E6A80076D70B2E0A1C457F1FD1A0EF2EA961D",
memo: "unbondSend/7C8B95EEE82CB63771E02EBEB05E6A80076D70B2E0A1C457F1FD1A0EF2EA961D",
err: false,
},
{
Expand All @@ -700,7 +700,7 @@ func (suite *KeeperTestSuite) TestHandleWithdrawForUserLSM() {
{Amount: sdk.NewCoins(sdk.NewCoin(v2+"1", sdk.NewInt(1500000)))},
{Amount: sdk.NewCoins(sdk.NewCoin(v1+"2", sdk.NewInt(1000000)))},
},
memo: "7C8B95EEE82CB63771E02EBEB05E6A80076D70B2E0A1C457F1FD1A0EF2EA961D",
memo: "unbondSend/7C8B95EEE82CB63771E02EBEB05E6A80076D70B2E0A1C457F1FD1A0EF2EA961D",
err: false,
},
}
Expand Down Expand Up @@ -741,14 +741,14 @@ func (suite *KeeperTestSuite) TestHandleWithdrawForUserLSM() {
}

quicksilver.InterchainstakingKeeper.IterateZoneStatusWithdrawalRecords(ctx, zone.ChainId, icstypes.WithdrawStatusSend, func(idx int64, withdrawal icstypes.WithdrawalRecord) bool {
if withdrawal.Txhash == test.memo {
if withdrawal.Txhash == test.memo[11:] {
suite.Require().Fail("unexpected withdrawal record; status should be Completed.")
}
return false
})

quicksilver.InterchainstakingKeeper.IterateZoneStatusWithdrawalRecords(ctx, zone.ChainId, icstypes.WithdrawStatusCompleted, func(idx int64, withdrawal icstypes.WithdrawalRecord) bool {
if withdrawal.Txhash != test.memo {
if withdrawal.Txhash != test.memo[11:] {
suite.Require().Fail("unexpected withdrawal record; status should be Completed.")
}
return false
Expand Down