From 59485ee483380b5262cde913fbbd23ae679d9f3f Mon Sep 17 00:00:00 2001 From: Collin Brittain Date: Mon, 7 Oct 2024 13:12:03 -0500 Subject: [PATCH] Add completedoutgoingtx check --- integration_tests/happy_path_test.go | 32 ++++++++++++++++++++++++++++ integration_tests/setup_test.go | 2 +- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/integration_tests/happy_path_test.go b/integration_tests/happy_path_test.go index 8a245d5c1..c2bbde046 100644 --- a/integration_tests/happy_path_test.go +++ b/integration_tests/happy_path_test.go @@ -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) @@ -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() diff --git a/integration_tests/setup_test.go b/integration_tests/setup_test.go index 652227979..f2f7b5d86 100644 --- a/integration_tests/setup_test.go +++ b/integration_tests/setup_test.go @@ -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