Skip to content

Commit

Permalink
Add completedoutgoingtx check
Browse files Browse the repository at this point in the history
  • Loading branch information
cbrit committed Oct 7, 2024
1 parent 746de79 commit 59485ee
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
32 changes: 32 additions & 0 deletions integration_tests/happy_path_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,18 @@ func (s *IntegrationTestSuite) TestHappyPath() {
)
s.T().Logf("Sent %s %s to %s", sendAmount, testDenom, recipient)

// Getting latest Batch Nonce
completed, err := gravityQueryClient.CompletedBatchTxs(context.Background(), &types.CompletedBatchTxsRequest{})
s.Require().NoError(err, "error querying CompletedBatchTxs")
// Search through completed batch txs to get the highest nonce
var highestNonce uint64
for _, batchTx := range completed.CompletedBatchTxs {
if batchTx.BatchNonce > highestNonce {
highestNonce = batchTx.BatchNonce
}
}
s.T().Logf("Highest completed batch nonce: %d", highestNonce)

// Send the message
s.T().Logf("Sending SendToEthereum message with %s", val.address().String())
response, err := s.chain.sendMsgs(*clientCtx, sendToEthereumMsg)
Expand All @@ -359,6 +371,26 @@ func (s *IntegrationTestSuite) TestHappyPath() {
return balance.Equal(expectedBalance)
}, 5*time.Minute, 10*time.Second, "Transaction did not complete on Ethereum")

// Wait for the CompletedOutgoingTx to be created
s.T().Log("Waiting for CompletedOutgoingTx to be created")
expectedNonce := highestNonce + 1
s.T().Logf("Expected nonce: %d", expectedNonce)
s.Require().Eventually(func() bool {
res, err := gravityQueryClient.CompletedBatchTxs(context.Background(), &types.CompletedBatchTxsRequest{})
if err != nil {
s.T().Logf("Error querying CompletedBatchTxs: %v", err)
return false
}

for _, batchTx := range res.CompletedBatchTxs {
if batchTx.BatchNonce >= expectedNonce {
return true
}
}

return false
}, 5*time.Minute, 3*time.Second, "CompletedBatchTx was not found")

// Turn the orchestrator back on
s.T().Log("Turning orchestrator1 back on")
err = s.startOrchestrator1()
Expand Down
2 changes: 1 addition & 1 deletion integration_tests/setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ func (s *IntegrationTestSuite) initGenesis() {
s.Require().NoError(cdc.UnmarshalJSON(appGenState[gravitytypes.ModuleName], &gravityGenState))
gravityGenState.Params.GravityId = "gravitytest"
gravityGenState.Params.BridgeEthereumAddress = gravityContract.String()
gravityGenState.Params.ConfirmedOutgoingTxWindow = 300
gravityGenState.Params.ConfirmedOutgoingTxWindow = 350
gravityGenState.Params.TargetEthTxTimeout = 3600000
gravityGenState.Params.AverageBlockTime = 1000
gravityGenState.Params.AverageEthereumBlockTime = 1000
Expand Down

0 comments on commit 59485ee

Please sign in to comment.