Skip to content

Commit

Permalink
Fix/pipelines (#918)
Browse files Browse the repository at this point in the history
* Fix pipelines e2e and unit-tests workflows

* Add current branch to e2e workflow

* Update e2e workflow branches, update wait times to 20 mins
  • Loading branch information
vlady-kotsev committed Dec 16, 2024
1 parent 1307e34 commit 960a1eb
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 33 deletions.
1 change: 1 addition & 0 deletions .github/workflows/go-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/run-e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
36 changes: 16 additions & 20 deletions e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ 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"

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"
Expand All @@ -40,7 +41,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"

Expand Down Expand Up @@ -422,7 +422,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())

Expand All @@ -445,10 +444,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{
{
Expand Down Expand Up @@ -551,10 +551,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)

Expand All @@ -580,7 +580,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,
)

Expand All @@ -601,7 +601,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)
Expand All @@ -615,7 +615,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,
Expand All @@ -642,7 +642,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 {
Expand Down Expand Up @@ -786,11 +786,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)
Expand Down
24 changes: 12 additions & 12 deletions e2e/helper/verify/hedera.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Expand All @@ -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 {
Expand All @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 960a1eb

Please sign in to comment.