Skip to content

Commit

Permalink
add v046 callback tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Joe Bowman committed Feb 20, 2023
1 parent b53dc87 commit 0aae701
Showing 1 changed file with 32 additions and 2 deletions.
34 changes: 32 additions & 2 deletions x/interchainstaking/keeper/callbacks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -935,6 +935,36 @@ func (s *KeeperTestSuite) TestAccountBalanceCallbackMismatch() {
})
}

func (s *KeeperTestSuite) TestAccountBalance046Callback() {
s.Run("account balance", func() {
s.SetupTest()
s.setupTestZones()

app := s.GetQuicksilverApp(s.chainA)
app.InterchainstakingKeeper.CallbackHandler().RegisterCallbacks()
ctx := s.chainA.GetContext()

zone, _ := app.InterchainstakingKeeper.GetZone(ctx, s.chainB.ChainID)
zone.DepositAddress.IncrementBalanceWaitgroup()
zone.WithdrawalAddress.IncrementBalanceWaitgroup()
app.InterchainstakingKeeper.SetZone(ctx, &zone)

response := sdk.NewInt(10)

respbz, err := response.Marshal()
s.Require().NoError(err)

for _, addr := range []string{zone.DepositAddress.Address, zone.WithdrawalAddress.Address} {
accAddr, err := sdk.AccAddressFromBech32(addr)
s.Require().NoError(err)
data := append(banktypes.CreateAccountBalancesPrefix(accAddr), []byte("qck")...)

err = keeper.AccountBalanceCallback(app.InterchainstakingKeeper, ctx, respbz, icqtypes.Query{ChainId: s.chainB.ChainID, Request: data})
s.Require().NoError(err)
}
})
}

func (s *KeeperTestSuite) TestAccountBalanceCallbackNil() {
s.Run("account balance", func() {
s.SetupTest()
Expand All @@ -949,8 +979,8 @@ func (s *KeeperTestSuite) TestAccountBalanceCallbackNil() {
zone.WithdrawalAddress.BalanceWaitgroup++
app.InterchainstakingKeeper.SetZone(ctx, &zone)

response := sdk.Coin{}
respbz, err := app.AppCodec().Marshal(&response)
var response *sdk.Coin = nil
respbz, err := app.AppCodec().Marshal(response)
s.Require().NoError(err)

for _, addr := range []string{zone.DepositAddress.Address, zone.WithdrawalAddress.Address} {
Expand Down

0 comments on commit 0aae701

Please sign in to comment.