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

chore: use new forwarding instead of struct init #6605

Merged
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 1 addition & 4 deletions modules/apps/transfer/keeper/forwarding.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,7 @@ func (k Keeper) forwardPacket(ctx sdk.Context, data types.FungibleTokenPacketDat
memo = data.Forwarding.Memo
nextForwardingPath = nil
} else {
nextForwardingPath = &types.Forwarding{
Hops: data.Forwarding.Hops[1:],
Memo: data.Forwarding.Memo,
}
nextForwardingPath = types.NewForwarding(data.Forwarding.Memo, data.Forwarding.Hops[1:]...)
}

// sending from the forward escrow address to the original receiver address.
Expand Down
77 changes: 26 additions & 51 deletions modules/apps/transfer/keeper/relay_forwarding_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,10 @@ func (suite *KeeperTestSuite) TestPathForwarding() {
coin := sdk.NewCoin(sdk.DefaultBondDenom, amount)
sender := suite.chainA.SenderAccounts[0].SenderAccount
receiver := suite.chainA.SenderAccounts[1].SenderAccount
forwarding := types.Forwarding{
Hops: []types.Hop{
{
PortId: path2.EndpointA.ChannelConfig.PortID,
ChannelId: path2.EndpointA.ChannelID,
},
},
Memo: "",
}
forwarding := types.NewForwarding("", types.Hop{
PortId: path2.EndpointA.ChannelConfig.PortID,
ChannelId: path2.EndpointA.ChannelID,
})

transferMsg := types.NewMsgTransfer(
path1.EndpointA.ChannelConfig.PortID,
Expand All @@ -46,7 +41,7 @@ func (suite *KeeperTestSuite) TestPathForwarding() {
receiver.GetAddress().String(),
suite.chainA.GetTimeoutHeight(),
0, "",
&forwarding,
forwarding,
)
result, err := suite.chainA.SendMsgs(transferMsg)
suite.Require().NoError(err) // message committed
Expand Down Expand Up @@ -90,15 +85,10 @@ func (suite *KeeperTestSuite) TestEscrowsAreSetAfterForwarding() {
coin := sdk.NewCoin(sdk.DefaultBondDenom, amount)
sender := suite.chainA.SenderAccounts[0].SenderAccount
receiver := suite.chainA.SenderAccounts[1].SenderAccount
forwarding := types.Forwarding{
Hops: []types.Hop{
{
PortId: path2.EndpointB.ChannelConfig.PortID,
ChannelId: path2.EndpointB.ChannelID,
},
},
Memo: "",
}
forwarding := types.NewForwarding("", types.Hop{
PortId: path2.EndpointB.ChannelConfig.PortID,
ChannelId: path2.EndpointB.ChannelID,
})

transferMsg := types.NewMsgTransfer(
path1.EndpointA.ChannelConfig.PortID,
Expand All @@ -108,7 +98,7 @@ func (suite *KeeperTestSuite) TestEscrowsAreSetAfterForwarding() {
receiver.GetAddress().String(),
suite.chainA.GetTimeoutHeight(),
0, "",
&forwarding,
forwarding,
)

result, err := suite.chainA.SendMsgs(transferMsg)
Expand Down Expand Up @@ -173,15 +163,10 @@ func (suite *KeeperTestSuite) TestHappyPathForwarding() {
coin = sdk.NewCoin(sdk.DefaultBondDenom, amount)
sender := suite.chainA.SenderAccounts[0].SenderAccount
receiver := suite.chainA.SenderAccounts[1].SenderAccount
forwarding := types.Forwarding{
Hops: []types.Hop{
{
PortId: path2.EndpointB.ChannelConfig.PortID,
ChannelId: path2.EndpointB.ChannelID,
},
},
Memo: "",
}
forwarding := types.NewForwarding("", types.Hop{
PortId: path2.EndpointB.ChannelConfig.PortID,
ChannelId: path2.EndpointB.ChannelID,
})

transferMsg := types.NewMsgTransfer(
path1.EndpointA.ChannelConfig.PortID,
Expand All @@ -191,7 +176,7 @@ func (suite *KeeperTestSuite) TestHappyPathForwarding() {
receiver.GetAddress().String(),
suite.chainA.GetTimeoutHeight(),
0, "",
&forwarding,
forwarding,
)

result, err := suite.chainA.SendMsgs(transferMsg)
Expand All @@ -209,7 +194,7 @@ func (suite *KeeperTestSuite) TestHappyPathForwarding() {
Denom: denom,
Amount: amount.String(),
},
}, sender.GetAddress().String(), receiver.GetAddress().String(), "", &forwarding)
}, sender.GetAddress().String(), receiver.GetAddress().String(), "", forwarding)
packetRecv := channeltypes.NewPacket(data.GetBytes(), 2, path1.EndpointA.ChannelConfig.PortID, path1.EndpointA.ChannelID, path1.EndpointB.ChannelConfig.PortID, path1.EndpointB.ChannelID, clienttypes.NewHeight(1, 100), 0)

err = suite.chainB.GetSimApp().TransferKeeper.OnRecvPacket(suite.chainB.GetContext(), packetRecv, data)
Expand Down Expand Up @@ -278,15 +263,10 @@ func (suite *KeeperTestSuite) TestSimplifiedHappyPathForwarding() {
coin := sdk.NewCoin(sdk.DefaultBondDenom, amount)
sender := suite.chainA.SenderAccounts[0].SenderAccount
receiver := suite.chainA.SenderAccounts[1].SenderAccount
forwarding := types.Forwarding{
Hops: []types.Hop{
{
PortId: path2.EndpointB.ChannelConfig.PortID,
ChannelId: path2.EndpointB.ChannelID,
},
},
Memo: "",
}
forwarding := types.NewForwarding("", types.Hop{
PortId: path2.EndpointB.ChannelConfig.PortID,
ChannelId: path2.EndpointB.ChannelID,
})

transferMsg := types.NewMsgTransfer(
path1.EndpointA.ChannelConfig.PortID,
Expand All @@ -296,7 +276,7 @@ func (suite *KeeperTestSuite) TestSimplifiedHappyPathForwarding() {
receiver.GetAddress().String(),
suite.chainA.GetTimeoutHeight(),
0, "",
&forwarding,
forwarding,
)

result, err := suite.chainA.SendMsgs(transferMsg)
Expand Down Expand Up @@ -472,15 +452,10 @@ func (suite *KeeperTestSuite) TestAcknowledgementFailureScenario5Forwarding() {
sender = suite.chainC.SenderAccounts[0].SenderAccount
receiver = suite.chainA.SenderAccounts[0].SenderAccount // Receiver is the A chain account

forwarding := types.Forwarding{
Hops: []types.Hop{
{
PortId: path1.EndpointB.ChannelConfig.PortID,
ChannelId: path1.EndpointB.ChannelID,
},
},
Memo: "",
}
forwarding := types.NewForwarding("", types.Hop{
PortId: path1.EndpointB.ChannelConfig.PortID,
ChannelId: path1.EndpointB.ChannelID,
})

transferMsg = types.NewMsgTransfer(
path2.EndpointB.ChannelConfig.PortID,
Expand All @@ -490,7 +465,7 @@ func (suite *KeeperTestSuite) TestAcknowledgementFailureScenario5Forwarding() {
receiver.GetAddress().String(),
suite.chainA.GetTimeoutHeight(),
0, "",
&forwarding,
forwarding,
)

result, err = suite.chainC.SendMsgs(transferMsg)
Expand Down
Loading