Skip to content

Commit

Permalink
other cases
Browse files Browse the repository at this point in the history
  • Loading branch information
hoangdv2429 committed Oct 9, 2023
1 parent 418d653 commit 92dc109
Showing 1 changed file with 65 additions and 0 deletions.
65 changes: 65 additions & 0 deletions x/interchainstaking/keeper/callbacks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1708,6 +1708,71 @@ func (suite *KeeperTestSuite) TestDepositTxCallback() {
// fail because of txHash mismatch with hash from tx Proof
suite.Error(err)
})
suite.Run("Deposit transaction failed: nil or wrong bytes", func() {
suite.SetupTest()
suite.setupTestZones()

// setup quicksilver test app
quicksilver := suite.GetQuicksilverApp(suite.chainA)
quicksilver.InterchainstakingKeeper.CallbackHandler().RegisterCallbacks()

// get chainA context
ctx := suite.chainA.GetContext()

// get zone chainB context
zone, _ := quicksilver.InterchainstakingKeeper.GetZone(ctx, suite.chainB.ChainID)
zone.DepositAddress.IncrementBalanceWaitgroup()
zone.WithdrawalAddress.IncrementBalanceWaitgroup()
quicksilver.InterchainstakingKeeper.SetZone(ctx, &zone)

// construct request data using txHash
requestData := tx.GetTxRequest{
// hash of tx in `txFixture`
Hash: "b1f1852d322328f6b8d8cacd180df2b1cbbd3dd64536c9ecbf1c896a15f6217a",
}
resDataBz, err := quicksilver.AppCodec().Marshal(&requestData)
suite.NoError(err)

// initialize the callback
err = keeper.DepositTxCallback(quicksilver.InterchainstakingKeeper, ctx, []byte("testing"), icqtypes.Query{ChainId: suite.chainB.ChainID, Request: resDataBz})
suite.Error(err)
})
suite.Run("Deposit transaction failed: failed on query state", func() {
suite.SetupTest()
suite.setupTestZones()

// setup quicksilver test app
quicksilver := suite.GetQuicksilverApp(suite.chainA)
quicksilver.InterchainstakingKeeper.CallbackHandler().RegisterCallbacks()

// get chainA context
ctx := suite.chainA.GetContext()

// get zone chainB context
zone, _ := quicksilver.InterchainstakingKeeper.GetZone(ctx, suite.chainB.ChainID)
zone.DepositAddress.IncrementBalanceWaitgroup()
zone.WithdrawalAddress.IncrementBalanceWaitgroup()
quicksilver.InterchainstakingKeeper.SetZone(ctx, &zone)

// get the tx from fixture
txWithProofBz := decodeBase64NoErr(localDepositTxFixture)
txRes := icqtypes.GetTxWithProofResponse{}
err := quicksilver.InterchainQueryKeeper.IBCKeeper.Codec().Unmarshal(txWithProofBz, &txRes)
suite.NoError(err)

// construct request data using txHash
requestData := tx.GetTxRequest{
// hash of tx in `txFixture`
Hash: "b1f1852d322328f6b8d8cacd180df2b1cbbd3dd64536c9ecbf1c896a15f6217a",
}
resDataBz, err := quicksilver.AppCodec().Marshal(&requestData)
suite.NoError(err)

// initialize the callback
err = keeper.DepositTxCallback(quicksilver.InterchainstakingKeeper, ctx, txWithProofBz, icqtypes.Query{ChainId: suite.chainB.ChainID, Request: resDataBz})
// fail on query state
suite.Error(err)
})
}

var localDepositTxFixture = `GsEDCiCFDDobCzFK2Vf0BXcgdEycLSdJL8IP7PEVWKelDQeJ3xL2AgrXAQrUAQocL2Nvc21vcy5iYW5rLnYxYmV0YTEuTXNnU2VuZBKzAQotY29zbW9zMWEyemh0OHgyajBkcXZ1ZWpyOHB4cHU3ZHVlM3FtazQwbGdkeTNoEkFjb3Ntb3MxYXZ2ZWhmM25wdm42d2V5eHR2eXU3bWh3d3Zqcnl6dzY5ZzQzdHEwbmw4MHdxamdscjZoc2U1bWN6NBo/Cjdjb3Ntb3N2YWxvcGVyMWdnN3c4dzJ5OWpmdjc2YTJ5eWFoZTQyeTA5ZzlyeTJyYWE1cnFmLzE0EgQ1MDAwElgKUApGCh8vY29zbW9zLmNyeXB0by5zZWNwMjU2azEuUHViS2V5EiMKIQLaGco86x6BgxaGOBf/rgbHMEyZzECi+5in9DJ31ln/0BIECgIIARgoEgQQwJoMGkAtbKm5mTCs2SJzFZL5UKaFbKascEfSLtLFX4w9H/iLKXVqia/1REtynG8yLW374PPGFRplDo62C3SrhSBSLETgGiQIARoghQw6GwsxStlX9AV3IHRMnC0nSS/CD+zxFVinpQ0Hid8i2wYK0AQKkgMKAggLEgpn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