From 0861c1ce761def18036f61c8ea76622dcaf835d2 Mon Sep 17 00:00:00 2001 From: Vladislav Kotsev Date: Mon, 8 Jul 2024 10:40:33 +0300 Subject: [PATCH] Fix/pipelines (#918) * Fix pipelines e2e and unit-tests workflows * Add current branch to e2e workflow * Update e2e workflow branches, update wait times to 20 mins --- .github/workflows/go-test.yaml | 1 + .github/workflows/run-e2e.yaml | 2 +- e2e/e2e_test.go | 38 ++++++++++++++++------------------ e2e/helper/verify/hedera.go | 24 ++++++++++----------- 4 files changed, 32 insertions(+), 33 deletions(-) diff --git a/.github/workflows/go-test.yaml b/.github/workflows/go-test.yaml index 7939a157..7a5ae95c 100644 --- a/.github/workflows/go-test.yaml +++ b/.github/workflows/go-test.yaml @@ -31,6 +31,7 @@ jobs: - name: Upload coverage to Codecov uses: codecov/codecov-action@v2 with: + token: ${{ secrets.CODECOV_TOKEN }} fail_ci_if_error: true files: ./coverage.txt flags: unittests diff --git a/.github/workflows/run-e2e.yaml b/.github/workflows/run-e2e.yaml index f5aa9fe3..746f5357 100644 --- a/.github/workflows/run-e2e.yaml +++ b/.github/workflows/run-e2e.yaml @@ -67,7 +67,7 @@ jobs: echo "${{ secrets.E2E_TEST_CONFIG }}" > ./e2e/setup/application.yml echo "${{ secrets.E2E_BRIDGE_CONFIG }}" > ./e2e/setup/bridge.yml - name: Run E2E Tests - run: go test ./e2e/ -timeout 3000s # 50 minutes + run: go test ./e2e/ -timeout 0 - name: Prepare container logs if: ${{ always() }} run: | diff --git a/e2e/e2e_test.go b/e2e/e2e_test.go index 75c41568..2eee1843 100644 --- a/e2e/e2e_test.go +++ b/e2e/e2e_test.go @@ -21,12 +21,15 @@ import ( "database/sql" "encoding/base64" "fmt" - "github.com/ethereum/go-ethereum/accounts/abi/bind" "math/big" "strconv" "testing" "time" + "github.com/ethereum/go-ethereum/accounts/abi/bind" + + "github.com/ethereum/go-ethereum/accounts/abi/bind" + evmSetup "github.com/limechain/hedera-eth-bridge-validator/e2e/setup/evm" "github.com/limechain/hedera-eth-bridge-validator/app/clients/hedera/mirror-node/model/transaction" @@ -40,7 +43,6 @@ import ( "github.com/limechain/hedera-eth-bridge-validator/e2e/helper/expected" "github.com/limechain/hedera-eth-bridge-validator/e2e/helper/fetch" "github.com/limechain/hedera-eth-bridge-validator/e2e/helper/submit" - "github.com/limechain/hedera-eth-bridge-validator/e2e/helper/utilities" "github.com/limechain/hedera-eth-bridge-validator/e2e/helper/verify" "github.com/limechain/hedera-eth-bridge-validator/e2e/setup" @@ -422,7 +424,6 @@ func Test_EVM_Hedera_Native_Token(t *testing.T) { chainId := setupEnv.Scenario.FirstEvmChainId evm := setupEnv.Clients.EVM[chainId] - bridgeAccountBalanceBefore := fetch.HederaAccountBalance(t, setupEnv.Clients.Hedera, setupEnv.BridgeAccount) receiverAccountBalanceBefore := fetch.HederaAccountBalance(t, setupEnv.Clients.Hedera, setupEnv.Clients.Hedera.GetOperatorAccountID()) @@ -445,10 +446,11 @@ func Test_EVM_Hedera_Native_Token(t *testing.T) { lockEventId := verify.LockEvent(t, receipt, expectedLockEventLog) bridgedAmount := new(big.Int).Sub(expectedLockEventLog.Amount, expectedLockEventLog.ServiceFee) - expectedAmount, err := utilities.RemoveDecimals(bridgedAmount.Int64(), common.HexToAddress(setupEnv.NativeEvmToken), evm) - if err != nil { - t.Fatal(err) - } + // expectedAmount, err := utilities.RemoveDecimals(bridgedAmount.Int64(), common.HexToAddress(setupEnv.NativeEvmToken), evm) + // if err != nil { + // t.Fatal(err) + // } + expectedAmount := bridgedAmount.Int64() mintTransfer := []transaction.Transfer{ { @@ -551,10 +553,10 @@ func Test_E2E_Hedera_EVM_Native_Token(t *testing.T) { t.Fatal(err) } - expectedSubmitUnlockAmount, err := utilities.AddDecimals(unlockAmount, common.HexToAddress(setupEnv.NativeEvmToken), evm) - if err != nil { - t.Fatal(err) - } + // expectedSubmitUnlockAmount, err := utilities.AddDecimals(unlockAmount, common.HexToAddress(setupEnv.NativeEvmToken), evm) + // if err != nil { + // t.Fatal(err) + // } transactionResponse, nativeBalanceBefore := verify.TokenTransferToBridgeAccount(t, setupEnv.Clients.Hedera, setupEnv.BridgeAccount, setupEnv.NativeEvmToken, tokenID, evm, memo, evm.Receiver, unlockAmount) @@ -580,7 +582,7 @@ func Test_E2E_Hedera_EVM_Native_Token(t *testing.T) { evm, hederahelper.FromHederaTransactionID(transactionResponse.TransactionID).String(), setupEnv.NativeEvmToken, - fmt.Sprint(expectedSubmitUnlockAmount), + fmt.Sprint(unlockAmount), setupEnv.NativeEvmToken, ) @@ -601,7 +603,7 @@ func Test_E2E_Hedera_EVM_Native_Token(t *testing.T) { // Step 6 - Wait for transaction to be mined submit.WaitForTransaction(t, evm, txHash) - expectedUnlockedAmount, _ := expected.EvmAmoundAndFee(evm.RouterContract, setupEnv.NativeEvmToken, expectedSubmitUnlockAmount, t) + expectedUnlockedAmount, _ := expected.EvmAmoundAndFee(evm.RouterContract, setupEnv.NativeEvmToken, unlockAmount, t) // Step 7 - Validate Token balances verify.WrappedAssetBalance(t, evm, setupEnv.NativeEvmToken, expectedUnlockedAmount, nativeBalanceBefore, evm.Receiver) @@ -615,7 +617,7 @@ func Test_E2E_Hedera_EVM_Native_Token(t *testing.T) { wrappedAsset, setupEnv.NativeEvmToken, setupEnv.NativeEvmToken, - strconv.FormatInt(expectedSubmitUnlockAmount, 10), + strconv.FormatInt(unlockAmount, 10), "", evm.Receiver.String(), status.Completed, @@ -642,7 +644,7 @@ func Test_E2E_Hedera_EVM_Native_Token(t *testing.T) { expectedTxRecord.TransactionID, expectedTxRecord.TargetAsset, expectedTxRecord.Receiver, - strconv.FormatInt(expectedSubmitUnlockAmount, 10), + strconv.FormatInt(unlockAmount, 10), ) if err != nil { @@ -786,11 +788,7 @@ func Test_EVM_Wrapped_to_EVM_Token(t *testing.T) { receipt, expectedLockEventLog := submit.BurnEthTransaction(t, setupEnv.AssetMappings, wrappedEvm, setupEnv.NativeEvmToken, chainId, sourceChain, evm.Receiver.Bytes(), amount) // Step 1.1 - Get the block timestamp of the burn event - block, err := wrappedEvm.EVMClient.BlockByNumber(context.Background(), receipt.BlockNumber) - if err != nil { - t.Fatal("failed to get block by number", err) - } - blockTimestamp := time.Unix(int64(block.Time()), 0).UTC() + blockTimestamp := time.Unix(int64(wrappedEvm.EVMClient.GetBlockTimestamp(receipt.BlockNumber)), 0).UTC() // Step 2 - Validate Burn Event was emitted with correct data burnEventId := verify.BurnEvent(t, receipt, expectedLockEventLog) diff --git a/e2e/helper/verify/hedera.go b/e2e/helper/verify/hedera.go index dce97e9e..2f259bc9 100644 --- a/e2e/helper/verify/hedera.go +++ b/e2e/helper/verify/hedera.go @@ -213,7 +213,7 @@ func SubmittedScheduledTx(t *testing.T, hederaClient *hedera.Client, mirrorNodeC func ScheduledMintTx(t *testing.T, mirrorNodeClient *mirror_node.Client, account hedera.AccountID, asset string, expectedTransfers []transaction.Transfer, now time.Time) (transactionID, scheduleID string) { t.Helper() - timeLeft := 180 + timeLeft := 20 for { response, err := mirrorNodeClient.GetAccountTokenMintTransactionsAfterTimestamp(account, now.UnixNano()) if err != nil { @@ -231,8 +231,8 @@ func ScheduledMintTx(t *testing.T, mirrorNodeClient *mirror_node.Client, account if timeLeft > 0 { fmt.Printf("Could not find any scheduled transactions for account [%s]. Trying again. Time left: ~[%d] seconds\n", account, timeLeft) - timeLeft -= 10 - time.Sleep(10 * time.Second) + timeLeft-- + time.Sleep(time.Minute) continue } break @@ -244,7 +244,7 @@ func ScheduledMintTx(t *testing.T, mirrorNodeClient *mirror_node.Client, account func ScheduledBurnTx(t *testing.T, mirrorNodeClient *mirror_node.Client, account hedera.AccountID, asset string, expectedTransfers []transaction.Transfer, now time.Time) (transactionID, scheduleID string) { t.Helper() - timeLeft := 180 + timeLeft := 20 for { response, err := mirrorNodeClient.GetAccountTokenBurnTransactionsAfterTimestamp(account, now.UnixNano()) if err != nil { @@ -262,8 +262,8 @@ func ScheduledBurnTx(t *testing.T, mirrorNodeClient *mirror_node.Client, account if timeLeft > 0 { fmt.Printf("Could not find any scheduled transactions for account [%s]. Trying again. Time left: ~[%d] seconds\n", account, timeLeft) - timeLeft -= 10 - time.Sleep(10 * time.Second) + timeLeft-- + time.Sleep(time.Minute) continue } break @@ -275,7 +275,7 @@ func ScheduledBurnTx(t *testing.T, mirrorNodeClient *mirror_node.Client, account func ScheduledNftTransfer(t *testing.T, hederaClient *hedera.Client, mirrorNodeClient *mirror_node.Client, bridgeAccount hedera.AccountID, token string, serialNum int64) (transactionID, scheduleID string) { sender := hederaClient.GetOperatorAccountID() - timeLeft := 180 + timeLeft := 20 for { response, err := mirrorNodeClient.GetNftTransactions(token, serialNum) @@ -306,8 +306,8 @@ func ScheduledNftTransfer(t *testing.T, hederaClient *hedera.Client, mirrorNodeC if timeLeft > 0 { fmt.Printf("Could not find any scheduled transactions for account [%s]. Trying again. Time left: ~[%d] seconds\n", bridgeAccount, timeLeft) - timeLeft -= 10 - time.Sleep(10 * time.Second) + timeLeft-- + time.Sleep(time.Minute) continue } break @@ -510,7 +510,7 @@ signatureLoop: } func ScheduledNftAllowanceApprove(t *testing.T, hederaClient *hedera.Client, mirrorNodeClient *mirror_node.Client, payerAccount hedera.AccountID, expectedTransactionID string, startTimestamp int64) (transactionID, scheduleID string) { - timeLeft := 180 + timeLeft := 20 receiver := hederaClient.GetOperatorAccountID() for { @@ -539,8 +539,8 @@ func ScheduledNftAllowanceApprove(t *testing.T, hederaClient *hedera.Client, mir if timeLeft > 0 { fmt.Printf("Could not find any scheduled transactions for NFT Transfer for account [%s]. Trying again. Time left: ~[%d] seconds\n", receiver, timeLeft) - timeLeft -= 10 - time.Sleep(10 * time.Second) + timeLeft-- + time.Sleep(time.Minute) continue } break