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

fixed packet forward configuration #1941

Merged
merged 3 commits into from
Dec 8, 2022
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
2 changes: 1 addition & 1 deletion app/keepers/keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ func NewAppKeeper(
// create static IBC router, add transfer route, then set and seal it
ibcRouter := porttypes.NewRouter()
ibcRouter.AddRoute(icahosttypes.SubModuleName, icaHostIBCModule).
AddRoute(ibctransfertypes.ModuleName, transferIBCModule)
AddRoute(ibctransfertypes.ModuleName, appKeepers.RouterModule)

appKeepers.IBCKeeper.SetRouter(ibcRouter)

Expand Down
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -288,10 +288,11 @@ replace (

// force all dependecies to use the same versions of ibc, tendermint and cosmos-sdk
github.com/cosmos/ibc-go/v3 => github.com/cosmos/ibc-go/v3 v3.4.0
github.com/tendermint/tendermint => github.com/tendermint/tendermint v0.34.24
github.com/cosmos/cosmos-sdk => github.com/cosmos/cosmos-sdk v0.45.11

// use cosmos style protobufs
github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1
github.com/tendermint/tendermint => github.com/tendermint/tendermint v0.34.24

// latest grpc doesn't work with with our modified proto compiler, so we need to enforce
// the following version across all dependencies.
Expand Down
22 changes: 3 additions & 19 deletions tests/e2e/e2e_ibc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -382,11 +382,9 @@ func (s *IntegrationTestSuite) testMultihopIBCTokenTransfer() {
func() bool {
afterSenderUAtomBalance, err := getSpecificBalance(chainAAPIEndpoint, sender, uatomDenom)
s.Require().NoError(err)
fmt.Println("afterSenderUAtomBalance", afterSenderUAtomBalance)

afterRecipientUAtomBalance, err := getSpecificBalance(chainAAPIEndpoint, recipient, uatomDenom)
s.Require().NoError(err)
fmt.Println("afterRecipientUAtomBalance", afterRecipientUAtomBalance)

decremented := beforeSenderUAtomBalance.Sub(tokenAmount).Sub(standardFees).IsEqual(afterSenderUAtomBalance)
incremented := beforeRecipientUAtomBalance.Add(tokenAmount).IsEqual(afterRecipientUAtomBalance)
Expand All @@ -400,52 +398,38 @@ func (s *IntegrationTestSuite) testMultihopIBCTokenTransfer() {
}

/*
TestFailedMultihopIBCTokenTransfer tests that sending a failing IBC transfer using the IBC Packet Forward Middleware will preserve the tokens
on the middle hop chain in the designated address.

Steps:
1. Check balance of Account 1 on Chain 1
2. Check balance of Account 1 on Chain 2
3. Account 1 on Chain 1 sends x tokens to Account 1 on non-existent chain via Account 1 on Chain 2
4. Check Balance of Account 1 on Chain 1, confirm it is original minus x tokens
5. Check Balance of Account 1 on Chain 2, confirm it is original plus x tokens
TestFailedMultihopIBCTokenTransfer tests that sending a failing IBC transfer using the IBC Packet Forward
Middleware will send the tokens back to the original account after failing.
*/
func (s *IntegrationTestSuite) testFailedMultihopIBCTokenTransfer() {
time.Sleep(30 * time.Second)

s.Run("send_failed_multihop_uatom_to_chainA_from_chainA", func() {
// require the recipient account receives the IBC tokens (IBC packets ACKd)

address := s.chainA.validators[0].keyInfo.GetAddress()
sender := address.String()

address = s.chainB.validators[0].keyInfo.GetAddress()
middlehop := address.String()

address = s.chainA.validators[1].keyInfo.GetAddress()
recipient := strings.Replace(address.String(), "cosmos", "foobar", 1) // this should be an invalid recipient but only fail the final send so it will be returned
recipient := strings.Replace(address.String(), "cosmos", "foobar", 1) // this should be an invalid recipient to force the tx to fail

forwardPort := "transfer"
forwardChannel := "channel-0"

tokenAmt := 3300000000

chainAAPIEndpoint := fmt.Sprintf("http://%s", s.valResources[s.chainA.id][0].GetHostPort("1317/tcp"))
chainBAPIEndpoint := fmt.Sprintf("http://%s", s.valResources[s.chainB.id][0].GetHostPort("1317/tcp"))

var (
beforeSenderUAtomBalance sdk.Coin
beforeMiddleIBCBalance sdk.Coin
err error
)

s.Require().Eventually(
func() bool {
beforeSenderUAtomBalance, err = getSpecificBalance(chainAAPIEndpoint, sender, uatomDenom)
s.Require().NoError(err)
beforeMiddleIBCBalance, err = getSpecificBalance(chainBAPIEndpoint, middlehop, "ibc/")
s.Require().True(beforeMiddleIBCBalance.IsNil())
s.Require().NoError(err)

return beforeSenderUAtomBalance.IsValid()
},
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ var (
runFeeGrantTest = true
runGlobalFeesTest = true
runGovTest = false // legacy gov system needs to be added back
runIBCTest = false // multihop ibc test is not working
runIBCTest = true
runSlashingTest = true
runStakingAndDistributionTest = true
runVestingTest = true
Expand Down