Skip to content

Commit

Permalink
some asserts
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastianElvis committed Jun 27, 2024
1 parent 8f28f8c commit 8ab4840
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 4 deletions.
35 changes: 32 additions & 3 deletions tests/e2e/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import (
"github.com/stretchr/testify/suite"
)

var testMsg types.ExecuteMessage

// In the Test function, we create and run the suite
func TestBabylonSDKTestSuite(t *testing.T) {
suite.Run(t, new(BabylonSDKTestSuite))
Expand Down Expand Up @@ -105,8 +107,8 @@ func (s *BabylonSDKTestSuite) Test1ContractDeployment() {

// TestExample is an example test case
func (s *BabylonSDKTestSuite) Test2MockConsumerFpDelegation() {
msg := types.GenExecMessage()
msgBytes, err := json.Marshal(msg)
testMsg = types.GenExecMessage()
msgBytes, err := json.Marshal(testMsg)
s.NoError(err)

// send msg to BTC staking contract via admin account
Expand All @@ -122,9 +124,36 @@ func (s *BabylonSDKTestSuite) Test2MockConsumerFpDelegation() {
consumerDels, err := s.ConsumerCli.Query(s.ConsumerContract.BTCStaking, Query{"delegations": {}})
s.NoError(err)
s.NotEmpty(consumerDels)

// ensure the BTC staking is activated
resp, err := s.ConsumerCli.Query(s.ConsumerContract.BTCStaking, Query{"activated_height": {}})
s.NoError(err)
parsedActivatedHeight := resp["height"].(float64)
currentHeight := s.ConsumerChain.GetContext().BlockHeight()
s.Equal(uint64(parsedActivatedHeight), uint64(currentHeight))
}

func (s *BabylonSDKTestSuite) Test3BeginBlock() {
err := s.ConsumerApp.BabylonKeeper.BeginBlocker(s.ConsumerChain.GetContext())
s.NoError(err)
}

func (s *BabylonSDKTestSuite) Test3NextBlock() {
func (s *BabylonSDKTestSuite) Test4EndBlock() {
_, err := s.ConsumerApp.BabylonKeeper.EndBlocker(s.ConsumerChain.GetContext())
s.NoError(err)
}

func (s *BabylonSDKTestSuite) Test5NextBlock() {
// get current height
height := s.ConsumerChain.GetContext().BlockHeight()
// ensure the current block is not indexed yet
_, err := s.ConsumerCli.Query(s.ConsumerContract.BTCStaking, Query{
"block": {
"height": uint64(height),
},
})
s.Error(err)

// this triggers BeginBlock and EndBlock
s.ConsumerChain.NextBlock()
}
Expand Down
3 changes: 2 additions & 1 deletion x/babylon/keeper/wasm.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ func (k Keeper) doSudoCall(ctx sdk.Context, contractAddr sdk.AccAddress, msg con
if err != nil {
return errorsmod.Wrap(err, "marshal sudo msg")
}
_, err = k.wasm.Sudo(ctx, contractAddr, bz)
resp, err := k.wasm.Sudo(ctx, contractAddr, bz)
k.Logger(ctx).Debug("response of sudo call %v to contract %s: %v", bz, contractAddr.String(), resp)
return err
}

0 comments on commit 8ab4840

Please sign in to comment.