From 5ee7a8b47fd91fc32b9a8f83f755c40d91b648ce Mon Sep 17 00:00:00 2001 From: Jineshdarjee Date: Mon, 29 Apr 2024 19:16:06 +0530 Subject: [PATCH] Added connext test cases for testnet networks --- package.json | 2 +- test/specs/testnet/connext/goerli.spec.js | 1272 ++++++++++++++++++++ test/specs/testnet/connext/mumbai.spec.js | 1272 ++++++++++++++++++++ test/specs/testnet/connext/sepolia.spec.js | 1272 ++++++++++++++++++++ 4 files changed, 3817 insertions(+), 1 deletion(-) create mode 100644 test/specs/testnet/connext/goerli.spec.js create mode 100644 test/specs/testnet/connext/mumbai.spec.js create mode 100644 test/specs/testnet/connext/sepolia.spec.js diff --git a/package.json b/package.json index ad20372..ec847a2 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "main": "index.js", "type": "module", "scripts": { - "test": "mocha --timeout 600000 --spec test/specs/testnet/version/version.spec.js --spec test/specs/testnet/paymaster/sepolia.spec.js --reporter mochawesome --require mochawesome/register --reporter-options charts=true,code=false,showHooks=always", + "test": "mocha --timeout 600000 --spec test/specs/testnet/version/version.spec.js --spec test/specs/testnet/connext/sepolia.spec.js --reporter mochawesome --require mochawesome/register --reporter-options charts=true,code=false,showHooks=always", "test-mainnet": "mocha --timeout 600000 --spec test/specs/mainnet/version/version.spec.js --spec test/specs/mainnet/*/xdai.spec.js --reporter mochawesome --reporter-options charts=true,code=false,showHooks=always", "test-mainnet-transfertoken-arbitrum": "mocha --timeout 600000 --spec test/specs/mainnet/version/version.spec.js --spec test/specs/mainnet/transferringFunds/arbitrum.spec.js --reporter mochawesome --reporter-options charts=true,code=false,showHooks=always", "test-mainnet-transfertoken-matic": "mocha --timeout 600000 --spec test/specs/mainnet/version/version.spec.js --spec test/specs/mainnet/transferringFunds/matic.spec.js --reporter mochawesome --reporter-options charts=true,code=false,showHooks=always", diff --git a/test/specs/testnet/connext/goerli.spec.js b/test/specs/testnet/connext/goerli.spec.js new file mode 100644 index 0000000..de1e00e --- /dev/null +++ b/test/specs/testnet/connext/goerli.spec.js @@ -0,0 +1,1272 @@ +import * as dotenv from 'dotenv'; +dotenv.config(); // init dotenv +import { PrimeSdk, DataUtils } from '@etherspot/prime-sdk'; +import { utils, constants, BigNumber, ethers } from 'ethers'; +import { BridgingProvider } from '@etherspot/prime-sdk/dist/sdk/data/index.js'; +import { assert } from 'chai'; +import addContext from 'mochawesome/addContext.js'; +import customRetryAsync from '../../../utils/baseTest.js'; +import helper from '../../../utils/helper.js'; +import data from '../../../data/testData.json' assert { type: 'json' }; +import constant from '../../../data/constant.json' assert { type: 'json' }; +import message from '../../../data/messages.json' assert { type: 'json' }; + +let goerliTestNetSdk; +let goerliEtherspotWalletAddress; +let goerliNativeAddress = null; +let goerliDataService; +let runTest; + +describe('The PrimeSDK, Validate the connext endpoints with goerli network on the TestNet', function () { + before(async function () { + var test = this; + + await customRetryAsync(async function () { + + helper.wait(data.mediumTimeout); + + // initializating sdk + try { + goerliTestNetSdk = new PrimeSdk( + { privateKey: process.env.PRIVATE_KEY }, + { + chainId: Number(data.goerli_chainid), + }, + ); + + try { + assert.strictEqual( + goerliTestNetSdk.state.EOAAddress, + data.eoaAddress, + message.vali_eoa_address + ); + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + } + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_sdk_initialize); + } + + // get EtherspotWallet address + try { + goerliEtherspotWalletAddress = + await goerliTestNetSdk.getCounterFactualAddress(); + + try { + assert.strictEqual( + goerliEtherspotWalletAddress, + data.sender, + message.vali_smart_address); + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + } + } catch (e) { + console.error(e.message); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_smart_address); + } + + // initializating Data service... + try { + goerliDataService = new DataUtils( + process.env.DATA_API_KEY + ); + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_data_service); + } + + // validate the balance of the wallet + try { + let output = await goerliDataService.getAccountBalances({ + account: data.sender, + chainId: Number(data.goerli_chainid), + }); + let native_balance; + let usdc_balance; + let native_final; + let usdc_final; + + for (let i = 0; i < output.items.length; i++) { + let tokenAddress = output.items[i].token; + if (tokenAddress === goerliNativeAddress) { + native_balance = output.items[i].balance; + native_final = utils.formatUnits(native_balance, 18); + } else if (tokenAddress === data.tokenAddress_goerliUSDC) { + usdc_balance = output.items[i].balance; + usdc_final = utils.formatUnits(usdc_balance, 6); + } + } + + if ( + native_final > data.minimum_native_balance && + usdc_final > data.minimum_token_balance + ) { + runTest = true; + } else { + runTest = false; + } + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_wallet_balance); + } + }, data.retry); // Retry this async test up to 5 times + }); + + it('SMOKE: Validate the all supported assets with valid details on the goerli network', async function () { + var test = this; + let allSupportedAssets; + if (runTest) { + await customRetryAsync(async function () { + + helper.wait(data.mediumTimeout); + + try { + allSupportedAssets = + await goerliDataService.getSupportedAssets({}); + + try { + assert.isNotEmpty( + allSupportedAssets[0].symbol, + message.vali_connext_getSupportedAssets_symbol + ); + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + } + + try { + assert.isNotEmpty( + allSupportedAssets[0].address, + message.vali_connext_getSupportedAssets_address + ); + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + } + + try { + assert.isNumber( + allSupportedAssets[0].decimals, + message.vali_connext_getSupportedAssets_decimals + ); + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + } + + try { + assert.isNumber( + allSupportedAssets[0].chainId, + message.vali_connext_getSupportedAssets_chainId + ); + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + } + + try { + assert.isNotEmpty( + allSupportedAssets[0].icon, + message.vali_connext_getSupportedAssets_icon + ); + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + } + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_connext_1); + } + }, data.retry); // Retry this async test up to 5 times + } else { + console.warn(message.connext_insufficientBalance); + } + }); + + it('SMOKE: Validate the supported assets with valid details on the goerli network', async function () { + var test = this; + let supportedAssets; + if (runTest) { + await customRetryAsync(async function () { + + helper.wait(data.mediumTimeout); + + try { + supportedAssets = + await goerliDataService.getSupportedAssets({ + chainId: data.goerli_chainid, + provider: BridgingProvider.Connext, + }); + + try { + assert.isNotEmpty( + supportedAssets[0].symbol, + message.vali_connext_getSupportedAssets_symbol + ); + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + } + + try { + assert.isNotEmpty( + supportedAssets[0].address, + message.vali_connext_getSupportedAssets_address + ); + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + } + + try { + assert.isNumber( + supportedAssets[0].decimals, + message.vali_connext_getSupportedAssets_decimals + ); + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + } + + try { + assert.strictEqual( + supportedAssets[0].chainId, + data.goerli_chainid, + message.vali_connext_getSupportedAssets_chainId + ); + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + } + + try { + assert.isNotEmpty( + supportedAssets[0].icon, + message.vali_connext_getSupportedAssets_icon + ); + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + } + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_connext_2); + } + }, data.retry); // Retry this async test up to 5 times + } else { + console.warn(message.connext_insufficientBalance); + } + }); + + it('SMOKE: Validate the get quotes with valid details on the goerli network', async function () { + var test = this; + let quotes; + if (runTest) { + await customRetryAsync(async function () { + + helper.wait(data.mediumTimeout); + + try { + quotes = await goerliDataService.getQuotes({ + fromAddress: data.sender, + toAddress: data.recipient, + fromChainId: data.goerli_chainid, + toChainId: data.matic_chainid, + fromToken: data.tokenAddress_goerliUSDC, + fromAmount: utils.parseUnits(data.swap_value, 18), + slippage: 0.1, + provider: BridgingProvider.Connext, + }); + + try { + assert.isNotEmpty( + quotes[0].data, + message.vali_connext_getQuotes_data + ); + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + } + + try { + assert.isNotEmpty( + quotes[0].to, + message.vali_connext_getQuotes_to + ); + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + } + + try { + assert.isNotEmpty( + quotes[0].value, + message.vali_connext_getQuotes_value + ); + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + } + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_connext_3); + } + }, data.retry); // Retry this async test up to 5 times + } else { + console.warn(message.connext_insufficientBalance); + } + }); + + it('SMOKE: Validate the get transaction status with valid details on the goerli network', async function () { + var test = this; + if (runTest) { + await customRetryAsync(async function () { + + helper.wait(data.mediumTimeout); + + // clear the transaction batch + try { + await goerliTestNetSdk.clearUserOpsFromBatch(); + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_clearTransaction_1); + } + + // add transactions to the batch + try { + await goerliTestNetSdk.addUserOpsToBatch({ + to: data.recipient, + value: ethers.utils.parseEther(data.value), + }); + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_addTransaction_1); + } + + // get balance of the account address + try { + await goerliTestNetSdk.getNativeBalance(); + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_getBalance_1); + } + + // estimate transactions added to the batch and get the fee data for the UserOp + let op; + try { + op = await goerliTestNetSdk.estimate(); + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_estimateTransaction_1); + } + + // sign the UserOp and sending to the bundler + let uoHash; + try { + uoHash = await goerliTestNetSdk.send(op); + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_submitTransaction_1); + } + + // get transaction hash + let userOpsReceipt = null; + try { + console.log('Waiting for transaction...'); + const timeout = Date.now() + 60000; // 1 minute timeout + while (userOpsReceipt == null && Date.now() < timeout) { + await helper.wait(5000); + userOpsReceipt = await goerliTestNetSdk.getUserOpReceipt(uoHash); + } + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_getTransactionHash_1); + } + + // validate the transaction status + let transactionStatus; + try { + transactionStatus = await goerliDataService.getTransactionStatus({ + fromChainId: data.goerli_chainid, + toChainId: data.matic_chainid, + transactionHash: userOpsReceipt.receipt.transactionHash, + provider: BridgingProvider.Connext, + }); + + try { + assert.isNotEmpty( + transactionStatus.status, + message.vali_connext_getTransactionStatus_status + ); + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + } + + try { + assert.isNotEmpty( + transactionStatus.transactionHash, + message.vali_connext_getTransactionStatus_transactionHash + ); + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + } + + try { + assert.isNotEmpty( + transactionStatus.connextscanUrl, + message.vali_connext_getTransactionStatus_connextscanUrl + ); + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + } + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_connext_4); + } + }, data.retry); // Retry this async test up to 5 times + } else { + console.warn(message.connext_insufficientBalance); + } + }); + + it('REGRESSION: Validate the supported assets with invalid chainid on the goerli network', async function () { + var test = this; + let supportedAssets; + if (runTest) { + await customRetryAsync(async function () { + + helper.wait(data.mediumTimeout); + + try { + supportedAssets = + await goerliDataService.getSupportedAssets({ + chainId: data.invalid_goerli_chainid, + provider: BridgingProvider.Connext, + }); + + if (supportedAssets.length === 0) { + addContext(test, message.vali_connext_1) + console.log(message.vali_connext_1) + } else { + addContext(test, message.fail_connext_5) + assert.fail(message.fail_connext_5) + } + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_connext_6); + } + }, data.retry); // Retry this async test up to 5 times + } else { + console.warn(message.connext_insufficientBalance); + } + }); + + it('REGRESSION: Validate the get quotes with invalid sender address on the goerli network', async function () { + var test = this; + let quotes; + if (runTest) { + await customRetryAsync(async function () { + + helper.wait(data.mediumTimeout); + + try { + quotes = await goerliDataService.getQuotes({ + fromAddress: data.invalidSender, + toAddress: data.recipient, + fromChainId: data.goerli_chainid, + toChainId: data.matic_chainid, + fromToken: data.tokenAddress_goerliUSDC, + fromAmount: utils.parseUnits(data.swap_value, 18), + slippage: 0.1, + provider: BridgingProvider.Connext, + }); + + addContext(test, message.fail_connext_7) + assert.fail(message.fail_connext_7); + } catch (e) { + if (e.errors[0].constraints.isAddress === constant.invalid_address_7) { + addContext(test, message.vali_connext_2) + console.log(message.vali_connext_2); + } else { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_connext_7); + } + } + }, data.retry); // Retry this async test up to 5 times + } else { + console.warn(message.connext_insufficientBalance); + } + }); + + it('REGRESSION: Validate the get quotes without sender address on the goerli network', async function () { + var test = this; + let quotes; + if (runTest) { + await customRetryAsync(async function () { + + helper.wait(data.mediumTimeout); + + try { + quotes = await goerliDataService.getQuotes({ + toAddress: data.recipient, + fromChainId: data.goerli_chainid, + toChainId: data.matic_chainid, + fromToken: data.tokenAddress_goerliUSDC, + fromAmount: utils.parseUnits(data.swap_value, 18), + slippage: 0.1, + provider: BridgingProvider.Connext, + }); + + addContext(test, message.fail_connext_8) + assert.fail(message.fail_connext_8); + } catch (e) { + if (e.errors[0].constraints.isAddress === constant.invalid_address_7) { + addContext(test, message.vali_connext_3) + console.log(message.vali_connext_3); + } else { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_connext_8); + } + } + }, data.retry); // Retry this async test up to 5 times + } else { + console.warn(message.connext_insufficientBalance); + } + }); + + it('REGRESSION: Validate the get quotes with incorrect sender address on the goerli network', async function () { + var test = this; + let quotes; + if (runTest) { + await customRetryAsync(async function () { + + helper.wait(data.mediumTimeout); + + try { + quotes = await goerliDataService.getQuotes({ + fromAddress: data.incorrectSender, + toAddress: data.recipient, + fromChainId: data.goerli_chainid, + toChainId: data.matic_chainid, + fromToken: data.tokenAddress_goerliUSDC, + fromAmount: utils.parseUnits(data.swap_value, 18), + slippage: 0.1, + provider: BridgingProvider.Connext, + }); + + addContext(test, message.fail_connext_9) + assert.fail(message.fail_connext_9); + } catch (e) { + if (e.errors[0].constraints.isAddress === constant.invalid_address_7) { + addContext(test, message.vali_connext_4) + console.log(message.vali_connext_4); + } else { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_connext_9); + } + } + }, data.retry); // Retry this async test up to 5 times + } else { + console.warn(message.connext_insufficientBalance); + } + }); + + it('REGRESSION: Validate the get quotes with invalid recepient address on the goerli network', async function () { + var test = this; + let quotes; + if (runTest) { + await customRetryAsync(async function () { + + helper.wait(data.mediumTimeout); + + try { + quotes = await goerliDataService.getQuotes({ + fromAddress: data.sender, + toAddress: data.invalidRecipient, + fromChainId: data.goerli_chainid, + toChainId: data.matic_chainid, + fromToken: data.tokenAddress_goerliUSDC, + fromAmount: utils.parseUnits(data.swap_value, 18), + slippage: 0.1, + provider: BridgingProvider.Connext, + }); + + addContext(test, message.fail_connext_10) + assert.fail(message.fail_connext_10); + } catch (e) { + if (e.errors[0].constraints.isAddress === constant.invalid_address_8) { + addContext(test, message.vali_connext_5) + console.log(message.vali_connext_5); + } else { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_connext_10); + } + } + }, data.retry); // Retry this async test up to 5 times + } else { + console.warn(message.connext_insufficientBalance); + } + }); + + it('REGRESSION: Validate the get quotes without recepient address on the goerli network', async function () { + var test = this; + let quotes; + if (runTest) { + await customRetryAsync(async function () { + + helper.wait(data.mediumTimeout); + + try { + quotes = await goerliDataService.getQuotes({ + fromAddress: data.sender, + fromChainId: data.goerli_chainid, + toChainId: data.matic_chainid, + fromToken: data.tokenAddress_goerliUSDC, + fromAmount: utils.parseUnits(data.swap_value, 18), + slippage: 0.1, + provider: BridgingProvider.Connext, + }); + + addContext(test, message.fail_connext_11) + assert.fail(message.fail_connext_11); + } catch (e) { + if (e.errors[0].constraints.isAddress === constant.invalid_address_8) { + addContext(test, message.vali_connext_6) + console.log(message.vali_connext_6); + } else { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_connext_11); + } + } + }, data.retry); // Retry this async test up to 5 times + } else { + console.warn(message.connext_insufficientBalance); + } + }); + + it('REGRESSION: Validate the get quotes with incorrect recepient address on the goerli network', async function () { + var test = this; + let quotes; + if (runTest) { + await customRetryAsync(async function () { + + helper.wait(data.mediumTimeout); + + try { + quotes = await goerliDataService.getQuotes({ + fromAddress: data.sender, + toAddress: data.incorrectRecipient, + fromChainId: data.goerli_chainid, + toChainId: data.matic_chainid, + fromToken: data.tokenAddress_goerliUSDC, + fromAmount: utils.parseUnits(data.swap_value, 18), + slippage: 0.1, + provider: BridgingProvider.Connext, + }); + + addContext(test, message.fail_connext_12) + assert.fail(message.fail_connext_12); + } catch (e) { + if (e.errors[0].constraints.isAddress === constant.invalid_address_8) { + addContext(test, message.vali_connext_7) + console.log(message.vali_connext_7); + } else { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_connext_12); + } + } + }, data.retry); // Retry this async test up to 5 times + } else { + console.warn(message.connext_insufficientBalance); + } + }); + + it('REGRESSION: Validate the get quotes without fromChainid details on the goerli network', async function () { + var test = this; + let quotes; + if (runTest) { + await customRetryAsync(async function () { + + helper.wait(data.mediumTimeout); + + try { + quotes = await goerliDataService.getQuotes({ + fromAddress: data.sender, + toAddress: data.recipient, + toChainId: data.matic_chainid, + fromToken: data.tokenAddress_goerliUSDC, + fromAmount: utils.parseUnits(data.swap_value, 18), + slippage: 0.1, + provider: BridgingProvider.Connext, + }); + + addContext(test, message.fail_connext_13) + assert.fail(message.fail_connext_13); + } catch (e) { + if (e.message === constant.invalid_address_9) { + addContext(test, message.vali_connext_8) + console.log(message.vali_connext_8); + } else { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_connext_13); + } + } + }, data.retry); // Retry this async test up to 5 times + } else { + console.warn(message.connext_insufficientBalance); + } + }); + + it('REGRESSION: Validate the get quotes without toChainid details on the goerli network', async function () { + var test = this; + let quotes; + if (runTest) { + await customRetryAsync(async function () { + + helper.wait(data.mediumTimeout); + + try { + quotes = await goerliDataService.getQuotes({ + fromAddress: data.sender, + toAddress: data.recipient, + fromChainId: data.goerli_chainid, + fromToken: data.tokenAddress_goerliUSDC, + fromAmount: utils.parseUnits(data.swap_value, 18), + slippage: 0.1, + provider: BridgingProvider.Connext, + }); + + addContext(test, message.fail_connext_14) + assert.fail(message.fail_connext_14); + } catch (e) { + if (e.message === constant.invalid_address_10) { + addContext(test, message.vali_connext_9) + console.log(message.vali_connext_9); + } else { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_connext_14); + } + } + }, data.retry); // Retry this async test up to 5 times + } else { + console.warn(message.connext_insufficientBalance); + } + }); + + it('REGRESSION: Validate the get quotes with invalid from token address on the goerli network', async function () { + var test = this; + let quotes; + if (runTest) { + await customRetryAsync(async function () { + + helper.wait(data.mediumTimeout); + + try { + quotes = await goerliDataService.getQuotes({ + fromAddress: data.sender, + toAddress: data.recipient, + fromChainId: data.goerli_chainid, + toChainId: data.matic_chainid, + fromToken: data.invalidTokenAddress_goerliUSDC, + fromAmount: utils.parseUnits(data.swap_value, 18), + slippage: 0.1, + provider: BridgingProvider.Connext, + }); + + addContext(test, message.fail_connext_15) + assert.fail(message.fail_connext_15); + } catch (e) { + if (e.errors[0].constraints.isAddress === constant.invalid_address_11) { + addContext(test, message.vali_connext_10) + console.log(message.vali_connext_10); + } else { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_connext_15); + } + } + }, data.retry); // Retry this async test up to 5 times + } else { + console.warn(message.connext_insufficientBalance); + } + }); + + it('REGRESSION: Validate the get quotes with incorrect from token address on the goerli network', async function () { + var test = this; + let quotes; + if (runTest) { + await customRetryAsync(async function () { + + helper.wait(data.mediumTimeout); + + try { + quotes = await goerliDataService.getQuotes({ + fromAddress: data.sender, + toAddress: data.recipient, + fromChainId: data.goerli_chainid, + toChainId: data.matic_chainid, + fromToken: data.incorrectTokenAddress_goerliUSDC, + fromAmount: utils.parseUnits(data.swap_value, 18), + slippage: 0.1, + provider: BridgingProvider.Connext, + }); + + addContext(test, message.fail_connext_16) + assert.fail(message.fail_connext_16); + } catch (e) { + if (e.errors[0].constraints.isAddress === constant.invalid_address_11) { + addContext(test, message.vali_connext_11) + console.log(message.vali_connext_11); + } else { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_connext_16); + } + } + }, data.retry); // Retry this async test up to 5 times + } else { + console.warn(message.connext_insufficientBalance); + } + }); + + it('REGRESSION: Validate the get quotes without from token address on the goerli network', async function () { + var test = this; + let quotes; + if (runTest) { + await customRetryAsync(async function () { + + helper.wait(data.mediumTimeout); + + try { + quotes = await goerliDataService.getQuotes({ + fromAddress: data.sender, + toAddress: data.recipient, + fromChainId: data.goerli_chainid, + toChainId: data.matic_chainid, + fromAmount: utils.parseUnits(data.swap_value, 18), + slippage: 0.1, + provider: BridgingProvider.Connext, + }); + + addContext(test, message.fail_connext_17) + assert.fail(message.fail_connext_17); + } catch (e) { + if (e.errors[0].constraints.isAddress === constant.invalid_address_11) { + addContext(test, message.vali_connext_12) + console.log(message.vali_connext_12); + } else { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_connext_17); + } + } + }, data.retry); // Retry this async test up to 5 times + } else { + console.warn(message.connext_insufficientBalance); + } + }); + + it('REGRESSION: Validate the get quotes with invalid value on the goerli network', async function () { + var test = this; + let quotes; + if (runTest) { + await customRetryAsync(async function () { + + helper.wait(data.mediumTimeout); + + try { + quotes = await goerliDataService.getQuotes({ + fromAddress: data.sender, + toAddress: data.recipient, + fromChainId: data.goerli_chainid, + toChainId: data.matic_chainid, + fromToken: data.tokenAddress_goerliUSDC, + fromAmount: utils.parseUnits(data.invalidValue, 18), + slippage: 0.1, + provider: BridgingProvider.Connext, + }); + + addContext(test, message.fail_connext_18) + assert.fail(message.fail_connext_18); + } catch (e) { + if (e.reason === constant.invalid_value_1) { + addContext(test, message.vali_connext_13) + console.log(message.vali_connext_13); + } else { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_connext_18); + } + } + }, data.retry); // Retry this async test up to 5 times + } else { + console.warn(message.connext_insufficientBalance); + } + }); + + it('REGRESSION: Validate the get quotes with small value on the goerli network', async function () { + var test = this; + let quotes; + if (runTest) { + await customRetryAsync(async function () { + + helper.wait(data.mediumTimeout); + + try { + quotes = await goerliDataService.getQuotes({ + fromAddress: data.sender, + toAddress: data.recipient, + fromChainId: data.goerli_chainid, + toChainId: data.matic_chainid, + fromToken: data.tokenAddress_goerliUSDC, + fromAmount: utils.parseUnits(data.smallValue, 18), + slippage: 0.1, + provider: BridgingProvider.Connext, + }); + + addContext(test, message.fail_connext_19) + assert.fail(message.fail_connext_19); + } catch (e) { + if (e.reason === constant.invalid_value_2) { + addContext(test, message.vali_connext_14) + console.log(message.vali_connext_14); + } else { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_connext_19); + } + } + }, data.retry); // Retry this async test up to 5 times + } else { + console.warn(message.connext_insufficientBalance); + } + }); + + it('REGRESSION: Validate the get quotes without value on the goerli network', async function () { + var test = this; + let quotes; + if (runTest) { + await customRetryAsync(async function () { + + helper.wait(data.mediumTimeout); + + try { + quotes = await goerliDataService.getQuotes({ + fromAddress: data.sender, + toAddress: data.recipient, + fromChainId: data.goerli_chainid, + toChainId: data.matic_chainid, + fromToken: data.tokenAddress_goerliUSDC, + slippage: 0.1, + provider: BridgingProvider.Connext, + }); + + addContext(test, message.fail_connext_20) + assert.fail(message.fail_connext_20); + } catch (e) { + if (e.errors[0].constraints.IsBigNumberish === constant.invalid_bignumber_2) { + addContext(test, message.vali_connext_15) + console.log(message.vali_connext_15); + } else { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_connext_20); + } + } + }, data.retry); // Retry this async test up to 5 times + } else { + console.warn(message.connext_insufficientBalance); + } + }); + + it('REGRESSION: Validate the get quotes without slippage on the goerli network', async function () { + var test = this; + let quotes; + if (runTest) { + await customRetryAsync(async function () { + + helper.wait(data.mediumTimeout); + + try { + quotes = await goerliDataService.getQuotes({ + fromAddress: data.sender, + toAddress: data.recipient, + fromChainId: data.goerli_chainid, + toChainId: data.matic_chainid, + fromToken: data.tokenAddress_goerliUSDC, + fromAmount: utils.parseUnits(data.swap_value, 18), + provider: BridgingProvider.Connext, + }); + + addContext(test, message.fail_connext_21) + assert.fail(message.fail_connext_21); + } catch (e) { + if (e.message === constant.invalid_address_13) { + addContext(test, message.vali_connext_16) + console.log(message.vali_connext_16); + } else { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_connext_21); + } + } + }, data.retry); // Retry this async test up to 5 times + } else { + console.warn(message.connext_insufficientBalance); + } + }); + + it('REGRESSION: Validate the get transaction status without fromChainId on the goerli network', async function () { + var test = this; + if (runTest) { + await customRetryAsync(async function () { + + helper.wait(data.mediumTimeout); + + // validate the transaction status + let transactionStatus; + try { + transactionStatus = await goerliDataService.getTransactionStatus({ + toChainId: data.matic_chainid, + transactionHash: data.transactionHash, + provider: BridgingProvider.Connext, + }); + + addContext(test, message.fail_connext_22) + assert.fail(message.fail_connext_22); + } catch (e) { + if (e.errors[0].constraints.isPositive === constant.invalid_chainid_4) { + addContext(test, message.vali_connext_17) + console.log(message.vali_connext_17); + } else { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_connext_22); + } + } + }, data.retry); // Retry this async test up to 5 times + } else { + console.warn(message.connext_insufficientBalance); + } + }); + + it('REGRESSION: Validate the get transaction status without toChainId on the goerli network', async function () { + var test = this; + if (runTest) { + await customRetryAsync(async function () { + + helper.wait(data.mediumTimeout); + + // validate the transaction status + let transactionStatus; + try { + transactionStatus = await goerliDataService.getTransactionStatus({ + fromChainId: data.invalid_goerli_chainid, + transactionHash: data.transactionHash, + provider: BridgingProvider.Connext, + }); + + addContext(test, message.fail_connext_23) + assert.fail(message.fail_connext_23); + } catch (e) { + if (e.errors[0].constraints.isPositive === constant.invalid_chainid_5) { + addContext(test, message.vali_connext_18) + console.log(message.vali_connext_18); + } else { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_connext_23); + } + } + }, data.retry); // Retry this async test up to 5 times + } else { + console.warn(message.connext_insufficientBalance); + } + }); + + it('REGRESSION: Validate the get transaction status with invalid transactionHash on the goerli network', async function () { + var test = this; + if (runTest) { + await customRetryAsync(async function () { + + helper.wait(data.mediumTimeout); + + // validate the transaction status + let transactionStatus; + try { + transactionStatus = await goerliDataService.getTransactionStatus({ + fromChainId: data.invalid_goerli_chainid, + toChainId: data.matic_chainid, + transactionHash: data.invalid_transactionHash, + provider: BridgingProvider.Connext, + }); + + addContext(test, message.fail_connext_24) + assert.fail(message.fail_connext_24); + } catch (e) { + if (e.errors[0].constraints.isHex === constant.transactionHash_32hex) { + addContext(test, message.vali_connext_19) + console.log(message.vali_connext_19); + } else { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_connext_24); + } + } + }, data.retry); // Retry this async test up to 5 times + } else { + console.warn(message.connext_insufficientBalance); + } + }); + + it('REGRESSION: Validate the get transaction status with incorrect transactionHash on the goerli network', async function () { + var test = this; + if (runTest) { + await customRetryAsync(async function () { + + helper.wait(data.mediumTimeout); + + // validate the transaction status + let transactionStatus; + try { + transactionStatus = await goerliDataService.getTransactionStatus({ + fromChainId: data.invalid_goerli_chainid, + toChainId: data.matic_chainid, + transactionHash: data.incorrect_transactionHash, + provider: BridgingProvider.Connext, + }); + + if (transactionStatus.status === constant.invalid_chainid_6) { + addContext(test, message.vali_connext_20) + console.log(message.vali_connext_20); + } else { + addContext(test, eString); + assert.fail(message.fail_connext_25); + } + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_connext_25); + } + }, data.retry); // Retry this async test up to 5 times + } else { + console.warn(message.connext_insufficientBalance); + } + }); + + it('REGRESSION: Validate the get transaction status without transactionHash on the goerli network', async function () { + var test = this; + if (runTest) { + await customRetryAsync(async function () { + + helper.wait(data.mediumTimeout); + + // validate the transaction status + let transactionStatus; + try { + transactionStatus = await goerliDataService.getTransactionStatus({ + fromChainId: data.invalid_goerli_chainid, + toChainId: data.matic_chainid, + provider: BridgingProvider.Connext, + }); + + addContext(test, message.fail_connext_26) + assert.fail(message.fail_connext_26); + } catch (e) { + if (e.errors[0].constraints.isHex === constant.transactionHash_32hex) { + addContext(test, message.vali_connext_21) + console.log(message.vali_connext_21); + } else { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_connext_26); + } + } + }, data.retry); // Retry this async test up to 5 times + } else { + console.warn(message.connext_insufficientBalance); + } + }); +}); diff --git a/test/specs/testnet/connext/mumbai.spec.js b/test/specs/testnet/connext/mumbai.spec.js new file mode 100644 index 0000000..e5da3c9 --- /dev/null +++ b/test/specs/testnet/connext/mumbai.spec.js @@ -0,0 +1,1272 @@ +import * as dotenv from 'dotenv'; +dotenv.config(); // init dotenv +import { PrimeSdk, DataUtils } from '@etherspot/prime-sdk'; +import { utils, constants, BigNumber, ethers } from 'ethers'; +import { BridgingProvider } from '@etherspot/prime-sdk/dist/sdk/data/index.js'; +import { assert } from 'chai'; +import addContext from 'mochawesome/addContext.js'; +import customRetryAsync from '../../../utils/baseTest.js'; +import helper from '../../../utils/helper.js'; +import data from '../../../data/testData.json' assert { type: 'json' }; +import constant from '../../../data/constant.json' assert { type: 'json' }; +import message from '../../../data/messages.json' assert { type: 'json' }; + +let mumbaiTestNetSdk; +let mumbaiEtherspotWalletAddress; +let mumbaiNativeAddress = null; +let mumbaiDataService; +let runTest; + +describe('The PrimeSDK, Validate the connext endpoints with mumbai network on the TestNet', function () { + before(async function () { + var test = this; + + await customRetryAsync(async function () { + + helper.wait(data.mediumTimeout); + + // initializating sdk + try { + mumbaiTestNetSdk = new PrimeSdk( + { privateKey: process.env.PRIVATE_KEY }, + { + chainId: Number(data.mumbai_chainid), + }, + ); + + try { + assert.strictEqual( + mumbaiTestNetSdk.state.EOAAddress, + data.eoaAddress, + message.vali_eoa_address + ); + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + } + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_sdk_initialize); + } + + // get EtherspotWallet address + try { + mumbaiEtherspotWalletAddress = + await mumbaiTestNetSdk.getCounterFactualAddress(); + + try { + assert.strictEqual( + mumbaiEtherspotWalletAddress, + data.sender, + message.vali_smart_address); + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + } + } catch (e) { + console.error(e.message); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_smart_address); + } + + // initializating Data service... + try { + mumbaiDataService = new DataUtils( + process.env.DATA_API_KEY + ); + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_data_service); + } + + // validate the balance of the wallet + try { + let output = await mumbaiDataService.getAccountBalances({ + account: data.sender, + chainId: Number(data.mumbai_chainid), + }); + let native_balance; + let usdc_balance; + let native_final; + let usdc_final; + + for (let i = 0; i < output.items.length; i++) { + let tokenAddress = output.items[i].token; + if (tokenAddress === mumbaiNativeAddress) { + native_balance = output.items[i].balance; + native_final = utils.formatUnits(native_balance, 18); + } else if (tokenAddress === data.tokenAddress_mumbaiUSDC) { + usdc_balance = output.items[i].balance; + usdc_final = utils.formatUnits(usdc_balance, 6); + } + } + + if ( + native_final > data.minimum_native_balance && + usdc_final > data.minimum_token_balance + ) { + runTest = true; + } else { + runTest = false; + } + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_wallet_balance); + } + }, data.retry); // Retry this async test up to 5 times + }); + + it('SMOKE: Validate the all supported assets with valid details on the mumbai network', async function () { + var test = this; + let allSupportedAssets; + if (runTest) { + await customRetryAsync(async function () { + + helper.wait(data.mediumTimeout); + + try { + allSupportedAssets = + await mumbaiDataService.getSupportedAssets({}); + + try { + assert.isNotEmpty( + allSupportedAssets[0].symbol, + message.vali_connext_getSupportedAssets_symbol + ); + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + } + + try { + assert.isNotEmpty( + allSupportedAssets[0].address, + message.vali_connext_getSupportedAssets_address + ); + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + } + + try { + assert.isNumber( + allSupportedAssets[0].decimals, + message.vali_connext_getSupportedAssets_decimals + ); + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + } + + try { + assert.isNumber( + allSupportedAssets[0].chainId, + message.vali_connext_getSupportedAssets_chainId + ); + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + } + + try { + assert.isNotEmpty( + allSupportedAssets[0].icon, + message.vali_connext_getSupportedAssets_icon + ); + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + } + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_connext_1); + } + }, data.retry); // Retry this async test up to 5 times + } else { + console.warn(message.connext_insufficientBalance); + } + }); + + it('SMOKE: Validate the supported assets with valid details on the mumbai network', async function () { + var test = this; + let supportedAssets; + if (runTest) { + await customRetryAsync(async function () { + + helper.wait(data.mediumTimeout); + + try { + supportedAssets = + await mumbaiDataService.getSupportedAssets({ + chainId: data.mumbai_chainid, + provider: BridgingProvider.Connext, + }); + + try { + assert.isNotEmpty( + supportedAssets[0].symbol, + message.vali_connext_getSupportedAssets_symbol + ); + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + } + + try { + assert.isNotEmpty( + supportedAssets[0].address, + message.vali_connext_getSupportedAssets_address + ); + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + } + + try { + assert.isNumber( + supportedAssets[0].decimals, + message.vali_connext_getSupportedAssets_decimals + ); + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + } + + try { + assert.strictEqual( + supportedAssets[0].chainId, + data.mumbai_chainid, + message.vali_connext_getSupportedAssets_chainId + ); + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + } + + try { + assert.isNotEmpty( + supportedAssets[0].icon, + message.vali_connext_getSupportedAssets_icon + ); + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + } + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_connext_2); + } + }, data.retry); // Retry this async test up to 5 times + } else { + console.warn(message.connext_insufficientBalance); + } + }); + + it('SMOKE: Validate the get quotes with valid details on the mumbai network', async function () { + var test = this; + let quotes; + if (runTest) { + await customRetryAsync(async function () { + + helper.wait(data.mediumTimeout); + + try { + quotes = await mumbaiDataService.getQuotes({ + fromAddress: data.sender, + toAddress: data.recipient, + fromChainId: data.mumbai_chainid, + toChainId: data.matic_chainid, + fromToken: data.tokenAddress_mumbaiUSDC, + fromAmount: utils.parseUnits(data.swap_value, 18), + slippage: 0.1, + provider: BridgingProvider.Connext, + }); + + try { + assert.isNotEmpty( + quotes[0].data, + message.vali_connext_getQuotes_data + ); + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + } + + try { + assert.isNotEmpty( + quotes[0].to, + message.vali_connext_getQuotes_to + ); + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + } + + try { + assert.isNotEmpty( + quotes[0].value, + message.vali_connext_getQuotes_value + ); + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + } + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_connext_3); + } + }, data.retry); // Retry this async test up to 5 times + } else { + console.warn(message.connext_insufficientBalance); + } + }); + + it('SMOKE: Validate the get transaction status with valid details on the mumbai network', async function () { + var test = this; + if (runTest) { + await customRetryAsync(async function () { + + helper.wait(data.mediumTimeout); + + // clear the transaction batch + try { + await mumbaiTestNetSdk.clearUserOpsFromBatch(); + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_clearTransaction_1); + } + + // add transactions to the batch + try { + await mumbaiTestNetSdk.addUserOpsToBatch({ + to: data.recipient, + value: ethers.utils.parseEther(data.value), + }); + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_addTransaction_1); + } + + // get balance of the account address + try { + await mumbaiTestNetSdk.getNativeBalance(); + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_getBalance_1); + } + + // estimate transactions added to the batch and get the fee data for the UserOp + let op; + try { + op = await mumbaiTestNetSdk.estimate(); + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_estimateTransaction_1); + } + + // sign the UserOp and sending to the bundler + let uoHash; + try { + uoHash = await mumbaiTestNetSdk.send(op); + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_submitTransaction_1); + } + + // get transaction hash + let userOpsReceipt = null; + try { + console.log('Waiting for transaction...'); + const timeout = Date.now() + 60000; // 1 minute timeout + while (userOpsReceipt == null && Date.now() < timeout) { + await helper.wait(5000); + userOpsReceipt = await mumbaiTestNetSdk.getUserOpReceipt(uoHash); + } + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_getTransactionHash_1); + } + + // validate the transaction status + let transactionStatus; + try { + transactionStatus = await mumbaiDataService.getTransactionStatus({ + fromChainId: data.mumbai_chainid, + toChainId: data.matic_chainid, + transactionHash: userOpsReceipt.receipt.transactionHash, + provider: BridgingProvider.Connext, + }); + + try { + assert.isNotEmpty( + transactionStatus.status, + message.vali_connext_getTransactionStatus_status + ); + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + } + + try { + assert.isNotEmpty( + transactionStatus.transactionHash, + message.vali_connext_getTransactionStatus_transactionHash + ); + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + } + + try { + assert.isNotEmpty( + transactionStatus.connextscanUrl, + message.vali_connext_getTransactionStatus_connextscanUrl + ); + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + } + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_connext_4); + } + }, data.retry); // Retry this async test up to 5 times + } else { + console.warn(message.connext_insufficientBalance); + } + }); + + it('REGRESSION: Validate the supported assets with invalid chainid on the mumbai network', async function () { + var test = this; + let supportedAssets; + if (runTest) { + await customRetryAsync(async function () { + + helper.wait(data.mediumTimeout); + + try { + supportedAssets = + await mumbaiDataService.getSupportedAssets({ + chainId: data.invalid_mumbai_chainid, + provider: BridgingProvider.Connext, + }); + + if (supportedAssets.length === 0) { + addContext(test, message.vali_connext_1) + console.log(message.vali_connext_1) + } else { + addContext(test, message.fail_connext_5) + assert.fail(message.fail_connext_5) + } + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_connext_6); + } + }, data.retry); // Retry this async test up to 5 times + } else { + console.warn(message.connext_insufficientBalance); + } + }); + + it('REGRESSION: Validate the get quotes with invalid sender address on the mumbai network', async function () { + var test = this; + let quotes; + if (runTest) { + await customRetryAsync(async function () { + + helper.wait(data.mediumTimeout); + + try { + quotes = await mumbaiDataService.getQuotes({ + fromAddress: data.invalidSender, + toAddress: data.recipient, + fromChainId: data.mumbai_chainid, + toChainId: data.matic_chainid, + fromToken: data.tokenAddress_mumbaiUSDC, + fromAmount: utils.parseUnits(data.swap_value, 18), + slippage: 0.1, + provider: BridgingProvider.Connext, + }); + + addContext(test, message.fail_connext_7) + assert.fail(message.fail_connext_7); + } catch (e) { + if (e.errors[0].constraints.isAddress === constant.invalid_address_7) { + addContext(test, message.vali_connext_2) + console.log(message.vali_connext_2); + } else { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_connext_7); + } + } + }, data.retry); // Retry this async test up to 5 times + } else { + console.warn(message.connext_insufficientBalance); + } + }); + + it('REGRESSION: Validate the get quotes without sender address on the mumbai network', async function () { + var test = this; + let quotes; + if (runTest) { + await customRetryAsync(async function () { + + helper.wait(data.mediumTimeout); + + try { + quotes = await mumbaiDataService.getQuotes({ + toAddress: data.recipient, + fromChainId: data.mumbai_chainid, + toChainId: data.matic_chainid, + fromToken: data.tokenAddress_mumbaiUSDC, + fromAmount: utils.parseUnits(data.swap_value, 18), + slippage: 0.1, + provider: BridgingProvider.Connext, + }); + + addContext(test, message.fail_connext_8) + assert.fail(message.fail_connext_8); + } catch (e) { + if (e.errors[0].constraints.isAddress === constant.invalid_address_7) { + addContext(test, message.vali_connext_3) + console.log(message.vali_connext_3); + } else { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_connext_8); + } + } + }, data.retry); // Retry this async test up to 5 times + } else { + console.warn(message.connext_insufficientBalance); + } + }); + + it('REGRESSION: Validate the get quotes with incorrect sender address on the mumbai network', async function () { + var test = this; + let quotes; + if (runTest) { + await customRetryAsync(async function () { + + helper.wait(data.mediumTimeout); + + try { + quotes = await mumbaiDataService.getQuotes({ + fromAddress: data.incorrectSender, + toAddress: data.recipient, + fromChainId: data.mumbai_chainid, + toChainId: data.matic_chainid, + fromToken: data.tokenAddress_mumbaiUSDC, + fromAmount: utils.parseUnits(data.swap_value, 18), + slippage: 0.1, + provider: BridgingProvider.Connext, + }); + + addContext(test, message.fail_connext_9) + assert.fail(message.fail_connext_9); + } catch (e) { + if (e.errors[0].constraints.isAddress === constant.invalid_address_7) { + addContext(test, message.vali_connext_4) + console.log(message.vali_connext_4); + } else { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_connext_9); + } + } + }, data.retry); // Retry this async test up to 5 times + } else { + console.warn(message.connext_insufficientBalance); + } + }); + + it('REGRESSION: Validate the get quotes with invalid recepient address on the mumbai network', async function () { + var test = this; + let quotes; + if (runTest) { + await customRetryAsync(async function () { + + helper.wait(data.mediumTimeout); + + try { + quotes = await mumbaiDataService.getQuotes({ + fromAddress: data.sender, + toAddress: data.invalidRecipient, + fromChainId: data.mumbai_chainid, + toChainId: data.matic_chainid, + fromToken: data.tokenAddress_mumbaiUSDC, + fromAmount: utils.parseUnits(data.swap_value, 18), + slippage: 0.1, + provider: BridgingProvider.Connext, + }); + + addContext(test, message.fail_connext_10) + assert.fail(message.fail_connext_10); + } catch (e) { + if (e.errors[0].constraints.isAddress === constant.invalid_address_8) { + addContext(test, message.vali_connext_5) + console.log(message.vali_connext_5); + } else { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_connext_10); + } + } + }, data.retry); // Retry this async test up to 5 times + } else { + console.warn(message.connext_insufficientBalance); + } + }); + + it('REGRESSION: Validate the get quotes without recepient address on the mumbai network', async function () { + var test = this; + let quotes; + if (runTest) { + await customRetryAsync(async function () { + + helper.wait(data.mediumTimeout); + + try { + quotes = await mumbaiDataService.getQuotes({ + fromAddress: data.sender, + fromChainId: data.mumbai_chainid, + toChainId: data.matic_chainid, + fromToken: data.tokenAddress_mumbaiUSDC, + fromAmount: utils.parseUnits(data.swap_value, 18), + slippage: 0.1, + provider: BridgingProvider.Connext, + }); + + addContext(test, message.fail_connext_11) + assert.fail(message.fail_connext_11); + } catch (e) { + if (e.errors[0].constraints.isAddress === constant.invalid_address_8) { + addContext(test, message.vali_connext_6) + console.log(message.vali_connext_6); + } else { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_connext_11); + } + } + }, data.retry); // Retry this async test up to 5 times + } else { + console.warn(message.connext_insufficientBalance); + } + }); + + it('REGRESSION: Validate the get quotes with incorrect recepient address on the mumbai network', async function () { + var test = this; + let quotes; + if (runTest) { + await customRetryAsync(async function () { + + helper.wait(data.mediumTimeout); + + try { + quotes = await mumbaiDataService.getQuotes({ + fromAddress: data.sender, + toAddress: data.incorrectRecipient, + fromChainId: data.mumbai_chainid, + toChainId: data.matic_chainid, + fromToken: data.tokenAddress_mumbaiUSDC, + fromAmount: utils.parseUnits(data.swap_value, 18), + slippage: 0.1, + provider: BridgingProvider.Connext, + }); + + addContext(test, message.fail_connext_12) + assert.fail(message.fail_connext_12); + } catch (e) { + if (e.errors[0].constraints.isAddress === constant.invalid_address_8) { + addContext(test, message.vali_connext_7) + console.log(message.vali_connext_7); + } else { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_connext_12); + } + } + }, data.retry); // Retry this async test up to 5 times + } else { + console.warn(message.connext_insufficientBalance); + } + }); + + it('REGRESSION: Validate the get quotes without fromChainid details on the mumbai network', async function () { + var test = this; + let quotes; + if (runTest) { + await customRetryAsync(async function () { + + helper.wait(data.mediumTimeout); + + try { + quotes = await mumbaiDataService.getQuotes({ + fromAddress: data.sender, + toAddress: data.recipient, + toChainId: data.matic_chainid, + fromToken: data.tokenAddress_mumbaiUSDC, + fromAmount: utils.parseUnits(data.swap_value, 18), + slippage: 0.1, + provider: BridgingProvider.Connext, + }); + + addContext(test, message.fail_connext_13) + assert.fail(message.fail_connext_13); + } catch (e) { + if (e.message === constant.invalid_address_9) { + addContext(test, message.vali_connext_8) + console.log(message.vali_connext_8); + } else { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_connext_13); + } + } + }, data.retry); // Retry this async test up to 5 times + } else { + console.warn(message.connext_insufficientBalance); + } + }); + + it('REGRESSION: Validate the get quotes without toChainid details on the mumbai network', async function () { + var test = this; + let quotes; + if (runTest) { + await customRetryAsync(async function () { + + helper.wait(data.mediumTimeout); + + try { + quotes = await mumbaiDataService.getQuotes({ + fromAddress: data.sender, + toAddress: data.recipient, + fromChainId: data.mumbai_chainid, + fromToken: data.tokenAddress_mumbaiUSDC, + fromAmount: utils.parseUnits(data.swap_value, 18), + slippage: 0.1, + provider: BridgingProvider.Connext, + }); + + addContext(test, message.fail_connext_14) + assert.fail(message.fail_connext_14); + } catch (e) { + if (e.message === constant.invalid_address_10) { + addContext(test, message.vali_connext_9) + console.log(message.vali_connext_9); + } else { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_connext_14); + } + } + }, data.retry); // Retry this async test up to 5 times + } else { + console.warn(message.connext_insufficientBalance); + } + }); + + it('REGRESSION: Validate the get quotes with invalid from token address on the mumbai network', async function () { + var test = this; + let quotes; + if (runTest) { + await customRetryAsync(async function () { + + helper.wait(data.mediumTimeout); + + try { + quotes = await mumbaiDataService.getQuotes({ + fromAddress: data.sender, + toAddress: data.recipient, + fromChainId: data.mumbai_chainid, + toChainId: data.matic_chainid, + fromToken: data.invalidTokenAddress_mumbaiUSDC, + fromAmount: utils.parseUnits(data.swap_value, 18), + slippage: 0.1, + provider: BridgingProvider.Connext, + }); + + addContext(test, message.fail_connext_15) + assert.fail(message.fail_connext_15); + } catch (e) { + if (e.errors[0].constraints.isAddress === constant.invalid_address_11) { + addContext(test, message.vali_connext_10) + console.log(message.vali_connext_10); + } else { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_connext_15); + } + } + }, data.retry); // Retry this async test up to 5 times + } else { + console.warn(message.connext_insufficientBalance); + } + }); + + it('REGRESSION: Validate the get quotes with incorrect from token address on the mumbai network', async function () { + var test = this; + let quotes; + if (runTest) { + await customRetryAsync(async function () { + + helper.wait(data.mediumTimeout); + + try { + quotes = await mumbaiDataService.getQuotes({ + fromAddress: data.sender, + toAddress: data.recipient, + fromChainId: data.mumbai_chainid, + toChainId: data.matic_chainid, + fromToken: data.incorrectTokenAddress_mumbaiUSDC, + fromAmount: utils.parseUnits(data.swap_value, 18), + slippage: 0.1, + provider: BridgingProvider.Connext, + }); + + addContext(test, message.fail_connext_16) + assert.fail(message.fail_connext_16); + } catch (e) { + if (e.errors[0].constraints.isAddress === constant.invalid_address_11) { + addContext(test, message.vali_connext_11) + console.log(message.vali_connext_11); + } else { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_connext_16); + } + } + }, data.retry); // Retry this async test up to 5 times + } else { + console.warn(message.connext_insufficientBalance); + } + }); + + it('REGRESSION: Validate the get quotes without from token address on the mumbai network', async function () { + var test = this; + let quotes; + if (runTest) { + await customRetryAsync(async function () { + + helper.wait(data.mediumTimeout); + + try { + quotes = await mumbaiDataService.getQuotes({ + fromAddress: data.sender, + toAddress: data.recipient, + fromChainId: data.mumbai_chainid, + toChainId: data.matic_chainid, + fromAmount: utils.parseUnits(data.swap_value, 18), + slippage: 0.1, + provider: BridgingProvider.Connext, + }); + + addContext(test, message.fail_connext_17) + assert.fail(message.fail_connext_17); + } catch (e) { + if (e.errors[0].constraints.isAddress === constant.invalid_address_11) { + addContext(test, message.vali_connext_12) + console.log(message.vali_connext_12); + } else { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_connext_17); + } + } + }, data.retry); // Retry this async test up to 5 times + } else { + console.warn(message.connext_insufficientBalance); + } + }); + + it('REGRESSION: Validate the get quotes with invalid value on the mumbai network', async function () { + var test = this; + let quotes; + if (runTest) { + await customRetryAsync(async function () { + + helper.wait(data.mediumTimeout); + + try { + quotes = await mumbaiDataService.getQuotes({ + fromAddress: data.sender, + toAddress: data.recipient, + fromChainId: data.mumbai_chainid, + toChainId: data.matic_chainid, + fromToken: data.tokenAddress_mumbaiUSDC, + fromAmount: utils.parseUnits(data.invalidValue, 18), + slippage: 0.1, + provider: BridgingProvider.Connext, + }); + + addContext(test, message.fail_connext_18) + assert.fail(message.fail_connext_18); + } catch (e) { + if (e.reason === constant.invalid_value_1) { + addContext(test, message.vali_connext_13) + console.log(message.vali_connext_13); + } else { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_connext_18); + } + } + }, data.retry); // Retry this async test up to 5 times + } else { + console.warn(message.connext_insufficientBalance); + } + }); + + it('REGRESSION: Validate the get quotes with small value on the mumbai network', async function () { + var test = this; + let quotes; + if (runTest) { + await customRetryAsync(async function () { + + helper.wait(data.mediumTimeout); + + try { + quotes = await mumbaiDataService.getQuotes({ + fromAddress: data.sender, + toAddress: data.recipient, + fromChainId: data.mumbai_chainid, + toChainId: data.matic_chainid, + fromToken: data.tokenAddress_mumbaiUSDC, + fromAmount: utils.parseUnits(data.smallValue, 18), + slippage: 0.1, + provider: BridgingProvider.Connext, + }); + + addContext(test, message.fail_connext_19) + assert.fail(message.fail_connext_19); + } catch (e) { + if (e.reason === constant.invalid_value_2) { + addContext(test, message.vali_connext_14) + console.log(message.vali_connext_14); + } else { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_connext_19); + } + } + }, data.retry); // Retry this async test up to 5 times + } else { + console.warn(message.connext_insufficientBalance); + } + }); + + it('REGRESSION: Validate the get quotes without value on the mumbai network', async function () { + var test = this; + let quotes; + if (runTest) { + await customRetryAsync(async function () { + + helper.wait(data.mediumTimeout); + + try { + quotes = await mumbaiDataService.getQuotes({ + fromAddress: data.sender, + toAddress: data.recipient, + fromChainId: data.mumbai_chainid, + toChainId: data.matic_chainid, + fromToken: data.tokenAddress_mumbaiUSDC, + slippage: 0.1, + provider: BridgingProvider.Connext, + }); + + addContext(test, message.fail_connext_20) + assert.fail(message.fail_connext_20); + } catch (e) { + if (e.errors[0].constraints.IsBigNumberish === constant.invalid_bignumber_2) { + addContext(test, message.vali_connext_15) + console.log(message.vali_connext_15); + } else { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_connext_20); + } + } + }, data.retry); // Retry this async test up to 5 times + } else { + console.warn(message.connext_insufficientBalance); + } + }); + + it('REGRESSION: Validate the get quotes without slippage on the mumbai network', async function () { + var test = this; + let quotes; + if (runTest) { + await customRetryAsync(async function () { + + helper.wait(data.mediumTimeout); + + try { + quotes = await mumbaiDataService.getQuotes({ + fromAddress: data.sender, + toAddress: data.recipient, + fromChainId: data.mumbai_chainid, + toChainId: data.matic_chainid, + fromToken: data.tokenAddress_mumbaiUSDC, + fromAmount: utils.parseUnits(data.swap_value, 18), + provider: BridgingProvider.Connext, + }); + + addContext(test, message.fail_connext_21) + assert.fail(message.fail_connext_21); + } catch (e) { + if (e.message === constant.invalid_address_13) { + addContext(test, message.vali_connext_16) + console.log(message.vali_connext_16); + } else { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_connext_21); + } + } + }, data.retry); // Retry this async test up to 5 times + } else { + console.warn(message.connext_insufficientBalance); + } + }); + + it('REGRESSION: Validate the get transaction status without fromChainId on the mumbai network', async function () { + var test = this; + if (runTest) { + await customRetryAsync(async function () { + + helper.wait(data.mediumTimeout); + + // validate the transaction status + let transactionStatus; + try { + transactionStatus = await mumbaiDataService.getTransactionStatus({ + toChainId: data.matic_chainid, + transactionHash: data.transactionHash, + provider: BridgingProvider.Connext, + }); + + addContext(test, message.fail_connext_22) + assert.fail(message.fail_connext_22); + } catch (e) { + if (e.errors[0].constraints.isPositive === constant.invalid_chainid_4) { + addContext(test, message.vali_connext_17) + console.log(message.vali_connext_17); + } else { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_connext_22); + } + } + }, data.retry); // Retry this async test up to 5 times + } else { + console.warn(message.connext_insufficientBalance); + } + }); + + it('REGRESSION: Validate the get transaction status without toChainId on the mumbai network', async function () { + var test = this; + if (runTest) { + await customRetryAsync(async function () { + + helper.wait(data.mediumTimeout); + + // validate the transaction status + let transactionStatus; + try { + transactionStatus = await mumbaiDataService.getTransactionStatus({ + fromChainId: data.invalid_mumbai_chainid, + transactionHash: data.transactionHash, + provider: BridgingProvider.Connext, + }); + + addContext(test, message.fail_connext_23) + assert.fail(message.fail_connext_23); + } catch (e) { + if (e.errors[0].constraints.isPositive === constant.invalid_chainid_5) { + addContext(test, message.vali_connext_18) + console.log(message.vali_connext_18); + } else { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_connext_23); + } + } + }, data.retry); // Retry this async test up to 5 times + } else { + console.warn(message.connext_insufficientBalance); + } + }); + + it('REGRESSION: Validate the get transaction status with invalid transactionHash on the mumbai network', async function () { + var test = this; + if (runTest) { + await customRetryAsync(async function () { + + helper.wait(data.mediumTimeout); + + // validate the transaction status + let transactionStatus; + try { + transactionStatus = await mumbaiDataService.getTransactionStatus({ + fromChainId: data.invalid_mumbai_chainid, + toChainId: data.matic_chainid, + transactionHash: data.invalid_transactionHash, + provider: BridgingProvider.Connext, + }); + + addContext(test, message.fail_connext_24) + assert.fail(message.fail_connext_24); + } catch (e) { + if (e.errors[0].constraints.isHex === constant.transactionHash_32hex) { + addContext(test, message.vali_connext_19) + console.log(message.vali_connext_19); + } else { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_connext_24); + } + } + }, data.retry); // Retry this async test up to 5 times + } else { + console.warn(message.connext_insufficientBalance); + } + }); + + it('REGRESSION: Validate the get transaction status with incorrect transactionHash on the mumbai network', async function () { + var test = this; + if (runTest) { + await customRetryAsync(async function () { + + helper.wait(data.mediumTimeout); + + // validate the transaction status + let transactionStatus; + try { + transactionStatus = await mumbaiDataService.getTransactionStatus({ + fromChainId: data.invalid_mumbai_chainid, + toChainId: data.matic_chainid, + transactionHash: data.incorrect_transactionHash, + provider: BridgingProvider.Connext, + }); + + if (transactionStatus.status === constant.invalid_chainid_6) { + addContext(test, message.vali_connext_20) + console.log(message.vali_connext_20); + } else { + addContext(test, eString); + assert.fail(message.fail_connext_25); + } + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_connext_25); + } + }, data.retry); // Retry this async test up to 5 times + } else { + console.warn(message.connext_insufficientBalance); + } + }); + + it('REGRESSION: Validate the get transaction status without transactionHash on the mumbai network', async function () { + var test = this; + if (runTest) { + await customRetryAsync(async function () { + + helper.wait(data.mediumTimeout); + + // validate the transaction status + let transactionStatus; + try { + transactionStatus = await mumbaiDataService.getTransactionStatus({ + fromChainId: data.invalid_mumbai_chainid, + toChainId: data.matic_chainid, + provider: BridgingProvider.Connext, + }); + + addContext(test, message.fail_connext_26) + assert.fail(message.fail_connext_26); + } catch (e) { + if (e.errors[0].constraints.isHex === constant.transactionHash_32hex) { + addContext(test, message.vali_connext_21) + console.log(message.vali_connext_21); + } else { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_connext_26); + } + } + }, data.retry); // Retry this async test up to 5 times + } else { + console.warn(message.connext_insufficientBalance); + } + }); +}); diff --git a/test/specs/testnet/connext/sepolia.spec.js b/test/specs/testnet/connext/sepolia.spec.js new file mode 100644 index 0000000..94c6626 --- /dev/null +++ b/test/specs/testnet/connext/sepolia.spec.js @@ -0,0 +1,1272 @@ +import * as dotenv from 'dotenv'; +dotenv.config(); // init dotenv +import { PrimeSdk, DataUtils } from '@etherspot/prime-sdk'; +import { utils, constants, BigNumber, ethers } from 'ethers'; +import { BridgingProvider } from '@etherspot/prime-sdk/dist/sdk/data/index.js'; +import { assert } from 'chai'; +import addContext from 'mochawesome/addContext.js'; +import customRetryAsync from '../../../utils/baseTest.js'; +import helper from '../../../utils/helper.js'; +import data from '../../../data/testData.json' assert { type: 'json' }; +import constant from '../../../data/constant.json' assert { type: 'json' }; +import message from '../../../data/messages.json' assert { type: 'json' }; + +let sepoliaTestNetSdk; +let sepoliaEtherspotWalletAddress; +let sepoliaNativeAddress = null; +let sepoliaDataService; +let runTest; + +describe('The PrimeSDK, Validate the connext endpoints with sepolia network on the TestNet', function () { + before(async function () { + var test = this; + + await customRetryAsync(async function () { + + helper.wait(data.mediumTimeout); + + // initializating sdk + try { + sepoliaTestNetSdk = new PrimeSdk( + { privateKey: process.env.PRIVATE_KEY }, + { + chainId: Number(data.sepolia_chainid), + }, + ); + + try { + assert.strictEqual( + sepoliaTestNetSdk.state.EOAAddress, + data.eoaAddress, + message.vali_eoa_address + ); + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + } + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_sdk_initialize); + } + + // get EtherspotWallet address + try { + sepoliaEtherspotWalletAddress = + await sepoliaTestNetSdk.getCounterFactualAddress(); + + try { + assert.strictEqual( + sepoliaEtherspotWalletAddress, + data.sender, + message.vali_smart_address); + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + } + } catch (e) { + console.error(e.message); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_smart_address); + } + + // initializating Data service... + try { + sepoliaDataService = new DataUtils( + process.env.DATA_API_KEY + ); + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_data_service); + } + + // validate the balance of the wallet + try { + let output = await sepoliaDataService.getAccountBalances({ + account: data.sender, + chainId: Number(data.sepolia_chainid), + }); + let native_balance; + let usdc_balance; + let native_final; + let usdc_final; + + for (let i = 0; i < output.items.length; i++) { + let tokenAddress = output.items[i].token; + if (tokenAddress === sepoliaNativeAddress) { + native_balance = output.items[i].balance; + native_final = utils.formatUnits(native_balance, 18); + } else if (tokenAddress === data.tokenAddress_sepoliaUSDC) { + usdc_balance = output.items[i].balance; + usdc_final = utils.formatUnits(usdc_balance, 6); + } + } + + if ( + native_final > data.minimum_native_balance && + usdc_final > data.minimum_token_balance + ) { + runTest = true; + } else { + runTest = false; + } + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_wallet_balance); + } + }, data.retry); // Retry this async test up to 5 times + }); + + it('SMOKE: Validate the all supported assets with valid details on the sepolia network', async function () { + var test = this; + let allSupportedAssets; + if (runTest) { + await customRetryAsync(async function () { + + helper.wait(data.mediumTimeout); + + try { + allSupportedAssets = + await sepoliaDataService.getSupportedAssets({}); + + try { + assert.isNotEmpty( + allSupportedAssets[0].symbol, + message.vali_connext_getSupportedAssets_symbol + ); + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + } + + try { + assert.isNotEmpty( + allSupportedAssets[0].address, + message.vali_connext_getSupportedAssets_address + ); + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + } + + try { + assert.isNumber( + allSupportedAssets[0].decimals, + message.vali_connext_getSupportedAssets_decimals + ); + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + } + + try { + assert.isNumber( + allSupportedAssets[0].chainId, + message.vali_connext_getSupportedAssets_chainId + ); + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + } + + try { + assert.isNotEmpty( + allSupportedAssets[0].icon, + message.vali_connext_getSupportedAssets_icon + ); + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + } + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_connext_1); + } + }, data.retry); // Retry this async test up to 5 times + } else { + console.warn(message.connext_insufficientBalance); + } + }); + + it('SMOKE: Validate the supported assets with valid details on the sepolia network', async function () { + var test = this; + let supportedAssets; + if (runTest) { + await customRetryAsync(async function () { + + helper.wait(data.mediumTimeout); + + try { + supportedAssets = + await sepoliaDataService.getSupportedAssets({ + chainId: data.sepolia_chainid, + provider: BridgingProvider.Connext, + }); + + try { + assert.isNotEmpty( + supportedAssets[0].symbol, + message.vali_connext_getSupportedAssets_symbol + ); + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + } + + try { + assert.isNotEmpty( + supportedAssets[0].address, + message.vali_connext_getSupportedAssets_address + ); + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + } + + try { + assert.isNumber( + supportedAssets[0].decimals, + message.vali_connext_getSupportedAssets_decimals + ); + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + } + + try { + assert.strictEqual( + supportedAssets[0].chainId, + data.sepolia_chainid, + message.vali_connext_getSupportedAssets_chainId + ); + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + } + + try { + assert.isNotEmpty( + supportedAssets[0].icon, + message.vali_connext_getSupportedAssets_icon + ); + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + } + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_connext_2); + } + }, data.retry); // Retry this async test up to 5 times + } else { + console.warn(message.connext_insufficientBalance); + } + }); + + it('SMOKE: Validate the get quotes with valid details on the sepolia network', async function () { + var test = this; + let quotes; + if (runTest) { + await customRetryAsync(async function () { + + helper.wait(data.mediumTimeout); + + try { + quotes = await sepoliaDataService.getQuotes({ + fromAddress: data.sender, + toAddress: data.recipient, + fromChainId: data.sepolia_chainid, + toChainId: data.matic_chainid, + fromToken: data.tokenAddress_sepoliaUSDC, + fromAmount: utils.parseUnits(data.swap_value, 18), + slippage: 0.1, + provider: BridgingProvider.Connext, + }); + + try { + assert.isNotEmpty( + quotes[0].data, + message.vali_connext_getQuotes_data + ); + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + } + + try { + assert.isNotEmpty( + quotes[0].to, + message.vali_connext_getQuotes_to + ); + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + } + + try { + assert.isNotEmpty( + quotes[0].value, + message.vali_connext_getQuotes_value + ); + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + } + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_connext_3); + } + }, data.retry); // Retry this async test up to 5 times + } else { + console.warn(message.connext_insufficientBalance); + } + }); + + it('SMOKE: Validate the get transaction status with valid details on the sepolia network', async function () { + var test = this; + if (runTest) { + await customRetryAsync(async function () { + + helper.wait(data.mediumTimeout); + + // clear the transaction batch + try { + await sepoliaTestNetSdk.clearUserOpsFromBatch(); + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_clearTransaction_1); + } + + // add transactions to the batch + try { + await sepoliaTestNetSdk.addUserOpsToBatch({ + to: data.recipient, + value: ethers.utils.parseEther(data.value), + }); + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_addTransaction_1); + } + + // get balance of the account address + try { + await sepoliaTestNetSdk.getNativeBalance(); + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_getBalance_1); + } + + // estimate transactions added to the batch and get the fee data for the UserOp + let op; + try { + op = await sepoliaTestNetSdk.estimate(); + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_estimateTransaction_1); + } + + // sign the UserOp and sending to the bundler + let uoHash; + try { + uoHash = await sepoliaTestNetSdk.send(op); + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_submitTransaction_1); + } + + // get transaction hash + let userOpsReceipt = null; + try { + console.log('Waiting for transaction...'); + const timeout = Date.now() + 60000; // 1 minute timeout + while (userOpsReceipt == null && Date.now() < timeout) { + await helper.wait(5000); + userOpsReceipt = await sepoliaTestNetSdk.getUserOpReceipt(uoHash); + } + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_getTransactionHash_1); + } + + // validate the transaction status + let transactionStatus; + try { + transactionStatus = await sepoliaDataService.getTransactionStatus({ + fromChainId: data.sepolia_chainid, + toChainId: data.matic_chainid, + transactionHash: userOpsReceipt.receipt.transactionHash, + provider: BridgingProvider.Connext, + }); + + try { + assert.isNotEmpty( + transactionStatus.status, + message.vali_connext_getTransactionStatus_status + ); + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + } + + try { + assert.isNotEmpty( + transactionStatus.transactionHash, + message.vali_connext_getTransactionStatus_transactionHash + ); + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + } + + try { + assert.isNotEmpty( + transactionStatus.connextscanUrl, + message.vali_connext_getTransactionStatus_connextscanUrl + ); + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + } + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_connext_4); + } + }, data.retry); // Retry this async test up to 5 times + } else { + console.warn(message.connext_insufficientBalance); + } + }); + + it('REGRESSION: Validate the supported assets with invalid chainid on the sepolia network', async function () { + var test = this; + let supportedAssets; + if (runTest) { + await customRetryAsync(async function () { + + helper.wait(data.mediumTimeout); + + try { + supportedAssets = + await sepoliaDataService.getSupportedAssets({ + chainId: data.invalid_sepolia_chainid, + provider: BridgingProvider.Connext, + }); + + if (supportedAssets.length === 0) { + addContext(test, message.vali_connext_1) + console.log(message.vali_connext_1) + } else { + addContext(test, message.fail_connext_5) + assert.fail(message.fail_connext_5) + } + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_connext_6); + } + }, data.retry); // Retry this async test up to 5 times + } else { + console.warn(message.connext_insufficientBalance); + } + }); + + it('REGRESSION: Validate the get quotes with invalid sender address on the sepolia network', async function () { + var test = this; + let quotes; + if (runTest) { + await customRetryAsync(async function () { + + helper.wait(data.mediumTimeout); + + try { + quotes = await sepoliaDataService.getQuotes({ + fromAddress: data.invalidSender, + toAddress: data.recipient, + fromChainId: data.sepolia_chainid, + toChainId: data.matic_chainid, + fromToken: data.tokenAddress_sepoliaUSDC, + fromAmount: utils.parseUnits(data.swap_value, 18), + slippage: 0.1, + provider: BridgingProvider.Connext, + }); + + addContext(test, message.fail_connext_7) + assert.fail(message.fail_connext_7); + } catch (e) { + if (e.errors[0].constraints.isAddress === constant.invalid_address_7) { + addContext(test, message.vali_connext_2) + console.log(message.vali_connext_2); + } else { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_connext_7); + } + } + }, data.retry); // Retry this async test up to 5 times + } else { + console.warn(message.connext_insufficientBalance); + } + }); + + it('REGRESSION: Validate the get quotes without sender address on the sepolia network', async function () { + var test = this; + let quotes; + if (runTest) { + await customRetryAsync(async function () { + + helper.wait(data.mediumTimeout); + + try { + quotes = await sepoliaDataService.getQuotes({ + toAddress: data.recipient, + fromChainId: data.sepolia_chainid, + toChainId: data.matic_chainid, + fromToken: data.tokenAddress_sepoliaUSDC, + fromAmount: utils.parseUnits(data.swap_value, 18), + slippage: 0.1, + provider: BridgingProvider.Connext, + }); + + addContext(test, message.fail_connext_8) + assert.fail(message.fail_connext_8); + } catch (e) { + if (e.errors[0].constraints.isAddress === constant.invalid_address_7) { + addContext(test, message.vali_connext_3) + console.log(message.vali_connext_3); + } else { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_connext_8); + } + } + }, data.retry); // Retry this async test up to 5 times + } else { + console.warn(message.connext_insufficientBalance); + } + }); + + it('REGRESSION: Validate the get quotes with incorrect sender address on the sepolia network', async function () { + var test = this; + let quotes; + if (runTest) { + await customRetryAsync(async function () { + + helper.wait(data.mediumTimeout); + + try { + quotes = await sepoliaDataService.getQuotes({ + fromAddress: data.incorrectSender, + toAddress: data.recipient, + fromChainId: data.sepolia_chainid, + toChainId: data.matic_chainid, + fromToken: data.tokenAddress_sepoliaUSDC, + fromAmount: utils.parseUnits(data.swap_value, 18), + slippage: 0.1, + provider: BridgingProvider.Connext, + }); + + addContext(test, message.fail_connext_9) + assert.fail(message.fail_connext_9); + } catch (e) { + if (e.errors[0].constraints.isAddress === constant.invalid_address_7) { + addContext(test, message.vali_connext_4) + console.log(message.vali_connext_4); + } else { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_connext_9); + } + } + }, data.retry); // Retry this async test up to 5 times + } else { + console.warn(message.connext_insufficientBalance); + } + }); + + it('REGRESSION: Validate the get quotes with invalid recepient address on the sepolia network', async function () { + var test = this; + let quotes; + if (runTest) { + await customRetryAsync(async function () { + + helper.wait(data.mediumTimeout); + + try { + quotes = await sepoliaDataService.getQuotes({ + fromAddress: data.sender, + toAddress: data.invalidRecipient, + fromChainId: data.sepolia_chainid, + toChainId: data.matic_chainid, + fromToken: data.tokenAddress_sepoliaUSDC, + fromAmount: utils.parseUnits(data.swap_value, 18), + slippage: 0.1, + provider: BridgingProvider.Connext, + }); + + addContext(test, message.fail_connext_10) + assert.fail(message.fail_connext_10); + } catch (e) { + if (e.errors[0].constraints.isAddress === constant.invalid_address_8) { + addContext(test, message.vali_connext_5) + console.log(message.vali_connext_5); + } else { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_connext_10); + } + } + }, data.retry); // Retry this async test up to 5 times + } else { + console.warn(message.connext_insufficientBalance); + } + }); + + it('REGRESSION: Validate the get quotes without recepient address on the sepolia network', async function () { + var test = this; + let quotes; + if (runTest) { + await customRetryAsync(async function () { + + helper.wait(data.mediumTimeout); + + try { + quotes = await sepoliaDataService.getQuotes({ + fromAddress: data.sender, + fromChainId: data.sepolia_chainid, + toChainId: data.matic_chainid, + fromToken: data.tokenAddress_sepoliaUSDC, + fromAmount: utils.parseUnits(data.swap_value, 18), + slippage: 0.1, + provider: BridgingProvider.Connext, + }); + + addContext(test, message.fail_connext_11) + assert.fail(message.fail_connext_11); + } catch (e) { + if (e.errors[0].constraints.isAddress === constant.invalid_address_8) { + addContext(test, message.vali_connext_6) + console.log(message.vali_connext_6); + } else { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_connext_11); + } + } + }, data.retry); // Retry this async test up to 5 times + } else { + console.warn(message.connext_insufficientBalance); + } + }); + + it('REGRESSION: Validate the get quotes with incorrect recepient address on the sepolia network', async function () { + var test = this; + let quotes; + if (runTest) { + await customRetryAsync(async function () { + + helper.wait(data.mediumTimeout); + + try { + quotes = await sepoliaDataService.getQuotes({ + fromAddress: data.sender, + toAddress: data.incorrectRecipient, + fromChainId: data.sepolia_chainid, + toChainId: data.matic_chainid, + fromToken: data.tokenAddress_sepoliaUSDC, + fromAmount: utils.parseUnits(data.swap_value, 18), + slippage: 0.1, + provider: BridgingProvider.Connext, + }); + + addContext(test, message.fail_connext_12) + assert.fail(message.fail_connext_12); + } catch (e) { + if (e.errors[0].constraints.isAddress === constant.invalid_address_8) { + addContext(test, message.vali_connext_7) + console.log(message.vali_connext_7); + } else { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_connext_12); + } + } + }, data.retry); // Retry this async test up to 5 times + } else { + console.warn(message.connext_insufficientBalance); + } + }); + + it('REGRESSION: Validate the get quotes without fromChainid details on the sepolia network', async function () { + var test = this; + let quotes; + if (runTest) { + await customRetryAsync(async function () { + + helper.wait(data.mediumTimeout); + + try { + quotes = await sepoliaDataService.getQuotes({ + fromAddress: data.sender, + toAddress: data.recipient, + toChainId: data.matic_chainid, + fromToken: data.tokenAddress_sepoliaUSDC, + fromAmount: utils.parseUnits(data.swap_value, 18), + slippage: 0.1, + provider: BridgingProvider.Connext, + }); + + addContext(test, message.fail_connext_13) + assert.fail(message.fail_connext_13); + } catch (e) { + if (e.message === constant.invalid_address_9) { + addContext(test, message.vali_connext_8) + console.log(message.vali_connext_8); + } else { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_connext_13); + } + } + }, data.retry); // Retry this async test up to 5 times + } else { + console.warn(message.connext_insufficientBalance); + } + }); + + it('REGRESSION: Validate the get quotes without toChainid details on the sepolia network', async function () { + var test = this; + let quotes; + if (runTest) { + await customRetryAsync(async function () { + + helper.wait(data.mediumTimeout); + + try { + quotes = await sepoliaDataService.getQuotes({ + fromAddress: data.sender, + toAddress: data.recipient, + fromChainId: data.sepolia_chainid, + fromToken: data.tokenAddress_sepoliaUSDC, + fromAmount: utils.parseUnits(data.swap_value, 18), + slippage: 0.1, + provider: BridgingProvider.Connext, + }); + + addContext(test, message.fail_connext_14) + assert.fail(message.fail_connext_14); + } catch (e) { + if (e.message === constant.invalid_address_10) { + addContext(test, message.vali_connext_9) + console.log(message.vali_connext_9); + } else { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_connext_14); + } + } + }, data.retry); // Retry this async test up to 5 times + } else { + console.warn(message.connext_insufficientBalance); + } + }); + + it('REGRESSION: Validate the get quotes with invalid from token address on the sepolia network', async function () { + var test = this; + let quotes; + if (runTest) { + await customRetryAsync(async function () { + + helper.wait(data.mediumTimeout); + + try { + quotes = await sepoliaDataService.getQuotes({ + fromAddress: data.sender, + toAddress: data.recipient, + fromChainId: data.sepolia_chainid, + toChainId: data.matic_chainid, + fromToken: data.invalidTokenAddress_sepoliaUSDC, + fromAmount: utils.parseUnits(data.swap_value, 18), + slippage: 0.1, + provider: BridgingProvider.Connext, + }); + + addContext(test, message.fail_connext_15) + assert.fail(message.fail_connext_15); + } catch (e) { + if (e.errors[0].constraints.isAddress === constant.invalid_address_11) { + addContext(test, message.vali_connext_10) + console.log(message.vali_connext_10); + } else { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_connext_15); + } + } + }, data.retry); // Retry this async test up to 5 times + } else { + console.warn(message.connext_insufficientBalance); + } + }); + + it('REGRESSION: Validate the get quotes with incorrect from token address on the sepolia network', async function () { + var test = this; + let quotes; + if (runTest) { + await customRetryAsync(async function () { + + helper.wait(data.mediumTimeout); + + try { + quotes = await sepoliaDataService.getQuotes({ + fromAddress: data.sender, + toAddress: data.recipient, + fromChainId: data.sepolia_chainid, + toChainId: data.matic_chainid, + fromToken: data.incorrectTokenAddress_sepoliaUSDC, + fromAmount: utils.parseUnits(data.swap_value, 18), + slippage: 0.1, + provider: BridgingProvider.Connext, + }); + + addContext(test, message.fail_connext_16) + assert.fail(message.fail_connext_16); + } catch (e) { + if (e.errors[0].constraints.isAddress === constant.invalid_address_11) { + addContext(test, message.vali_connext_11) + console.log(message.vali_connext_11); + } else { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_connext_16); + } + } + }, data.retry); // Retry this async test up to 5 times + } else { + console.warn(message.connext_insufficientBalance); + } + }); + + it('REGRESSION: Validate the get quotes without from token address on the sepolia network', async function () { + var test = this; + let quotes; + if (runTest) { + await customRetryAsync(async function () { + + helper.wait(data.mediumTimeout); + + try { + quotes = await sepoliaDataService.getQuotes({ + fromAddress: data.sender, + toAddress: data.recipient, + fromChainId: data.sepolia_chainid, + toChainId: data.matic_chainid, + fromAmount: utils.parseUnits(data.swap_value, 18), + slippage: 0.1, + provider: BridgingProvider.Connext, + }); + + addContext(test, message.fail_connext_17) + assert.fail(message.fail_connext_17); + } catch (e) { + if (e.errors[0].constraints.isAddress === constant.invalid_address_11) { + addContext(test, message.vali_connext_12) + console.log(message.vali_connext_12); + } else { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_connext_17); + } + } + }, data.retry); // Retry this async test up to 5 times + } else { + console.warn(message.connext_insufficientBalance); + } + }); + + it('REGRESSION: Validate the get quotes with invalid value on the sepolia network', async function () { + var test = this; + let quotes; + if (runTest) { + await customRetryAsync(async function () { + + helper.wait(data.mediumTimeout); + + try { + quotes = await sepoliaDataService.getQuotes({ + fromAddress: data.sender, + toAddress: data.recipient, + fromChainId: data.sepolia_chainid, + toChainId: data.matic_chainid, + fromToken: data.tokenAddress_sepoliaUSDC, + fromAmount: utils.parseUnits(data.invalidValue, 18), + slippage: 0.1, + provider: BridgingProvider.Connext, + }); + + addContext(test, message.fail_connext_18) + assert.fail(message.fail_connext_18); + } catch (e) { + if (e.reason === constant.invalid_value_1) { + addContext(test, message.vali_connext_13) + console.log(message.vali_connext_13); + } else { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_connext_18); + } + } + }, data.retry); // Retry this async test up to 5 times + } else { + console.warn(message.connext_insufficientBalance); + } + }); + + it('REGRESSION: Validate the get quotes with small value on the sepolia network', async function () { + var test = this; + let quotes; + if (runTest) { + await customRetryAsync(async function () { + + helper.wait(data.mediumTimeout); + + try { + quotes = await sepoliaDataService.getQuotes({ + fromAddress: data.sender, + toAddress: data.recipient, + fromChainId: data.sepolia_chainid, + toChainId: data.matic_chainid, + fromToken: data.tokenAddress_sepoliaUSDC, + fromAmount: utils.parseUnits(data.smallValue, 18), + slippage: 0.1, + provider: BridgingProvider.Connext, + }); + + addContext(test, message.fail_connext_19) + assert.fail(message.fail_connext_19); + } catch (e) { + if (e.reason === constant.invalid_value_2) { + addContext(test, message.vali_connext_14) + console.log(message.vali_connext_14); + } else { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_connext_19); + } + } + }, data.retry); // Retry this async test up to 5 times + } else { + console.warn(message.connext_insufficientBalance); + } + }); + + it('REGRESSION: Validate the get quotes without value on the sepolia network', async function () { + var test = this; + let quotes; + if (runTest) { + await customRetryAsync(async function () { + + helper.wait(data.mediumTimeout); + + try { + quotes = await sepoliaDataService.getQuotes({ + fromAddress: data.sender, + toAddress: data.recipient, + fromChainId: data.sepolia_chainid, + toChainId: data.matic_chainid, + fromToken: data.tokenAddress_sepoliaUSDC, + slippage: 0.1, + provider: BridgingProvider.Connext, + }); + + addContext(test, message.fail_connext_20) + assert.fail(message.fail_connext_20); + } catch (e) { + if (e.errors[0].constraints.IsBigNumberish === constant.invalid_bignumber_2) { + addContext(test, message.vali_connext_15) + console.log(message.vali_connext_15); + } else { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_connext_20); + } + } + }, data.retry); // Retry this async test up to 5 times + } else { + console.warn(message.connext_insufficientBalance); + } + }); + + it('REGRESSION: Validate the get quotes without slippage on the sepolia network', async function () { + var test = this; + let quotes; + if (runTest) { + await customRetryAsync(async function () { + + helper.wait(data.mediumTimeout); + + try { + quotes = await sepoliaDataService.getQuotes({ + fromAddress: data.sender, + toAddress: data.recipient, + fromChainId: data.sepolia_chainid, + toChainId: data.matic_chainid, + fromToken: data.tokenAddress_sepoliaUSDC, + fromAmount: utils.parseUnits(data.swap_value, 18), + provider: BridgingProvider.Connext, + }); + + addContext(test, message.fail_connext_21) + assert.fail(message.fail_connext_21); + } catch (e) { + if (e.message === constant.invalid_address_13) { + addContext(test, message.vali_connext_16) + console.log(message.vali_connext_16); + } else { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_connext_21); + } + } + }, data.retry); // Retry this async test up to 5 times + } else { + console.warn(message.connext_insufficientBalance); + } + }); + + it('REGRESSION: Validate the get transaction status without fromChainId on the sepolia network', async function () { + var test = this; + if (runTest) { + await customRetryAsync(async function () { + + helper.wait(data.mediumTimeout); + + // validate the transaction status + let transactionStatus; + try { + transactionStatus = await sepoliaDataService.getTransactionStatus({ + toChainId: data.matic_chainid, + transactionHash: data.transactionHash, + provider: BridgingProvider.Connext, + }); + + addContext(test, message.fail_connext_22) + assert.fail(message.fail_connext_22); + } catch (e) { + if (e.errors[0].constraints.isPositive === constant.invalid_chainid_4) { + addContext(test, message.vali_connext_17) + console.log(message.vali_connext_17); + } else { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_connext_22); + } + } + }, data.retry); // Retry this async test up to 5 times + } else { + console.warn(message.connext_insufficientBalance); + } + }); + + it('REGRESSION: Validate the get transaction status without toChainId on the sepolia network', async function () { + var test = this; + if (runTest) { + await customRetryAsync(async function () { + + helper.wait(data.mediumTimeout); + + // validate the transaction status + let transactionStatus; + try { + transactionStatus = await sepoliaDataService.getTransactionStatus({ + fromChainId: data.invalid_sepolia_chainid, + transactionHash: data.transactionHash, + provider: BridgingProvider.Connext, + }); + + addContext(test, message.fail_connext_23) + assert.fail(message.fail_connext_23); + } catch (e) { + if (e.errors[0].constraints.isPositive === constant.invalid_chainid_5) { + addContext(test, message.vali_connext_18) + console.log(message.vali_connext_18); + } else { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_connext_23); + } + } + }, data.retry); // Retry this async test up to 5 times + } else { + console.warn(message.connext_insufficientBalance); + } + }); + + it('REGRESSION: Validate the get transaction status with invalid transactionHash on the sepolia network', async function () { + var test = this; + if (runTest) { + await customRetryAsync(async function () { + + helper.wait(data.mediumTimeout); + + // validate the transaction status + let transactionStatus; + try { + transactionStatus = await sepoliaDataService.getTransactionStatus({ + fromChainId: data.invalid_sepolia_chainid, + toChainId: data.matic_chainid, + transactionHash: data.invalid_transactionHash, + provider: BridgingProvider.Connext, + }); + + addContext(test, message.fail_connext_24) + assert.fail(message.fail_connext_24); + } catch (e) { + if (e.errors[0].constraints.isHex === constant.transactionHash_32hex) { + addContext(test, message.vali_connext_19) + console.log(message.vali_connext_19); + } else { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_connext_24); + } + } + }, data.retry); // Retry this async test up to 5 times + } else { + console.warn(message.connext_insufficientBalance); + } + }); + + it('REGRESSION: Validate the get transaction status with incorrect transactionHash on the sepolia network', async function () { + var test = this; + if (runTest) { + await customRetryAsync(async function () { + + helper.wait(data.mediumTimeout); + + // validate the transaction status + let transactionStatus; + try { + transactionStatus = await sepoliaDataService.getTransactionStatus({ + fromChainId: data.invalid_sepolia_chainid, + toChainId: data.matic_chainid, + transactionHash: data.incorrect_transactionHash, + provider: BridgingProvider.Connext, + }); + + if (transactionStatus.status === constant.invalid_chainid_6) { + addContext(test, message.vali_connext_20) + console.log(message.vali_connext_20); + } else { + addContext(test, eString); + assert.fail(message.fail_connext_25); + } + } catch (e) { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_connext_25); + } + }, data.retry); // Retry this async test up to 5 times + } else { + console.warn(message.connext_insufficientBalance); + } + }); + + it('REGRESSION: Validate the get transaction status without transactionHash on the sepolia network', async function () { + var test = this; + if (runTest) { + await customRetryAsync(async function () { + + helper.wait(data.mediumTimeout); + + // validate the transaction status + let transactionStatus; + try { + transactionStatus = await sepoliaDataService.getTransactionStatus({ + fromChainId: data.invalid_sepolia_chainid, + toChainId: data.matic_chainid, + provider: BridgingProvider.Connext, + }); + + addContext(test, message.fail_connext_26) + assert.fail(message.fail_connext_26); + } catch (e) { + if (e.errors[0].constraints.isHex === constant.transactionHash_32hex) { + addContext(test, message.vali_connext_21) + console.log(message.vali_connext_21); + } else { + console.error(e); + const eString = e.toString(); + addContext(test, eString); + assert.fail(message.fail_connext_26); + } + } + }, data.retry); // Retry this async test up to 5 times + } else { + console.warn(message.connext_insufficientBalance); + } + }); +});