From 4a6841a52da0f26b9168cc7aa31411c3128eeea0 Mon Sep 17 00:00:00 2001 From: Jineshdarjee Date: Wed, 15 May 2024 14:48:34 +0530 Subject: [PATCH] Added deplay in the smoke test cases and remove mumbai and goerli test cases --- .env | 13 +- package.json | 25 +- test/specs/mainnet/connext/arbitrum.spec.js | 10 +- test/specs/mainnet/connext/matic.spec.js | 10 +- test/specs/mainnet/connext/optimism.spec.js | 10 +- test/specs/mainnet/connext/xdai.spec.js | 10 +- .../mainnet/getAddresses/arbitrum.spec.js | 6 +- test/specs/mainnet/getAddresses/matic.spec.js | 6 +- .../mainnet/getAddresses/optimism.spec.js | 6 +- test/specs/mainnet/getAddresses/xdai.spec.js | 6 +- .../mainnet/listAndRates/arbitrum.spec.js | 8 +- test/specs/mainnet/listAndRates/matic.spec.js | 8 +- .../mainnet/listAndRates/optimism.spec.js | 8 +- test/specs/mainnet/listAndRates/xdai.spec.js | 8 +- test/specs/mainnet/paymaster/arbitrum.spec.js | 20 +- test/specs/mainnet/paymaster/matic.spec.js | 21 +- test/specs/mainnet/paymaster/optimism.spec.js | 21 +- test/specs/mainnet/paymaster/xdai.spec.js | 30 +- test/specs/mainnet/swap/arbitrum.spec.js | 10 +- test/specs/mainnet/swap/matic.spec.js | 10 +- test/specs/mainnet/swap/optimism.spec.js | 10 +- test/specs/mainnet/swap/xdai.spec.js | 10 +- .../transactionHistory/arbitrum.spec.js | 10 +- .../mainnet/transactionHistory/matic.spec.js | 10 +- .../transactionHistory/optimism.spec.js | 10 +- .../mainnet/transactionHistory/xdai.spec.js | 10 +- .../transferringFunds/arbitrum.spec.js | 12 +- .../mainnet/transferringFunds/matic.spec.js | 12 +- .../transferringFunds/optimism.spec.js | 12 +- .../mainnet/transferringFunds/xdai.spec.js | 12 +- test/specs/testnet/connext/goerli.spec.js | 1272 ----- test/specs/testnet/connext/mumbai.spec.js | 1272 ----- .../specs/testnet/getAddresses/goerli.spec.js | 246 - .../specs/testnet/getAddresses/mumbai.spec.js | 246 - .../specs/testnet/listAndRates/goerli.spec.js | 1043 ---- .../specs/testnet/listAndRates/mumbai.spec.js | 1043 ---- test/specs/testnet/paymaster/goerli.spec.js | 4227 ----------------- test/specs/testnet/paymaster/mumbai.spec.js | 4227 ----------------- .../testnet/transactionHistory/goerli.spec.js | 1684 ------- .../testnet/transactionHistory/mumbai.spec.js | 1684 ------- .../testnet/transferringFunds/goerli.spec.js | 3616 -------------- .../testnet/transferringFunds/mumbai.spec.js | 3616 -------------- test/utils/baseTest.js | 4 +- 43 files changed, 171 insertions(+), 24363 deletions(-) delete mode 100644 test/specs/testnet/connext/goerli.spec.js delete mode 100644 test/specs/testnet/connext/mumbai.spec.js delete mode 100644 test/specs/testnet/getAddresses/goerli.spec.js delete mode 100644 test/specs/testnet/getAddresses/mumbai.spec.js delete mode 100644 test/specs/testnet/listAndRates/goerli.spec.js delete mode 100644 test/specs/testnet/listAndRates/mumbai.spec.js delete mode 100644 test/specs/testnet/paymaster/goerli.spec.js delete mode 100644 test/specs/testnet/paymaster/mumbai.spec.js delete mode 100644 test/specs/testnet/transactionHistory/goerli.spec.js delete mode 100644 test/specs/testnet/transactionHistory/mumbai.spec.js delete mode 100644 test/specs/testnet/transferringFunds/goerli.spec.js delete mode 100644 test/specs/testnet/transferringFunds/mumbai.spec.js diff --git a/.env b/.env index c4acaad..305deb9 100644 --- a/.env +++ b/.env @@ -8,19 +8,8 @@ INVALID_API_KEY=invalid_api_key BUNDLER_API_KEY=bundler_api_key DATA_API_KEY=data_api_key -## Private Key for Testing -PRIVATE_KEY1=private_key1 -PRIVATE_KEY2=private_key2 -PRIVATE_KEY3=private_key3 -PRIVATE_KEY4=private_key4 -PRIVATE_KEY5=private_key5 - ## Database Details DB_HOST=db_host DB_USER=db_user DB_PASSWORD=db_password -DB_DATABASE=bd_database - -## Path -SKANDHA_CSV_PATH=skandha_path -ARKA_CSV_PATH=arka_path \ No newline at end of file +DB_DATABASE=bd_database \ No newline at end of file diff --git a/package.json b/package.json index ec847a2..3ec780d 100644 --- a/package.json +++ b/package.json @@ -37,25 +37,26 @@ "test-mainnet-getaddresses-optimism": "mocha --timeout 600000 --spec test/specs/mainnet/version/version.spec.js --spec test/specs/mainnet/getAddresses/optimism.spec.js --reporter mochawesome --reporter-options charts=true,code=false,showHooks=always", "test-mainnet-getaddresses-xdai": "mocha --timeout 600000 --spec test/specs/mainnet/version/version.spec.js --spec test/specs/mainnet/getAddresses/xdai.spec.js --reporter mochawesome --reporter-options charts=true,code=false,showHooks=always", "test-mainnet-getaddresses": "mocha --timeout 600000 --spec test/specs/mainnet/version/version.spec.js --spec test/specs/mainnet/getAddresses/*.spec.js --reporter mochawesome --reporter-options charts=true,code=false,showHooks=always", + "test-mainnet-connext-arbitrum": "mocha --timeout 600000 --spec test/specs/mainnet/version/version.spec.js --spec test/specs/mainnet/connext/arbitrum.spec.js --reporter mochawesome --reporter-options charts=true,code=false,showHooks=always", + "test-mainnet-connext-matic": "mocha --timeout 600000 --spec test/specs/mainnet/version/version.spec.js --spec test/specs/mainnet/connext/matic.spec.js --reporter mochawesome --reporter-options charts=true,code=false,showHooks=always", + "test-mainnet-connext-optimism": "mocha --timeout 600000 --spec test/specs/mainnet/version/version.spec.js --spec test/specs/mainnet/connext/optimism.spec.js --reporter mochawesome --reporter-options charts=true,code=false,showHooks=always", + "test-mainnet-connext-xdai": "mocha --timeout 600000 --spec test/specs/mainnet/version/version.spec.js --spec test/specs/mainnet/connext/xdai.spec.js --reporter mochawesome --reporter-options charts=true,code=false,showHooks=always", + "test-mainnet-connext": "mocha --timeout 600000 --spec test/specs/mainnet/version/version.spec.js --spec test/specs/mainnet/connext/*.spec.js --reporter mochawesome --reporter-options charts=true,code=false,showHooks=always", "test-testnet": "mocha --timeout 600000 --spec test/specs/testnet/version/version.spec.js --spec test/specs/testnet/*/sepolia.spec.js --reporter mochawesome --reporter-options charts=true,code=false,showHooks=always", - "test-testnet-transfertoken-mumbai": "mocha --timeout 600000 --spec test/specs/testnet/version/version.spec.js --spec test/specs/testnet/transferringFunds/mumbai.spec.js --reporter mochawesome --reporter-options charts=true,code=false,showHooks=always", - "test-testnet-transfertoken-goerli": "mocha --timeout 600000 --spec test/specs/testnet/version/version.spec.js --spec test/specs/testnet/transferringFunds/goerli.spec.js --reporter mochawesome --reporter-options charts=true,code=false,showHooks=always", + "test-testnet-transfertoken-sepolia": "mocha --timeout 600000 --spec test/specs/testnet/version/version.spec.js --spec test/specs/testnet/transferringFunds/sepolia.spec.js --reporter mochawesome --reporter-options charts=true,code=false,showHooks=always", "test-testnet-transfertoken": "mocha --timeout 600000 --spec test/specs/testnet/version/version.spec.js --spec test/specs/testnet/transferringFunds/*.spec.js --reporter mochawesome --reporter-options charts=true,code=false,showHooks=always", - "test-testnet-transactionhistory-mumbai": "mocha --timeout 600000 --spec test/specs/testnet/version/version.spec.js --spec test/specs/testnet/transactionHistory/mumbai.spec.js --reporter mochawesome --reporter-options charts=true,code=false,showHooks=always", - "test-testnet-transactionhistory-goerli": "mocha --timeout 600000 --spec test/specs/testnet/version/version.spec.js --spec test/specs/testnet/transactionHistory/goerli.spec.js --reporter mochawesome --reporter-options charts=true,code=false,showHooks=always", + "test-testnet-transactionhistory-sepolia": "mocha --timeout 600000 --spec test/specs/testnet/version/version.spec.js --spec test/specs/testnet/transactionHistory/sepolia.spec.js --reporter mochawesome --reporter-options charts=true,code=false,showHooks=always", "test-testnet-transactionhistory": "mocha --timeout 600000 --spec test/specs/testnet/version/version.spec.js --spec test/specs/testnet/transactionHistory/*.spec.js --reporter mochawesome --reporter-options charts=true,code=false,showHooks=always", - "test-testnet-swap-mumbai": "mocha --timeout 600000 --spec test/specs/testnet/version/version.spec.js --spec test/specs/testnet/swap/mumbai.spec.js --reporter mochawesome --reporter-options charts=true,code=false,showHooks=always", - "test-testnet-swap-goerli": "mocha --timeout 600000 --spec test/specs/testnet/version/version.spec.js --spec test/specs/testnet/swap/goerli.spec.js --reporter mochawesome --reporter-options charts=true,code=false,showHooks=always", + "test-testnet-swap-sepolia": "mocha --timeout 600000 --spec test/specs/testnet/version/version.spec.js --spec test/specs/testnet/swap/sepolia.spec.js --reporter mochawesome --reporter-options charts=true,code=false,showHooks=always", "test-testnet-swap": "mocha --timeout 600000 --spec test/specs/testnet/version/version.spec.js --spec test/specs/testnet/swap/*.spec.js --reporter mochawesome --reporter-options charts=true,code=false,showHooks=always", - "test-testnet-paymaster-mumbai": "mocha --timeout 600000 --spec test/specs/testnet/version/version.spec.js --spec test/specs/testnet/paymaster/mumbai.spec.js --reporter mochawesome --reporter-options charts=true,code=false,showHooks=always", - "test-testnet-paymaster-goerli": "mocha --timeout 600000 --spec test/specs/testnet/version/version.spec.js --spec test/specs/testnet/paymaster/goerli.spec.js --reporter mochawesome --reporter-options charts=true,code=false,showHooks=always", + "test-testnet-paymaster-sepolia": "mocha --timeout 600000 --spec test/specs/testnet/version/version.spec.js --spec test/specs/testnet/paymaster/sepolia.spec.js --reporter mochawesome --reporter-options charts=true,code=false,showHooks=always", "test-testnet-paymaster": "mocha --timeout 600000 --spec test/specs/testnet/version/version.spec.js --spec test/specs/testnet/paymaster/*.spec.js --reporter mochawesome --reporter-options charts=true,code=false,showHooks=always", - "test-testnet-listandrates-mumbai": "mocha --timeout 600000 --spec test/specs/testnet/version/version.spec.js --spec test/specs/testnet/listAndRates/mumbai.spec.js --reporter mochawesome --reporter-options charts=true,code=false,showHooks=always", - "test-testnet-listandrates-goerli": "mocha --timeout 600000 --spec test/specs/testnet/version/version.spec.js --spec test/specs/testnet/listAndRates/goerli.spec.js --reporter mochawesome --reporter-options charts=true,code=false,showHooks=always", + "test-testnet-listandrates-sepolia": "mocha --timeout 600000 --spec test/specs/testnet/version/version.spec.js --spec test/specs/testnet/listAndRates/sepolia.spec.js --reporter mochawesome --reporter-options charts=true,code=false,showHooks=always", "test-testnet-listandrates": "mocha --timeout 600000 --spec test/specs/testnet/version/version.spec.js --spec test/specs/testnet/listAndRates/*.spec.js --reporter mochawesome --reporter-options charts=true,code=false,showHooks=always", - "test-testnet-getaddresses-mumbai": "mocha --timeout 600000 --spec test/specs/testnet/version/version.spec.js --spec test/specs/testnet/getAddresses/mumbai.spec.js --reporter mochawesome --reporter-options charts=true,code=false,showHooks=always", - "test-testnet-getaddresses-goerli": "mocha --timeout 600000 --spec test/specs/testnet/version/version.spec.js --spec test/specs/testnet/getAddresses/goerli.spec.js --reporter mochawesome --reporter-options charts=true,code=false,showHooks=always", + "test-testnet-getaddresses-sepolia": "mocha --timeout 600000 --spec test/specs/testnet/version/version.spec.js --spec test/specs/testnet/getAddresses/sepolia.spec.js --reporter mochawesome --reporter-options charts=true,code=false,showHooks=always", "test-testnet-getaddresses": "mocha --timeout 600000 --spec test/specs/testnet/version/version.spec.js --spec test/specs/testnet/getAddresses/*.spec.js --reporter mochawesome --reporter-options charts=true,code=false,showHooks=always", + "test-testnet-connext-sepolia": "mocha --timeout 600000 --spec test/specs/testnet/version/version.spec.js --spec test/specs/testnet/connext/sepolia.spec.js --reporter mochawesome --reporter-options charts=true,code=false,showHooks=always", + "test-testnet-connext": "mocha --timeout 600000 --spec test/specs/testnet/version/version.spec.js --spec test/specs/testnet/connext/*.spec.js --reporter mochawesome --reporter-options charts=true,code=false,showHooks=always", "test-arka-mumbai": "mocha --timeout 600000 --spec test/specs/loadAndPerformance/arka/mumbai.spec.js --reporter mochawesome --reporter-options charts=true,code=false,showHooks=always", "test-arka-goerli": "mocha --timeout 600000 --spec test/specs/loadAndPerformance/arka/goerli.spec.js --reporter mochawesome --reporter-options charts=true,code=false,showHooks=always", "test-arka": "mocha --timeout 600000 --spec test/specs/loadAndPerformance/arka/mumbai.spec.js --spec test/specs/loadAndPerformance/arka/goerli.spec.js --reporter mochawesome --reporter-options charts=true,code=false,showHooks=always", diff --git a/test/specs/mainnet/connext/arbitrum.spec.js b/test/specs/mainnet/connext/arbitrum.spec.js index eabf5aa..cced6f0 100644 --- a/test/specs/mainnet/connext/arbitrum.spec.js +++ b/test/specs/mainnet/connext/arbitrum.spec.js @@ -23,7 +23,7 @@ describe('The PrimeSDK, Validate the connext endpoints with arbitrum network on await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // initializating sdk try { @@ -132,7 +132,7 @@ describe('The PrimeSDK, Validate the connext endpoints with arbitrum network on if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); try { allSupportedAssets = @@ -210,7 +210,7 @@ describe('The PrimeSDK, Validate the connext endpoints with arbitrum network on if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); try { supportedAssets = @@ -292,7 +292,7 @@ describe('The PrimeSDK, Validate the connext endpoints with arbitrum network on if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); try { quotes = await arbitrumDataService.getQuotes({ @@ -355,7 +355,7 @@ describe('The PrimeSDK, Validate the connext endpoints with arbitrum network on if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // clear the transaction batch try { diff --git a/test/specs/mainnet/connext/matic.spec.js b/test/specs/mainnet/connext/matic.spec.js index 1bb960c..ef000a7 100644 --- a/test/specs/mainnet/connext/matic.spec.js +++ b/test/specs/mainnet/connext/matic.spec.js @@ -23,7 +23,7 @@ describe('The PrimeSDK, Validate the connext endpoints with matic network on the await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // initializating sdk try { @@ -132,7 +132,7 @@ describe('The PrimeSDK, Validate the connext endpoints with matic network on the if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); try { allSupportedAssets = @@ -210,7 +210,7 @@ describe('The PrimeSDK, Validate the connext endpoints with matic network on the if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); try { supportedAssets = @@ -292,7 +292,7 @@ describe('The PrimeSDK, Validate the connext endpoints with matic network on the if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); try { quotes = await maticDataService.getQuotes({ @@ -355,7 +355,7 @@ describe('The PrimeSDK, Validate the connext endpoints with matic network on the if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // clear the transaction batch try { diff --git a/test/specs/mainnet/connext/optimism.spec.js b/test/specs/mainnet/connext/optimism.spec.js index 7a52ea1..87afd72 100644 --- a/test/specs/mainnet/connext/optimism.spec.js +++ b/test/specs/mainnet/connext/optimism.spec.js @@ -23,7 +23,7 @@ describe('The PrimeSDK, Validate the connext endpoints with optimism network on await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // initializating sdk try { @@ -132,7 +132,7 @@ describe('The PrimeSDK, Validate the connext endpoints with optimism network on if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); try { allSupportedAssets = @@ -210,7 +210,7 @@ describe('The PrimeSDK, Validate the connext endpoints with optimism network on if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); try { supportedAssets = @@ -292,7 +292,7 @@ describe('The PrimeSDK, Validate the connext endpoints with optimism network on if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); try { quotes = await optimismDataService.getQuotes({ @@ -355,7 +355,7 @@ describe('The PrimeSDK, Validate the connext endpoints with optimism network on if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // clear the transaction batch try { diff --git a/test/specs/mainnet/connext/xdai.spec.js b/test/specs/mainnet/connext/xdai.spec.js index abeed28..ddaa8e9 100644 --- a/test/specs/mainnet/connext/xdai.spec.js +++ b/test/specs/mainnet/connext/xdai.spec.js @@ -23,7 +23,7 @@ describe('The PrimeSDK, Validate the connext endpoints with xdai network on the await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // initializating sdk try { @@ -132,7 +132,7 @@ describe('The PrimeSDK, Validate the connext endpoints with xdai network on the if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); try { allSupportedAssets = @@ -210,7 +210,7 @@ describe('The PrimeSDK, Validate the connext endpoints with xdai network on the if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); try { supportedAssets = @@ -292,7 +292,7 @@ describe('The PrimeSDK, Validate the connext endpoints with xdai network on the if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); try { quotes = await xdaiDataService.getQuotes({ @@ -355,7 +355,7 @@ describe('The PrimeSDK, Validate the connext endpoints with xdai network on the if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // clear the transaction batch try { diff --git a/test/specs/mainnet/getAddresses/arbitrum.spec.js b/test/specs/mainnet/getAddresses/arbitrum.spec.js index 767747b..59274a5 100644 --- a/test/specs/mainnet/getAddresses/arbitrum.spec.js +++ b/test/specs/mainnet/getAddresses/arbitrum.spec.js @@ -20,7 +20,7 @@ describe('The PrimeSDK, when get the ZeroDev address and SimpleAccount address d await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // initializating sdk try { @@ -80,7 +80,7 @@ describe('The PrimeSDK, when get the ZeroDev address and SimpleAccount address d await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // initializating sdk try { @@ -140,7 +140,7 @@ describe('The PrimeSDK, when get the ZeroDev address and SimpleAccount address d await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // initializating sdk try { diff --git a/test/specs/mainnet/getAddresses/matic.spec.js b/test/specs/mainnet/getAddresses/matic.spec.js index e11de40..f87ab78 100644 --- a/test/specs/mainnet/getAddresses/matic.spec.js +++ b/test/specs/mainnet/getAddresses/matic.spec.js @@ -20,7 +20,7 @@ describe('The PrimeSDK, when get the ZeroDev address and SimpleAccount address d await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // initializating sdk try { @@ -80,7 +80,7 @@ describe('The PrimeSDK, when get the ZeroDev address and SimpleAccount address d await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // initializating sdk try { @@ -140,7 +140,7 @@ describe('The PrimeSDK, when get the ZeroDev address and SimpleAccount address d await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // initializating sdk try { diff --git a/test/specs/mainnet/getAddresses/optimism.spec.js b/test/specs/mainnet/getAddresses/optimism.spec.js index c6837dc..6ff25c4 100644 --- a/test/specs/mainnet/getAddresses/optimism.spec.js +++ b/test/specs/mainnet/getAddresses/optimism.spec.js @@ -20,7 +20,7 @@ describe('The PrimeSDK, when get the ZeroDev address and SimpleAccount address d await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // initializating sdk try { @@ -80,7 +80,7 @@ describe('The PrimeSDK, when get the ZeroDev address and SimpleAccount address d await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // initializating sdk try { @@ -140,7 +140,7 @@ describe('The PrimeSDK, when get the ZeroDev address and SimpleAccount address d await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // initializating sdk try { diff --git a/test/specs/mainnet/getAddresses/xdai.spec.js b/test/specs/mainnet/getAddresses/xdai.spec.js index e48ea9a..ce9f9bb 100644 --- a/test/specs/mainnet/getAddresses/xdai.spec.js +++ b/test/specs/mainnet/getAddresses/xdai.spec.js @@ -20,7 +20,7 @@ describe('The PrimeSDK, when get the ZeroDev address and SimpleAccount address d await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // initializating sdk try { @@ -80,7 +80,7 @@ describe('The PrimeSDK, when get the ZeroDev address and SimpleAccount address d await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // initializating sdk try { @@ -140,7 +140,7 @@ describe('The PrimeSDK, when get the ZeroDev address and SimpleAccount address d await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // initializating sdk try { diff --git a/test/specs/mainnet/listAndRates/arbitrum.spec.js b/test/specs/mainnet/listAndRates/arbitrum.spec.js index 30ac208..f9c89da 100644 --- a/test/specs/mainnet/listAndRates/arbitrum.spec.js +++ b/test/specs/mainnet/listAndRates/arbitrum.spec.js @@ -22,7 +22,7 @@ describe('The PrimeSDK, when get the NFT List, Token List and Exchange Rates det await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // initializating sdk try { @@ -129,7 +129,7 @@ describe('The PrimeSDK, when get the NFT List, Token List and Exchange Rates det if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); let nfts; try { @@ -239,7 +239,7 @@ describe('The PrimeSDK, when get the NFT List, Token List and Exchange Rates det if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); let tokenLists; let tokenListTokens; @@ -455,7 +455,7 @@ describe('The PrimeSDK, when get the NFT List, Token List and Exchange Rates det if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); let TOKEN_LIST; let rates; diff --git a/test/specs/mainnet/listAndRates/matic.spec.js b/test/specs/mainnet/listAndRates/matic.spec.js index 4bee892..f9fd7c0 100644 --- a/test/specs/mainnet/listAndRates/matic.spec.js +++ b/test/specs/mainnet/listAndRates/matic.spec.js @@ -22,7 +22,7 @@ describe('The PrimeSDK, when get the NFT List, Token List and Exchange Rates det await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // initializating sdk try { @@ -129,7 +129,7 @@ describe('The PrimeSDK, when get the NFT List, Token List and Exchange Rates det if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); let nfts; try { @@ -239,7 +239,7 @@ describe('The PrimeSDK, when get the NFT List, Token List and Exchange Rates det if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); let tokenLists; let tokenListTokens; @@ -455,7 +455,7 @@ describe('The PrimeSDK, when get the NFT List, Token List and Exchange Rates det if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); let TOKEN_LIST; let rates; diff --git a/test/specs/mainnet/listAndRates/optimism.spec.js b/test/specs/mainnet/listAndRates/optimism.spec.js index ecbc788..a4bd857 100644 --- a/test/specs/mainnet/listAndRates/optimism.spec.js +++ b/test/specs/mainnet/listAndRates/optimism.spec.js @@ -22,7 +22,7 @@ describe('The PrimeSDK, when get the NFT List, Token List and Exchange Rates det await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // initializating sdk try { @@ -129,7 +129,7 @@ describe('The PrimeSDK, when get the NFT List, Token List and Exchange Rates det if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); let nfts; try { @@ -239,7 +239,7 @@ describe('The PrimeSDK, when get the NFT List, Token List and Exchange Rates det if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); let tokenLists; let tokenListTokens; @@ -455,7 +455,7 @@ describe('The PrimeSDK, when get the NFT List, Token List and Exchange Rates det if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); let TOKEN_LIST; let rates; diff --git a/test/specs/mainnet/listAndRates/xdai.spec.js b/test/specs/mainnet/listAndRates/xdai.spec.js index 1832385..94598f1 100644 --- a/test/specs/mainnet/listAndRates/xdai.spec.js +++ b/test/specs/mainnet/listAndRates/xdai.spec.js @@ -22,7 +22,7 @@ describe('The PrimeSDK, when get the NFT List, Token List and Exchange Rates det await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // initializating sdk try { @@ -129,7 +129,7 @@ describe('The PrimeSDK, when get the NFT List, Token List and Exchange Rates det if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); let nfts; try { @@ -239,7 +239,7 @@ describe('The PrimeSDK, when get the NFT List, Token List and Exchange Rates det if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); let tokenLists; let tokenListTokens; @@ -455,7 +455,7 @@ describe('The PrimeSDK, when get the NFT List, Token List and Exchange Rates det if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); let TOKEN_LIST; let rates; diff --git a/test/specs/mainnet/paymaster/arbitrum.spec.js b/test/specs/mainnet/paymaster/arbitrum.spec.js index d5b0b38..34bdaaf 100644 --- a/test/specs/mainnet/paymaster/arbitrum.spec.js +++ b/test/specs/mainnet/paymaster/arbitrum.spec.js @@ -25,7 +25,7 @@ describe('The PrimeSDK, when transaction with arka and pimlico paymasters with a await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // initializating sdk try { @@ -144,7 +144,7 @@ describe('The PrimeSDK, when transaction with arka and pimlico paymasters with a if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // clear the transaction batch try { @@ -383,7 +383,7 @@ describe('The PrimeSDK, when transaction with arka and pimlico paymasters with a if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); let balance; // get balance of the account address @@ -865,7 +865,7 @@ describe('The PrimeSDK, when transaction with arka and pimlico paymasters with a if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); let balance; let transactionBatch; @@ -1120,7 +1120,7 @@ describe('The PrimeSDK, when transaction with arka and pimlico paymasters with a if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // get the metadata @@ -1183,7 +1183,7 @@ describe('The PrimeSDK, when transaction with arka and pimlico paymasters with a if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // validate the get token paymaster address @@ -1216,7 +1216,7 @@ describe('The PrimeSDK, when transaction with arka and pimlico paymasters with a if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // validate the remove whitelist address @@ -1253,7 +1253,7 @@ describe('The PrimeSDK, when transaction with arka and pimlico paymasters with a if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // validate the add whitelist address @@ -1290,7 +1290,7 @@ describe('The PrimeSDK, when transaction with arka and pimlico paymasters with a if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // validate the whilelist address @@ -1321,7 +1321,7 @@ describe('The PrimeSDK, when transaction with arka and pimlico paymasters with a if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // validate the deposit diff --git a/test/specs/mainnet/paymaster/matic.spec.js b/test/specs/mainnet/paymaster/matic.spec.js index 099554b..b75ea2a 100644 --- a/test/specs/mainnet/paymaster/matic.spec.js +++ b/test/specs/mainnet/paymaster/matic.spec.js @@ -25,7 +25,7 @@ describe('The PrimeSDK, when transaction with arka and pimlico paymasters with m await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // initializating sdk try { @@ -144,7 +144,7 @@ describe('The PrimeSDK, when transaction with arka and pimlico paymasters with m if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // clear the transaction batch try { @@ -383,7 +383,7 @@ describe('The PrimeSDK, when transaction with arka and pimlico paymasters with m if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); let balance; // get balance of the account address @@ -865,7 +865,7 @@ describe('The PrimeSDK, when transaction with arka and pimlico paymasters with m if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); let balance; let transactionBatch; @@ -1120,7 +1120,7 @@ describe('The PrimeSDK, when transaction with arka and pimlico paymasters with m if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // get the metadata @@ -1183,7 +1183,7 @@ describe('The PrimeSDK, when transaction with arka and pimlico paymasters with m if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // validate the get token paymaster address @@ -1216,7 +1216,7 @@ describe('The PrimeSDK, when transaction with arka and pimlico paymasters with m if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // validate the remove whitelist address @@ -1253,7 +1253,7 @@ describe('The PrimeSDK, when transaction with arka and pimlico paymasters with m if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // validate the add whitelist address @@ -1290,7 +1290,7 @@ describe('The PrimeSDK, when transaction with arka and pimlico paymasters with m if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // validate the whilelist address @@ -1321,8 +1321,7 @@ describe('The PrimeSDK, when transaction with arka and pimlico paymasters with m if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); - + helper.wait(data.longTimeout); // validate the deposit try { diff --git a/test/specs/mainnet/paymaster/optimism.spec.js b/test/specs/mainnet/paymaster/optimism.spec.js index b77b094..9f5f3a5 100644 --- a/test/specs/mainnet/paymaster/optimism.spec.js +++ b/test/specs/mainnet/paymaster/optimism.spec.js @@ -25,7 +25,7 @@ describe('The PrimeSDK, when transaction with arka and pimlico paymasters with o await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // initializating sdk try { @@ -144,7 +144,7 @@ describe('The PrimeSDK, when transaction with arka and pimlico paymasters with o if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // clear the transaction batch try { @@ -383,7 +383,7 @@ describe('The PrimeSDK, when transaction with arka and pimlico paymasters with o if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); let balance; // get balance of the account address @@ -865,7 +865,7 @@ describe('The PrimeSDK, when transaction with arka and pimlico paymasters with o if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); let balance; let transactionBatch; @@ -1120,7 +1120,7 @@ describe('The PrimeSDK, when transaction with arka and pimlico paymasters with o if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // get the metadata @@ -1183,7 +1183,7 @@ describe('The PrimeSDK, when transaction with arka and pimlico paymasters with o if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // validate the get token paymaster address @@ -1216,7 +1216,7 @@ describe('The PrimeSDK, when transaction with arka and pimlico paymasters with o if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // validate the remove whitelist address @@ -1253,7 +1253,7 @@ describe('The PrimeSDK, when transaction with arka and pimlico paymasters with o if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // validate the add whitelist address @@ -1290,7 +1290,7 @@ describe('The PrimeSDK, when transaction with arka and pimlico paymasters with o if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // validate the whilelist address @@ -1321,8 +1321,7 @@ describe('The PrimeSDK, when transaction with arka and pimlico paymasters with o if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); - + helper.wait(data.longTimeout); // validate the deposit try { diff --git a/test/specs/mainnet/paymaster/xdai.spec.js b/test/specs/mainnet/paymaster/xdai.spec.js index 549ace2..0b8e49d 100644 --- a/test/specs/mainnet/paymaster/xdai.spec.js +++ b/test/specs/mainnet/paymaster/xdai.spec.js @@ -25,7 +25,7 @@ describe('The PrimeSDK, when transaction with arka and pimlico paymasters with x await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // initializating sdk try { @@ -144,7 +144,7 @@ describe('The PrimeSDK, when transaction with arka and pimlico paymasters with x if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // clear the transaction batch try { @@ -383,7 +383,7 @@ describe('The PrimeSDK, when transaction with arka and pimlico paymasters with x if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); let balance; // get balance of the account address @@ -858,15 +858,15 @@ describe('The PrimeSDK, when transaction with arka and pimlico paymasters with x it('SMOKE: Perform the transfer token with arka paymaster with validUntil and validAfter on the XDAI network', async function () { var test = this; - let arka_url = data.paymaster_arka; - let queryString = `?apiKey=${process.env.API_KEY}&chainId=${Number( - data.xdai_chainid, - )}`; if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); + let arka_url = data.paymaster_arka; + let queryString = `?apiKey=${process.env.API_KEY}&chainId=${Number( + data.xdai_chainid, + )}`; let balance; let transactionBatch; let op; @@ -1120,8 +1120,7 @@ describe('The PrimeSDK, when transaction with arka and pimlico paymasters with x if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); - + helper.wait(data.longTimeout); // get the metadata try { @@ -1183,7 +1182,7 @@ describe('The PrimeSDK, when transaction with arka and pimlico paymasters with x if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // validate the get token paymaster address @@ -1216,7 +1215,7 @@ describe('The PrimeSDK, when transaction with arka and pimlico paymasters with x if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // validate the remove whitelist address @@ -1253,7 +1252,7 @@ describe('The PrimeSDK, when transaction with arka and pimlico paymasters with x if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // validate the add whitelist address @@ -1290,7 +1289,7 @@ describe('The PrimeSDK, when transaction with arka and pimlico paymasters with x if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // validate the whilelist address @@ -1321,8 +1320,7 @@ describe('The PrimeSDK, when transaction with arka and pimlico paymasters with x if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); - + helper.wait(data.longTimeout); // validate the deposit try { diff --git a/test/specs/mainnet/swap/arbitrum.spec.js b/test/specs/mainnet/swap/arbitrum.spec.js index de1363b..da354b6 100644 --- a/test/specs/mainnet/swap/arbitrum.spec.js +++ b/test/specs/mainnet/swap/arbitrum.spec.js @@ -22,7 +22,7 @@ describe('The PrimeSDK, when get cross chain quotes and get advance routes LiFi await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // initializating sdk try { @@ -131,7 +131,7 @@ describe('The PrimeSDK, when get cross chain quotes and get advance routes LiFi if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); exchangeSupportedAssets = await arbitrumDataService.getExchangeSupportedAssets({ @@ -305,7 +305,7 @@ describe('The PrimeSDK, when get cross chain quotes and get advance routes LiFi if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); exchangeSupportedAssets = await arbitrumDataService.getExchangeSupportedAssets({ @@ -478,7 +478,7 @@ describe('The PrimeSDK, when get cross chain quotes and get advance routes LiFi if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); let quoteRequestPayload; let quotes; @@ -582,7 +582,7 @@ describe('The PrimeSDK, when get cross chain quotes and get advance routes LiFi if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); let quoteRequestPayload; let quotes; diff --git a/test/specs/mainnet/swap/matic.spec.js b/test/specs/mainnet/swap/matic.spec.js index 229ac57..3d5d219 100644 --- a/test/specs/mainnet/swap/matic.spec.js +++ b/test/specs/mainnet/swap/matic.spec.js @@ -22,7 +22,7 @@ describe('The PrimeSDK, when get cross chain quotes and get advance routes LiFi await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // initializating sdk try { @@ -131,7 +131,7 @@ describe('The PrimeSDK, when get cross chain quotes and get advance routes LiFi if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); exchangeSupportedAssets = await maticDataService.getExchangeSupportedAssets({ @@ -305,7 +305,7 @@ describe('The PrimeSDK, when get cross chain quotes and get advance routes LiFi if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); exchangeSupportedAssets = await maticDataService.getExchangeSupportedAssets({ @@ -478,7 +478,7 @@ describe('The PrimeSDK, when get cross chain quotes and get advance routes LiFi if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); let quoteRequestPayload; let quotes; @@ -582,7 +582,7 @@ describe('The PrimeSDK, when get cross chain quotes and get advance routes LiFi if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); let quoteRequestPayload; let quotes; diff --git a/test/specs/mainnet/swap/optimism.spec.js b/test/specs/mainnet/swap/optimism.spec.js index 66ec65a..9af6f84 100644 --- a/test/specs/mainnet/swap/optimism.spec.js +++ b/test/specs/mainnet/swap/optimism.spec.js @@ -22,7 +22,7 @@ describe('The PrimeSDK, when get cross chain quotes and get advance routes LiFi await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // initializating sdk try { @@ -131,7 +131,7 @@ describe('The PrimeSDK, when get cross chain quotes and get advance routes LiFi if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); exchangeSupportedAssets = await optimismDataService.getExchangeSupportedAssets({ @@ -305,7 +305,7 @@ describe('The PrimeSDK, when get cross chain quotes and get advance routes LiFi if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); exchangeSupportedAssets = await optimismDataService.getExchangeSupportedAssets({ @@ -478,7 +478,7 @@ describe('The PrimeSDK, when get cross chain quotes and get advance routes LiFi if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); let quoteRequestPayload; let quotes; @@ -582,7 +582,7 @@ describe('The PrimeSDK, when get cross chain quotes and get advance routes LiFi if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); let quoteRequestPayload; let quotes; diff --git a/test/specs/mainnet/swap/xdai.spec.js b/test/specs/mainnet/swap/xdai.spec.js index 19c01ac..0b0d792 100644 --- a/test/specs/mainnet/swap/xdai.spec.js +++ b/test/specs/mainnet/swap/xdai.spec.js @@ -22,7 +22,7 @@ describe('The PrimeSDK, when get cross chain quotes and get advance routes LiFi await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // initializating sdk try { @@ -131,7 +131,7 @@ describe('The PrimeSDK, when get cross chain quotes and get advance routes LiFi if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); exchangeSupportedAssets = await xdaiDataService.getExchangeSupportedAssets({ @@ -305,7 +305,7 @@ describe('The PrimeSDK, when get cross chain quotes and get advance routes LiFi if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); exchangeSupportedAssets = await xdaiDataService.getExchangeSupportedAssets({ @@ -478,7 +478,7 @@ describe('The PrimeSDK, when get cross chain quotes and get advance routes LiFi if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); let quoteRequestPayload; let quotes; @@ -582,7 +582,7 @@ describe('The PrimeSDK, when get cross chain quotes and get advance routes LiFi if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); let quoteRequestPayload; let quotes; diff --git a/test/specs/mainnet/transactionHistory/arbitrum.spec.js b/test/specs/mainnet/transactionHistory/arbitrum.spec.js index 009751c..0ede9d9 100644 --- a/test/specs/mainnet/transactionHistory/arbitrum.spec.js +++ b/test/specs/mainnet/transactionHistory/arbitrum.spec.js @@ -23,7 +23,7 @@ describe('The PrimeSDK, when get the single transaction and multiple transaction await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // initializating sdk try { @@ -132,7 +132,7 @@ describe('The PrimeSDK, when get the single transaction and multiple transaction if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // clear the transaction batch try { @@ -467,7 +467,7 @@ describe('The PrimeSDK, when get the single transaction and multiple transaction if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // Fetching historical transactions let transactions; @@ -688,7 +688,7 @@ describe('The PrimeSDK, when get the single transaction and multiple transaction if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // clear the transaction batch try { @@ -1085,7 +1085,7 @@ describe('The PrimeSDK, when get the single transaction and multiple transaction if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // get the respective provider details let provider; diff --git a/test/specs/mainnet/transactionHistory/matic.spec.js b/test/specs/mainnet/transactionHistory/matic.spec.js index 25518a3..2cf1579 100644 --- a/test/specs/mainnet/transactionHistory/matic.spec.js +++ b/test/specs/mainnet/transactionHistory/matic.spec.js @@ -23,7 +23,7 @@ describe('The PrimeSDK, when get the single transaction and multiple transaction await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // initializating sdk try { @@ -132,7 +132,7 @@ describe('The PrimeSDK, when get the single transaction and multiple transaction if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // clear the transaction batch try { @@ -467,7 +467,7 @@ describe('The PrimeSDK, when get the single transaction and multiple transaction if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // Fetching historical transactions let transactions; @@ -688,7 +688,7 @@ describe('The PrimeSDK, when get the single transaction and multiple transaction if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // clear the transaction batch try { @@ -1085,7 +1085,7 @@ describe('The PrimeSDK, when get the single transaction and multiple transaction if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // get the respective provider details let provider; diff --git a/test/specs/mainnet/transactionHistory/optimism.spec.js b/test/specs/mainnet/transactionHistory/optimism.spec.js index d27e464..e74d23b 100644 --- a/test/specs/mainnet/transactionHistory/optimism.spec.js +++ b/test/specs/mainnet/transactionHistory/optimism.spec.js @@ -23,7 +23,7 @@ describe('The PrimeSDK, when get the single transaction and multiple transaction await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // initializating sdk try { @@ -132,7 +132,7 @@ describe('The PrimeSDK, when get the single transaction and multiple transaction if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // clear the transaction batch try { @@ -467,7 +467,7 @@ describe('The PrimeSDK, when get the single transaction and multiple transaction if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // Fetching historical transactions let transactions; @@ -688,7 +688,7 @@ describe('The PrimeSDK, when get the single transaction and multiple transaction if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // clear the transaction batch try { @@ -1085,7 +1085,7 @@ describe('The PrimeSDK, when get the single transaction and multiple transaction if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // get the respective provider details let provider; diff --git a/test/specs/mainnet/transactionHistory/xdai.spec.js b/test/specs/mainnet/transactionHistory/xdai.spec.js index e5f13a7..9bd2cad 100644 --- a/test/specs/mainnet/transactionHistory/xdai.spec.js +++ b/test/specs/mainnet/transactionHistory/xdai.spec.js @@ -23,7 +23,7 @@ describe('The PrimeSDK, when get the single transaction and multiple transaction await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // initializating sdk try { @@ -132,7 +132,7 @@ describe('The PrimeSDK, when get the single transaction and multiple transaction if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // clear the transaction batch try { @@ -467,7 +467,7 @@ describe('The PrimeSDK, when get the single transaction and multiple transaction if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // Fetching historical transactions let transactions; @@ -688,7 +688,7 @@ describe('The PrimeSDK, when get the single transaction and multiple transaction if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // clear the transaction batch try { @@ -1085,7 +1085,7 @@ describe('The PrimeSDK, when get the single transaction and multiple transaction if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // get the respective provider details let provider; diff --git a/test/specs/mainnet/transferringFunds/arbitrum.spec.js b/test/specs/mainnet/transferringFunds/arbitrum.spec.js index 529377e..deea1b6 100644 --- a/test/specs/mainnet/transferringFunds/arbitrum.spec.js +++ b/test/specs/mainnet/transferringFunds/arbitrum.spec.js @@ -24,7 +24,7 @@ describe('The PrimeSDK, when transfer a token with arbitrum network on the MainN await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // initializating sdk try { @@ -129,7 +129,7 @@ describe('The PrimeSDK, when transfer a token with arbitrum network on the MainN if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // clear the transaction batch try { @@ -358,7 +358,7 @@ describe('The PrimeSDK, when transfer a token with arbitrum network on the MainN if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // get the respective provider details let provider; @@ -646,7 +646,7 @@ describe('The PrimeSDK, when transfer a token with arbitrum network on the MainN if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // get erc721 Contract Interface let erc721Interface; @@ -882,7 +882,7 @@ describe('The PrimeSDK, when transfer a token with arbitrum network on the MainN if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // clear the transaction batch try { @@ -1115,7 +1115,7 @@ describe('The PrimeSDK, when transfer a token with arbitrum network on the MainN await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); const provider = new providers.JsonRpcProvider(); diff --git a/test/specs/mainnet/transferringFunds/matic.spec.js b/test/specs/mainnet/transferringFunds/matic.spec.js index c0e422f..95e7dca 100644 --- a/test/specs/mainnet/transferringFunds/matic.spec.js +++ b/test/specs/mainnet/transferringFunds/matic.spec.js @@ -24,7 +24,7 @@ describe('The PrimeSDK, when transfer a token with matic network on the MainNet' await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // initializating sdk try { @@ -129,7 +129,7 @@ describe('The PrimeSDK, when transfer a token with matic network on the MainNet' if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // clear the transaction batch try { @@ -358,7 +358,7 @@ describe('The PrimeSDK, when transfer a token with matic network on the MainNet' if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // get the respective provider details let provider; @@ -646,7 +646,7 @@ describe('The PrimeSDK, when transfer a token with matic network on the MainNet' if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // get erc721 Contract Interface let erc721Interface; @@ -882,7 +882,7 @@ describe('The PrimeSDK, when transfer a token with matic network on the MainNet' if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // clear the transaction batch try { @@ -1115,7 +1115,7 @@ describe('The PrimeSDK, when transfer a token with matic network on the MainNet' await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); const provider = new providers.JsonRpcProvider(); diff --git a/test/specs/mainnet/transferringFunds/optimism.spec.js b/test/specs/mainnet/transferringFunds/optimism.spec.js index 47d9c72..1a66d1d 100644 --- a/test/specs/mainnet/transferringFunds/optimism.spec.js +++ b/test/specs/mainnet/transferringFunds/optimism.spec.js @@ -24,7 +24,7 @@ describe('The PrimeSDK, when transfer a token with optimism network on the MainN await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // initializating sdk try { @@ -129,7 +129,7 @@ describe('The PrimeSDK, when transfer a token with optimism network on the MainN if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // clear the transaction batch try { @@ -358,7 +358,7 @@ describe('The PrimeSDK, when transfer a token with optimism network on the MainN if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // get the respective provider details let provider; @@ -646,7 +646,7 @@ describe('The PrimeSDK, when transfer a token with optimism network on the MainN if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // get erc721 Contract Interface let erc721Interface; @@ -882,7 +882,7 @@ describe('The PrimeSDK, when transfer a token with optimism network on the MainN if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // clear the transaction batch try { @@ -1115,7 +1115,7 @@ describe('The PrimeSDK, when transfer a token with optimism network on the MainN await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); const provider = new providers.JsonRpcProvider(); diff --git a/test/specs/mainnet/transferringFunds/xdai.spec.js b/test/specs/mainnet/transferringFunds/xdai.spec.js index f2fb69f..a7e9a20 100644 --- a/test/specs/mainnet/transferringFunds/xdai.spec.js +++ b/test/specs/mainnet/transferringFunds/xdai.spec.js @@ -24,7 +24,7 @@ describe('The PrimeSDK, when transfer a token with xdai network on the MainNet', await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // initializating sdk try { @@ -129,7 +129,7 @@ describe('The PrimeSDK, when transfer a token with xdai network on the MainNet', if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // clear the transaction batch try { @@ -358,7 +358,7 @@ describe('The PrimeSDK, when transfer a token with xdai network on the MainNet', if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // get the respective provider details let provider; @@ -646,7 +646,7 @@ describe('The PrimeSDK, when transfer a token with xdai network on the MainNet', if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // get erc721 Contract Interface let erc721Interface; @@ -882,7 +882,7 @@ describe('The PrimeSDK, when transfer a token with xdai network on the MainNet', if (runTest) { await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); // clear the transaction batch try { @@ -1115,7 +1115,7 @@ describe('The PrimeSDK, when transfer a token with xdai network on the MainNet', await customRetryAsync(async function () { - helper.wait(data.mediumTimeout); + helper.wait(data.longTimeout); const provider = new providers.JsonRpcProvider(); diff --git a/test/specs/testnet/connext/goerli.spec.js b/test/specs/testnet/connext/goerli.spec.js deleted file mode 100644 index de1e00e..0000000 --- a/test/specs/testnet/connext/goerli.spec.js +++ /dev/null @@ -1,1272 +0,0 @@ -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 deleted file mode 100644 index e5da3c9..0000000 --- a/test/specs/testnet/connext/mumbai.spec.js +++ /dev/null @@ -1,1272 +0,0 @@ -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/getAddresses/goerli.spec.js b/test/specs/testnet/getAddresses/goerli.spec.js deleted file mode 100644 index b2b852a..0000000 --- a/test/specs/testnet/getAddresses/goerli.spec.js +++ /dev/null @@ -1,246 +0,0 @@ -import * as dotenv from 'dotenv'; -dotenv.config(); // init dotenv -import { Factory, PrimeSdk } from '@etherspot/prime-sdk'; -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 message from '../../../data/messages.json' assert { type: 'json' }; - -let goerliTestNetSdk; -let goerliAccountAddress; -let goerliTestNetSdk1; -let goerliAccountAddress1; -let goerliSimpleAccountAddress; - -describe('The PrimeSDK, when get the ZeroDev address and SimpleAccount address details with goerli network on the TestNet', function () { - it('SMOKE: Validate the ZeroDev address on the goerli network', 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), - factoryWallet: Factory.ZERO_DEV - }, - ); - - 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 ZeroDev address - try { - goerliSimpleAccountAddress = - await goerliTestNetSdk.getCounterFactualAddress(); - - try { - assert.strictEqual( - goerliSimpleAccountAddress, - data.zerodev_address, - message.vali_zero_dev - ); - } 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_zero_dev); - } - }, data.retry); // Retry this async test up to 5 times - }); - - it('SMOKE: Validate the SimpleAccount address on the goerli network', 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), - factoryWallet: Factory.SIMPLE_ACCOUNT - }, - ); - - 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 SimpleAccount address - try { - goerliSimpleAccountAddress = - await goerliTestNetSdk.getCounterFactualAddress(); - - try { - assert.strictEqual( - goerliSimpleAccountAddress, - data.simpleaccount_address, - message.vali_simple_account, - ); - } 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_simple_account); - } - }, data.retry); // Retry this async test up to 5 times - }); - - it('SMOKE: Validate the get multiple accounts on the goerli network', 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 account address - try { - goerliAccountAddress = - await goerliTestNetSdk.getCounterFactualAddress(); - - try { - assert.strictEqual( - goerliAccountAddress, - data.sender, - message.vali_account_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_account_address); - } - - // initializating sdk for index 1... - try { - goerliTestNetSdk1 = new PrimeSdk( - { privateKey: process.env.PRIVATE_KEY }, - { - chainId: Number(data.goerli_chainid), - projectKey: process.env.PROJECT_KEY, index: 1 - }); - - try { - assert.strictEqual( - goerliTestNetSdk1.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 account address - try { - goerliAccountAddress1 = - await goerliTestNetSdk1.getCounterFactualAddress(); - - try { - assert.strictEqual( - goerliAccountAddress1, - data.sender1, - message.vali_account_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_account_address); - } - }, data.retry); // Retry this async test up to 5 times - }); -}); \ No newline at end of file diff --git a/test/specs/testnet/getAddresses/mumbai.spec.js b/test/specs/testnet/getAddresses/mumbai.spec.js deleted file mode 100644 index 706f736..0000000 --- a/test/specs/testnet/getAddresses/mumbai.spec.js +++ /dev/null @@ -1,246 +0,0 @@ -import * as dotenv from 'dotenv'; -dotenv.config(); // init dotenv -import { Factory, PrimeSdk } from '@etherspot/prime-sdk'; -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 message from '../../../data/messages.json' assert { type: 'json' }; - -let mumbaiTestNetSdk; -let mumbaiAccountAddress; -let mumbaiTestNetSdk1; -let mumbaiAccountAddress1; -let mumbaiSimpleAccountAddress; - -describe('The PrimeSDK, when get the ZeroDev address and SimpleAccount address details with mumbai network on the TestNet', function () { - it('SMOKE: Validate the ZeroDev address on the mumbai network', 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), - factoryWallet: Factory.ZERO_DEV - }, - ); - - 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 ZeroDev address - try { - mumbaiSimpleAccountAddress = - await mumbaiTestNetSdk.getCounterFactualAddress(); - - try { - assert.strictEqual( - mumbaiSimpleAccountAddress, - data.zerodev_address, - message.vali_zero_dev - ); - } 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_zero_dev); - } - }, data.retry); // Retry this async test up to 5 times - }); - - it('SMOKE: Validate the SimpleAccount address on the mumbai network', 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), - factoryWallet: Factory.SIMPLE_ACCOUNT - }, - ); - - 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 SimpleAccount address - try { - mumbaiSimpleAccountAddress = - await mumbaiTestNetSdk.getCounterFactualAddress(); - - try { - assert.strictEqual( - mumbaiSimpleAccountAddress, - data.simpleaccount_address, - message.vali_simple_account, - ); - } 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_simple_account); - } - }, data.retry); // Retry this async test up to 5 times - }); - - it('SMOKE: Validate the get multiple accounts on the mumbai network', 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 account address - try { - mumbaiAccountAddress = - await mumbaiTestNetSdk.getCounterFactualAddress(); - - try { - assert.strictEqual( - mumbaiAccountAddress, - data.sender, - message.vali_account_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_account_address); - } - - // initializating sdk for index 1... - try { - mumbaiTestNetSdk1 = new PrimeSdk( - { privateKey: process.env.PRIVATE_KEY }, - { - chainId: Number(data.mumbai_chainid), - projectKey: process.env.PROJECT_KEY, index: 1 - }); - - try { - assert.strictEqual( - mumbaiTestNetSdk1.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 account address - try { - mumbaiAccountAddress1 = - await mumbaiTestNetSdk1.getCounterFactualAddress(); - - try { - assert.strictEqual( - mumbaiAccountAddress1, - data.sender1, - message.vali_account_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_account_address); - } - }, data.retry); // Retry this async test up to 5 times - }); -}); diff --git a/test/specs/testnet/listAndRates/goerli.spec.js b/test/specs/testnet/listAndRates/goerli.spec.js deleted file mode 100644 index 5fb3233..0000000 --- a/test/specs/testnet/listAndRates/goerli.spec.js +++ /dev/null @@ -1,1043 +0,0 @@ -import * as dotenv from 'dotenv'; -dotenv.config(); // init dotenv -import { PrimeSdk, DataUtils } from '@etherspot/prime-sdk'; -import { utils } from 'ethers'; -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, when get the NFT List, Token List and Exchange Rates details 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 NFT List on the goerli network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - let nfts; - try { - nfts = await goerliDataService.getNftList({ - chainId: Number(data.goerli_chainid), - account: data.sender, - }); - - if (nfts.items.length > 0) { - addContext(test, message.pass_nft_list_1) - console.log(message.pass_nftList_1); - - try { - assert.isNotEmpty( - nfts.items[0].contractName, - message.vali_nftList_contractName, - ); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - nfts.items[0].contractAddress, - message.vali_nftList_contractAddress, - ); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - nfts.items[0].tokenType, - message.vali_nftList_tokenType - ); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNumber( - nfts.items[0].balance, - message.vali_nftList_balance - ); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - nfts.items[0].items[0].tokenId, - message.vali_nftList_items_tokenId - ); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - nfts.items[0].items[0].name, - message.vali_nftList_items_name, - ); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNumber( - nfts.items[0].items[0].amount, - message.vali_nftList_items_amount, - ); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - } else { - addContext(test, message.pass_nftList_2) - console.log(message.pass_nftList_2); - } - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_nftList_1); - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.nftList_insufficientBalance); - } - }); - - it('SMOKE: Validate the Token List on the goerli network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - let tokenLists; - let tokenListTokens; - try { - tokenLists = await goerliDataService.getTokenLists({ chainId: data.goerli_chainid }); - - if (tokenLists.length > 0) { - console.log(message.pass_tokenList_1); - addContext(test, message.pass_tokenList_1); - - try { - assert.isNotEmpty( - tokenLists[0].name, - message.vali_tokenList_name, - ); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - tokenLists[0].endpoint, - message.vali_tokenList_endpoint, - ); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - } else { - addContext(test, message.pass_tokenList_2) - console.log(message.pass_tokenList_2); - } - - tokenListTokens = await goerliDataService.getTokenListTokens({ chainId: data.goerli_chainid }); - - if (tokenListTokens.length > 0) { - console.log(message.pass_tokenList_3); - addContext(test, message.pass_tokenList_3); - - try { - assert.isNotEmpty( - tokenListTokens[0].address, - message.vali_tokenListTokens_address, - ); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - tokenListTokens[0].name, - message.vali_tokenListTokens_name, - ); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - tokenListTokens[0].symbol, - message.vali_tokenListTokens_symbol, - ); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNumber( - tokenListTokens[0].decimals, - message.vali_tokenListTokens_decimals, - ); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - tokenListTokens[0].logoURI, - message.vali_tokenListTokens_logoURI - ); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNumber( - tokenListTokens[0].chainId, - message.vali_tokenListTokens_chainId, - ); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - } else { - addContext(test, message.pass_tokenList_4) - console.log(message.pass_tokenList_4); - } - - if (tokenLists.length > 0) { - - const { name } = tokenLists[0]; - - tokenListTokens = await goerliDataService.getTokenListTokens({ - chainId: data.goerli_chainid, - name, - }); - - if (tokenListTokens.length > 0) { - addContext(test, message.pass_tokenList_5) - console.log(message.pass_tokenList_5); - - try { - assert.isNotEmpty( - tokenListTokens[0].address, - message.vali_selectedTokenListTokens_address, - ); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - tokenListTokens[0].name, - message.vali_selectedTokenListTokens_name - ); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - tokenListTokens[0].symbol, - message.vali_selectedTokenListTokens_symbol - ); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNumber( - tokenListTokens[0].decimals, - message.vali_selectedTokenListTokens_decimals - ); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - tokenListTokens[0].logoURI, - message.vali_selectedTokenListTokens_logoURI - ); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNumber( - tokenListTokens[0].chainId, - message.vali_selectedTokenListTokens_chainId - ); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - } else { - addContext(test, message.pass_tokenList_6) - console.log(message.pass_tokenList_6); - } - } else { - addContext(test, message.pass_tokenList_2) - console.log(message.pass_tokenList_2); - } - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_tokenList_1); - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.tokenList_insufficientBalance); - } - }); - - it('SMOKE: Validate the Exchange Rates on the goerli network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - let TOKEN_LIST; - let rates; - let requestPayload; - try { - TOKEN_LIST = [data.tokenAddress_goerliUSDC, data.tokenAddress_goerliUSDT]; - - requestPayload = { - tokens: TOKEN_LIST, - chainId: Number(data.goerli_chainid), - }; - - rates = await goerliDataService.fetchExchangeRates(requestPayload); - - for (let i = 0; i < rates.items.length; i++) { - try { - assert.isNotEmpty( - rates.items[i].address, - message.vali_exchangeRates_address, - ); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNumber( - rates.items[i].eth, - message.vali_exchangeRates_eth, - ); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNumber( - rates.items[i].eur, - message.vali_exchangeRates_eur, - ); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNumber( - rates.items[i].gbp, - message.vali_exchangeRates_gbp, - ); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNumber( - rates.items[i].usd, - message.vali_exchangeRates_usd, - ); - } 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_exchangeRates_1); - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.exchangeRates_insufficientBalance); - } - }); - - it('REGRESSION: Validate the NFT List with invalid account address on the goerli network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - try { - await goerliDataService.getNftList({ - chainId: Number(data.goerli_chainid), - account: data.invalidSender, - }); - - addContext(test, message.fail_nftList_2) - assert.fail(message.fail_nftList_2); - } catch (e) { - const errorResponse = JSON.parse(e.message); - if (errorResponse[0].constraints.isAddress === constant.invalid_address_1) { - addContext(test, message.pass_nftList_3) - console.log(message.pass_nftList_3); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_nftList_2); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.nftList_insufficientBalance); - } - }); - - it('REGRESSION: Validate the NFT List with incorrect account address on the goerli network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - try { - await goerliDataService.getNftList({ - chainId: Number(data.goerli_chainid), - account: data.incorrectSender, - }); - - addContext(test, message.fail_nftList_3) - assert.fail(message.fail_nftList_3); - } catch (e) { - const errorResponse = JSON.parse(e.message); - if (errorResponse[0].constraints.isAddress === constant.invalid_address_1) { - addContext(test, message.pass_nftList_4) - console.log(message.pass_nftList_4); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_nftList_3); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.nftList_insufficientBalance); - } - }); - - it('REGRESSION: Validate the Token List with different argument in the on the goerli network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - let tokenLists; - let tokenListTokens; - let endpoint; - try { - tokenLists = await goerliDataService.getTokenLists({ chainId: data.goerli_chainid }); - endpoint = tokenLists[0].endpoint; - - if (tokenLists.length > 0) { - console.log(message.pass_tokenList_1); - addContext(test, message.pass_tokenList_1); - - try { - assert.isNotEmpty( - tokenLists[0].name, - message.vali_tokenList_name, - ); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - tokenLists[0].endpoint, - message.vali_tokenList_endpoint, - ); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - } else { - addContext(test, message.pass_tokenList_2) - console.log(message.pass_tokenList_2); - } - - tokenListTokens = await goerliDataService.getTokenListTokens({ chainId: data.goerli_chainid }); - - if (tokenListTokens.length > 0) { - addContext(test, message.pass_tokenList_3); - console.log(message.pass_tokenList_3); - - try { - assert.isNotEmpty( - tokenListTokens[0].address, - message.vali_tokenListTokens_address, - ); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - tokenListTokens[0].name, - message.vali_tokenListTokens_name, - ); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - tokenListTokens[0].symbol, - message.vali_tokenListTokens_symbol, - ); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNumber( - tokenListTokens[0].decimals, - message.vali_tokenListTokens_decimals, - ); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - tokenListTokens[0].logoURI, - message.vali_tokenListTokens_logoURI - ); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNumber( - tokenListTokens[0].chainId, - message.vali_tokenListTokens_chainId, - ); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - } else { - addContext(test, message.pass_tokenList_4) - console.log(message.pass_tokenList_4); - } - - tokenListTokens = await goerliDataService.getTokenListTokens({ - chainId: data.goerli_chainid, - endpoint, - }); - - if (tokenListTokens.length > 0) { - try { - assert.isNotEmpty( - tokenListTokens[0].address, - message.vali_selectedTokenListTokens_address, - ); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - tokenListTokens[0].name, - message.vali_selectedTokenListTokens_name - ); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - tokenListTokens[0].symbol, - message.vali_selectedTokenListTokens_symbol - ); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNumber( - tokenListTokens[0].decimals, - message.vali_selectedTokenListTokens_decimals - ); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - tokenListTokens[0].logoURI, - message.vali_selectedTokenListTokens_logoURI - ); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNumber( - tokenListTokens[0].chainId, - message.vali_selectedTokenListTokens_chainId - ); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - } else { - addContext(test, message.pass_tokenList_4) - console.log(message.pass_tokenList_4); - } - } catch (e) { - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_tokenList_1); - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.tokenList_insufficientBalance); - } - }); - - it('REGRESSION: Validate the Exchange Rates with other token address on the goerli network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - let TOKEN_LIST; - let requestPayload; - try { - TOKEN_LIST = [ - data.tokenAddress_goerliUSDC, - data.tokenAddress_goerliUSDT, - data.tokenAddress_maticUSDC, - ]; - - requestPayload = { - tokens: TOKEN_LIST, - chainId: Number(data.goerli_chainid), - }; - - await goerliDataService.fetchExchangeRates(requestPayload); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_exchangeRates_2); - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.exchangeRates_insufficientBalance); - } - }); - - it('REGRESSION: Validate the Exchange Rates with invalid token address on the goerli network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - let TOKEN_LIST; - let requestPayload; - try { - TOKEN_LIST = [ - data.invalidTokenAddress_goerliUSDC, - data.tokenAddress_goerliUSDT, - ]; - - requestPayload = { - tokens: TOKEN_LIST, - chainId: Number(data.goerli_chainid), - }; - - await goerliDataService.fetchExchangeRates(requestPayload); - - addContext(test, message.fail_exchangeRates_3) - assert.fail(message.fail_exchangeRates_3); - } catch (e) { - let errorMessage = e.message; - if (errorMessage.includes(constant.property_undefined)) { - addContext(test, message.pass_exchangeRates_1) - console.log(message.pass_exchangeRates_1); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_exchangeRates_3); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.exchangeRates_insufficientBalance); - } - }); - - it('REGRESSION: Validate the Exchange Rates with incorrect token address on the goerli network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - let TOKEN_LIST; - let requestPayload; - - try { - TOKEN_LIST = [ - data.incorrectTokenAddress_goerliUSDC, - data.tokenAddress_goerliUSDT, - ]; - - requestPayload = { - tokens: TOKEN_LIST, - chainId: Number(data.goerli_chainid), - }; - - await goerliDataService.fetchExchangeRates(requestPayload); - - addContext(test, message.fail_exchangeRates_4) - assert.fail(message.fail_exchangeRates_4); - } catch (e) { - let errorMessage = e.message; - if (errorMessage.includes(constant.property_undefined)) { - addContext(test, message.pass_exchangeRates_2) - console.log(message.pass_exchangeRates_2); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_exchangeRates_4); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.exchangeRates_insufficientBalance); - } - }); - - it('REGRESSION: Validate the Exchange Rates without token address on the goerli network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - try { - let TOKEN_LIST = []; - - let requestPayload = { - tokens: TOKEN_LIST, - chainId: Number(data.goerli_chainid), - }; - - await goerliDataService.fetchExchangeRates(requestPayload); - - addContext(test, message.fail_exchangeRates_5) - assert.fail(message.fail_exchangeRates_5); - } catch (e) { - let error = e.message; - if (error.includes(constant.property_undefined)) { - addContext(test, message.pass_exchangeRates_3) - console.log(message.pass_exchangeRates_3); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_exchangeRates_5); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.exchangeRates_insufficientBalance); - } - }); - - it('REGRESSION: Validate the Exchange Rates with invalid chainid on the goerli network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - let TOKEN_LIST; - let requestPayload; - - try { - TOKEN_LIST = [data.tokenAddress_goerliUSDC, data.tokenAddress_goerliUSDT]; - - requestPayload = { - tokens: TOKEN_LIST, - chainId: Number(data.invalid_goerli_chainid), - }; - - await goerliDataService.fetchExchangeRates(requestPayload); - } catch (e) { - let errorMessage = e.message; - if (errorMessage.includes(constant.property_undefined)) { - addContext(test, message.pass_exchangeRates_4) - console.log(message.pass_exchangeRates_4); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_exchangeRates_6); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.exchangeRates_insufficientBalance); - } - }); - - it('REGRESSION: Validate the Exchange Rates without chainid on the goerli network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - let TOKEN_LIST; - let requestPayload; - - try { - TOKEN_LIST = [data.tokenAddress_goerliUSDC, data.tokenAddress_goerliUSDT]; - - requestPayload = { - tokens: TOKEN_LIST, - }; - - await goerliDataService.fetchExchangeRates(requestPayload); - - addContext(test, message.fail_exchangeRates_7) - assert.fail(message.fail_exchangeRates_7); - } catch (e) { - let errorMessage = e.message; - if (errorMessage.includes(constant.property_undefined)) { - addContext(test, message.pass_exchangeRates_5) - console.log(message.pass_exchangeRates_5); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_exchangeRates_7); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.exchangeRates_insufficientBalance); - } - }); -}); diff --git a/test/specs/testnet/listAndRates/mumbai.spec.js b/test/specs/testnet/listAndRates/mumbai.spec.js deleted file mode 100644 index 24e1d60..0000000 --- a/test/specs/testnet/listAndRates/mumbai.spec.js +++ /dev/null @@ -1,1043 +0,0 @@ -import * as dotenv from 'dotenv'; -dotenv.config(); // init dotenv -import { PrimeSdk, DataUtils } from '@etherspot/prime-sdk'; -import { utils } from 'ethers'; -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, when get the NFT List, Token List and Exchange Rates details 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 NFT List on the mumbai network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - let nfts; - try { - nfts = await mumbaiDataService.getNftList({ - chainId: Number(data.mumbai_chainid), - account: data.sender, - }); - - if (nfts.items.length > 0) { - addContext(test, message.pass_nft_list_1) - console.log(message.pass_nftList_1); - - try { - assert.isNotEmpty( - nfts.items[0].contractName, - message.vali_nftList_contractName, - ); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - nfts.items[0].contractAddress, - message.vali_nftList_contractAddress, - ); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - nfts.items[0].tokenType, - message.vali_nftList_tokenType - ); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNumber( - nfts.items[0].balance, - message.vali_nftList_balance - ); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - nfts.items[0].items[0].tokenId, - message.vali_nftList_items_tokenId - ); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - nfts.items[0].items[0].name, - message.vali_nftList_items_name, - ); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNumber( - nfts.items[0].items[0].amount, - message.vali_nftList_items_amount, - ); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - } else { - addContext(test, message.pass_nftList_2) - console.log(message.pass_nftList_2); - } - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_nftList_1); - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.nftList_insufficientBalance); - } - }); - - it('SMOKE: Validate the Token List on the mumbai network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - let tokenLists; - let tokenListTokens; - try { - tokenLists = await mumbaiDataService.getTokenLists({ chainId: data.mumbai_chainid }); - - if (tokenLists.length > 0) { - console.log(message.pass_tokenList_1); - addContext(test, message.pass_tokenList_1); - - try { - assert.isNotEmpty( - tokenLists[0].name, - message.vali_tokenList_name, - ); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - tokenLists[0].endpoint, - message.vali_tokenList_endpoint, - ); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - } else { - addContext(test, message.pass_tokenList_2) - console.log(message.pass_tokenList_2); - } - - tokenListTokens = await mumbaiDataService.getTokenListTokens({ chainId: data.mumbai_chainid }); - - if (tokenListTokens.length > 0) { - console.log(message.pass_tokenList_3); - addContext(test, message.pass_tokenList_3); - - try { - assert.isNotEmpty( - tokenListTokens[0].address, - message.vali_tokenListTokens_address, - ); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - tokenListTokens[0].name, - message.vali_tokenListTokens_name, - ); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - tokenListTokens[0].symbol, - message.vali_tokenListTokens_symbol, - ); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNumber( - tokenListTokens[0].decimals, - message.vali_tokenListTokens_decimals, - ); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - tokenListTokens[0].logoURI, - message.vali_tokenListTokens_logoURI - ); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNumber( - tokenListTokens[0].chainId, - message.vali_tokenListTokens_chainId, - ); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - } else { - addContext(test, message.pass_tokenList_4) - console.log(message.pass_tokenList_4); - } - - if (tokenLists.length > 0) { - - const { name } = tokenLists[0]; - - tokenListTokens = await mumbaiDataService.getTokenListTokens({ - chainId: data.mumbai_chainid, - name, - }); - - if (tokenListTokens.length > 0) { - addContext(test, message.pass_tokenList_5) - console.log(message.pass_tokenList_5); - - try { - assert.isNotEmpty( - tokenListTokens[0].address, - message.vali_selectedTokenListTokens_address, - ); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - tokenListTokens[0].name, - message.vali_selectedTokenListTokens_name - ); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - tokenListTokens[0].symbol, - message.vali_selectedTokenListTokens_symbol - ); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNumber( - tokenListTokens[0].decimals, - message.vali_selectedTokenListTokens_decimals - ); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - tokenListTokens[0].logoURI, - message.vali_selectedTokenListTokens_logoURI - ); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNumber( - tokenListTokens[0].chainId, - message.vali_selectedTokenListTokens_chainId - ); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - } else { - addContext(test, message.pass_tokenList_6) - console.log(message.pass_tokenList_6); - } - } else { - addContext(test, message.pass_tokenList_2) - console.log(message.pass_tokenList_2); - } - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_tokenList_1); - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.tokenList_insufficientBalance); - } - }); - - it('SMOKE: Validate the Exchange Rates on the mumbai network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - let TOKEN_LIST; - let rates; - let requestPayload; - try { - TOKEN_LIST = [data.tokenAddress_mumbaiUSDC, data.tokenAddress_mumbaiUSDT]; - - requestPayload = { - tokens: TOKEN_LIST, - chainId: Number(data.mumbai_chainid), - }; - - rates = await mumbaiDataService.fetchExchangeRates(requestPayload); - - for (let i = 0; i < rates.items.length; i++) { - try { - assert.isNotEmpty( - rates.items[i].address, - message.vali_exchangeRates_address, - ); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNumber( - rates.items[i].eth, - message.vali_exchangeRates_eth, - ); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNumber( - rates.items[i].eur, - message.vali_exchangeRates_eur, - ); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNumber( - rates.items[i].gbp, - message.vali_exchangeRates_gbp, - ); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNumber( - rates.items[i].usd, - message.vali_exchangeRates_usd, - ); - } 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_exchangeRates_1); - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.exchangeRates_insufficientBalance); - } - }); - - it('REGRESSION: Validate the NFT List with invalid account address on the mumbai network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - try { - await mumbaiDataService.getNftList({ - chainId: Number(data.mumbai_chainid), - account: data.invalidSender, - }); - - addContext(test, message.fail_nftList_2) - assert.fail(message.fail_nftList_2); - } catch (e) { - const errorResponse = JSON.parse(e.message); - if (errorResponse[0].constraints.isAddress === constant.invalid_address_1) { - addContext(test, message.pass_nftList_3) - console.log(message.pass_nftList_3); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_nftList_2); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.nftList_insufficientBalance); - } - }); - - it('REGRESSION: Validate the NFT List with incorrect account address on the mumbai network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - try { - await mumbaiDataService.getNftList({ - chainId: Number(data.mumbai_chainid), - account: data.incorrectSender, - }); - - addContext(test, message.fail_nftList_3) - assert.fail(message.fail_nftList_3); - } catch (e) { - const errorResponse = JSON.parse(e.message); - if (errorResponse[0].constraints.isAddress === constant.invalid_address_1) { - addContext(test, message.pass_nftList_4) - console.log(message.pass_nftList_4); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_nftList_3); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.nftList_insufficientBalance); - } - }); - - it('REGRESSION: Validate the Token List with different argument in the on the mumbai network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - let tokenLists; - let tokenListTokens; - let endpoint; - try { - tokenLists = await mumbaiDataService.getTokenLists({ chainId: data.mumbai_chainid }); - endpoint = tokenLists[0].endpoint; - - if (tokenLists.length > 0) { - console.log(message.pass_tokenList_1); - addContext(test, message.pass_tokenList_1); - - try { - assert.isNotEmpty( - tokenLists[0].name, - message.vali_tokenList_name, - ); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - tokenLists[0].endpoint, - message.vali_tokenList_endpoint, - ); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - } else { - addContext(test, message.pass_tokenList_2) - console.log(message.pass_tokenList_2); - } - - tokenListTokens = await mumbaiDataService.getTokenListTokens({ chainId: data.mumbai_chainid }); - - if (tokenListTokens.length > 0) { - addContext(test, message.pass_tokenList_3); - console.log(message.pass_tokenList_3); - - try { - assert.isNotEmpty( - tokenListTokens[0].address, - message.vali_tokenListTokens_address, - ); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - tokenListTokens[0].name, - message.vali_tokenListTokens_name, - ); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - tokenListTokens[0].symbol, - message.vali_tokenListTokens_symbol, - ); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNumber( - tokenListTokens[0].decimals, - message.vali_tokenListTokens_decimals, - ); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - tokenListTokens[0].logoURI, - message.vali_tokenListTokens_logoURI - ); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNumber( - tokenListTokens[0].chainId, - message.vali_tokenListTokens_chainId, - ); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - } else { - addContext(test, message.pass_tokenList_4) - console.log(message.pass_tokenList_4); - } - - tokenListTokens = await mumbaiDataService.getTokenListTokens({ - chainId: data.mumbai_chainid, - endpoint, - }); - - if (tokenListTokens.length > 0) { - try { - assert.isNotEmpty( - tokenListTokens[0].address, - message.vali_selectedTokenListTokens_address, - ); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - tokenListTokens[0].name, - message.vali_selectedTokenListTokens_name - ); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - tokenListTokens[0].symbol, - message.vali_selectedTokenListTokens_symbol - ); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNumber( - tokenListTokens[0].decimals, - message.vali_selectedTokenListTokens_decimals - ); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - tokenListTokens[0].logoURI, - message.vali_selectedTokenListTokens_logoURI - ); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNumber( - tokenListTokens[0].chainId, - message.vali_selectedTokenListTokens_chainId - ); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - } else { - addContext(test, message.pass_tokenList_4) - console.log(message.pass_tokenList_4); - } - } catch (e) { - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_tokenList_1); - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.tokenList_insufficientBalance); - } - }); - - it('REGRESSION: Validate the Exchange Rates with other token address on the mumbai network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - let TOKEN_LIST; - let requestPayload; - try { - TOKEN_LIST = [ - data.tokenAddress_mumbaiUSDC, - data.tokenAddress_mumbaiUSDT, - data.tokenAddress_maticUSDC, - ]; - - requestPayload = { - tokens: TOKEN_LIST, - chainId: Number(data.mumbai_chainid), - }; - - await mumbaiDataService.fetchExchangeRates(requestPayload); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_exchangeRates_2); - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.exchangeRates_insufficientBalance); - } - }); - - it('REGRESSION: Validate the Exchange Rates with invalid token address on the mumbai network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - let TOKEN_LIST; - let requestPayload; - try { - TOKEN_LIST = [ - data.invalidTokenAddress_mumbaiUSDC, - data.tokenAddress_mumbaiUSDT, - ]; - - requestPayload = { - tokens: TOKEN_LIST, - chainId: Number(data.mumbai_chainid), - }; - - await mumbaiDataService.fetchExchangeRates(requestPayload); - - addContext(test, message.fail_exchangeRates_3) - assert.fail(message.fail_exchangeRates_3); - } catch (e) { - let errorMessage = e.message; - if (errorMessage.includes(constant.property_undefined)) { - addContext(test, message.pass_exchangeRates_1) - console.log(message.pass_exchangeRates_1); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_exchangeRates_3); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.exchangeRates_insufficientBalance); - } - }); - - it('REGRESSION: Validate the Exchange Rates with incorrect token address on the mumbai network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - let TOKEN_LIST; - let requestPayload; - - try { - TOKEN_LIST = [ - data.incorrectTokenAddress_mumbaiUSDC, - data.tokenAddress_mumbaiUSDT, - ]; - - requestPayload = { - tokens: TOKEN_LIST, - chainId: Number(data.mumbai_chainid), - }; - - await mumbaiDataService.fetchExchangeRates(requestPayload); - - addContext(test, message.fail_exchangeRates_4) - assert.fail(message.fail_exchangeRates_4); - } catch (e) { - let errorMessage = e.message; - if (errorMessage.includes(constant.property_undefined)) { - addContext(test, message.pass_exchangeRates_2) - console.log(message.pass_exchangeRates_2); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_exchangeRates_4); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.exchangeRates_insufficientBalance); - } - }); - - it('REGRESSION: Validate the Exchange Rates without token address on the mumbai network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - try { - let TOKEN_LIST = []; - - let requestPayload = { - tokens: TOKEN_LIST, - chainId: Number(data.mumbai_chainid), - }; - - await mumbaiDataService.fetchExchangeRates(requestPayload); - - addContext(test, message.fail_exchangeRates_5) - assert.fail(message.fail_exchangeRates_5); - } catch (e) { - let error = e.message; - if (error.includes(constant.property_undefined)) { - addContext(test, message.pass_exchangeRates_3) - console.log(message.pass_exchangeRates_3); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_exchangeRates_5); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.exchangeRates_insufficientBalance); - } - }); - - it('REGRESSION: Validate the Exchange Rates with invalid chainid on the mumbai network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - let TOKEN_LIST; - let requestPayload; - - try { - TOKEN_LIST = [data.tokenAddress_mumbaiUSDC, data.tokenAddress_mumbaiUSDT]; - - requestPayload = { - tokens: TOKEN_LIST, - chainId: Number(data.invalid_mumbai_chainid), - }; - - await mumbaiDataService.fetchExchangeRates(requestPayload); - } catch (e) { - let errorMessage = e.message; - if (errorMessage.includes(constant.property_undefined)) { - addContext(test, message.pass_exchangeRates_4) - console.log(message.pass_exchangeRates_4); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_exchangeRates_6); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.exchangeRates_insufficientBalance); - } - }); - - it('REGRESSION: Validate the Exchange Rates without chainid on the mumbai network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - let TOKEN_LIST; - let requestPayload; - - try { - TOKEN_LIST = [data.tokenAddress_mumbaiUSDC, data.tokenAddress_mumbaiUSDT]; - - requestPayload = { - tokens: TOKEN_LIST, - }; - - await mumbaiDataService.fetchExchangeRates(requestPayload); - - addContext(test, message.fail_exchangeRates_7) - assert.fail(message.fail_exchangeRates_7); - } catch (e) { - let errorMessage = e.message; - if (errorMessage.includes(constant.property_undefined)) { - addContext(test, message.pass_exchangeRates_5) - console.log(message.pass_exchangeRates_5); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_exchangeRates_7); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.exchangeRates_insufficientBalance); - } - }); -}); diff --git a/test/specs/testnet/paymaster/goerli.spec.js b/test/specs/testnet/paymaster/goerli.spec.js deleted file mode 100644 index f172441..0000000 --- a/test/specs/testnet/paymaster/goerli.spec.js +++ /dev/null @@ -1,4227 +0,0 @@ -import * as dotenv from 'dotenv'; -dotenv.config(); // init dotenv -import { PrimeSdk, DataUtils, ArkaPaymaster } from '@etherspot/prime-sdk'; -import { ethers, utils } from 'ethers'; -import { assert } from 'chai'; -import { ERC20_ABI } from '@etherspot/prime-sdk/dist/sdk/helpers/abi/ERC20_ABI.js'; -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 arkaPaymaster; -let runTest; - -/* eslint-disable prettier/prettier */ -describe('The PrimeSDK, when transaction with arka and pimlico paymasters 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); - } - - // initializating ArkaPaymaster... - try { - arkaPaymaster = new ArkaPaymaster(Number(data.goerli_chainid), process.env.API_KEY, data.paymaster_arka); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_arka_initialize); - } - - // 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: Perform the transfer native token on arka paymaster 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 - let transactionBatch; - try { - transactionBatch = await goerliTestNetSdk.addUserOpsToBatch({ - to: data.recipient, - value: ethers.utils.parseEther(data.value), - }); - - try { - assert.isNotEmpty( - transactionBatch.to, - message.vali_addTransaction_to); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactionBatch.data, - message.vali_addTransaction_data); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactionBatch.value, - message.vali_addTransaction_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_addTransaction_1); - } - - // get balance of the account address - let balance; - try { - balance = await goerliTestNetSdk.getNativeBalance(); - - try { - assert.isNotEmpty( - balance, - message.vali_getBalance_balance); - } 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_getBalance_1); - } - - // estimate transactions added to the batch and get the fee data for the UserOp - let op; - try { - op = await goerliTestNetSdk.estimate({ - paymasterDetails: { - url: `https://arka.etherspot.io?apiKey=${process.env.API_KEY - }&chainId=${Number(data.goerli_chainid)}`, - context: { mode: 'sponsor' }, - } - }); - - try { - assert.isNotEmpty( - op.sender, - message.vali_estimateTransaction_sender); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.nonce, - message.vali_estimateTransaction_nonce); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.initCode, - message.vali_estimateTransaction_initCode); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.callData, - message.vali_estimateTransaction_callData); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.callGasLimit, - message.vali_estimateTransaction_callGasLimit); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.verificationGasLimit, - message.vali_estimateTransaction_verificationGasLimit); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.maxFeePerGas, - message.vali_estimateTransaction_maxFeePerGas); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.maxPriorityFeePerGas, - message.vali_estimateTransaction_maxPriorityFeePerGas); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.paymasterAndData, - message.vali_estimateTransaction_paymasterAndData); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.preVerificationGas, - message.vali_estimateTransaction_preVerificationGas); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.signature, - message.vali_estimateTransaction_signature); - } 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_estimateTransaction_1); - } - - // sign the UserOp and sending to the bundler - let uoHash; - try { - uoHash = await goerliTestNetSdk.send(op); - - try { - assert.isNotEmpty( - uoHash, - message.vali_submitTransaction_uoHash); - } 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_submitTransaction_1); - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.nativeTransaction_insufficientBalance); - } - }); - - xit('SMOKE: Perform the transfer token with arka pimlico paymaster on the goerli network', async function () { - var test = this; - let arka_url = data.paymaster_arka; - let queryString = `?apiKey=${process.env.API_KEY}&chainId=${Number( - data.goerli_chainid, - )}`; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - let balance; - // get balance of the account address - try { - balance = await goerliTestNetSdk.getNativeBalance(); - - try { - assert.isNotEmpty( - balance, - message.vali_getBalance_balance); - } 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_getBalance_1); - } - - /** - * The fetching of pimlico erc20 paymaster address is only required for the first time for each specified gas token since we need to approve the tokens to spend - * from the paymaster address on behalf of you. - */ - let returnedValue; - let paymasterAddress; - let erc20Contract; - let encodedData; - let approveOp; - let uoHash1; - let transactionBatch; - let op; - let uoHash; - - try { - returnedValue = await fetch( - `${arka_url}/pimlicoAddress${queryString}`, - { - method: 'POST', - headers: { - Accept: 'application/json', - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ - params: [data.entryPointAddress, { token: data.usdc_token }], - }), - }, - ).then((res) => { - return res.json(); - }); - - paymasterAddress = returnedValue.message; - - try { - assert.isNotEmpty( - paymasterAddress, - message.vali_pimlico_paymasterAddress_1); - } 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_pimlico_paymasterAddress_1); - } - - if (utils.isAddress(paymasterAddress)) { - // get the erc20 Contract - let contract; - try { - erc20Contract = new ethers.Contract( - data.tokenAddress_goerliUSDC, - ERC20_ABI, - ); - encodedData = erc20Contract.interface.encodeFunctionData( - 'approve', - [paymasterAddress, ethers.constants.MaxUint256], - ); - - contract = await goerliTestNetSdk.addUserOpsToBatch({ - to: data.tokenAddress_goerliUSDC, - data: encodedData, - }); - - try { - assert.isNotEmpty( - contract.to, - message.vali_erc20Contract_to); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - contract.data, - message.vali_erc20Contract_data); - } 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_erc20Contract_1); - } - - // get estimation of transaction - try { - approveOp = await goerliTestNetSdk.estimate(); - - try { - assert.isNotEmpty( - approveOp.sender, - message.vali_estimateTransaction_sender); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - approveOp.nonce, - message.vali_estimateTransaction_nonce); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - approveOp.initCode, - message.vali_estimateTransaction_initCode); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - approveOp.callData, - message.vali_estimateTransaction_callData); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - approveOp.callGasLimit, - message.vali_estimateTransaction_callGasLimit); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - approveOp.verificationGasLimit, - message.vali_estimateTransaction_verificationGasLimit); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - approveOp.maxFeePerGas, - message.vali_estimateTransaction_maxFeePerGas); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - approveOp.maxPriorityFeePerGas, - message.vali_estimateTransaction_maxPriorityFeePerGas); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - approveOp.paymasterAndData, - message.vali_estimateTransaction_paymasterAndData); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - approveOp.preVerificationGas, - message.vali_estimateTransaction_preVerificationGas); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - approveOp.signature, - message.vali_estimateTransaction_signature); - } 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_estimateTransaction_1); - } - - // get the uoHash1 - try { - uoHash1 = await goerliTestNetSdk.send(approveOp); - - try { - assert.isNotEmpty( - uoHash1, - message.vali_submitTransaction_uoHash); - } 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_submitTransaction_1); - } - - // 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 { - transactionBatch = await goerliTestNetSdk.addUserOpsToBatch({ - to: data.recipient, - value: ethers.utils.parseEther(data.value), - }); - - try { - assert.isNotEmpty( - transactionBatch.to, - message.vali_addTransaction_to); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactionBatch.data, - message.vali_addTransaction_data); - } 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_addTransaction_1); - } - - // get balance of the account address - try { - balance = await goerliTestNetSdk.getNativeBalance(); - - try { - assert.isNotEmpty( - balance, - message.vali_getBalance_balance); - } 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_getBalance_1); - } - - // estimate transactions added to the batch and get the fee data for the UserOp - try { - op = await goerliTestNetSdk.estimate({ - paymasterDetails: { - url: `${arka_url}${queryString}`, - context: { token: data.usdc_token, mode: 'erc20' }, - } - }); - - try { - assert.isNotEmpty( - op.sender, - message.vali_estimateTransaction_sender); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.nonce, - message.vali_estimateTransaction_nonce); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.initCode, - message.vali_estimateTransaction_initCode); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.callData, - message.vali_estimateTransaction_callData); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.callGasLimit, - message.vali_estimateTransaction_callGasLimit); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.verificationGasLimit, - message.vali_estimateTransaction_verificationGasLimit); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.maxFeePerGas, - message.vali_estimateTransaction_maxFeePerGas); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.maxPriorityFeePerGas, - message.vali_estimateTransaction_maxPriorityFeePerGas); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.paymasterAndData, - message.vali_estimateTransaction_paymasterAndData); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.preVerificationGas, - message.vali_estimateTransaction_preVerificationGas); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.signature, - message.vali_estimateTransaction_signature); - } 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_estimateTransaction_1); - } - - // sign the UserOp and sending to the bundler... - try { - uoHash = await goerliTestNetSdk.send(op); - - try { - assert.isNotEmpty( - uoHash, - message.vali_submitTransaction_uoHash); - } 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_submitTransaction_1); - } - } else { - addContext(test, message.fail_paymasterAddress_1); - assert.fail(message.fail_paymasterAddress_1); - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.pimlocoPaymaster_insufficientBalance); - } - }); - - it('SMOKE: Perform the transfer token with arka paymaster with validUntil and validAfter on the goerli network', async function () { - var test = this; - let arka_url = data.paymaster_arka; - let queryString = `?apiKey=${process.env.API_KEY}&chainId=${Number( - data.goerli_chainid, - )}`; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - let balance; - let transactionBatch; - let op; - let uoHash; - - // get balance of the account address - try { - balance = await goerliTestNetSdk.getNativeBalance(); - - try { - assert.isNotEmpty( - balance, - message.vali_getBalance_balance); - } 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_getBalance_1); - } - - // 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 { - transactionBatch = await goerliTestNetSdk.addUserOpsToBatch({ - to: data.recipient, - value: ethers.utils.parseEther(data.value), - }); - - try { - assert.isNotEmpty( - transactionBatch.to, - message.vali_addTransaction_to); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactionBatch.data, - message.vali_addTransaction_data); - } 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_addTransaction_1); - } - - // get balance of the account address - try { - balance = await goerliTestNetSdk.getNativeBalance(); - - try { - assert.isNotEmpty( - balance, - message.vali_getBalance_balance); - } 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_getBalance_1); - } - - /* estimate transactions added to the batch and get the fee data for the UserOp - validUntil and validAfter are optional defaults to 10 mins of expiry from send call and should be passed in terms of milliseconds - For example purpose, the valid is fixed as expiring in 100 mins once the paymaster data is generated - validUntil and validAfter is relevant only with sponsor transactions and not for token paymasters - */ - - // estimate transactions added to the batch and get the fee data for the UserOp - try { - op = await goerliTestNetSdk.estimate({ - paymasterDetails: { - url: `${arka_url}${queryString}`, - context: { - mode: 'sponsor', - validAfter: new Date().valueOf(), - validUntil: new Date().valueOf() + 6000000, - }, - } - }); - - try { - assert.isNotEmpty( - op.sender, - message.vali_estimateTransaction_sender); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.nonce, - message.vali_estimateTransaction_nonce); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.initCode, - message.vali_estimateTransaction_initCode); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.callData, - message.vali_estimateTransaction_callData); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.callGasLimit, - message.vali_estimateTransaction_callGasLimit); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.verificationGasLimit, - message.vali_estimateTransaction_verificationGasLimit); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.maxFeePerGas, - message.vali_estimateTransaction_maxFeePerGas); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.maxPriorityFeePerGas, - message.vali_estimateTransaction_maxPriorityFeePerGas); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.paymasterAndData, - message.vali_estimateTransaction_paymasterAndData); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.preVerificationGas, - message.vali_estimateTransaction_preVerificationGas); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.signature, - message.vali_estimateTransaction_signature); - } 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_estimateTransaction_1); - } - - // sign the UserOp and sending to the bundler... - try { - uoHash = await goerliTestNetSdk.send(op); - - try { - assert.isNotEmpty( - uoHash, - message.vali_submitTransaction_uoHash); - } 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_submitTransaction_1); - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.nativeTransaction_insufficientBalance); - } - }); - - it('SMOKE: Validate the metadata of the arka paymaster on the goerli network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - - // get the metadata - try { - let metadata = await arkaPaymaster.metadata(); - - try { - assert.isNotEmpty( - metadata.sponsorAddress, - message.vali_metadata_sponsorAddress); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - metadata.sponsorWalletBalance, - message.vali_metadata_sponsorWalletBalance); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - metadata.chainsSupported, - message.vali_metadata_chainsSupported); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - metadata.tokenPaymasters, - message.vali_metadata_tokenPaymasters); - } 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_metadata_1); - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.arkaFunction_insufficientBalance); - } - }); - - it('SMOKE: Validate the get token paymaster address function of the arka paymaster on the goerli network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - - // validate the get token paymaster address - try { - let getTokenPaymasterAddress = await arkaPaymaster.getTokenPaymasterAddress("USDC"); - - try { - assert.isNotEmpty( - getTokenPaymasterAddress, - message.vali_getTokenPaymasterAddress_tokenPaymasterAddress); - } 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_getTokenPaymasterAddress_1); - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.arkaFunction_insufficientBalance); - } - }); - - it('SMOKE: Validate the remove whitelist address function of the arka paymaster on the goerli network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - - // validate the remove whitelist address - try { - let removeWhitelist = await arkaPaymaster.removeWhitelist([data.sender]); - - if (removeWhitelist.includes(constant.remove_whitelist_2)) { - addContext(test, message.vali_removeWhitelist_1); - console.log(message.vali_removeWhitelist_1); - } else { - addContext(test, message.fail_removeWhitelist_1); - assert.fail(message.fail_removeWhitelist_1); - } - } catch (e) { - let errorMessage = e.message; - if (errorMessage.includes(constant.remove_whitelist_1)) { - addContext(test, message.vali_removeWhitelist_2); - console.log(message.vali_removeWhitelist_2); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_removeWhitelist_2); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.arkaFunction_insufficientBalance); - } - }); - - it('SMOKE: Validate the add whitelist address function of the arka paymaster on the goerli network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - - // validate the add whitelist address - try { - let addWhitelist = await arkaPaymaster.addWhitelist([data.sender]); - - if (addWhitelist.includes(constant.add_whitelist_1)) { - addContext(test, message.vali_addWhitelist_1); - console.log(message.vali_addWhitelist_1); - } else { - addContext(test, message.fail_addWhitelist_1); - assert.fail(message.fail_addWhitelist_1); - } - } catch (e) { - let errorMessage = e.message; - if (errorMessage.includes(constant.add_whitelist_2)) { - addContext(test, message.vali_addWhitelist_2); - console.log(message.vali_addWhitelist_2); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_addWhitelist_2); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.arkaFunction_insufficientBalance); - } - }); - - it('SMOKE: Validate the check whitelist function of the arka paymaster on the goerli network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - - // validate the whilelist address - try { - let checkWhitelist = await arkaPaymaster.checkWhitelist(data.sender); - - if (checkWhitelist.includes(constant.check_whitelist_1)) { - addContext(test, message.vali_addWhitelist_2); - console.log(message.vali_addWhitelist_2); - } else if (checkWhitelist.includes(constant.check_whitelist_2)) { - addContext(test, message.vali_removeWhitelist_2); - console.log(message.vali_removeWhitelist_2); - } - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_checkWhitelist_1); - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.arkaFunction_insufficientBalance); - } - }); - - it('SMOKE: Validate the deposit function of the arka paymaster on the goerli network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - - // validate the deposit - try { - let deposit = await arkaPaymaster.deposit(data.value); - - if (deposit.includes(constant.deposit_1)) { - addContext(test, message.vali_deposit_1) - console.log(message.vali_deposit_1) - } else { - addContext(test, message.fail_deposit_1) - assert.fail(message.fail_deposit_1) - } - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_deposit_2); - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.arkaFunction_insufficientBalance); - } - }); - - it('REGRESSION: Perform the transfer native token with invalid arka paymaster url 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); - } - - // 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 - try { - await goerliTestNetSdk.estimate({ - paymasterDetails: { - url: data.invalid_paymaster_arka, // invalid URL - api_key: process.env.API_KEY, - context: { mode: 'sponsor' }, - } - }); - - addContext(test, message.fail_estimateTransaction_2) - assert.fail(message.fail_estimateTransaction_2); - } catch (e) { - if (e.message === constant.not_found) { - addContext(test, message.vali_estimateTransaction_1) - console.log(message.vali_estimateTransaction_1); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_estimateTransaction_2); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.nativeTransaction_insufficientBalance); - } - }); - - it('REGRESSION: Perform the transfer native token with invalid API Key of arka paymaster 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); - } - - // 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 - try { - await goerliTestNetSdk.estimate({ - paymasterDetails: { - url: data.paymaster_arka, - api_key: process.env.INVALID_API_KEY, - context: { mode: 'sponsor' }, - } - }); - - addContext(test, message.fail_estimateTransaction_4) - assert.fail(message.fail_estimateTransaction_4); - } catch (e) { - if (e.message === constant.invalid_apiKey) { - addContext(test, message.vali_estimateTransaction_3) - console.log(message.vali_estimateTransaction_3); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_estimateTransaction_4); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.nativeTransaction_insufficientBalance); - } - }); - - it('REGRESSION: Perform the transfer native token with incorrect API Key of arka paymaster 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); - } - - // 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 - try { - await goerliTestNetSdk.estimate({ - paymasterDetails: { - url: data.paymaster_arka, - api_key: process.env.INCORRECT_API_KEY, - context: { mode: 'sponsor' }, - } - }); - - addContext(test, message.fail_estimateTransaction_5) - assert.fail(message.fail_estimateTransaction_5); - } catch (e) { - if (e.message === constant.invalid_apiKey) { - addContext(test, message.vali_estimateTransaction_4) - console.log(message.vali_estimateTransaction_4); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_estimateTransaction_5); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.nativeTransaction_insufficientBalance); - } - }); - - it('REGRESSION: Perform the transfer native token without API Key of arka paymaster 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); - } - - // 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 - try { - await goerliTestNetSdk.estimate({ - paymasterDetails: { - url: data.paymaster_arka, - // without api_key - context: { mode: 'sponsor' }, - } - }); - - addContext(test, message.fail_estimateTransaction_6) - assert.fail(message.fail_estimateTransaction_6); - } catch (e) { - if (e.message === constant.invalid_apiKey) { - addContext(test, message.vali_estimateTransaction_5) - console.log(message.vali_estimateTransaction_5); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_estimateTransaction_6); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.nativeTransaction_insufficientBalance); - } - }); - - xit('REGRESSION: Perform the transfer token on arka pimlico paymaster with invalid paymaster URL on the goerli network', async function () { - var test = this; - const invalid_arka_url = data.invalid_paymaster_arka; - let queryString = `?apiKey=${process.env.API_KEY}&chainId=${Number( - data.goerli_chainid, - )}`; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - let returnedValue; - let paymasterAddress; - - try { - returnedValue = await fetch( - `${invalid_arka_url}/pimlicoAddress${queryString}`, // invalid paymaster URL - { - method: 'POST', - headers: { - Accept: 'application/json', - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ - params: [data.entryPointAddress, { token: data.usdc_token }], - }), - }, - ).then((res) => { - return res.json(); - }); - - paymasterAddress = returnedValue.message; - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_pimlico_paymasterAddress_1); - } - - if (paymasterAddress.includes(constant.not_found)) { - addContext(test, message.vali_pimlico_paymasterAddress_2) - console.log(message.vali_pimlico_paymasterAddress_2); - } else { - addContext(test, message.fail_pimlico_paymasterAddress_2); - assert.fail(message.fail_pimlico_paymasterAddress_2); - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.pimlocoPaymaster_insufficientBalance); - } - }); - - xit('REGRESSION: Perform the transfer token on arka pimlico paymaster with invalid API Key in queryString on the goerli network', async function () { - var test = this; - let arka_url = data.paymaster_arka; - let queryString = `?apiKey=${process.env.INVALID_API_KEY}&chainId=${Number( - data.goerli_chainid, - )}`; // invalid API Key in queryString - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - let returnedValue; - - try { - returnedValue = await fetch( - `${arka_url}/pimlicoAddress${queryString}`, - { - method: 'POST', - headers: { - Accept: 'application/json', - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ - params: [data.entryPointAddress, { token: data.usdc_token }], - }), - }, - ).then((res) => { - return res.json(); - }); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_pimlico_paymasterAddress_1); - } - - if (returnedValue.error === constant.invalid_apiKey) { - addContext(test, message.vali_pimlico_paymasterAddress_3) - console.log(message.vali_pimlico_paymasterAddress_3); - } else { - addContext(test, message.fail_pimlico_paymasterAddress_3); - assert.fail(message.fail_pimlico_paymasterAddress_3); - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.pimlocoPaymaster_insufficientBalance); - } - }); - - xit('REGRESSION: Perform the transfer token on arka pimlico paymaster without API Key in queryString on the goerli network', async function () { - var test = this; - let arka_url = data.paymaster_arka; - let queryString = `?chainId=${Number(data.goerli_chainid)}`; // without API Key in queryString - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - let returnedValue; - - try { - returnedValue = await fetch( - `${arka_url}/pimlicoAddress${queryString}`, - { - method: 'POST', - headers: { - Accept: 'application/json', - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ - params: [data.entryPointAddress, { token: data.usdc_token }], - }), - }, - ).then((res) => { - return res.json(); - }); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_pimlico_paymasterAddress_1); - } - - if (returnedValue.error === constant.invalid_apiKey) { - addContext(test, message.vali_pimlico_paymasterAddress_4) - console.log(message.vali_pimlico_paymasterAddress_4); - } else { - addContext(test, message.fail_pimlico_paymasterAddress_4); - assert.fail(message.fail_pimlico_paymasterAddress_4); - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.pimlocoPaymaster_insufficientBalance); - } - }); - - xit('REGRESSION: Perform the transfer token on arka pimlico paymaster with invalid ChainID in queryString on the goerli network', async function () { - var test = this; - let arka_url = data.paymaster_arka; - let queryString = `?apiKey=${process.env.API_KEY}&chainId=${Number( - data.invalid_goerli_chainid, - )}`; // invalid chainid in queryString - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - let returnedValue; - - try { - returnedValue = await fetch( - `${arka_url}/pimlicoAddress${queryString}`, - { - method: 'POST', - headers: { - Accept: 'application/json', - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ - params: [data.entryPointAddress, { token: data.usdc_token }], - }), - }, - ).then((res) => { - return res.json(); - }); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_pimlico_paymasterAddress_1); - } - - if (returnedValue.error === constant.invalid_network_3) { - addContext(test, message.vali_pimlico_paymasterAddress_5) - console.log(message.vali_pimlico_paymasterAddress_5); - } else { - addContext(test, message.fail_pimlico_paymasterAddress_5); - assert.fail(message.fail_pimlico_paymasterAddress_5); - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.pimlocoPaymaster_insufficientBalance); - } - }); - - xit('REGRESSION: Perform the transfer token on arka pimlico paymaster without ChainID in queryString on the goerli network', async function () { - var test = this; - let arka_url = data.paymaster_arka; - let queryString = `?apiKey=${process.env.API_KEY}`; // without ChainID - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - let returnedValue; - try { - returnedValue = await fetch( - `${arka_url}/pimlicoAddress${queryString}`, - { - // without chainid in queryString - method: 'POST', - headers: { - Accept: 'application/json', - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ - params: [data.entryPointAddress, { token: data.usdc_token }], - }), - }, - ).then((res) => { - return res.json(); - }); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_pimlico_paymasterAddress_1); - } - - if (returnedValue.error === constant.invalid_data) { - addContext(test, message.vali_pimlico_paymasterAddress_6) - console.log(message.vali_pimlico_paymasterAddress_6); - } else { - addContext(test, message.fail_pimlico_paymasterAddress_6); - assert.fail(message.fail_pimlico_paymasterAddress_6); - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.pimlocoPaymaster_insufficientBalance); - } - }); - - xit('REGRESSION: Perform the transfer token on arka pimlico paymaster with invalid Entry Point Address while fetching the paymaster address on the goerli network', async function () { - var test = this; - let arka_url = data.paymaster_arka; - let queryString = `?apiKey=${process.env.API_KEY}&chainId=${Number( - data.goerli_chainid, - )}`; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - let returnedValue; - - try { - returnedValue = await fetch( - `${arka_url}/pimlicoAddress${queryString}`, - { - method: 'POST', - headers: { - Accept: 'application/json', - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ - params: [ - data.invalidEntryPointAddress, // invalid entry point address - { token: data.usdc_token }, - ], - }), - }, - ).then((res) => { - return res.json(); - }); - } catch (e) { - const errorMessage = returnedValue.error; - if (errorMessage.includes(constant.invalid_address_4)) { - addContext(test, message.vali_pimlico_paymasterAddress_7) - console.log(message.vali_pimlico_paymasterAddress_7); - } else { - addContext(test, message.fail_pimlico_paymasterAddress_7); - assert.fail(message.fail_pimlico_paymasterAddress_7); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.pimlocoPaymaster_insufficientBalance); - } - }); - - xit('REGRESSION: Perform the transfer token on arka pimlico paymaster with invalid token while fetching the paymaster address on the goerli network', async function () { - var test = this; - let arka_url = data.paymaster_arka; - let queryString = `?apiKey=${process.env.API_KEY}&chainId=${Number( - data.goerli_chainid, - )}`; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - let returnedValue; - - try { - returnedValue = await fetch( - `${arka_url}/pimlicoAddress${queryString}`, - { - method: 'POST', - headers: { - Accept: 'application/json', - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ - params: [ - data.entryPointAddress, - { token: data.invalid_usdc_token }, // invalid token - ], - }), - }, - ).then((res) => { - return res.json(); - }); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_pimlico_paymasterAddress_1); - } - - if (returnedValue.error === constant.invalid_network_1) { - addContext(test, message.vali_pimlico_paymasterAddress_8) - console.log(message.vali_pimlico_paymasterAddress_8); - } else { - addContext(test, message.fail_pimlico_paymasterAddress_8); - assert.fail(message.fail_pimlico_paymasterAddress_8); - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.pimlocoPaymaster_insufficientBalance); - } - }); - - xit('REGRESSION: Perform the transfer token on arka pimlico paymaster without parameters while fetching the paymaster address on the goerli network', async function () { - var test = this; - let arka_url = data.paymaster_arka; - let queryString = `?apiKey=${process.env.API_KEY}&chainId=${Number( - data.goerli_chainid, - )}`; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - let returnedValue; - - try { - returnedValue = await fetch( - `${arka_url}/pimlicoAddress${queryString}`, - { - method: 'POST', - headers: { - Accept: 'application/json', - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ - params: [], // without parametets - }), - }, - ).then((res) => { - return res.json(); - }); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_pimlico_paymasterAddress_1); - } - - if (returnedValue.error === constant.invalid_data) { - addContext(test, message.vali_pimlico_paymasterAddress_9) - console.log(message.vali_pimlico_paymasterAddress_9); - } else { - addContext(test, message.fail_pimlico_paymasterAddress_9); - assert.fail(message.fail_pimlico_paymasterAddress_9); - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.pimlocoPaymaster_insufficientBalance); - } - }); - - xit('REGRESSION: Perform the transfer token on arka pimlico paymaster with incorrect token address of the erc20 contract on the goerli network', async function () { - var test = this; - let arka_url = data.paymaster_arka; - let queryString = `?apiKey=${process.env.API_KEY}&chainId=${Number( - data.goerli_chainid, - )}`; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - let returnedValue; - let paymasterAddress; - - try { - returnedValue = await fetch( - `${arka_url}/pimlicoAddress${queryString}`, - { - method: 'POST', - headers: { - Accept: 'application/json', - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ - params: [data.entryPointAddress, { token: data.usdc_token }], - }), - }, - ).then((res) => { - return res.json(); - }); - - paymasterAddress = returnedValue.message; - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_pimlico_paymasterAddress_1); - } - - if (utils.isAddress(paymasterAddress)) { - // get the erc20 Contract - try { - erc20Contract = new ethers.Contract( - data.incorrectTokenAddress_goerliUSDC, // incorrect token address - ERC20_ABI, - ); - encodedData = erc20Contract.interface.encodeFunctionData( - 'approve', - [paymasterAddress, ethers.constants.MaxUint256], - ); - await goerliTestNetSdk.addUserOpsToBatch({ - to: data.tokenAddress_goerliUSDC, - data: encodedData, - }); - } catch (e) { - let errorMessage = e.message; - if (errorMessage.includes(constant.contract_address_1)) { - addContext(test, message.vali_erc20Contract_1) - console.log(message.vali_erc20Contract_1); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Contract_3); - } - } - } else { - addContext(test, message.fail_erc20Contract_2); - assert.fail(message.fail_erc20Contract_2); - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.pimlocoPaymaster_insufficientBalance); - } - }); - - xit('REGRESSION: Perform the transfer token on arka pimlico paymaster with invalid token address of the erc20 contract on the goerli network', async function () { - var test = this; - let arka_url = data.paymaster_arka; - let queryString = `?apiKey=${process.env.API_KEY}&chainId=${Number( - data.goerli_chainid, - )}`; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - let returnedValue; - let paymasterAddress; - - try { - returnedValue = await fetch( - `${arka_url}/pimlicoAddress${queryString}`, - { - method: 'POST', - headers: { - Accept: 'application/json', - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ - params: [data.entryPointAddress, { token: data.usdc_token }], - }), - }, - ).then((res) => { - return res.json(); - }); - - paymasterAddress = returnedValue.message; - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_pimlico_paymasterAddress_1); - } - - if (utils.isAddress(paymasterAddress)) { - // get the erc20 Contract - try { - erc20Contract = new ethers.Contract( - data.invalidTokenAddress_goerliUSDC, // invalid token address - ERC20_ABI, - ); - encodedData = erc20Contract.interface.encodeFunctionData( - 'approve', - [paymasterAddress, ethers.constants.MaxUint256], - ); - await goerliTestNetSdk.addUserOpsToBatch({ - to: data.tokenAddress_goerliUSDC, - data: encodedData, - }); - } catch (e) { - let errorMessage = e.message; - if (errorMessage.includes(constant.contract_address_1)) { - addContext(test, message.vali_erc20Contract_2) - console.log(message.vali_erc20Contract_2); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Contract_4); - } - } - } else { - addContext(test, message.fail_erc20Contract_2); - assert.fail(message.fail_erc20Contract_2); - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.pimlocoPaymaster_insufficientBalance); - } - }); - - xit('REGRESSION: Perform the transfer token on arka pimlico paymaster with invalid paymaster address of the erc20 contract on the goerli network', async function () { - var test = this; - let arka_url = data.paymaster_arka; - let queryString = `?apiKey=${process.env.API_KEY}&chainId=${Number( - data.goerli_chainid, - )}`; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - let returnedValue; - let paymasterAddress; - let erc20Contract; - - try { - returnedValue = await fetch( - `${arka_url}/pimlicoAddress${queryString}`, - { - method: 'POST', - headers: { - Accept: 'application/json', - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ - params: [data.entryPointAddress, { token: data.usdc_token }], - }), - }, - ).then((res) => { - return res.json(); - }); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_pimlico_paymasterAddress_1); - } - - paymasterAddress = returnedValue.message; - - if (utils.isAddress(paymasterAddress)) { - // get the erc20 Contract - try { - erc20Contract = new ethers.Contract( - data.tokenAddress_goerliUSDC, - ERC20_ABI, - ); - encodedData = erc20Contract.interface.encodeFunctionData( - 'approve', - [data.invalid_paymasterAddress, ethers.constants.MaxUint256], // invalid paymaster address - ); - await goerliTestNetSdk.addUserOpsToBatch({ - to: data.tokenAddress_goerliUSDC, - data: encodedData, - }); - } catch (e) { - let errorMessage = e.message; - if (errorMessage.includes(constant.invalid_address_4)) { - addContext(test, message.vali_erc20Contract_3) - console.log(message.vali_erc20Contract_3); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Contract_5); - } - } - } else { - addContext(test, message.fail_erc20Contract_2); - assert.fail(message.fail_erc20Contract_2); - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.pimlocoPaymaster_insufficientBalance); - } - }); - - xit('REGRESSION: Perform the transfer token on arka pimlico paymaster with incorrect paymaster address of the erc20 contract on the goerli network', async function () { - var test = this; - let arka_url = data.paymaster_arka; - let queryString = `?apiKey=${process.env.API_KEY}&chainId=${Number( - data.goerli_chainid, - )}`; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - let returnedValue; - let paymasterAddress; - let erc20Contract; - - try { - returnedValue = await fetch( - `${arka_url}/pimlicoAddress${queryString}`, - { - method: 'POST', - headers: { - Accept: 'application/json', - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ - params: [data.entryPointAddress, { token: data.usdc_token }], - }), - }, - ).then((res) => { - return res.json(); - }); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_pimlico_paymasterAddress_1); - } - - paymasterAddress = returnedValue.message; - - if (utils.isAddress(paymasterAddress)) { - // get the erc20 Contract - try { - erc20Contract = new ethers.Contract( - data.tokenAddress_goerliUSDC, - ERC20_ABI, - ); - encodedData = erc20Contract.interface.encodeFunctionData( - 'approve', - [data.incorrect_paymasterAddress, ethers.constants.MaxUint256], // incorrect paymaster address - ); - await goerliTestNetSdk.addUserOpsToBatch({ - to: data.tokenAddress_goerliUSDC, - data: encodedData, - }); - } catch (e) { - let errorMessage = e.message; - if (errorMessage.includes(constant.invalid_address_6)) { - addContext(test, message.vali_erc20Contract_4) - console.log(message.vali_erc20Contract_4); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Contract_6); - } - } - } else { - addContext(test, message.fail_erc20Contract_2); - assert.fail(message.fail_erc20Contract_2); - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.pimlocoPaymaster_insufficientBalance); - } - }); - - xit('REGRESSION: Perform the transfer token on arka pimlico paymaster with invalid value of the transactions on the goerli network', async function () { - var test = this; - let arka_url = data.paymaster_arka; - let queryString = `?apiKey=${process.env.API_KEY}&chainId=${Number( - data.goerli_chainid, - )}`; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - let returnedValue; - let paymasterAddress; - let erc20Contract; - let encodedData; - let approveOp; - - try { - returnedValue = await fetch( - `${arka_url}/pimlicoAddress${queryString}`, - { - method: 'POST', - headers: { - Accept: 'application/json', - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ - params: [data.entryPointAddress, { token: data.usdc_token }], - }), - }, - ).then((res) => { - return res.json(); - }); - - paymasterAddress = returnedValue.message; - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_pimlico_paymasterAddress_1); - } - - if (utils.isAddress(paymasterAddress)) { - // get the erc20 Contract - try { - erc20Contract = new ethers.Contract( - data.tokenAddress_goerliUSDC, - ERC20_ABI, - ); - encodedData = erc20Contract.interface.encodeFunctionData( - 'approve', - [paymasterAddress, ethers.constants.MaxUint256], - ); - await goerliTestNetSdk.addUserOpsToBatch({ - to: data.tokenAddress_goerliUSDC, - data: encodedData, - }); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Contract_1); - } - - // get the UserOp Hash - try { - approveOp = await goerliTestNetSdk.estimate(); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_estimateTransaction_1); - } - - // get the uoHash1 - try { - await goerliTestNetSdk.send(approveOp); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_submitTransaction_1); - } - - // 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.invalidValue), - }); - - addContext(test, message.fail_addTransaction_2) - assert.fail(message.fail_addTransaction_2); - } catch (e) { - let errorMessage = e.message; - if (errorMessage.includes(constant.invalid_value_1)) { - addContext(test, vali_addTransaction_1) - console.log(vali_addTransaction_1); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_addTransaction_3); - } - } - } else { - addContext(test, message.fail_erc20Contract_2); - assert.fail(message.fail_erc20Contract_2); - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.pimlocoPaymaster_insufficientBalance); - } - }); - - xit('REGRESSION: Perform the transfer token on arka pimlico paymaster with invalid paymaster URL while estimate the transactions on the goerli network', async function () { - var test = this; - let arka_url = data.paymaster_arka; - let invalid_arka_url = data.invalid_paymaster_arka; - let queryString = `?apiKey=${process.env.API_KEY}&chainId=${Number( - data.goerli_chainid, - )}`; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - let returnedValue; - let paymasterAddress; - let erc20Contract; - let encodedData; - let approveOp; - - try { - returnedValue = await fetch( - `${arka_url}/pimlicoAddress${queryString}`, - { - method: 'POST', - headers: { - Accept: 'application/json', - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ - params: [data.entryPointAddress, { token: data.usdc_token }], - }), - }, - ).then((res) => { - return res.json(); - }); - - paymasterAddress = returnedValue.message; - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_pimlico_paymasterAddress_1); - } - - if (utils.isAddress(paymasterAddress)) { - // get the erc20 Contract - try { - erc20Contract = new ethers.Contract( - data.tokenAddress_goerliUSDC, - ERC20_ABI, - ); - encodedData = erc20Contract.interface.encodeFunctionData( - 'approve', - [paymasterAddress, ethers.constants.MaxUint256], - ); - await goerliTestNetSdk.addUserOpsToBatch({ - to: data.tokenAddress_goerliUSDC, - data: encodedData, - }); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Contract_1); - } - - // get the UserOp Hash - try { - approveOp = await goerliTestNetSdk.estimate(); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_estimateTransaction_1); - } - - // get the uoHash1 - try { - await goerliTestNetSdk.send(approveOp); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_submitTransaction_1); - } - - // 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_pimlico_paymasterAddress_1); - } - - // estimate transactions added to the batch and get the fee data for the UserOp - try { - await goerliTestNetSdk.estimate({ - paymasterDetails: { - url: `${invalid_arka_url}${queryString}`, - context: { token: data.usdc_token, mode: 'erc20' }, - } - }); - - addContext(test, message.fail_estimateTransaction_2) - assert.fail(message.fail_estimateTransaction_2); - } catch (e) { - let errorMessage = e.message; - if (errorMessage.includes(constant.not_found)) { - addContext(test, message.vali_estimateTransaction_1) - console.log(message.vali_estimateTransaction_1); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_estimateTransaction_2); - } - } - } else { - addContext(test, message.fail_erc20Contract_2); - assert.fail(message.fail_erc20Contract_2); - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.pimlocoPaymaster_insufficientBalance); - } - }); - - xit('REGRESSION: Perform the transfer token on arka pimlico paymaster with invalid Api Key while estimate the transactions on the goerli network', async function () { - var test = this; - let arka_url = data.paymaster_arka; - let queryString = `?apiKey=${process.env.API_KEY}&chainId=${Number( - data.goerli_chainid, - )}`; - let invalid_queryString = `?apiKey=${process.env.INVALID_API_KEY - }&chainId=${Number(data.goerli_chainid)}`; // invalid API Key in queryString - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - let returnedValue; - let paymasterAddress; - let erc20Contract; - let encodedData; - let approveOp; - - try { - returnedValue = await fetch( - `${arka_url}/pimlicoAddress${queryString}`, - { - method: 'POST', - headers: { - Accept: 'application/json', - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ - params: [data.entryPointAddress, { token: data.usdc_token }], - }), - }, - ).then((res) => { - return res.json(); - }); - - paymasterAddress = returnedValue.message; - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_pimlico_paymasterAddress_1); - } - - if (utils.isAddress(paymasterAddress)) { - // get the erc20 Contract - try { - erc20Contract = new ethers.Contract( - data.tokenAddress_goerliUSDC, - ERC20_ABI, - ); - encodedData = erc20Contract.interface.encodeFunctionData( - 'approve', - [paymasterAddress, ethers.constants.MaxUint256], - ); - await goerliTestNetSdk.addUserOpsToBatch({ - to: data.tokenAddress_goerliUSDC, - data: encodedData, - }); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Contract_1); - } - - // get the UserOp Hash - try { - approveOp = await goerliTestNetSdk.estimate(); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_estimateTransaction_1); - } - - // get the uoHash1 - try { - await goerliTestNetSdk.send(approveOp); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_submitTransaction_1); - } - - // 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_pimlico_paymasterAddress_1); - } - - // estimate transactions added to the batch and get the fee data for the UserOp - try { - await goerliTestNetSdk.estimate({ - paymasterDetails: { - url: `${arka_url}${invalid_queryString}`, - context: { token: data.usdc_token, mode: 'erc20' }, - } - }); - - addContext(test, message.fail_estimateTransaction_4) - assert.fail(message.fail_estimateTransaction_4); - } catch (e) { - let errorMessage = e.message; - if (errorMessage.includes(constant.invalid_apiKey)) { - addContext(test, message.vali_estimateTransaction_3) - console.log(message.vali_estimateTransaction_3); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_estimateTransaction_4); - } - } - } else { - addContext(test, message.fail_erc20Contract_2); - assert.fail(message.fail_erc20Contract_2); - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.pimlocoPaymaster_insufficientBalance); - } - }); - - xit('REGRESSION: Perform the transfer token on arka pimlico paymaster without Api Key while estimate the transactions on the goerli network', async function () { - var test = this; - let arka_url = data.paymaster_arka; - let queryString = `?apiKey=${process.env.API_KEY}&chainId=${Number( - data.goerli_chainid, - )}`; - let invalid_queryString = `?chainId=${Number(data.goerli_chainid)}`; // without API Key in queryString - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - let returnedValue; - let paymasterAddress; - let erc20Contract; - let encodedData; - let approveOp; - - try { - returnedValue = await fetch( - `${arka_url}/pimlicoAddress${queryString}`, - { - method: 'POST', - headers: { - Accept: 'application/json', - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ - params: [data.entryPointAddress, { token: data.usdc_token }], - }), - }, - ).then((res) => { - return res.json(); - }); - - paymasterAddress = returnedValue.message; - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_pimlico_paymasterAddress_1); - } - - if (utils.isAddress(paymasterAddress)) { - // get the erc20 Contract - try { - erc20Contract = new ethers.Contract( - data.tokenAddress_goerliUSDC, - ERC20_ABI, - ); - encodedData = erc20Contract.interface.encodeFunctionData( - 'approve', - [paymasterAddress, ethers.constants.MaxUint256], - ); - await goerliTestNetSdk.addUserOpsToBatch({ - to: data.tokenAddress_goerliUSDC, - data: encodedData, - }); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Contract_1); - } - - // get the UserOp Hash - try { - approveOp = await goerliTestNetSdk.estimate(); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_estimateTransaction_1); - } - - // get the uoHash1 - try { - await goerliTestNetSdk.send(approveOp); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_submitTransaction_1); - } - - // 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_pimlico_paymasterAddress_1); - } - - // estimate transactions added to the batch and get the fee data for the UserOp - try { - await goerliTestNetSdk.estimate({ - paymasterDetails: { - url: `${arka_url}${invalid_queryString}`, - context: { token: data.usdc_token, mode: 'erc20' }, - } - }); - - addContext(test, message.fail_estimateTransaction_6) - assert.fail(message.fail_estimateTransaction_6); - } catch (e) { - let errorMessage = e.message; - if (errorMessage.includes(constant.invalid_apiKey)) { - addContext(test, message.vali_estimateTransaction_5) - console.log(message.vali_estimateTransaction_5); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_estimateTransaction_6); - } - } - } else { - addContext(test, message.fail_erc20Contract_2); - assert.fail(message.fail_erc20Contract_2); - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.pimlocoPaymaster_insufficientBalance); - } - }); - - xit('REGRESSION: Perform the transfer token on arka pimlico paymaster with invalid chainid while estimate the transactions on the goerli network', async function () { - var test = this; - let arka_url = data.paymaster_arka; - let queryString = `?apiKey=${process.env.API_KEY}&chainId=${Number( - data.goerli_chainid, - )}`; - let invalid_queryString = `?apiKey=${process.env.API_KEY}&chainId=${Number( - data.invalid_goerli_chainid, - )}`; // invalid chainid in queryString - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - let returnedValue; - let paymasterAddress; - let erc20Contract; - let encodedData; - let approveOp; - - try { - returnedValue = await fetch( - `${arka_url}/pimlicoAddress${queryString}`, - { - method: 'POST', - headers: { - Accept: 'application/json', - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ - params: [data.entryPointAddress, { token: data.usdc_token }], - }), - }, - ).then((res) => { - return res.json(); - }); - - paymasterAddress = returnedValue.message; - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_pimlico_paymasterAddress_1); - } - - if (utils.isAddress(paymasterAddress)) { - // get the erc20 Contract - try { - erc20Contract = new ethers.Contract( - data.tokenAddress_goerliUSDC, - ERC20_ABI, - ); - encodedData = erc20Contract.interface.encodeFunctionData( - 'approve', - [paymasterAddress, ethers.constants.MaxUint256], - ); - await goerliTestNetSdk.addUserOpsToBatch({ - to: data.tokenAddress_goerliUSDC, - data: encodedData, - }); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Contract_1); - } - - // get the UserOp Hash - try { - approveOp = await goerliTestNetSdk.estimate(); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_estimateTransaction_1); - } - - // get the uoHash1 - try { - await goerliTestNetSdk.send(approveOp); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_submitTransaction_1); - } - - // 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_pimlico_paymasterAddress_1); - } - - // estimate transactions added to the batch and get the fee data for the UserOp - try { - await goerliTestNetSdk.estimate({ - paymasterDetails: { - url: `${arka_url}${invalid_queryString}`, - context: { token: data.usdc_token, mode: 'erc20' }, - } - }); - - addContext(test, message.fail_estimateTransaction_7) - assert.fail(message.fail_estimateTransaction_7); - } catch (e) { - let errorMessage = e.message; - if (errorMessage.includes(constant.invalid_network_3)) { - addContext(test, message.vali_estimateTransaction_6) - console.log(message.vali_estimateTransaction_6); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_estimateTransaction_7); - } - } - } else { - addContext(test, message.fail_erc20Contract_2); - assert.fail(message.fail_erc20Contract_2); - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.pimlocoPaymaster_insufficientBalance); - } - }); - - xit('REGRESSION: Perform the transfer token on arka pimlico paymaster without chainid while estimate the transactions on the goerli network', async function () { - var test = this; - let arka_url = data.paymaster_arka; - let queryString = `?apiKey=${process.env.API_KEY}&chainId=${Number( - data.goerli_chainid, - )}`; - let invalid_queryString = `?apiKey=${process.env.API_KEY}`; // without ChainID - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - let returnedValue; - let paymasterAddress; - let erc20Contract; - let encodedData; - let approveOp; - - try { - returnedValue = await fetch( - `${arka_url}/pimlicoAddress${queryString}`, - { - method: 'POST', - headers: { - Accept: 'application/json', - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ - params: [data.entryPointAddress, { token: data.usdc_token }], - }), - }, - ).then((res) => { - return res.json(); - }); - - paymasterAddress = returnedValue.message; - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_pimlico_paymasterAddress_1); - } - - if (utils.isAddress(paymasterAddress)) { - // get the erc20 Contract - try { - erc20Contract = new ethers.Contract( - data.tokenAddress_goerliUSDC, - ERC20_ABI, - ); - encodedData = erc20Contract.interface.encodeFunctionData( - 'approve', - [paymasterAddress, ethers.constants.MaxUint256], - ); - await goerliTestNetSdk.addUserOpsToBatch({ - to: data.tokenAddress_goerliUSDC, - data: encodedData, - }); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Contract_1); - } - - // get the UserOp Hash - try { - approveOp = await goerliTestNetSdk.estimate(); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_estimateTransaction_1); - } - - // get the uoHash1 - try { - await goerliTestNetSdk.send(approveOp); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_submitTransaction_1); - } - - // 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_pimlico_paymasterAddress_1); - } - - // estimate transactions added to the batch and get the fee data for the UserOp - try { - await goerliTestNetSdk.estimate({ - paymasterDetails: { - url: `${arka_url}${invalid_queryString}`, - context: { token: data.usdc_token, mode: 'erc20' }, - } - }); - - addContext(test, message.fail_estimateTransaction_8) - assert.fail(message.fail_estimateTransaction_8); - } catch (e) { - let errorMessage = e.message; - if (errorMessage.includes(constant.invalid_data)) { - addContext(test, message.vali_estimateTransaction_7) - console.log(message.vali_estimateTransaction_7); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_estimateTransaction_8); - } - } - } else { - addContext(test, message.fail_erc20Contract_2); - assert.fail(message.fail_erc20Contract_2); - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.pimlocoPaymaster_insufficientBalance); - } - }); - - it('REGRESSION: Perform the transfer token on arka paymaster with validUntil and validAfter with invalid paymaster URL on the goerli network', async function () { - var test = this; - let invalid_arka_url = data.invalid_paymaster_arka; - let queryString = `?apiKey=${process.env.API_KEY}&chainId=${Number( - data.goerli_chainid, - )}`; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - // 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); - } - - // 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_pimlico_paymasterAddress_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_pimlico_paymasterAddress_1); - } - - /* estimate transactions added to the batch and get the fee data for the UserOp - validUntil and validAfter are optional defaults to 10 mins of expiry from send call and should be passed in terms of milliseconds - For example purpose, the valid is fixed as expiring in 100 mins once the paymaster data is generated - validUntil and validAfter is relevant only with sponsor transactions and not for token paymasters - */ - - // estimate transactions added to the batch and get the fee data for the UserOp - try { - await goerliTestNetSdk.estimate({ - paymasterDetails: { - url: `${invalid_arka_url}${queryString}`, - context: { - mode: 'sponsor', - validAfter: new Date().valueOf(), - validUntil: new Date().valueOf() + 6000000, - }, - } - }); - - addContext(test, message.fail_estimateTransaction_2) - assert.fail(message.fail_estimateTransaction_2); - } catch (e) { - let errorMessage = e.message; - if (errorMessage.includes(constant.not_found)) { - addContext(test, message.vali_estimateTransaction_1) - console.log(message.vali_estimateTransaction_1); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_estimateTransaction_2); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.pimlocoPaymaster_insufficientBalance); - } - }); - - it('REGRESSION: Perform the transfer token on arka paymaster with validUntil and validAfter with invalid API Token on the goerli network', async function () { - var test = this; - let arka_url = data.paymaster_arka; - let invalid_queryString = `?apiKey=${process.env.INVALID_API_KEY - }&chainId=${Number(data.goerli_chainid)}`; // invalid API Key in queryString - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - // 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); - } - - // 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_pimlico_paymasterAddress_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_pimlico_paymasterAddress_1); - } - - /* estimate transactions added to the batch and get the fee data for the UserOp - validUntil and validAfter are optional defaults to 10 mins of expiry from send call and should be passed in terms of milliseconds - For example purpose, the valid is fixed as expiring in 100 mins once the paymaster data is generated - validUntil and validAfter is relevant only with sponsor transactions and not for token paymasters - */ - - // estimate transactions added to the batch and get the fee data for the UserOp - try { - await goerliTestNetSdk.estimate({ - paymasterDetails: { - url: `${arka_url}${invalid_queryString}`, - context: { - mode: 'sponsor', - validAfter: new Date().valueOf(), - validUntil: new Date().valueOf() + 6000000, - }, - } - }); - - addContext(test, message.fail_estimateTransaction_4) - assert.fail(message.fail_estimateTransaction_4); - } catch (e) { - if (e.message === constant.invalid_apiKey) { - addContext(test, message.vali_estimateTransaction_3) - console.log(message.vali_estimateTransaction_3); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_estimateTransaction_4); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.pimlocoPaymaster_insufficientBalance); - } - }); - - it('REGRESSION: Perform the transfer token on arka paymaster with validUntil and validAfter without API Token on the goerli network', async function () { - var test = this; - let arka_url = data.paymaster_arka; - let invalid_queryString = `?chainId=${Number(data.goerli_chainid)}`; // without API Key in queryString - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - // 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); - } - - // 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_pimlico_paymasterAddress_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_pimlico_paymasterAddress_1); - } - - /* estimate transactions added to the batch and get the fee data for the UserOp - validUntil and validAfter are optional defaults to 10 mins of expiry from send call and should be passed in terms of milliseconds - For example purpose, the valid is fixed as expiring in 100 mins once the paymaster data is generated - validUntil and validAfter is relevant only with sponsor transactions and not for token paymasters - */ - - // estimate transactions added to the batch and get the fee data for the UserOp - try { - await goerliTestNetSdk.estimate({ - paymasterDetails: { - url: `${arka_url}${invalid_queryString}`, - context: { - mode: 'sponsor', - validAfter: new Date().valueOf(), - validUntil: new Date().valueOf() + 6000000, - }, - } - }); - - addContext(test, message.fail_estimateTransaction_6) - assert.fail(message.fail_estimateTransaction_6); - } catch (e) { - if (e.message === constant.invalid_apiKey) { - addContext(test, message.vali_estimateTransaction_3) - console.log(message.vali_estimateTransaction_3); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_estimateTransaction_4); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.pimlocoPaymaster_insufficientBalance); - } - }); - - it('REGRESSION: Perform the transfer token on arka paymaster with validUntil and validAfter with invalid ChainID on the goerli network', async function () { - var test = this; - let arka_url = data.paymaster_arka; - let invalid_queryString = `?apiKey=${process.env.API_KEY}&chainId=${Number( - data.invalid_goerli_chainid, - )}`; // invalid ChainID in queryString - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - // 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); - } - - // 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_pimlico_paymasterAddress_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_pimlico_paymasterAddress_1); - } - - /* estimate transactions added to the batch and get the fee data for the UserOp - validUntil and validAfter are optional defaults to 10 mins of expiry from send call and should be passed in terms of milliseconds - For example purpose, the valid is fixed as expiring in 100 mins once the paymaster data is generated - validUntil and validAfter is relevant only with sponsor transactions and not for token paymasters - */ - - // estimate transactions added to the batch and get the fee data for the UserOp - try { - await goerliTestNetSdk.estimate({ - paymasterDetails: { - url: `${arka_url}${invalid_queryString}`, - context: { - mode: 'sponsor', - validAfter: new Date().valueOf(), - validUntil: new Date().valueOf() + 6000000, - }, - } - }); - - addContext(test, message.fail_estimateTransaction_7) - assert.fail(message.fail_estimateTransaction_7); - } catch (e) { - let errorMessage = e.message; - if (errorMessage.includes(constant.invalid_network_3)) { - addContext(test, message.vali_estimateTransaction_6) - console.log(message.vali_estimateTransaction_6); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_estimateTransaction_7); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.pimlocoPaymaster_insufficientBalance); - } - }); - - it('REGRESSION: Perform the transfer token on arka paymaster with validUntil and validAfter without ChainID on the goerli network', async function () { - var test = this; - let arka_url = data.paymaster_arka; - let invalid_queryString = `?apiKey=${process.env.API_KEY}`; // without ChainID in queryString - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - // 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); - } - - // 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_pimlico_paymasterAddress_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_pimlico_paymasterAddress_1); - } - - /* estimate transactions added to the batch and get the fee data for the UserOp - validUntil and validAfter are optional defaults to 10 mins of expiry from send call and should be passed in terms of milliseconds - For example purpose, the valid is fixed as expiring in 100 mins once the paymaster data is generated - validUntil and validAfter is relevant only with sponsor transactions and not for token paymasters - */ - - // estimate transactions added to the batch and get the fee data for the UserOp - try { - await goerliTestNetSdk.estimate({ - paymasterDetails: { - url: `${arka_url}${invalid_queryString}`, - context: { - mode: 'sponsor', - validAfter: new Date().valueOf(), - validUntil: new Date().valueOf() + 6000000, - }, - } - }); - - addContext(test, message.fail_estimateTransaction_8) - assert.fail(message.fail_estimateTransaction_8); - } catch (e) { - let errorMessage = e.message; - if (errorMessage.includes(constant.invalid_data)) { - addContext(test, message.vali_estimateTransaction_7) - console.log(message.vali_estimateTransaction_7); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_estimateTransaction_8); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.pimlocoPaymaster_insufficientBalance); - } - }); - - it('REGRESSION: Validate the get token paymaster address function of the arka paymaster with incorrect token on the goerli network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - - // validate the get token paymaster address - try { - await arkaPaymaster.getTokenPaymasterAddress(data.invalid_usdc_token); - - addContext(test, message.fail_getTokenPaymasterAddress_2) - assert.fail(message.fail_getTokenPaymasterAddress_2) - } catch (e) { - let errorMessage = e.message; - if (errorMessage.includes(constant.invalid_network_1)) { - addContext(test, message.vali_getTokenPaymasterAddress_1); - console.log(message.vali_getTokenPaymasterAddress_1); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_getTokenPaymasterAddress_2); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.arkaFunction_insufficientBalance); - } - }); - - it('REGRESSION: Validate the get token paymaster address function of the arka paymaster without token on the goerli network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - - // validate the get token paymaster address - try { - await arkaPaymaster.getTokenPaymasterAddress(); - - addContext(test, message.fail_getTokenPaymasterAddress_3) - assert.fail(message.fail_getTokenPaymasterAddress_3) - } catch (e) { - let errorMessage = e.message; - if (errorMessage.includes(constant.invalid_data)) { - addContext(test, message.vali_getTokenPaymasterAddress_2); - console.log(message.vali_getTokenPaymasterAddress_2); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_getTokenPaymasterAddress_3); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.arkaFunction_insufficientBalance); - } - }); - - it('REGRESSION: Validate the remove whitelist address function of the arka paymaster with invalid address on the goerli network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - - // validate the remove whitelist address - try { - await arkaPaymaster.removeWhitelist([data.invalidSender]); - - addContext(test, message.fail_removeWhitelist_3) - assert.fail(message.fail_removeWhitelist_3); - } catch (e) { - let errorMessage = e.message; - if (errorMessage.includes(constant.invalid_address_5)) { - addContext(test, message.vali_removeWhitelist_3); - console.log(message.vali_removeWhitelist_3); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_removeWhitelist_3); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.arkaFunction_insufficientBalance); - } - }); - - it('REGRESSION: Validate the remove whitelist address function of the arka paymaster with incorrect address on the goerli network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - - // validate the remove whitelist address - try { - await arkaPaymaster.removeWhitelist([data.incorrectSender]); - - addContext(test, message.fail_removeWhitelist_4) - assert.fail(message.fail_removeWhitelist_4); - } catch (e) { - let errorMessage = e.message; - if (errorMessage.includes(constant.invalid_address_5)) { - addContext(test, message.vali_removeWhitelist_4); - console.log(message.vali_removeWhitelist_4); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_removeWhitelist_4); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.arkaFunction_insufficientBalance); - } - }); - - it('REGRESSION: Validate the remove whitelist address function of the arka paymaster with random address on the goerli network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - - // validate the remove whitelist address - try { - const randomAddress = ethers.Wallet.createRandom(); - await arkaPaymaster.removeWhitelist([randomAddress.address]); - - addContext(test, message.fail_removeWhitelist_5) - assert.fail(message.fail_removeWhitelist_5); - } catch (e) { - let errorMessage = e.message; - if (errorMessage.includes(constant.remove_whitelist_1)) { - addContext(test, message.vali_removeWhitelist_2); - console.log(message.vali_removeWhitelist_2); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_removeWhitelist_2); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.arkaFunction_insufficientBalance); - } - }); - - it('REGRESSION: Validate the remove whitelist address function of the arka paymaster with random and whitelisted addresses on the goerli network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - - // validate the remove whitelist address - try { - const randomAddress = ethers.Wallet.createRandom(); - await arkaPaymaster.removeWhitelist([randomAddress.address, data.sender]); - - addContext(test, message.fail_removeWhitelist_5) - assert.fail(message.fail_removeWhitelist_5); - } catch (e) { - let errorMessage = e.message; - if (errorMessage.includes(constant.remove_whitelist_1)) { - addContext(test, message.vali_removeWhitelist_2); - console.log(message.vali_removeWhitelist_2); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_removeWhitelist_2); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.arkaFunction_insufficientBalance); - } - }); - - it('REGRESSION: Validate the remove whitelist address function of the arka paymaster with multiple whitelisted addresses on the goerli network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - - // validate the remove whitelist address - try { - const randomAddress1 = ethers.Wallet.createRandom(); - const randomAddress2 = ethers.Wallet.createRandom(); - - // make whitelisted addresses - await arkaPaymaster.addWhitelist([randomAddress1.address, randomAddress2.address]); - - // remove whitelist addresses - let removewhitelist = await arkaPaymaster.removeWhitelist([randomAddress1.address, randomAddress2.address]); - - if (removewhitelist.includes(constant.remove_whitelist_2)) { - addContext(test, message.vali_removeWhitelist_1); - console.log(message.vali_removeWhitelist_1); - } else { - addContext(test, message.fail_removeWhitelist_1); - assert.fail(message.fail_removeWhitelist_1); - } - } catch (e) { - let errorMessage = e.message; - if (errorMessage.includes(constant.remove_whitelist_1)) { - addContext(test, message.vali_removeWhitelist_2); - console.log(message.vali_removeWhitelist_2); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_removeWhitelist_2); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.arkaFunction_insufficientBalance); - } - }); - - it('REGRESSION: Validate the remove whitelist address function of the arka paymaster with multiple random addresses on the goerli network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - - // validate the remove whitelist address - try { - const randomAddress1 = ethers.Wallet.createRandom(); - const randomAddress2 = ethers.Wallet.createRandom(); - await arkaPaymaster.removeWhitelist([randomAddress1.address, randomAddress2.address]); - - addContext(test, message.fail_removeWhitelist_6) - assert.fail(message.fail_removeWhitelist_6); - } catch (e) { - let errorMessage = e.message; - if (errorMessage.includes(constant.remove_whitelist_1)) { - addContext(test, message.vali_removeWhitelist_2); - console.log(message.vali_removeWhitelist_2); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_removeWhitelist_2); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.arkaFunction_insufficientBalance); - } - }); - - it('REGRESSION: Validate the add whitelist address function of the arka paymaster with invalid address on the goerli network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - - // validate the add whitelist address - try { - await arkaPaymaster.addWhitelist([data.invalidSender]); - - addContext(test, message.fail_addWhitelist_3) - assert.fail(message.fail_addWhitelist_3); - } catch (e) { - let errorMessage = e.message; - if (errorMessage.includes(constant.invalid_address_5)) { - addContext(test, message.vali_addWhitelist_3); - console.log(message.vali_addWhitelist_3); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_addWhitelist_3); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.arkaFunction_insufficientBalance); - } - }); - - it('REGRESSION: Validate the add whitelist address function of the arka paymaster with incorrect address on the goerli network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - - // validate the add whitelist address - try { - await arkaPaymaster.addWhitelist([data.incorrectSender]); - - addContext(test, message.fail_addWhitelist_4) - assert.fail(message.fail_addWhitelist_4); - } catch (e) { - let errorMessage = e.message; - if (errorMessage.includes(constant.invalid_address_5)) { - addContext(test, message.vali_addWhitelist_4); - console.log(message.vali_addWhitelist_4); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_addWhitelist_4); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.arkaFunction_insufficientBalance); - } - }); - - it('REGRESSION: Validate the add whitelist address function of the arka paymaster with random address on the goerli network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - - // validate the add whitelist address - try { - const randomAddress = ethers.Wallet.createRandom(); - let addwhitelist = await arkaPaymaster.addWhitelist([randomAddress.address]); - - if (addwhitelist.includes(constant.add_whitelist_3)) { - addContext(test, message.vali_addWhitelist_5); - console.log(message.vali_addWhitelist_5); - } else { - addContext(test, message.fail_addWhitelist_7); - assert.fail(message.fail_addWhitelist_7); - } - } catch (e) { - let errorMessage = e.message; - if (errorMessage.includes(constant.add_whitelist_2)) { - addContext(test, message.vali_addWhitelist_2); - console.log(message.vali_addWhitelist_2); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_addWhitelist_2); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.arkaFunction_insufficientBalance); - } - }); - - it('REGRESSION: Validate the add whitelist address function of the arka paymaster with random and whitelisted addresses on the goerli network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - - // validate the add whitelist address - try { - const randomAddress = ethers.Wallet.createRandom(); - await arkaPaymaster.addWhitelist([randomAddress.address, data.sender]); - - if (addWhitelist.includes(constant.add_whitelist_3)) { - addContext(test, message.vali_addWhitelist_1); - console.log(message.vali_addWhitelist_1); - } else { - addContext(test, message.fail_addWhitelist_1); - assert.fail(message.fail_addWhitelist_1); - } - } catch (e) { - let errorMessage = e.message; - if (errorMessage.includes(constant.add_whitelist_2)) { - addContext(test, message.vali_addWhitelist_2); - console.log(message.vali_addWhitelist_2); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_addWhitelist_2); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.arkaFunction_insufficientBalance); - } - }); - - it('REGRESSION: Validate the add whitelist address function of the arka paymaster with multiple whitelisted addresses on the goerli network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - - // validate the add whitelist address - try { - const randomAddress1 = ethers.Wallet.createRandom(); - const randomAddress2 = ethers.Wallet.createRandom(); - - // add whitelist addresses - let addwhitelist = await arkaPaymaster.addWhitelist([randomAddress1.address, randomAddress2.address]); - - if (addwhitelist.includes(constant.add_whitelist_3)) { - addContext(test, message.vali_addWhitelist_1); - console.log(message.vali_addWhitelist_1); - } else { - addContext(test, message.fail_addWhitelist_1); - assert.fail(message.fail_addWhitelist_1); - } - } catch (e) { - let errorMessage = e.message; - if (errorMessage.includes(constant.add_whitelist_2)) { - addContext(test, message.vali_addWhitelist_2); - console.log(message.vali_addWhitelist_2); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_addWhitelist_2); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.arkaFunction_insufficientBalance); - } - }); - - it('REGRESSION: Validate the check whitelist function of the arka paymaster with invalid address on the goerli network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - - // validate the whilelist address - try { - await arkaPaymaster.checkWhitelist(data.invalidSender); - - addContext(test, message.fail_checkWhitelist_2) - assert.fail(message.fail_checkWhitelist_2) - } catch (e) { - let errorMessage = e.message; - if (errorMessage.includes(constant.invalid_address_5)) { - addContext(test, message.vali_checkWhitelist_1); - console.log(message.vali_checkWhitelist_1); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_checkWhitelist_2); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.arkaFunction_insufficientBalance); - } - }); - - it('REGRESSION: Validate the check whitelist function of the arka paymaster with incorrect address on the goerli network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - - // validate the whilelist address - try { - await arkaPaymaster.checkWhitelist(data.invalidSender); - - addContext(test, message.fail_checkWhitelist_3) - assert.fail(message.fail_checkWhitelist_3) - } catch (e) { - let errorMessage = e.message; - if (errorMessage.includes(constant.invalid_address_5)) { - addContext(test, message.vali_checkWhitelist_2); - console.log(message.vali_checkWhitelist_2); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_checkWhitelist_2); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.arkaFunction_insufficientBalance); - } - }); - - it('REGRESSION: Validate the check whitelist function of the arka paymaster with random address on the goerli network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - - // validate the whilelist address - try { - const randomAddress = ethers.Wallet.createRandom(); - let checkwhitelist = await arkaPaymaster.checkWhitelist(randomAddress.address); - - if (checkwhitelist.includes(constant.check_whitelist_1)) { - addContext(test, message.vali_addWhitelist_2); - console.log(message.vali_addWhitelist_2); - } else if (checkwhitelist.includes(constant.check_whitelist_2)) { - addContext(test, message.vali_removeWhitelist_2); - console.log(message.vali_removeWhitelist_2); - } - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_checkWhitelist_4); - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.arkaFunction_insufficientBalance); - } - }); - - it('REGRESSION: Validate the check whitelist function of the arka paymaster without address on the goerli network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - - // validate the whilelist address - try { - await arkaPaymaster.checkWhitelist(); - - addContext(test, message.fail_checkWhitelist_5) - assert.fail(message.fail_checkWhitelist_5); - } catch (e) { - let errorMessage = e.message; - if (errorMessage.includes(constant.invalid_address_5)) { - addContext(test, message.vali_checkWhitelist_3); - console.log(message.vali_checkWhitelist_3); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_checkWhitelist_5); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.arkaFunction_insufficientBalance); - } - }); - - it('REGRESSION: Validate the deposit function of the arka paymaster with invalid amount on the goerli network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - - // validate the deposit - try { - await arkaPaymaster.deposit("one"); - - addContext(test, message.fail_deposit_3) - assert.fail(message.fail_deposit_3) - } catch (e) { - let errorMessage = e.message; - if (errorMessage.includes(constant.invalid_data)) { - addContext(test, message.vali_deposit_2); - console.log(message.vali_deposit_2); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_deposit_3); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.arkaFunction_insufficientBalance); - } - }); -}); diff --git a/test/specs/testnet/paymaster/mumbai.spec.js b/test/specs/testnet/paymaster/mumbai.spec.js deleted file mode 100644 index 31ffe36..0000000 --- a/test/specs/testnet/paymaster/mumbai.spec.js +++ /dev/null @@ -1,4227 +0,0 @@ -import * as dotenv from 'dotenv'; -dotenv.config(); // init dotenv -import { PrimeSdk, DataUtils, ArkaPaymaster } from '@etherspot/prime-sdk'; -import { ethers, utils } from 'ethers'; -import { assert } from 'chai'; -import { ERC20_ABI } from '@etherspot/prime-sdk/dist/sdk/helpers/abi/ERC20_ABI.js'; -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 arkaPaymaster; -let runTest; - -/* eslint-disable prettier/prettier */ -describe('The PrimeSDK, when transaction with arka and pimlico paymasters 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); - } - - // initializating ArkaPaymaster... - try { - arkaPaymaster = new ArkaPaymaster(Number(data.mumbai_chainid), process.env.API_KEY, data.paymaster_arka); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_arka_initialize); - } - - // 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: Perform the transfer native token on arka paymaster 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 - let transactionBatch; - try { - transactionBatch = await mumbaiTestNetSdk.addUserOpsToBatch({ - to: data.recipient, - value: ethers.utils.parseEther(data.value), - }); - - try { - assert.isNotEmpty( - transactionBatch.to, - message.vali_addTransaction_to); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactionBatch.data, - message.vali_addTransaction_data); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactionBatch.value, - message.vali_addTransaction_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_addTransaction_1); - } - - // get balance of the account address - let balance; - try { - balance = await mumbaiTestNetSdk.getNativeBalance(); - - try { - assert.isNotEmpty( - balance, - message.vali_getBalance_balance); - } 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_getBalance_1); - } - - // estimate transactions added to the batch and get the fee data for the UserOp - let op; - try { - op = await mumbaiTestNetSdk.estimate({ - paymasterDetails: { - url: `https://arka.etherspot.io?apiKey=${process.env.API_KEY - }&chainId=${Number(data.mumbai_chainid)}`, - context: { mode: 'sponsor' }, - } - }); - - try { - assert.isNotEmpty( - op.sender, - message.vali_estimateTransaction_sender); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.nonce, - message.vali_estimateTransaction_nonce); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.initCode, - message.vali_estimateTransaction_initCode); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.callData, - message.vali_estimateTransaction_callData); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.callGasLimit, - message.vali_estimateTransaction_callGasLimit); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.verificationGasLimit, - message.vali_estimateTransaction_verificationGasLimit); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.maxFeePerGas, - message.vali_estimateTransaction_maxFeePerGas); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.maxPriorityFeePerGas, - message.vali_estimateTransaction_maxPriorityFeePerGas); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.paymasterAndData, - message.vali_estimateTransaction_paymasterAndData); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.preVerificationGas, - message.vali_estimateTransaction_preVerificationGas); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.signature, - message.vali_estimateTransaction_signature); - } 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_estimateTransaction_1); - } - - // sign the UserOp and sending to the bundler - let uoHash; - try { - uoHash = await mumbaiTestNetSdk.send(op); - - try { - assert.isNotEmpty( - uoHash, - message.vali_submitTransaction_uoHash); - } 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_submitTransaction_1); - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.nativeTransaction_insufficientBalance); - } - }); - - xit('SMOKE: Perform the transfer token with arka pimlico paymaster on the mumbai network', async function () { - var test = this; - let arka_url = data.paymaster_arka; - let queryString = `?apiKey=${process.env.API_KEY}&chainId=${Number( - data.mumbai_chainid, - )}`; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - let balance; - // get balance of the account address - try { - balance = await mumbaiTestNetSdk.getNativeBalance(); - - try { - assert.isNotEmpty( - balance, - message.vali_getBalance_balance); - } 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_getBalance_1); - } - - /** - * The fetching of pimlico erc20 paymaster address is only required for the first time for each specified gas token since we need to approve the tokens to spend - * from the paymaster address on behalf of you. - */ - let returnedValue; - let paymasterAddress; - let erc20Contract; - let encodedData; - let approveOp; - let uoHash1; - let transactionBatch; - let op; - let uoHash; - - try { - returnedValue = await fetch( - `${arka_url}/pimlicoAddress${queryString}`, - { - method: 'POST', - headers: { - Accept: 'application/json', - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ - params: [data.entryPointAddress, { token: data.usdc_token }], - }), - }, - ).then((res) => { - return res.json(); - }); - - paymasterAddress = returnedValue.message; - - try { - assert.isNotEmpty( - paymasterAddress, - message.vali_pimlico_paymasterAddress_1); - } 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_pimlico_paymasterAddress_1); - } - - if (utils.isAddress(paymasterAddress)) { - // get the erc20 Contract - let contract; - try { - erc20Contract = new ethers.Contract( - data.tokenAddress_mumbaiUSDC, - ERC20_ABI, - ); - encodedData = erc20Contract.interface.encodeFunctionData( - 'approve', - [paymasterAddress, ethers.constants.MaxUint256], - ); - - contract = await mumbaiTestNetSdk.addUserOpsToBatch({ - to: data.tokenAddress_mumbaiUSDC, - data: encodedData, - }); - - try { - assert.isNotEmpty( - contract.to, - message.vali_erc20Contract_to); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - contract.data, - message.vali_erc20Contract_data); - } 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_erc20Contract_1); - } - - // get estimation of transaction - try { - approveOp = await mumbaiTestNetSdk.estimate(); - - try { - assert.isNotEmpty( - approveOp.sender, - message.vali_estimateTransaction_sender); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - approveOp.nonce, - message.vali_estimateTransaction_nonce); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - approveOp.initCode, - message.vali_estimateTransaction_initCode); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - approveOp.callData, - message.vali_estimateTransaction_callData); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - approveOp.callGasLimit, - message.vali_estimateTransaction_callGasLimit); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - approveOp.verificationGasLimit, - message.vali_estimateTransaction_verificationGasLimit); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - approveOp.maxFeePerGas, - message.vali_estimateTransaction_maxFeePerGas); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - approveOp.maxPriorityFeePerGas, - message.vali_estimateTransaction_maxPriorityFeePerGas); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - approveOp.paymasterAndData, - message.vali_estimateTransaction_paymasterAndData); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - approveOp.preVerificationGas, - message.vali_estimateTransaction_preVerificationGas); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - approveOp.signature, - message.vali_estimateTransaction_signature); - } 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_estimateTransaction_1); - } - - // get the uoHash1 - try { - uoHash1 = await mumbaiTestNetSdk.send(approveOp); - - try { - assert.isNotEmpty( - uoHash1, - message.vali_submitTransaction_uoHash); - } 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_submitTransaction_1); - } - - // 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 { - transactionBatch = await mumbaiTestNetSdk.addUserOpsToBatch({ - to: data.recipient, - value: ethers.utils.parseEther(data.value), - }); - - try { - assert.isNotEmpty( - transactionBatch.to, - message.vali_addTransaction_to); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactionBatch.data, - message.vali_addTransaction_data); - } 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_addTransaction_1); - } - - // get balance of the account address - try { - balance = await mumbaiTestNetSdk.getNativeBalance(); - - try { - assert.isNotEmpty( - balance, - message.vali_getBalance_balance); - } 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_getBalance_1); - } - - // estimate transactions added to the batch and get the fee data for the UserOp - try { - op = await mumbaiTestNetSdk.estimate({ - paymasterDetails: { - url: `${arka_url}${queryString}`, - context: { token: data.usdc_token, mode: 'erc20' }, - } - }); - - try { - assert.isNotEmpty( - op.sender, - message.vali_estimateTransaction_sender); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.nonce, - message.vali_estimateTransaction_nonce); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.initCode, - message.vali_estimateTransaction_initCode); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.callData, - message.vali_estimateTransaction_callData); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.callGasLimit, - message.vali_estimateTransaction_callGasLimit); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.verificationGasLimit, - message.vali_estimateTransaction_verificationGasLimit); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.maxFeePerGas, - message.vali_estimateTransaction_maxFeePerGas); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.maxPriorityFeePerGas, - message.vali_estimateTransaction_maxPriorityFeePerGas); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.paymasterAndData, - message.vali_estimateTransaction_paymasterAndData); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.preVerificationGas, - message.vali_estimateTransaction_preVerificationGas); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.signature, - message.vali_estimateTransaction_signature); - } 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_estimateTransaction_1); - } - - // sign the UserOp and sending to the bundler... - try { - uoHash = await mumbaiTestNetSdk.send(op); - - try { - assert.isNotEmpty( - uoHash, - message.vali_submitTransaction_uoHash); - } 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_submitTransaction_1); - } - } else { - addContext(test, message.fail_paymasterAddress_1); - assert.fail(message.fail_paymasterAddress_1); - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.pimlocoPaymaster_insufficientBalance); - } - }); - - it('SMOKE: Perform the transfer token with arka paymaster with validUntil and validAfter on the mumbai network', async function () { - var test = this; - let arka_url = data.paymaster_arka; - let queryString = `?apiKey=${process.env.API_KEY}&chainId=${Number( - data.mumbai_chainid, - )}`; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - let balance; - let transactionBatch; - let op; - let uoHash; - - // get balance of the account address - try { - balance = await mumbaiTestNetSdk.getNativeBalance(); - - try { - assert.isNotEmpty( - balance, - message.vali_getBalance_balance); - } 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_getBalance_1); - } - - // 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 { - transactionBatch = await mumbaiTestNetSdk.addUserOpsToBatch({ - to: data.recipient, - value: ethers.utils.parseEther(data.value), - }); - - try { - assert.isNotEmpty( - transactionBatch.to, - message.vali_addTransaction_to); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactionBatch.data, - message.vali_addTransaction_data); - } 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_addTransaction_1); - } - - // get balance of the account address - try { - balance = await mumbaiTestNetSdk.getNativeBalance(); - - try { - assert.isNotEmpty( - balance, - message.vali_getBalance_balance); - } 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_getBalance_1); - } - - /* estimate transactions added to the batch and get the fee data for the UserOp - validUntil and validAfter are optional defaults to 10 mins of expiry from send call and should be passed in terms of milliseconds - For example purpose, the valid is fixed as expiring in 100 mins once the paymaster data is generated - validUntil and validAfter is relevant only with sponsor transactions and not for token paymasters - */ - - // estimate transactions added to the batch and get the fee data for the UserOp - try { - op = await mumbaiTestNetSdk.estimate({ - paymasterDetails: { - url: `${arka_url}${queryString}`, - context: { - mode: 'sponsor', - validAfter: new Date().valueOf(), - validUntil: new Date().valueOf() + 6000000, - }, - } - }); - - try { - assert.isNotEmpty( - op.sender, - message.vali_estimateTransaction_sender); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.nonce, - message.vali_estimateTransaction_nonce); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.initCode, - message.vali_estimateTransaction_initCode); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.callData, - message.vali_estimateTransaction_callData); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.callGasLimit, - message.vali_estimateTransaction_callGasLimit); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.verificationGasLimit, - message.vali_estimateTransaction_verificationGasLimit); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.maxFeePerGas, - message.vali_estimateTransaction_maxFeePerGas); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.maxPriorityFeePerGas, - message.vali_estimateTransaction_maxPriorityFeePerGas); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.paymasterAndData, - message.vali_estimateTransaction_paymasterAndData); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.preVerificationGas, - message.vali_estimateTransaction_preVerificationGas); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.signature, - message.vali_estimateTransaction_signature); - } 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_estimateTransaction_1); - } - - // sign the UserOp and sending to the bundler... - try { - uoHash = await mumbaiTestNetSdk.send(op); - - try { - assert.isNotEmpty( - uoHash, - message.vali_submitTransaction_uoHash); - } 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_submitTransaction_1); - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.nativeTransaction_insufficientBalance); - } - }); - - it('SMOKE: Validate the metadata of the arka paymaster on the mumbai network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - - // get the metadata - try { - let metadata = await arkaPaymaster.metadata(); - - try { - assert.isNotEmpty( - metadata.sponsorAddress, - message.vali_metadata_sponsorAddress); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - metadata.sponsorWalletBalance, - message.vali_metadata_sponsorWalletBalance); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - metadata.chainsSupported, - message.vali_metadata_chainsSupported); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - metadata.tokenPaymasters, - message.vali_metadata_tokenPaymasters); - } 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_metadata_1); - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.arkaFunction_insufficientBalance); - } - }); - - it('SMOKE: Validate the get token paymaster address function of the arka paymaster on the mumbai network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - - // validate the get token paymaster address - try { - let getTokenPaymasterAddress = await arkaPaymaster.getTokenPaymasterAddress("USDC"); - - try { - assert.isNotEmpty( - getTokenPaymasterAddress, - message.vali_getTokenPaymasterAddress_tokenPaymasterAddress); - } 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_getTokenPaymasterAddress_1); - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.arkaFunction_insufficientBalance); - } - }); - - it('SMOKE: Validate the remove whitelist address function of the arka paymaster on the mumbai network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - - // validate the remove whitelist address - try { - let removeWhitelist = await arkaPaymaster.removeWhitelist([data.sender]); - - if (removeWhitelist.includes(constant.remove_whitelist_2)) { - addContext(test, message.vali_removeWhitelist_1); - console.log(message.vali_removeWhitelist_1); - } else { - addContext(test, message.fail_removeWhitelist_1); - assert.fail(message.fail_removeWhitelist_1); - } - } catch (e) { - let errorMessage = e.message; - if (errorMessage.includes(constant.remove_whitelist_1)) { - addContext(test, message.vali_removeWhitelist_2); - console.log(message.vali_removeWhitelist_2); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_removeWhitelist_2); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.arkaFunction_insufficientBalance); - } - }); - - it('SMOKE: Validate the add whitelist address function of the arka paymaster on the mumbai network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - - // validate the add whitelist address - try { - let addWhitelist = await arkaPaymaster.addWhitelist([data.sender]); - - if (addWhitelist.includes(constant.add_whitelist_1)) { - addContext(test, message.vali_addWhitelist_1); - console.log(message.vali_addWhitelist_1); - } else { - addContext(test, message.fail_addWhitelist_1); - assert.fail(message.fail_addWhitelist_1); - } - } catch (e) { - let errorMessage = e.message; - if (errorMessage.includes(constant.add_whitelist_2)) { - addContext(test, message.vali_addWhitelist_2); - console.log(message.vali_addWhitelist_2); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_addWhitelist_2); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.arkaFunction_insufficientBalance); - } - }); - - it('SMOKE: Validate the check whitelist function of the arka paymaster on the mumbai network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - - // validate the whilelist address - try { - let checkWhitelist = await arkaPaymaster.checkWhitelist(data.sender); - - if (checkWhitelist.includes(constant.check_whitelist_1)) { - addContext(test, message.vali_addWhitelist_2); - console.log(message.vali_addWhitelist_2); - } else if (checkWhitelist.includes(constant.check_whitelist_2)) { - addContext(test, message.vali_removeWhitelist_2); - console.log(message.vali_removeWhitelist_2); - } - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_checkWhitelist_1); - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.arkaFunction_insufficientBalance); - } - }); - - it('SMOKE: Validate the deposit function of the arka paymaster on the mumbai network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - - // validate the deposit - try { - let deposit = await arkaPaymaster.deposit(data.value); - - if (deposit.includes(constant.deposit_1)) { - addContext(test, message.vali_deposit_1) - console.log(message.vali_deposit_1) - } else { - addContext(test, message.fail_deposit_1) - assert.fail(message.fail_deposit_1) - } - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_deposit_2); - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.arkaFunction_insufficientBalance); - } - }); - - it('REGRESSION: Perform the transfer native token with invalid arka paymaster url 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); - } - - // 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 - try { - await mumbaiTestNetSdk.estimate({ - paymasterDetails: { - url: data.invalid_paymaster_arka, // invalid URL - api_key: process.env.API_KEY, - context: { mode: 'sponsor' }, - } - }); - - addContext(test, message.fail_estimateTransaction_2) - assert.fail(message.fail_estimateTransaction_2); - } catch (e) { - if (e.message === constant.not_found) { - addContext(test, message.vali_estimateTransaction_1) - console.log(message.vali_estimateTransaction_1); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_estimateTransaction_2); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.nativeTransaction_insufficientBalance); - } - }); - - it('REGRESSION: Perform the transfer native token with invalid API Key of arka paymaster 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); - } - - // 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 - try { - await mumbaiTestNetSdk.estimate({ - paymasterDetails: { - url: data.paymaster_arka, - api_key: process.env.INVALID_API_KEY, - context: { mode: 'sponsor' }, - } - }); - - addContext(test, message.fail_estimateTransaction_4) - assert.fail(message.fail_estimateTransaction_4); - } catch (e) { - if (e.message === constant.invalid_apiKey) { - addContext(test, message.vali_estimateTransaction_3) - console.log(message.vali_estimateTransaction_3); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_estimateTransaction_4); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.nativeTransaction_insufficientBalance); - } - }); - - it('REGRESSION: Perform the transfer native token with incorrect API Key of arka paymaster 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); - } - - // 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 - try { - await mumbaiTestNetSdk.estimate({ - paymasterDetails: { - url: data.paymaster_arka, - api_key: process.env.INCORRECT_API_KEY, - context: { mode: 'sponsor' }, - } - }); - - addContext(test, message.fail_estimateTransaction_5) - assert.fail(message.fail_estimateTransaction_5); - } catch (e) { - if (e.message === constant.invalid_apiKey) { - addContext(test, message.vali_estimateTransaction_4) - console.log(message.vali_estimateTransaction_4); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_estimateTransaction_5); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.nativeTransaction_insufficientBalance); - } - }); - - it('REGRESSION: Perform the transfer native token without API Key of arka paymaster 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); - } - - // 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 - try { - await mumbaiTestNetSdk.estimate({ - paymasterDetails: { - url: data.paymaster_arka, - // without api_key - context: { mode: 'sponsor' }, - } - }); - - addContext(test, message.fail_estimateTransaction_6) - assert.fail(message.fail_estimateTransaction_6); - } catch (e) { - if (e.message === constant.invalid_apiKey) { - addContext(test, message.vali_estimateTransaction_5) - console.log(message.vali_estimateTransaction_5); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_estimateTransaction_6); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.nativeTransaction_insufficientBalance); - } - }); - - xit('REGRESSION: Perform the transfer token on arka pimlico paymaster with invalid paymaster URL on the mumbai network', async function () { - var test = this; - const invalid_arka_url = data.invalid_paymaster_arka; - let queryString = `?apiKey=${process.env.API_KEY}&chainId=${Number( - data.mumbai_chainid, - )}`; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - let returnedValue; - let paymasterAddress; - - try { - returnedValue = await fetch( - `${invalid_arka_url}/pimlicoAddress${queryString}`, // invalid paymaster URL - { - method: 'POST', - headers: { - Accept: 'application/json', - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ - params: [data.entryPointAddress, { token: data.usdc_token }], - }), - }, - ).then((res) => { - return res.json(); - }); - - paymasterAddress = returnedValue.message; - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_pimlico_paymasterAddress_1); - } - - if (paymasterAddress.includes(constant.not_found)) { - addContext(test, message.vali_pimlico_paymasterAddress_2) - console.log(message.vali_pimlico_paymasterAddress_2); - } else { - addContext(test, message.fail_pimlico_paymasterAddress_2); - assert.fail(message.fail_pimlico_paymasterAddress_2); - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.pimlocoPaymaster_insufficientBalance); - } - }); - - xit('REGRESSION: Perform the transfer token on arka pimlico paymaster with invalid API Key in queryString on the mumbai network', async function () { - var test = this; - let arka_url = data.paymaster_arka; - let queryString = `?apiKey=${process.env.INVALID_API_KEY}&chainId=${Number( - data.mumbai_chainid, - )}`; // invalid API Key in queryString - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - let returnedValue; - - try { - returnedValue = await fetch( - `${arka_url}/pimlicoAddress${queryString}`, - { - method: 'POST', - headers: { - Accept: 'application/json', - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ - params: [data.entryPointAddress, { token: data.usdc_token }], - }), - }, - ).then((res) => { - return res.json(); - }); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_pimlico_paymasterAddress_1); - } - - if (returnedValue.error === constant.invalid_apiKey) { - addContext(test, message.vali_pimlico_paymasterAddress_3) - console.log(message.vali_pimlico_paymasterAddress_3); - } else { - addContext(test, message.fail_pimlico_paymasterAddress_3); - assert.fail(message.fail_pimlico_paymasterAddress_3); - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.pimlocoPaymaster_insufficientBalance); - } - }); - - xit('REGRESSION: Perform the transfer token on arka pimlico paymaster without API Key in queryString on the mumbai network', async function () { - var test = this; - let arka_url = data.paymaster_arka; - let queryString = `?chainId=${Number(data.mumbai_chainid)}`; // without API Key in queryString - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - let returnedValue; - - try { - returnedValue = await fetch( - `${arka_url}/pimlicoAddress${queryString}`, - { - method: 'POST', - headers: { - Accept: 'application/json', - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ - params: [data.entryPointAddress, { token: data.usdc_token }], - }), - }, - ).then((res) => { - return res.json(); - }); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_pimlico_paymasterAddress_1); - } - - if (returnedValue.error === constant.invalid_apiKey) { - addContext(test, message.vali_pimlico_paymasterAddress_4) - console.log(message.vali_pimlico_paymasterAddress_4); - } else { - addContext(test, message.fail_pimlico_paymasterAddress_4); - assert.fail(message.fail_pimlico_paymasterAddress_4); - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.pimlocoPaymaster_insufficientBalance); - } - }); - - xit('REGRESSION: Perform the transfer token on arka pimlico paymaster with invalid ChainID in queryString on the mumbai network', async function () { - var test = this; - let arka_url = data.paymaster_arka; - let queryString = `?apiKey=${process.env.API_KEY}&chainId=${Number( - data.invalid_mumbai_chainid, - )}`; // invalid chainid in queryString - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - let returnedValue; - - try { - returnedValue = await fetch( - `${arka_url}/pimlicoAddress${queryString}`, - { - method: 'POST', - headers: { - Accept: 'application/json', - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ - params: [data.entryPointAddress, { token: data.usdc_token }], - }), - }, - ).then((res) => { - return res.json(); - }); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_pimlico_paymasterAddress_1); - } - - if (returnedValue.error === constant.invalid_network_3) { - addContext(test, message.vali_pimlico_paymasterAddress_5) - console.log(message.vali_pimlico_paymasterAddress_5); - } else { - addContext(test, message.fail_pimlico_paymasterAddress_5); - assert.fail(message.fail_pimlico_paymasterAddress_5); - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.pimlocoPaymaster_insufficientBalance); - } - }); - - xit('REGRESSION: Perform the transfer token on arka pimlico paymaster without ChainID in queryString on the mumbai network', async function () { - var test = this; - let arka_url = data.paymaster_arka; - let queryString = `?apiKey=${process.env.API_KEY}`; // without ChainID - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - let returnedValue; - try { - returnedValue = await fetch( - `${arka_url}/pimlicoAddress${queryString}`, - { - // without chainid in queryString - method: 'POST', - headers: { - Accept: 'application/json', - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ - params: [data.entryPointAddress, { token: data.usdc_token }], - }), - }, - ).then((res) => { - return res.json(); - }); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_pimlico_paymasterAddress_1); - } - - if (returnedValue.error === constant.invalid_data) { - addContext(test, message.vali_pimlico_paymasterAddress_6) - console.log(message.vali_pimlico_paymasterAddress_6); - } else { - addContext(test, message.fail_pimlico_paymasterAddress_6); - assert.fail(message.fail_pimlico_paymasterAddress_6); - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.pimlocoPaymaster_insufficientBalance); - } - }); - - xit('REGRESSION: Perform the transfer token on arka pimlico paymaster with invalid Entry Point Address while fetching the paymaster address on the mumbai network', async function () { - var test = this; - let arka_url = data.paymaster_arka; - let queryString = `?apiKey=${process.env.API_KEY}&chainId=${Number( - data.mumbai_chainid, - )}`; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - let returnedValue; - - try { - returnedValue = await fetch( - `${arka_url}/pimlicoAddress${queryString}`, - { - method: 'POST', - headers: { - Accept: 'application/json', - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ - params: [ - data.invalidEntryPointAddress, // invalid entry point address - { token: data.usdc_token }, - ], - }), - }, - ).then((res) => { - return res.json(); - }); - } catch (e) { - const errorMessage = returnedValue.error; - if (errorMessage.includes(constant.invalid_address_4)) { - addContext(test, message.vali_pimlico_paymasterAddress_7) - console.log(message.vali_pimlico_paymasterAddress_7); - } else { - addContext(test, message.fail_pimlico_paymasterAddress_7); - assert.fail(message.fail_pimlico_paymasterAddress_7); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.pimlocoPaymaster_insufficientBalance); - } - }); - - xit('REGRESSION: Perform the transfer token on arka pimlico paymaster with invalid token while fetching the paymaster address on the mumbai network', async function () { - var test = this; - let arka_url = data.paymaster_arka; - let queryString = `?apiKey=${process.env.API_KEY}&chainId=${Number( - data.mumbai_chainid, - )}`; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - let returnedValue; - - try { - returnedValue = await fetch( - `${arka_url}/pimlicoAddress${queryString}`, - { - method: 'POST', - headers: { - Accept: 'application/json', - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ - params: [ - data.entryPointAddress, - { token: data.invalid_usdc_token }, // invalid token - ], - }), - }, - ).then((res) => { - return res.json(); - }); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_pimlico_paymasterAddress_1); - } - - if (returnedValue.error === constant.invalid_network_1) { - addContext(test, message.vali_pimlico_paymasterAddress_8) - console.log(message.vali_pimlico_paymasterAddress_8); - } else { - addContext(test, message.fail_pimlico_paymasterAddress_8); - assert.fail(message.fail_pimlico_paymasterAddress_8); - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.pimlocoPaymaster_insufficientBalance); - } - }); - - xit('REGRESSION: Perform the transfer token on arka pimlico paymaster without parameters while fetching the paymaster address on the mumbai network', async function () { - var test = this; - let arka_url = data.paymaster_arka; - let queryString = `?apiKey=${process.env.API_KEY}&chainId=${Number( - data.mumbai_chainid, - )}`; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - let returnedValue; - - try { - returnedValue = await fetch( - `${arka_url}/pimlicoAddress${queryString}`, - { - method: 'POST', - headers: { - Accept: 'application/json', - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ - params: [], // without parametets - }), - }, - ).then((res) => { - return res.json(); - }); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_pimlico_paymasterAddress_1); - } - - if (returnedValue.error === constant.invalid_data) { - addContext(test, message.vali_pimlico_paymasterAddress_9) - console.log(message.vali_pimlico_paymasterAddress_9); - } else { - addContext(test, message.fail_pimlico_paymasterAddress_9); - assert.fail(message.fail_pimlico_paymasterAddress_9); - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.pimlocoPaymaster_insufficientBalance); - } - }); - - xit('REGRESSION: Perform the transfer token on arka pimlico paymaster with incorrect token address of the erc20 contract on the mumbai network', async function () { - var test = this; - let arka_url = data.paymaster_arka; - let queryString = `?apiKey=${process.env.API_KEY}&chainId=${Number( - data.mumbai_chainid, - )}`; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - let returnedValue; - let paymasterAddress; - - try { - returnedValue = await fetch( - `${arka_url}/pimlicoAddress${queryString}`, - { - method: 'POST', - headers: { - Accept: 'application/json', - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ - params: [data.entryPointAddress, { token: data.usdc_token }], - }), - }, - ).then((res) => { - return res.json(); - }); - - paymasterAddress = returnedValue.message; - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_pimlico_paymasterAddress_1); - } - - if (utils.isAddress(paymasterAddress)) { - // get the erc20 Contract - try { - erc20Contract = new ethers.Contract( - data.incorrectTokenAddress_mumbaiUSDC, // incorrect token address - ERC20_ABI, - ); - encodedData = erc20Contract.interface.encodeFunctionData( - 'approve', - [paymasterAddress, ethers.constants.MaxUint256], - ); - await mumbaiTestNetSdk.addUserOpsToBatch({ - to: data.tokenAddress_mumbaiUSDC, - data: encodedData, - }); - } catch (e) { - let errorMessage = e.message; - if (errorMessage.includes(constant.contract_address_1)) { - addContext(test, message.vali_erc20Contract_1) - console.log(message.vali_erc20Contract_1); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Contract_3); - } - } - } else { - addContext(test, message.fail_erc20Contract_2); - assert.fail(message.fail_erc20Contract_2); - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.pimlocoPaymaster_insufficientBalance); - } - }); - - xit('REGRESSION: Perform the transfer token on arka pimlico paymaster with invalid token address of the erc20 contract on the mumbai network', async function () { - var test = this; - let arka_url = data.paymaster_arka; - let queryString = `?apiKey=${process.env.API_KEY}&chainId=${Number( - data.mumbai_chainid, - )}`; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - let returnedValue; - let paymasterAddress; - - try { - returnedValue = await fetch( - `${arka_url}/pimlicoAddress${queryString}`, - { - method: 'POST', - headers: { - Accept: 'application/json', - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ - params: [data.entryPointAddress, { token: data.usdc_token }], - }), - }, - ).then((res) => { - return res.json(); - }); - - paymasterAddress = returnedValue.message; - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_pimlico_paymasterAddress_1); - } - - if (utils.isAddress(paymasterAddress)) { - // get the erc20 Contract - try { - erc20Contract = new ethers.Contract( - data.invalidTokenAddress_mumbaiUSDC, // invalid token address - ERC20_ABI, - ); - encodedData = erc20Contract.interface.encodeFunctionData( - 'approve', - [paymasterAddress, ethers.constants.MaxUint256], - ); - await mumbaiTestNetSdk.addUserOpsToBatch({ - to: data.tokenAddress_mumbaiUSDC, - data: encodedData, - }); - } catch (e) { - let errorMessage = e.message; - if (errorMessage.includes(constant.contract_address_1)) { - addContext(test, message.vali_erc20Contract_2) - console.log(message.vali_erc20Contract_2); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Contract_4); - } - } - } else { - addContext(test, message.fail_erc20Contract_2); - assert.fail(message.fail_erc20Contract_2); - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.pimlocoPaymaster_insufficientBalance); - } - }); - - xit('REGRESSION: Perform the transfer token on arka pimlico paymaster with invalid paymaster address of the erc20 contract on the mumbai network', async function () { - var test = this; - let arka_url = data.paymaster_arka; - let queryString = `?apiKey=${process.env.API_KEY}&chainId=${Number( - data.mumbai_chainid, - )}`; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - let returnedValue; - let paymasterAddress; - let erc20Contract; - - try { - returnedValue = await fetch( - `${arka_url}/pimlicoAddress${queryString}`, - { - method: 'POST', - headers: { - Accept: 'application/json', - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ - params: [data.entryPointAddress, { token: data.usdc_token }], - }), - }, - ).then((res) => { - return res.json(); - }); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_pimlico_paymasterAddress_1); - } - - paymasterAddress = returnedValue.message; - - if (utils.isAddress(paymasterAddress)) { - // get the erc20 Contract - try { - erc20Contract = new ethers.Contract( - data.tokenAddress_mumbaiUSDC, - ERC20_ABI, - ); - encodedData = erc20Contract.interface.encodeFunctionData( - 'approve', - [data.invalid_paymasterAddress, ethers.constants.MaxUint256], // invalid paymaster address - ); - await mumbaiTestNetSdk.addUserOpsToBatch({ - to: data.tokenAddress_mumbaiUSDC, - data: encodedData, - }); - } catch (e) { - let errorMessage = e.message; - if (errorMessage.includes(constant.invalid_address_4)) { - addContext(test, message.vali_erc20Contract_3) - console.log(message.vali_erc20Contract_3); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Contract_5); - } - } - } else { - addContext(test, message.fail_erc20Contract_2); - assert.fail(message.fail_erc20Contract_2); - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.pimlocoPaymaster_insufficientBalance); - } - }); - - xit('REGRESSION: Perform the transfer token on arka pimlico paymaster with incorrect paymaster address of the erc20 contract on the mumbai network', async function () { - var test = this; - let arka_url = data.paymaster_arka; - let queryString = `?apiKey=${process.env.API_KEY}&chainId=${Number( - data.mumbai_chainid, - )}`; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - let returnedValue; - let paymasterAddress; - let erc20Contract; - - try { - returnedValue = await fetch( - `${arka_url}/pimlicoAddress${queryString}`, - { - method: 'POST', - headers: { - Accept: 'application/json', - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ - params: [data.entryPointAddress, { token: data.usdc_token }], - }), - }, - ).then((res) => { - return res.json(); - }); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_pimlico_paymasterAddress_1); - } - - paymasterAddress = returnedValue.message; - - if (utils.isAddress(paymasterAddress)) { - // get the erc20 Contract - try { - erc20Contract = new ethers.Contract( - data.tokenAddress_mumbaiUSDC, - ERC20_ABI, - ); - encodedData = erc20Contract.interface.encodeFunctionData( - 'approve', - [data.incorrect_paymasterAddress, ethers.constants.MaxUint256], // incorrect paymaster address - ); - await mumbaiTestNetSdk.addUserOpsToBatch({ - to: data.tokenAddress_mumbaiUSDC, - data: encodedData, - }); - } catch (e) { - let errorMessage = e.message; - if (errorMessage.includes(constant.invalid_address_6)) { - addContext(test, message.vali_erc20Contract_4) - console.log(message.vali_erc20Contract_4); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Contract_6); - } - } - } else { - addContext(test, message.fail_erc20Contract_2); - assert.fail(message.fail_erc20Contract_2); - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.pimlocoPaymaster_insufficientBalance); - } - }); - - xit('REGRESSION: Perform the transfer token on arka pimlico paymaster with invalid value of the transactions on the mumbai network', async function () { - var test = this; - let arka_url = data.paymaster_arka; - let queryString = `?apiKey=${process.env.API_KEY}&chainId=${Number( - data.mumbai_chainid, - )}`; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - let returnedValue; - let paymasterAddress; - let erc20Contract; - let encodedData; - let approveOp; - - try { - returnedValue = await fetch( - `${arka_url}/pimlicoAddress${queryString}`, - { - method: 'POST', - headers: { - Accept: 'application/json', - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ - params: [data.entryPointAddress, { token: data.usdc_token }], - }), - }, - ).then((res) => { - return res.json(); - }); - - paymasterAddress = returnedValue.message; - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_pimlico_paymasterAddress_1); - } - - if (utils.isAddress(paymasterAddress)) { - // get the erc20 Contract - try { - erc20Contract = new ethers.Contract( - data.tokenAddress_mumbaiUSDC, - ERC20_ABI, - ); - encodedData = erc20Contract.interface.encodeFunctionData( - 'approve', - [paymasterAddress, ethers.constants.MaxUint256], - ); - await mumbaiTestNetSdk.addUserOpsToBatch({ - to: data.tokenAddress_mumbaiUSDC, - data: encodedData, - }); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Contract_1); - } - - // get the UserOp Hash - try { - approveOp = await mumbaiTestNetSdk.estimate(); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_estimateTransaction_1); - } - - // get the uoHash1 - try { - await mumbaiTestNetSdk.send(approveOp); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_submitTransaction_1); - } - - // 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.invalidValue), - }); - - addContext(test, message.fail_addTransaction_2) - assert.fail(message.fail_addTransaction_2); - } catch (e) { - let errorMessage = e.message; - if (errorMessage.includes(constant.invalid_value_1)) { - addContext(test, vali_addTransaction_1) - console.log(vali_addTransaction_1); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_addTransaction_3); - } - } - } else { - addContext(test, message.fail_erc20Contract_2); - assert.fail(message.fail_erc20Contract_2); - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.pimlocoPaymaster_insufficientBalance); - } - }); - - xit('REGRESSION: Perform the transfer token on arka pimlico paymaster with invalid paymaster URL while estimate the transactions on the mumbai network', async function () { - var test = this; - let arka_url = data.paymaster_arka; - let invalid_arka_url = data.invalid_paymaster_arka; - let queryString = `?apiKey=${process.env.API_KEY}&chainId=${Number( - data.mumbai_chainid, - )}`; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - let returnedValue; - let paymasterAddress; - let erc20Contract; - let encodedData; - let approveOp; - - try { - returnedValue = await fetch( - `${arka_url}/pimlicoAddress${queryString}`, - { - method: 'POST', - headers: { - Accept: 'application/json', - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ - params: [data.entryPointAddress, { token: data.usdc_token }], - }), - }, - ).then((res) => { - return res.json(); - }); - - paymasterAddress = returnedValue.message; - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_pimlico_paymasterAddress_1); - } - - if (utils.isAddress(paymasterAddress)) { - // get the erc20 Contract - try { - erc20Contract = new ethers.Contract( - data.tokenAddress_mumbaiUSDC, - ERC20_ABI, - ); - encodedData = erc20Contract.interface.encodeFunctionData( - 'approve', - [paymasterAddress, ethers.constants.MaxUint256], - ); - await mumbaiTestNetSdk.addUserOpsToBatch({ - to: data.tokenAddress_mumbaiUSDC, - data: encodedData, - }); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Contract_1); - } - - // get the UserOp Hash - try { - approveOp = await mumbaiTestNetSdk.estimate(); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_estimateTransaction_1); - } - - // get the uoHash1 - try { - await mumbaiTestNetSdk.send(approveOp); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_submitTransaction_1); - } - - // 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_pimlico_paymasterAddress_1); - } - - // estimate transactions added to the batch and get the fee data for the UserOp - try { - await mumbaiTestNetSdk.estimate({ - paymasterDetails: { - url: `${invalid_arka_url}${queryString}`, - context: { token: data.usdc_token, mode: 'erc20' }, - } - }); - - addContext(test, message.fail_estimateTransaction_2) - assert.fail(message.fail_estimateTransaction_2); - } catch (e) { - let errorMessage = e.message; - if (errorMessage.includes(constant.not_found)) { - addContext(test, message.vali_estimateTransaction_1) - console.log(message.vali_estimateTransaction_1); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_estimateTransaction_2); - } - } - } else { - addContext(test, message.fail_erc20Contract_2); - assert.fail(message.fail_erc20Contract_2); - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.pimlocoPaymaster_insufficientBalance); - } - }); - - xit('REGRESSION: Perform the transfer token on arka pimlico paymaster with invalid Api Key while estimate the transactions on the mumbai network', async function () { - var test = this; - let arka_url = data.paymaster_arka; - let queryString = `?apiKey=${process.env.API_KEY}&chainId=${Number( - data.mumbai_chainid, - )}`; - let invalid_queryString = `?apiKey=${process.env.INVALID_API_KEY - }&chainId=${Number(data.mumbai_chainid)}`; // invalid API Key in queryString - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - let returnedValue; - let paymasterAddress; - let erc20Contract; - let encodedData; - let approveOp; - - try { - returnedValue = await fetch( - `${arka_url}/pimlicoAddress${queryString}`, - { - method: 'POST', - headers: { - Accept: 'application/json', - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ - params: [data.entryPointAddress, { token: data.usdc_token }], - }), - }, - ).then((res) => { - return res.json(); - }); - - paymasterAddress = returnedValue.message; - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_pimlico_paymasterAddress_1); - } - - if (utils.isAddress(paymasterAddress)) { - // get the erc20 Contract - try { - erc20Contract = new ethers.Contract( - data.tokenAddress_mumbaiUSDC, - ERC20_ABI, - ); - encodedData = erc20Contract.interface.encodeFunctionData( - 'approve', - [paymasterAddress, ethers.constants.MaxUint256], - ); - await mumbaiTestNetSdk.addUserOpsToBatch({ - to: data.tokenAddress_mumbaiUSDC, - data: encodedData, - }); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Contract_1); - } - - // get the UserOp Hash - try { - approveOp = await mumbaiTestNetSdk.estimate(); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_estimateTransaction_1); - } - - // get the uoHash1 - try { - await mumbaiTestNetSdk.send(approveOp); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_submitTransaction_1); - } - - // 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_pimlico_paymasterAddress_1); - } - - // estimate transactions added to the batch and get the fee data for the UserOp - try { - await mumbaiTestNetSdk.estimate({ - paymasterDetails: { - url: `${arka_url}${invalid_queryString}`, - context: { token: data.usdc_token, mode: 'erc20' }, - } - }); - - addContext(test, message.fail_estimateTransaction_4) - assert.fail(message.fail_estimateTransaction_4); - } catch (e) { - let errorMessage = e.message; - if (errorMessage.includes(constant.invalid_apiKey)) { - addContext(test, message.vali_estimateTransaction_3) - console.log(message.vali_estimateTransaction_3); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_estimateTransaction_4); - } - } - } else { - addContext(test, message.fail_erc20Contract_2); - assert.fail(message.fail_erc20Contract_2); - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.pimlocoPaymaster_insufficientBalance); - } - }); - - xit('REGRESSION: Perform the transfer token on arka pimlico paymaster without Api Key while estimate the transactions on the mumbai network', async function () { - var test = this; - let arka_url = data.paymaster_arka; - let queryString = `?apiKey=${process.env.API_KEY}&chainId=${Number( - data.mumbai_chainid, - )}`; - let invalid_queryString = `?chainId=${Number(data.mumbai_chainid)}`; // without API Key in queryString - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - let returnedValue; - let paymasterAddress; - let erc20Contract; - let encodedData; - let approveOp; - - try { - returnedValue = await fetch( - `${arka_url}/pimlicoAddress${queryString}`, - { - method: 'POST', - headers: { - Accept: 'application/json', - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ - params: [data.entryPointAddress, { token: data.usdc_token }], - }), - }, - ).then((res) => { - return res.json(); - }); - - paymasterAddress = returnedValue.message; - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_pimlico_paymasterAddress_1); - } - - if (utils.isAddress(paymasterAddress)) { - // get the erc20 Contract - try { - erc20Contract = new ethers.Contract( - data.tokenAddress_mumbaiUSDC, - ERC20_ABI, - ); - encodedData = erc20Contract.interface.encodeFunctionData( - 'approve', - [paymasterAddress, ethers.constants.MaxUint256], - ); - await mumbaiTestNetSdk.addUserOpsToBatch({ - to: data.tokenAddress_mumbaiUSDC, - data: encodedData, - }); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Contract_1); - } - - // get the UserOp Hash - try { - approveOp = await mumbaiTestNetSdk.estimate(); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_estimateTransaction_1); - } - - // get the uoHash1 - try { - await mumbaiTestNetSdk.send(approveOp); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_submitTransaction_1); - } - - // 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_pimlico_paymasterAddress_1); - } - - // estimate transactions added to the batch and get the fee data for the UserOp - try { - await mumbaiTestNetSdk.estimate({ - paymasterDetails: { - url: `${arka_url}${invalid_queryString}`, - context: { token: data.usdc_token, mode: 'erc20' }, - } - }); - - addContext(test, message.fail_estimateTransaction_6) - assert.fail(message.fail_estimateTransaction_6); - } catch (e) { - let errorMessage = e.message; - if (errorMessage.includes(constant.invalid_apiKey)) { - addContext(test, message.vali_estimateTransaction_5) - console.log(message.vali_estimateTransaction_5); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_estimateTransaction_6); - } - } - } else { - addContext(test, message.fail_erc20Contract_2); - assert.fail(message.fail_erc20Contract_2); - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.pimlocoPaymaster_insufficientBalance); - } - }); - - xit('REGRESSION: Perform the transfer token on arka pimlico paymaster with invalid chainid while estimate the transactions on the mumbai network', async function () { - var test = this; - let arka_url = data.paymaster_arka; - let queryString = `?apiKey=${process.env.API_KEY}&chainId=${Number( - data.mumbai_chainid, - )}`; - let invalid_queryString = `?apiKey=${process.env.API_KEY}&chainId=${Number( - data.invalid_mumbai_chainid, - )}`; // invalid chainid in queryString - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - let returnedValue; - let paymasterAddress; - let erc20Contract; - let encodedData; - let approveOp; - - try { - returnedValue = await fetch( - `${arka_url}/pimlicoAddress${queryString}`, - { - method: 'POST', - headers: { - Accept: 'application/json', - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ - params: [data.entryPointAddress, { token: data.usdc_token }], - }), - }, - ).then((res) => { - return res.json(); - }); - - paymasterAddress = returnedValue.message; - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_pimlico_paymasterAddress_1); - } - - if (utils.isAddress(paymasterAddress)) { - // get the erc20 Contract - try { - erc20Contract = new ethers.Contract( - data.tokenAddress_mumbaiUSDC, - ERC20_ABI, - ); - encodedData = erc20Contract.interface.encodeFunctionData( - 'approve', - [paymasterAddress, ethers.constants.MaxUint256], - ); - await mumbaiTestNetSdk.addUserOpsToBatch({ - to: data.tokenAddress_mumbaiUSDC, - data: encodedData, - }); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Contract_1); - } - - // get the UserOp Hash - try { - approveOp = await mumbaiTestNetSdk.estimate(); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_estimateTransaction_1); - } - - // get the uoHash1 - try { - await mumbaiTestNetSdk.send(approveOp); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_submitTransaction_1); - } - - // 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_pimlico_paymasterAddress_1); - } - - // estimate transactions added to the batch and get the fee data for the UserOp - try { - await mumbaiTestNetSdk.estimate({ - paymasterDetails: { - url: `${arka_url}${invalid_queryString}`, - context: { token: data.usdc_token, mode: 'erc20' }, - } - }); - - addContext(test, message.fail_estimateTransaction_7) - assert.fail(message.fail_estimateTransaction_7); - } catch (e) { - let errorMessage = e.message; - if (errorMessage.includes(constant.invalid_network_3)) { - addContext(test, message.vali_estimateTransaction_6) - console.log(message.vali_estimateTransaction_6); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_estimateTransaction_7); - } - } - } else { - addContext(test, message.fail_erc20Contract_2); - assert.fail(message.fail_erc20Contract_2); - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.pimlocoPaymaster_insufficientBalance); - } - }); - - xit('REGRESSION: Perform the transfer token on arka pimlico paymaster without chainid while estimate the transactions on the mumbai network', async function () { - var test = this; - let arka_url = data.paymaster_arka; - let queryString = `?apiKey=${process.env.API_KEY}&chainId=${Number( - data.mumbai_chainid, - )}`; - let invalid_queryString = `?apiKey=${process.env.API_KEY}`; // without ChainID - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - let returnedValue; - let paymasterAddress; - let erc20Contract; - let encodedData; - let approveOp; - - try { - returnedValue = await fetch( - `${arka_url}/pimlicoAddress${queryString}`, - { - method: 'POST', - headers: { - Accept: 'application/json', - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ - params: [data.entryPointAddress, { token: data.usdc_token }], - }), - }, - ).then((res) => { - return res.json(); - }); - - paymasterAddress = returnedValue.message; - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_pimlico_paymasterAddress_1); - } - - if (utils.isAddress(paymasterAddress)) { - // get the erc20 Contract - try { - erc20Contract = new ethers.Contract( - data.tokenAddress_mumbaiUSDC, - ERC20_ABI, - ); - encodedData = erc20Contract.interface.encodeFunctionData( - 'approve', - [paymasterAddress, ethers.constants.MaxUint256], - ); - await mumbaiTestNetSdk.addUserOpsToBatch({ - to: data.tokenAddress_mumbaiUSDC, - data: encodedData, - }); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Contract_1); - } - - // get the UserOp Hash - try { - approveOp = await mumbaiTestNetSdk.estimate(); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_estimateTransaction_1); - } - - // get the uoHash1 - try { - await mumbaiTestNetSdk.send(approveOp); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_submitTransaction_1); - } - - // 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_pimlico_paymasterAddress_1); - } - - // estimate transactions added to the batch and get the fee data for the UserOp - try { - await mumbaiTestNetSdk.estimate({ - paymasterDetails: { - url: `${arka_url}${invalid_queryString}`, - context: { token: data.usdc_token, mode: 'erc20' }, - } - }); - - addContext(test, message.fail_estimateTransaction_8) - assert.fail(message.fail_estimateTransaction_8); - } catch (e) { - let errorMessage = e.message; - if (errorMessage.includes(constant.invalid_data)) { - addContext(test, message.vali_estimateTransaction_7) - console.log(message.vali_estimateTransaction_7); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_estimateTransaction_8); - } - } - } else { - addContext(test, message.fail_erc20Contract_2); - assert.fail(message.fail_erc20Contract_2); - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.pimlocoPaymaster_insufficientBalance); - } - }); - - it('REGRESSION: Perform the transfer token on arka paymaster with validUntil and validAfter with invalid paymaster URL on the mumbai network', async function () { - var test = this; - let invalid_arka_url = data.invalid_paymaster_arka; - let queryString = `?apiKey=${process.env.API_KEY}&chainId=${Number( - data.mumbai_chainid, - )}`; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - // 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); - } - - // 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_pimlico_paymasterAddress_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_pimlico_paymasterAddress_1); - } - - /* estimate transactions added to the batch and get the fee data for the UserOp - validUntil and validAfter are optional defaults to 10 mins of expiry from send call and should be passed in terms of milliseconds - For example purpose, the valid is fixed as expiring in 100 mins once the paymaster data is generated - validUntil and validAfter is relevant only with sponsor transactions and not for token paymasters - */ - - // estimate transactions added to the batch and get the fee data for the UserOp - try { - await mumbaiTestNetSdk.estimate({ - paymasterDetails: { - url: `${invalid_arka_url}${queryString}`, - context: { - mode: 'sponsor', - validAfter: new Date().valueOf(), - validUntil: new Date().valueOf() + 6000000, - }, - } - }); - - addContext(test, message.fail_estimateTransaction_2) - assert.fail(message.fail_estimateTransaction_2); - } catch (e) { - let errorMessage = e.message; - if (errorMessage.includes(constant.not_found)) { - addContext(test, message.vali_estimateTransaction_1) - console.log(message.vali_estimateTransaction_1); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_estimateTransaction_2); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.pimlocoPaymaster_insufficientBalance); - } - }); - - it('REGRESSION: Perform the transfer token on arka paymaster with validUntil and validAfter with invalid API Token on the mumbai network', async function () { - var test = this; - let arka_url = data.paymaster_arka; - let invalid_queryString = `?apiKey=${process.env.INVALID_API_KEY - }&chainId=${Number(data.mumbai_chainid)}`; // invalid API Key in queryString - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - // 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); - } - - // 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_pimlico_paymasterAddress_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_pimlico_paymasterAddress_1); - } - - /* estimate transactions added to the batch and get the fee data for the UserOp - validUntil and validAfter are optional defaults to 10 mins of expiry from send call and should be passed in terms of milliseconds - For example purpose, the valid is fixed as expiring in 100 mins once the paymaster data is generated - validUntil and validAfter is relevant only with sponsor transactions and not for token paymasters - */ - - // estimate transactions added to the batch and get the fee data for the UserOp - try { - await mumbaiTestNetSdk.estimate({ - paymasterDetails: { - url: `${arka_url}${invalid_queryString}`, - context: { - mode: 'sponsor', - validAfter: new Date().valueOf(), - validUntil: new Date().valueOf() + 6000000, - }, - } - }); - - addContext(test, message.fail_estimateTransaction_4) - assert.fail(message.fail_estimateTransaction_4); - } catch (e) { - if (e.message === constant.invalid_apiKey) { - addContext(test, message.vali_estimateTransaction_3) - console.log(message.vali_estimateTransaction_3); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_estimateTransaction_4); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.pimlocoPaymaster_insufficientBalance); - } - }); - - it('REGRESSION: Perform the transfer token on arka paymaster with validUntil and validAfter without API Token on the mumbai network', async function () { - var test = this; - let arka_url = data.paymaster_arka; - let invalid_queryString = `?chainId=${Number(data.mumbai_chainid)}`; // without API Key in queryString - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - // 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); - } - - // 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_pimlico_paymasterAddress_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_pimlico_paymasterAddress_1); - } - - /* estimate transactions added to the batch and get the fee data for the UserOp - validUntil and validAfter are optional defaults to 10 mins of expiry from send call and should be passed in terms of milliseconds - For example purpose, the valid is fixed as expiring in 100 mins once the paymaster data is generated - validUntil and validAfter is relevant only with sponsor transactions and not for token paymasters - */ - - // estimate transactions added to the batch and get the fee data for the UserOp - try { - await mumbaiTestNetSdk.estimate({ - paymasterDetails: { - url: `${arka_url}${invalid_queryString}`, - context: { - mode: 'sponsor', - validAfter: new Date().valueOf(), - validUntil: new Date().valueOf() + 6000000, - }, - } - }); - - addContext(test, message.fail_estimateTransaction_6) - assert.fail(message.fail_estimateTransaction_6); - } catch (e) { - if (e.message === constant.invalid_apiKey) { - addContext(test, message.vali_estimateTransaction_3) - console.log(message.vali_estimateTransaction_3); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_estimateTransaction_4); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.pimlocoPaymaster_insufficientBalance); - } - }); - - it('REGRESSION: Perform the transfer token on arka paymaster with validUntil and validAfter with invalid ChainID on the mumbai network', async function () { - var test = this; - let arka_url = data.paymaster_arka; - let invalid_queryString = `?apiKey=${process.env.API_KEY}&chainId=${Number( - data.invalid_mumbai_chainid, - )}`; // invalid ChainID in queryString - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - // 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); - } - - // 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_pimlico_paymasterAddress_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_pimlico_paymasterAddress_1); - } - - /* estimate transactions added to the batch and get the fee data for the UserOp - validUntil and validAfter are optional defaults to 10 mins of expiry from send call and should be passed in terms of milliseconds - For example purpose, the valid is fixed as expiring in 100 mins once the paymaster data is generated - validUntil and validAfter is relevant only with sponsor transactions and not for token paymasters - */ - - // estimate transactions added to the batch and get the fee data for the UserOp - try { - await mumbaiTestNetSdk.estimate({ - paymasterDetails: { - url: `${arka_url}${invalid_queryString}`, - context: { - mode: 'sponsor', - validAfter: new Date().valueOf(), - validUntil: new Date().valueOf() + 6000000, - }, - } - }); - - addContext(test, message.fail_estimateTransaction_7) - assert.fail(message.fail_estimateTransaction_7); - } catch (e) { - let errorMessage = e.message; - if (errorMessage.includes(constant.invalid_network_3)) { - addContext(test, message.vali_estimateTransaction_6) - console.log(message.vali_estimateTransaction_6); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_estimateTransaction_7); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.pimlocoPaymaster_insufficientBalance); - } - }); - - it('REGRESSION: Perform the transfer token on arka paymaster with validUntil and validAfter without ChainID on the mumbai network', async function () { - var test = this; - let arka_url = data.paymaster_arka; - let invalid_queryString = `?apiKey=${process.env.API_KEY}`; // without ChainID in queryString - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - // 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); - } - - // 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_pimlico_paymasterAddress_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_pimlico_paymasterAddress_1); - } - - /* estimate transactions added to the batch and get the fee data for the UserOp - validUntil and validAfter are optional defaults to 10 mins of expiry from send call and should be passed in terms of milliseconds - For example purpose, the valid is fixed as expiring in 100 mins once the paymaster data is generated - validUntil and validAfter is relevant only with sponsor transactions and not for token paymasters - */ - - // estimate transactions added to the batch and get the fee data for the UserOp - try { - await mumbaiTestNetSdk.estimate({ - paymasterDetails: { - url: `${arka_url}${invalid_queryString}`, - context: { - mode: 'sponsor', - validAfter: new Date().valueOf(), - validUntil: new Date().valueOf() + 6000000, - }, - } - }); - - addContext(test, message.fail_estimateTransaction_8) - assert.fail(message.fail_estimateTransaction_8); - } catch (e) { - let errorMessage = e.message; - if (errorMessage.includes(constant.invalid_data)) { - addContext(test, message.vali_estimateTransaction_7) - console.log(message.vali_estimateTransaction_7); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_estimateTransaction_8); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.pimlocoPaymaster_insufficientBalance); - } - }); - - it('REGRESSION: Validate the get token paymaster address function of the arka paymaster with incorrect token on the mumbai network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - - // validate the get token paymaster address - try { - await arkaPaymaster.getTokenPaymasterAddress(data.invalid_usdc_token); - - addContext(test, message.fail_getTokenPaymasterAddress_2) - assert.fail(message.fail_getTokenPaymasterAddress_2) - } catch (e) { - let errorMessage = e.message; - if (errorMessage.includes(constant.invalid_network_1)) { - addContext(test, message.vali_getTokenPaymasterAddress_1); - console.log(message.vali_getTokenPaymasterAddress_1); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_getTokenPaymasterAddress_2); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.arkaFunction_insufficientBalance); - } - }); - - it('REGRESSION: Validate the get token paymaster address function of the arka paymaster without token on the mumbai network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - - // validate the get token paymaster address - try { - await arkaPaymaster.getTokenPaymasterAddress(); - - addContext(test, message.fail_getTokenPaymasterAddress_3) - assert.fail(message.fail_getTokenPaymasterAddress_3) - } catch (e) { - let errorMessage = e.message; - if (errorMessage.includes(constant.invalid_data)) { - addContext(test, message.vali_getTokenPaymasterAddress_2); - console.log(message.vali_getTokenPaymasterAddress_2); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_getTokenPaymasterAddress_3); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.arkaFunction_insufficientBalance); - } - }); - - it('REGRESSION: Validate the remove whitelist address function of the arka paymaster with invalid address on the mumbai network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - - // validate the remove whitelist address - try { - await arkaPaymaster.removeWhitelist([data.invalidSender]); - - addContext(test, message.fail_removeWhitelist_3) - assert.fail(message.fail_removeWhitelist_3); - } catch (e) { - let errorMessage = e.message; - if (errorMessage.includes(constant.invalid_address_5)) { - addContext(test, message.vali_removeWhitelist_3); - console.log(message.vali_removeWhitelist_3); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_removeWhitelist_3); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.arkaFunction_insufficientBalance); - } - }); - - it('REGRESSION: Validate the remove whitelist address function of the arka paymaster with incorrect address on the mumbai network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - - // validate the remove whitelist address - try { - await arkaPaymaster.removeWhitelist([data.incorrectSender]); - - addContext(test, message.fail_removeWhitelist_4) - assert.fail(message.fail_removeWhitelist_4); - } catch (e) { - let errorMessage = e.message; - if (errorMessage.includes(constant.invalid_address_5)) { - addContext(test, message.vali_removeWhitelist_4); - console.log(message.vali_removeWhitelist_4); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_removeWhitelist_4); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.arkaFunction_insufficientBalance); - } - }); - - it('REGRESSION: Validate the remove whitelist address function of the arka paymaster with random address on the mumbai network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - - // validate the remove whitelist address - try { - const randomAddress = ethers.Wallet.createRandom(); - await arkaPaymaster.removeWhitelist([randomAddress.address]); - - addContext(test, message.fail_removeWhitelist_5) - assert.fail(message.fail_removeWhitelist_5); - } catch (e) { - let errorMessage = e.message; - if (errorMessage.includes(constant.remove_whitelist_1)) { - addContext(test, message.vali_removeWhitelist_2); - console.log(message.vali_removeWhitelist_2); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_removeWhitelist_2); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.arkaFunction_insufficientBalance); - } - }); - - it('REGRESSION: Validate the remove whitelist address function of the arka paymaster with random and whitelisted addresses on the mumbai network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - - // validate the remove whitelist address - try { - const randomAddress = ethers.Wallet.createRandom(); - await arkaPaymaster.removeWhitelist([randomAddress.address, data.sender]); - - addContext(test, message.fail_removeWhitelist_5) - assert.fail(message.fail_removeWhitelist_5); - } catch (e) { - let errorMessage = e.message; - if (errorMessage.includes(constant.remove_whitelist_1)) { - addContext(test, message.vali_removeWhitelist_2); - console.log(message.vali_removeWhitelist_2); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_removeWhitelist_2); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.arkaFunction_insufficientBalance); - } - }); - - it('REGRESSION: Validate the remove whitelist address function of the arka paymaster with multiple whitelisted addresses on the mumbai network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - - // validate the remove whitelist address - try { - const randomAddress1 = ethers.Wallet.createRandom(); - const randomAddress2 = ethers.Wallet.createRandom(); - - // make whitelisted addresses - await arkaPaymaster.addWhitelist([randomAddress1.address, randomAddress2.address]); - - // remove whitelist addresses - let removewhitelist = await arkaPaymaster.removeWhitelist([randomAddress1.address, randomAddress2.address]); - - if (removewhitelist.includes(constant.remove_whitelist_2)) { - addContext(test, message.vali_removeWhitelist_1); - console.log(message.vali_removeWhitelist_1); - } else { - addContext(test, message.fail_removeWhitelist_1); - assert.fail(message.fail_removeWhitelist_1); - } - } catch (e) { - let errorMessage = e.message; - if (errorMessage.includes(constant.remove_whitelist_1)) { - addContext(test, message.vali_removeWhitelist_2); - console.log(message.vali_removeWhitelist_2); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_removeWhitelist_2); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.arkaFunction_insufficientBalance); - } - }); - - it('REGRESSION: Validate the remove whitelist address function of the arka paymaster with multiple random addresses on the mumbai network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - - // validate the remove whitelist address - try { - const randomAddress1 = ethers.Wallet.createRandom(); - const randomAddress2 = ethers.Wallet.createRandom(); - await arkaPaymaster.removeWhitelist([randomAddress1.address, randomAddress2.address]); - - addContext(test, message.fail_removeWhitelist_6) - assert.fail(message.fail_removeWhitelist_6); - } catch (e) { - let errorMessage = e.message; - if (errorMessage.includes(constant.remove_whitelist_1)) { - addContext(test, message.vali_removeWhitelist_2); - console.log(message.vali_removeWhitelist_2); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_removeWhitelist_2); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.arkaFunction_insufficientBalance); - } - }); - - it('REGRESSION: Validate the add whitelist address function of the arka paymaster with invalid address on the mumbai network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - - // validate the add whitelist address - try { - await arkaPaymaster.addWhitelist([data.invalidSender]); - - addContext(test, message.fail_addWhitelist_3) - assert.fail(message.fail_addWhitelist_3); - } catch (e) { - let errorMessage = e.message; - if (errorMessage.includes(constant.invalid_address_5)) { - addContext(test, message.vali_addWhitelist_3); - console.log(message.vali_addWhitelist_3); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_addWhitelist_3); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.arkaFunction_insufficientBalance); - } - }); - - it('REGRESSION: Validate the add whitelist address function of the arka paymaster with incorrect address on the mumbai network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - - // validate the add whitelist address - try { - await arkaPaymaster.addWhitelist([data.incorrectSender]); - - addContext(test, message.fail_addWhitelist_4) - assert.fail(message.fail_addWhitelist_4); - } catch (e) { - let errorMessage = e.message; - if (errorMessage.includes(constant.invalid_address_5)) { - addContext(test, message.vali_addWhitelist_4); - console.log(message.vali_addWhitelist_4); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_addWhitelist_4); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.arkaFunction_insufficientBalance); - } - }); - - it('REGRESSION: Validate the add whitelist address function of the arka paymaster with random address on the mumbai network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - - // validate the add whitelist address - try { - const randomAddress = ethers.Wallet.createRandom(); - let addwhitelist = await arkaPaymaster.addWhitelist([randomAddress.address]); - - if (addwhitelist.includes(constant.add_whitelist_3)) { - addContext(test, message.vali_addWhitelist_5); - console.log(message.vali_addWhitelist_5); - } else { - addContext(test, message.fail_addWhitelist_7); - assert.fail(message.fail_addWhitelist_7); - } - } catch (e) { - let errorMessage = e.message; - if (errorMessage.includes(constant.add_whitelist_2)) { - addContext(test, message.vali_addWhitelist_2); - console.log(message.vali_addWhitelist_2); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_addWhitelist_2); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.arkaFunction_insufficientBalance); - } - }); - - it('REGRESSION: Validate the add whitelist address function of the arka paymaster with random and whitelisted addresses on the mumbai network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - - // validate the add whitelist address - try { - const randomAddress = ethers.Wallet.createRandom(); - await arkaPaymaster.addWhitelist([randomAddress.address, data.sender]); - - if (addWhitelist.includes(constant.add_whitelist_3)) { - addContext(test, message.vali_addWhitelist_1); - console.log(message.vali_addWhitelist_1); - } else { - addContext(test, message.fail_addWhitelist_1); - assert.fail(message.fail_addWhitelist_1); - } - } catch (e) { - let errorMessage = e.message; - if (errorMessage.includes(constant.add_whitelist_2)) { - addContext(test, message.vali_addWhitelist_2); - console.log(message.vali_addWhitelist_2); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_addWhitelist_2); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.arkaFunction_insufficientBalance); - } - }); - - it('REGRESSION: Validate the add whitelist address function of the arka paymaster with multiple whitelisted addresses on the mumbai network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - - // validate the add whitelist address - try { - const randomAddress1 = ethers.Wallet.createRandom(); - const randomAddress2 = ethers.Wallet.createRandom(); - - // add whitelist addresses - let addwhitelist = await arkaPaymaster.addWhitelist([randomAddress1.address, randomAddress2.address]); - - if (addwhitelist.includes(constant.add_whitelist_3)) { - addContext(test, message.vali_addWhitelist_1); - console.log(message.vali_addWhitelist_1); - } else { - addContext(test, message.fail_addWhitelist_1); - assert.fail(message.fail_addWhitelist_1); - } - } catch (e) { - let errorMessage = e.message; - if (errorMessage.includes(constant.add_whitelist_2)) { - addContext(test, message.vali_addWhitelist_2); - console.log(message.vali_addWhitelist_2); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_addWhitelist_2); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.arkaFunction_insufficientBalance); - } - }); - - it('REGRESSION: Validate the check whitelist function of the arka paymaster with invalid address on the mumbai network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - - // validate the whilelist address - try { - await arkaPaymaster.checkWhitelist(data.invalidSender); - - addContext(test, message.fail_checkWhitelist_2) - assert.fail(message.fail_checkWhitelist_2) - } catch (e) { - let errorMessage = e.message; - if (errorMessage.includes(constant.invalid_address_5)) { - addContext(test, message.vali_checkWhitelist_1); - console.log(message.vali_checkWhitelist_1); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_checkWhitelist_2); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.arkaFunction_insufficientBalance); - } - }); - - it('REGRESSION: Validate the check whitelist function of the arka paymaster with incorrect address on the mumbai network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - - // validate the whilelist address - try { - await arkaPaymaster.checkWhitelist(data.invalidSender); - - addContext(test, message.fail_checkWhitelist_3) - assert.fail(message.fail_checkWhitelist_3) - } catch (e) { - let errorMessage = e.message; - if (errorMessage.includes(constant.invalid_address_5)) { - addContext(test, message.vali_checkWhitelist_2); - console.log(message.vali_checkWhitelist_2); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_checkWhitelist_2); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.arkaFunction_insufficientBalance); - } - }); - - it('REGRESSION: Validate the check whitelist function of the arka paymaster with random address on the mumbai network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - - // validate the whilelist address - try { - const randomAddress = ethers.Wallet.createRandom(); - let checkwhitelist = await arkaPaymaster.checkWhitelist(randomAddress.address); - - if (checkwhitelist.includes(constant.check_whitelist_1)) { - addContext(test, message.vali_addWhitelist_2); - console.log(message.vali_addWhitelist_2); - } else if (checkwhitelist.includes(constant.check_whitelist_2)) { - addContext(test, message.vali_removeWhitelist_2); - console.log(message.vali_removeWhitelist_2); - } - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_checkWhitelist_4); - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.arkaFunction_insufficientBalance); - } - }); - - it('REGRESSION: Validate the check whitelist function of the arka paymaster without address on the mumbai network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - - // validate the whilelist address - try { - await arkaPaymaster.checkWhitelist(); - - addContext(test, message.fail_checkWhitelist_5) - assert.fail(message.fail_checkWhitelist_5); - } catch (e) { - let errorMessage = e.message; - if (errorMessage.includes(constant.invalid_address_5)) { - addContext(test, message.vali_checkWhitelist_3); - console.log(message.vali_checkWhitelist_3); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_checkWhitelist_5); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.arkaFunction_insufficientBalance); - } - }); - - it('REGRESSION: Validate the deposit function of the arka paymaster with invalid amount on the mumbai network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - - // validate the deposit - try { - await arkaPaymaster.deposit("one"); - - addContext(test, message.fail_deposit_3) - assert.fail(message.fail_deposit_3) - } catch (e) { - let errorMessage = e.message; - if (errorMessage.includes(constant.invalid_data)) { - addContext(test, message.vali_deposit_2); - console.log(message.vali_deposit_2); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_deposit_3); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.arkaFunction_insufficientBalance); - } - }); -}); diff --git a/test/specs/testnet/transactionHistory/goerli.spec.js b/test/specs/testnet/transactionHistory/goerli.spec.js deleted file mode 100644 index 45a0a9c..0000000 --- a/test/specs/testnet/transactionHistory/goerli.spec.js +++ /dev/null @@ -1,1684 +0,0 @@ -import * as dotenv from 'dotenv'; -dotenv.config(); // init dotenv -import { PrimeSdk, DataUtils } from '@etherspot/prime-sdk'; -import { ethers, utils, providers } from 'ethers'; -import { ERC20_ABI } from '@etherspot/prime-sdk/dist/sdk/helpers/abi/ERC20_ABI.js'; -import { assert } from 'chai'; -import addContext from 'mochawesome/addContext.js'; -import helper from '../../../utils/helper.js'; -import customRetryAsync from '../../../utils/baseTest.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, when get the single transaction and multiple transaction details 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 transaction history of the native token transaction 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); - } - - // get single transaction history details - let transactionHash; - let singleTransaction; - - if (!(userOpsReceipt === null)) { - try { - transactionHash = userOpsReceipt.receipt.transactionHash; - singleTransaction = await goerliDataService.getTransaction({ - hash: transactionHash, - chainId: Number(data.goerli_chainid), - }); - - try { - assert.isNumber( - singleTransaction.chainId, - message.vali_getTransaction_chainId); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - singleTransaction.hash, - message.vali_getTransaction_hash); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNumber( - singleTransaction.nonce, - message.vali_getTransaction_nonce); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - singleTransaction.blockHash, - message.vali_getTransaction_blockHash); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNumber( - singleTransaction.blockNumber, - message.vali_getTransaction_blockNumber); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - singleTransaction.from, - message.vali_getTransaction_from); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - singleTransaction.to, - message.vali_getTransaction_to); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - singleTransaction.value, - message.vali_getTransaction_value); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - singleTransaction.gasPrice, - message.vali_getTransaction_gasPrice); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNumber( - singleTransaction.gasLimit, - message.vali_getTransaction_gasLimit); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - singleTransaction.input, - message.vali_getTransaction_input); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - singleTransaction.status, - message.vali_getTransaction_status); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - singleTransaction.blockExplorerUrl, - message.vali_getTransaction_blockExplorerUrl); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNumber( - singleTransaction.transactionIndex, - message.vali_getTransaction_transactionIndex); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNumber( - singleTransaction.gasUsed, - message.vali_getTransaction_gasUsed); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNumber( - singleTransaction.logs[0].transactionIndex, - message.vali_getTransaction_log_transactionIndex); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNumber( - singleTransaction.logs[0].blockNumber, - message.vali_getTransaction_log_blockNumber); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - singleTransaction.logs[0].transactionHash, - message.vali_getTransaction_log_transactionHash); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - singleTransaction.logs[0].address, - message.vali_getTransaction_log_address); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - singleTransaction.logs[0].topics, - message.vali_getTransaction_log_topics); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - singleTransaction.logs[0].data, - message.vali_getTransaction_log_data); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNumber( - singleTransaction.logs[0].logIndex, - message.vali_getTransaction_log_logIndex); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - singleTransaction.logs[0].blockHash, - message.vali_getTransaction_log_blockHash); - } 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_getTransaction_1); - } - } else { - addContext(test, message.vali_getTransaction_1) - console.log(message.vali_getTransaction_1); - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.getTransaction_insufficientBalance); - } - }); - - it('SMOKE: Validate the get transactions history response with random transaction in goerli network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - // Fetching historical transactions - let transactions; - let randomTransaction; - - try { - transactions = await goerliDataService.getTransactions({ - chainId: Number(data.goerli_chainid), - account: data.sender - }); - - randomTransaction = - Math.floor(Math.random() * (transactions.transactions.length - 1)) + 1; - - try { - assert.isNumber( - transactions.transactions[randomTransaction].chainId, - message.vali_getTransactions_chainId); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[randomTransaction].sender, - message.vali_getTransactions_sender); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[randomTransaction].transactionHash, - message.vali_getTransactions_transactionHash); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[randomTransaction].userOpHash, - message.vali_getTransactions_userOpHash); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNumber( - transactions.transactions[randomTransaction].actualGasCost, - message.vali_getTransactions_actualGasCost); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNumber( - transactions.transactions[randomTransaction].actualGasUsed, - message.vali_getTransactions_actualGasUsed); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[randomTransaction].success, - message.vali_getTransactions_success); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNumber( - transactions.transactions[randomTransaction].timestamp, - message.vali_getTransactions_timestamp); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[randomTransaction].paymaster, - message.vali_getTransactions_paymaster); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNumber( - transactions.transactions[randomTransaction].value, - message.vali_getTransactions_value); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[randomTransaction].blockExplorerUrl, - message.vali_getTransactions_blockExplorerUrl); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[randomTransaction].input, - message.vali_getTransactions_input); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNumber( - transactions.transactions[randomTransaction].nonce, - message.vali_getTransactions_nonce); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[randomTransaction].initCode, - message.vali_getTransactions_initCode); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[randomTransaction].callData, - message.vali_getTransactions_callData); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[randomTransaction].verificationGasLimit, - message.vali_getTransactions_verificationGasLimit); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[randomTransaction].preVerificationGas, - message.vali_getTransactions_preVerificationGas); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[randomTransaction].maxFeePerGas, - message.vali_getTransactions_maxFeePerGas); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[randomTransaction].maxPriorityFeePerGas, - message.vali_getTransactions_maxPriorityFeePerGas); - } 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_getTransactions_1); - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.getTransaction_insufficientBalance); - } - }); - - it('SMOKE: Validate the get transactions history response of the native transaction in 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); - } - - // wait for the 10 seconds - helper.wait(10000) - - // Fetching historical transactions - let transactions; - try { - transactions = await goerliDataService.getTransactions({ - chainId: Number(data.goerli_chainid), - account: data.sender, - page: 1, - limit: 10 - }); - - if (userOpsReceipt != null) { - try { - assert.isNumber( - transactions.transactions[0].chainId, - message.vali_getTransactions_chainId); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNumber( - transactions.transactions[0].blockNumber, - message.vali_getTransactions_blockNumber); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[0].sender, - message.vali_getTransactions_sender); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[0].target, - message.vali_getTransactions_target); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[0].transactionHash, - message.vali_getTransactions_transactionHash); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[0].userOpHash, - message.vali_getTransactions_userOpHash); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNumber( - transactions.transactions[0].actualGasCost, - message.vali_getTransactions_actualGasCost); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNumber( - transactions.transactions[0].actualGasUsed, - message.vali_getTransactions_actualGasUsed); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[0].success, - message.vali_getTransactions_success); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNumber( - transactions.transactions[0].timestamp, - message.vali_getTransactions_timestamp); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[0].paymaster, - message.vali_getTransactions_paymaster); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNumber( - transactions.transactions[0].value, - message.vali_getTransactions_value); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[0].blockExplorerUrl, - message.vali_getTransactions_blockExplorerUrl); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[0].input, - message.vali_getTransactions_input); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNumber( - transactions.transactions[0].nonce, - message.vali_getTransactions_nonce); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[0].initCode, - message.vali_getTransactions_initCode); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[0].callData, - message.vali_getTransactions_callData); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[0].verificationGasLimit, - message.vali_getTransactions_verificationGasLimit); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[0].preVerificationGas, - 'The preVerificationGas value is empty in the get transactions response.'); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[0].maxFeePerGas, - message.vali_getTransactions_maxFeePerGas); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[0].maxPriorityFeePerGas, - message.vali_getTransactions_maxPriorityFeePerGas); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[0].maxPriorityFeePerGas, - message.vali_getTransactions_maxPriorityFeePerGas); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[0].nativeTransfers[0].from, - message.vali_getTransactions_nativeTransfers_from); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[0].nativeTransfers[0].to, - message.vali_getTransactions_nativeTransfers_to); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[0].nativeTransfers[0].value, - message.vali_getTransactions_nativeTransfers_value); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[0].nativeTransfers[0].asset, - message.vali_getTransactions_nativeTransfers_asset); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[0].nativeTransfers[0].address, - message.vali_getTransactions_nativeTransfers_address); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNumber( - transactions.transactions[0].nativeTransfers[0].decimal, - message.vali_getTransactions_nativeTransfers_decimal); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[0].nativeTransfers[0].data, - message.vali_getTransactions_nativeTransfers_data); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - } else { - addContext(test, message.vali_getTransactions_1) - console.log(message.vali_getTransactions_1) - } - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_getTransactions_1); - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.getTransaction_insufficientBalance); - } - }); - - it('SMOKE: Validate the get transactions history response of the erc20 transaction in goerli network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - // get the respective provider details - let provider; - try { - provider = new ethers.providers.JsonRpcProvider( - data.providerNetwork_goerli); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_getTransactions_2); - } - - // get erc20 Contract Interface - let erc20Instance; - try { - erc20Instance = new ethers.Contract( - data.tokenAddress_goerliUSDC, - ERC20_ABI, - provider); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_getTransactions_3); - } - - // get decimals from erc20 contract - let decimals; - try { - decimals = await erc20Instance.functions.decimals(); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_getTransactions_4); - } - - // get transfer From encoded data - let transactionData; - try { - transactionData = erc20Instance.interface.encodeFunctionData( - 'transfer', - [data.recipient, ethers.utils.parseUnits(data.erc20_value, decimals)]); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_getTransactions_5); - } - - // 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 - let userOpsBatch; - try { - userOpsBatch = await goerliTestNetSdk.addUserOpsToBatch({ - to: data.tokenAddress_goerliUSDC, - data: transactionData, - }); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_clearTransaction_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); - } - - // wait for the 10 seconds - helper.wait(10000) - - // Fetching historical transactions - let transactions; - try { - transactions = await goerliDataService.getTransactions({ - chainId: Number(data.goerli_chainid), - account: data.sender, - page: 1, - limit: 10 - }); - - if (userOpsReceipt != null) { - try { - assert.isNumber( - transactions.transactions[0].chainId, - message.vali_getTransactions_chainId); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNumber( - transactions.transactions[0].blockNumber, - message.vali_getTransactions_blockNumber); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[0].sender, - message.vali_getTransactions_sender); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[0].target, - message.vali_getTransactions_target); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[0].transactionHash, - message.vali_getTransactions_transactionHash); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[0].userOpHash, - message.vali_getTransactions_userOpHash); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNumber( - transactions.transactions[0].actualGasCost, - message.vali_getTransactions_actualGasCost); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNumber( - transactions.transactions[0].actualGasUsed, - message.vali_getTransactions_actualGasUsed); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[0].success, - message.vali_getTransactions_success); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNumber( - transactions.transactions[0].timestamp, - message.vali_getTransactions_timestamp); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[0].paymaster, - message.vali_getTransactions_paymaster); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNumber( - transactions.transactions[0].value, - message.vali_getTransactions_value); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[0].blockExplorerUrl, - message.vali_getTransactions_blockExplorerUrl); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[0].input, - message.vali_getTransactions_input); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNumber( - transactions.transactions[0].nonce, - message.vali_getTransactions_nonce); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[0].initCode, - message.vali_getTransactions_initCode); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[0].callData, - message.vali_getTransactions_callData); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[0].verificationGasLimit, - message.vali_getTransactions_verificationGasLimit); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[0].preVerificationGas, - message.vali_getTransactions_preVerificationGas); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[0].maxFeePerGas, - message.vali_getTransactions_maxFeePerGas); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[0].maxPriorityFeePerGas, - message.vali_getTransactions_maxPriorityFeePerGas); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[0].maxPriorityFeePerGas, - message.vali_getTransactions_maxPriorityFeePerGas); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[0].erc20Transfers[0].from, - message.vali_getTransactions_erc20Transfers_from); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[0].erc20Transfers[0].to, - message.vali_getTransactions_erc20Transfers_to); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[0].erc20Transfers[0].value, - message.vali_getTransactions_erc20Transfers_value); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[0].erc20Transfers[0].asset, - message.vali_getTransactions_erc20Transfers_asset); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[0].erc20Transfers[0].address, - message.vali_getTransactions_erc20Transfers_address); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNumber( - transactions.transactions[0].erc20Transfers[0].decimal, - message.vali_getTransactions_erc20Transfers_decimal); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[0].erc20Transfers[0].data, - message.vali_getTransactions_erc20Transfers_data); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - } else { - addContext(test, message.vali_getTransactions_1) - console.log(message.vali_getTransactions_1) - } - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_getTransactions_1); - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.getTransaction_insufficientBalance); - } - }); - - it('REGRESSION: Validate the get transaction history response with invalid hash on goerli network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - // Fetching a single transaction - let transaction; - try { - transaction = await goerliDataService.getTransaction({ - hash: data.incorrect_hash, // Incorrect Transaction Hash - chainId: Number(data.goerli_chainid), - }); - - if (transaction === null || Object.keys(transaction).length === 0) { - addContext(test, message.vali_getTransactions_2) - console.log(message.vali_getTransactions_2); - } else { - addContext(test, message.fail_getTransactions_6); - assert.fail(message.fail_getTransactions_6); - } - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_getTransactions_6); - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.getTransaction_insufficientBalance); - } - }); - - it('REGRESSION: Validate the get transaction history response when hash hex is not with 32 size on goerli network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - // Fetching a single transaction - try { - await goerliDataService.getTransaction({ - hash: data.invalid_hash, // Invalid Transaction Hash - chainId: Number(data.goerli_chainid), - }); - - addContext(test, message.fail_getTransactions_7) - assert.fail(message.fail_getTransactions_7); - } catch (e) { - if (e.errors[0].constraints.isHex === constant.hash_32) { - addContext(test, message.vali_getTransactions_3) - console.log(message.vali_getTransactions_3); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_getTransactions_7); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.getTransaction_insufficientBalance); - } - }); - - it('REGRESSION: Validate the get transactions history response with invalid chainid in goerli network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - try { - let transactions = await goerliDataService.getTransactions({ - chainId: Number(data.invalid_goerli_chainid), - account: data.sender, - }); - - if (transactions.transactions.length === 0) { - addContext(test, message.vali_getTransactions_4) - console.log(message.vali_getTransactions_4); - } else { - addContext(test, message.fail_getTransactions_8); - assert.fail(message.fail_getTransactions_8); - } - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_getTransactions_1); - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.getTransaction_insufficientBalance); - } - }); - - it('REGRESSION: Validate the get transactions history response with invalid account in goerli network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - try { - let a = await goerliDataService.getTransactions({ - chainId: Number(data.goerli_chainid), - account: data.invalidSender, - }); - - addContext(test, message.fail_getTransactions_10) - assert.fail(message.fail_getTransactions_10); - } catch (e) { - const errorResponse = JSON.parse(e.message); - if (errorResponse[0].constraints.isAddress === constant.invalid_address_1) { - addContext(test, message.vali_getTransactions_6) - console.log(message.vali_getTransactions_6); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_getTransactions_10); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.getTransaction_insufficientBalance); - } - }); - - it('REGRESSION: Validate the get transactions history response with incorrect account in goerli network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - try { - await goerliDataService.getTransactions({ - chainId: Number(data.goerli_chainid), - account: data.incorrectSender, - }); - - addContext(test, message.fail_getTransactions_11) - assert.fail(message.fail_getTransactions_11); - } catch (e) { - const errorResponse = JSON.parse(e.message); - if (errorResponse[0].constraints.isAddress === constant.invalid_address_1) { - addContext(test, message.vali_getTransactions_7) - console.log(message.vali_getTransactions_7); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_getTransactions_11); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.getTransaction_insufficientBalance); - } - }); -}); diff --git a/test/specs/testnet/transactionHistory/mumbai.spec.js b/test/specs/testnet/transactionHistory/mumbai.spec.js deleted file mode 100644 index 66c38ce..0000000 --- a/test/specs/testnet/transactionHistory/mumbai.spec.js +++ /dev/null @@ -1,1684 +0,0 @@ -import * as dotenv from 'dotenv'; -dotenv.config(); // init dotenv -import { PrimeSdk, DataUtils } from '@etherspot/prime-sdk'; -import { ethers, utils, providers } from 'ethers'; -import { ERC20_ABI } from '@etherspot/prime-sdk/dist/sdk/helpers/abi/ERC20_ABI.js'; -import { assert } from 'chai'; -import addContext from 'mochawesome/addContext.js'; -import helper from '../../../utils/helper.js'; -import customRetryAsync from '../../../utils/baseTest.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, when get the single transaction and multiple transaction details 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 transaction history of the native token transaction 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); - } - - // get single transaction history details - let transactionHash; - let singleTransaction; - - if (!(userOpsReceipt === null)) { - try { - transactionHash = userOpsReceipt.receipt.transactionHash; - singleTransaction = await mumbaiDataService.getTransaction({ - hash: transactionHash, - chainId: Number(data.mumbai_chainid), - }); - - try { - assert.isNumber( - singleTransaction.chainId, - message.vali_getTransaction_chainId); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - singleTransaction.hash, - message.vali_getTransaction_hash); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNumber( - singleTransaction.nonce, - message.vali_getTransaction_nonce); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - singleTransaction.blockHash, - message.vali_getTransaction_blockHash); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNumber( - singleTransaction.blockNumber, - message.vali_getTransaction_blockNumber); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - singleTransaction.from, - message.vali_getTransaction_from); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - singleTransaction.to, - message.vali_getTransaction_to); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - singleTransaction.value, - message.vali_getTransaction_value); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - singleTransaction.gasPrice, - message.vali_getTransaction_gasPrice); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNumber( - singleTransaction.gasLimit, - message.vali_getTransaction_gasLimit); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - singleTransaction.input, - message.vali_getTransaction_input); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - singleTransaction.status, - message.vali_getTransaction_status); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - singleTransaction.blockExplorerUrl, - message.vali_getTransaction_blockExplorerUrl); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNumber( - singleTransaction.transactionIndex, - message.vali_getTransaction_transactionIndex); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNumber( - singleTransaction.gasUsed, - message.vali_getTransaction_gasUsed); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNumber( - singleTransaction.logs[0].transactionIndex, - message.vali_getTransaction_log_transactionIndex); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNumber( - singleTransaction.logs[0].blockNumber, - message.vali_getTransaction_log_blockNumber); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - singleTransaction.logs[0].transactionHash, - message.vali_getTransaction_log_transactionHash); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - singleTransaction.logs[0].address, - message.vali_getTransaction_log_address); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - singleTransaction.logs[0].topics, - message.vali_getTransaction_log_topics); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - singleTransaction.logs[0].data, - message.vali_getTransaction_log_data); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNumber( - singleTransaction.logs[0].logIndex, - message.vali_getTransaction_log_logIndex); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - singleTransaction.logs[0].blockHash, - message.vali_getTransaction_log_blockHash); - } 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_getTransaction_1); - } - } else { - addContext(test, message.vali_getTransaction_1) - console.log(message.vali_getTransaction_1); - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.getTransaction_insufficientBalance); - } - }); - - it('SMOKE: Validate the get transactions history response with random transaction in mumbai network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - // Fetching historical transactions - let transactions; - let randomTransaction; - - try { - transactions = await mumbaiDataService.getTransactions({ - chainId: Number(data.mumbai_chainid), - account: data.sender - }); - - randomTransaction = - Math.floor(Math.random() * (transactions.transactions.length - 1)) + 1; - - try { - assert.isNumber( - transactions.transactions[randomTransaction].chainId, - message.vali_getTransactions_chainId); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[randomTransaction].sender, - message.vali_getTransactions_sender); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[randomTransaction].transactionHash, - message.vali_getTransactions_transactionHash); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[randomTransaction].userOpHash, - message.vali_getTransactions_userOpHash); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNumber( - transactions.transactions[randomTransaction].actualGasCost, - message.vali_getTransactions_actualGasCost); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNumber( - transactions.transactions[randomTransaction].actualGasUsed, - message.vali_getTransactions_actualGasUsed); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[randomTransaction].success, - message.vali_getTransactions_success); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNumber( - transactions.transactions[randomTransaction].timestamp, - message.vali_getTransactions_timestamp); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[randomTransaction].paymaster, - message.vali_getTransactions_paymaster); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNumber( - transactions.transactions[randomTransaction].value, - message.vali_getTransactions_value); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[randomTransaction].blockExplorerUrl, - message.vali_getTransactions_blockExplorerUrl); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[randomTransaction].input, - message.vali_getTransactions_input); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNumber( - transactions.transactions[randomTransaction].nonce, - message.vali_getTransactions_nonce); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[randomTransaction].initCode, - message.vali_getTransactions_initCode); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[randomTransaction].callData, - message.vali_getTransactions_callData); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[randomTransaction].verificationGasLimit, - message.vali_getTransactions_verificationGasLimit); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[randomTransaction].preVerificationGas, - message.vali_getTransactions_preVerificationGas); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[randomTransaction].maxFeePerGas, - message.vali_getTransactions_maxFeePerGas); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[randomTransaction].maxPriorityFeePerGas, - message.vali_getTransactions_maxPriorityFeePerGas); - } 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_getTransactions_1); - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.getTransaction_insufficientBalance); - } - }); - - it('SMOKE: Validate the get transactions history response of the native transaction in 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); - } - - // wait for the 10 seconds - helper.wait(10000) - - // Fetching historical transactions - let transactions; - try { - transactions = await mumbaiDataService.getTransactions({ - chainId: Number(data.mumbai_chainid), - account: data.sender, - page: 1, - limit: 10 - }); - - if (userOpsReceipt != null) { - try { - assert.isNumber( - transactions.transactions[0].chainId, - message.vali_getTransactions_chainId); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNumber( - transactions.transactions[0].blockNumber, - message.vali_getTransactions_blockNumber); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[0].sender, - message.vali_getTransactions_sender); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[0].target, - message.vali_getTransactions_target); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[0].transactionHash, - message.vali_getTransactions_transactionHash); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[0].userOpHash, - message.vali_getTransactions_userOpHash); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNumber( - transactions.transactions[0].actualGasCost, - message.vali_getTransactions_actualGasCost); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNumber( - transactions.transactions[0].actualGasUsed, - message.vali_getTransactions_actualGasUsed); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[0].success, - message.vali_getTransactions_success); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNumber( - transactions.transactions[0].timestamp, - message.vali_getTransactions_timestamp); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[0].paymaster, - message.vali_getTransactions_paymaster); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNumber( - transactions.transactions[0].value, - message.vali_getTransactions_value); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[0].blockExplorerUrl, - message.vali_getTransactions_blockExplorerUrl); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[0].input, - message.vali_getTransactions_input); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNumber( - transactions.transactions[0].nonce, - message.vali_getTransactions_nonce); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[0].initCode, - message.vali_getTransactions_initCode); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[0].callData, - message.vali_getTransactions_callData); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[0].verificationGasLimit, - message.vali_getTransactions_verificationGasLimit); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[0].preVerificationGas, - 'The preVerificationGas value is empty in the get transactions response.'); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[0].maxFeePerGas, - message.vali_getTransactions_maxFeePerGas); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[0].maxPriorityFeePerGas, - message.vali_getTransactions_maxPriorityFeePerGas); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[0].maxPriorityFeePerGas, - message.vali_getTransactions_maxPriorityFeePerGas); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[0].nativeTransfers[0].from, - message.vali_getTransactions_nativeTransfers_from); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[0].nativeTransfers[0].to, - message.vali_getTransactions_nativeTransfers_to); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[0].nativeTransfers[0].value, - message.vali_getTransactions_nativeTransfers_value); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[0].nativeTransfers[0].asset, - message.vali_getTransactions_nativeTransfers_asset); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[0].nativeTransfers[0].address, - message.vali_getTransactions_nativeTransfers_address); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNumber( - transactions.transactions[0].nativeTransfers[0].decimal, - message.vali_getTransactions_nativeTransfers_decimal); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[0].nativeTransfers[0].data, - message.vali_getTransactions_nativeTransfers_data); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - } else { - addContext(test, message.vali_getTransactions_1) - console.log(message.vali_getTransactions_1) - } - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_getTransactions_1); - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.getTransaction_insufficientBalance); - } - }); - - it('SMOKE: Validate the get transactions history response of the erc20 transaction in mumbai network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - // get the respective provider details - let provider; - try { - provider = new ethers.providers.JsonRpcProvider( - data.providerNetwork_mumbai); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_getTransactions_2); - } - - // get erc20 Contract Interface - let erc20Instance; - try { - erc20Instance = new ethers.Contract( - data.tokenAddress_mumbaiUSDC, - ERC20_ABI, - provider); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_getTransactions_3); - } - - // get decimals from erc20 contract - let decimals; - try { - decimals = await erc20Instance.functions.decimals(); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_getTransactions_4); - } - - // get transfer From encoded data - let transactionData; - try { - transactionData = erc20Instance.interface.encodeFunctionData( - 'transfer', - [data.recipient, ethers.utils.parseUnits(data.erc20_value, decimals)]); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_getTransactions_5); - } - - // 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 - let userOpsBatch; - try { - userOpsBatch = await mumbaiTestNetSdk.addUserOpsToBatch({ - to: data.tokenAddress_mumbaiUSDC, - data: transactionData, - }); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_clearTransaction_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); - } - - // wait for the 10 seconds - helper.wait(10000) - - // Fetching historical transactions - let transactions; - try { - transactions = await mumbaiDataService.getTransactions({ - chainId: Number(data.mumbai_chainid), - account: data.sender, - page: 1, - limit: 10 - }); - - if (userOpsReceipt != null) { - try { - assert.isNumber( - transactions.transactions[0].chainId, - message.vali_getTransactions_chainId); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNumber( - transactions.transactions[0].blockNumber, - message.vali_getTransactions_blockNumber); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[0].sender, - message.vali_getTransactions_sender); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[0].target, - message.vali_getTransactions_target); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[0].transactionHash, - message.vali_getTransactions_transactionHash); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[0].userOpHash, - message.vali_getTransactions_userOpHash); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNumber( - transactions.transactions[0].actualGasCost, - message.vali_getTransactions_actualGasCost); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNumber( - transactions.transactions[0].actualGasUsed, - message.vali_getTransactions_actualGasUsed); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[0].success, - message.vali_getTransactions_success); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNumber( - transactions.transactions[0].timestamp, - message.vali_getTransactions_timestamp); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[0].paymaster, - message.vali_getTransactions_paymaster); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNumber( - transactions.transactions[0].value, - message.vali_getTransactions_value); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[0].blockExplorerUrl, - message.vali_getTransactions_blockExplorerUrl); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[0].input, - message.vali_getTransactions_input); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNumber( - transactions.transactions[0].nonce, - message.vali_getTransactions_nonce); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[0].initCode, - message.vali_getTransactions_initCode); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[0].callData, - message.vali_getTransactions_callData); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[0].verificationGasLimit, - message.vali_getTransactions_verificationGasLimit); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[0].preVerificationGas, - message.vali_getTransactions_preVerificationGas); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[0].maxFeePerGas, - message.vali_getTransactions_maxFeePerGas); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[0].maxPriorityFeePerGas, - message.vali_getTransactions_maxPriorityFeePerGas); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[0].maxPriorityFeePerGas, - message.vali_getTransactions_maxPriorityFeePerGas); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[0].erc20Transfers[0].from, - message.vali_getTransactions_erc20Transfers_from); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[0].erc20Transfers[0].to, - message.vali_getTransactions_erc20Transfers_to); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[0].erc20Transfers[0].value, - message.vali_getTransactions_erc20Transfers_value); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[0].erc20Transfers[0].asset, - message.vali_getTransactions_erc20Transfers_asset); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[0].erc20Transfers[0].address, - message.vali_getTransactions_erc20Transfers_address); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNumber( - transactions.transactions[0].erc20Transfers[0].decimal, - message.vali_getTransactions_erc20Transfers_decimal); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactions.transactions[0].erc20Transfers[0].data, - message.vali_getTransactions_erc20Transfers_data); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - } else { - addContext(test, message.vali_getTransactions_1) - console.log(message.vali_getTransactions_1) - } - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_getTransactions_1); - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.getTransaction_insufficientBalance); - } - }); - - it('REGRESSION: Validate the get transaction history response with invalid hash on mumbai network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - // Fetching a single transaction - let transaction; - try { - transaction = await mumbaiDataService.getTransaction({ - hash: data.incorrect_hash, // Incorrect Transaction Hash - chainId: Number(data.mumbai_chainid), - }); - - if (transaction === null || Object.keys(transaction).length === 0) { - addContext(test, message.vali_getTransactions_2) - console.log(message.vali_getTransactions_2); - } else { - addContext(test, message.fail_getTransactions_6); - assert.fail(message.fail_getTransactions_6); - } - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_getTransactions_6); - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.getTransaction_insufficientBalance); - } - }); - - it('REGRESSION: Validate the get transaction history response when hash hex is not with 32 size on mumbai network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - // Fetching a single transaction - try { - await mumbaiDataService.getTransaction({ - hash: data.invalid_hash, // Invalid Transaction Hash - chainId: Number(data.mumbai_chainid), - }); - - addContext(test, message.fail_getTransactions_7) - assert.fail(message.fail_getTransactions_7); - } catch (e) { - if (e.errors[0].constraints.isHex === constant.hash_32) { - addContext(test, message.vali_getTransactions_3) - console.log(message.vali_getTransactions_3); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_getTransactions_7); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.getTransaction_insufficientBalance); - } - }); - - it('REGRESSION: Validate the get transactions history response with invalid chainid in mumbai network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - try { - let transactions = await mumbaiDataService.getTransactions({ - chainId: Number(data.invalid_mumbai_chainid), - account: data.sender, - }); - - if (transactions.transactions.length === 0) { - addContext(test, message.vali_getTransactions_4) - console.log(message.vali_getTransactions_4); - } else { - addContext(test, message.fail_getTransactions_8); - assert.fail(message.fail_getTransactions_8); - } - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_getTransactions_1); - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.getTransaction_insufficientBalance); - } - }); - - it('REGRESSION: Validate the get transactions history response with invalid account in mumbai network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - try { - let a = await mumbaiDataService.getTransactions({ - chainId: Number(data.mumbai_chainid), - account: data.invalidSender, - }); - - addContext(test, message.fail_getTransactions_10) - assert.fail(message.fail_getTransactions_10); - } catch (e) { - const errorResponse = JSON.parse(e.message); - if (errorResponse[0].constraints.isAddress === constant.invalid_address_1) { - addContext(test, message.vali_getTransactions_6) - console.log(message.vali_getTransactions_6); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_getTransactions_10); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.getTransaction_insufficientBalance); - } - }); - - it('REGRESSION: Validate the get transactions history response with incorrect account in mumbai network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - try { - await mumbaiDataService.getTransactions({ - chainId: Number(data.mumbai_chainid), - account: data.incorrectSender, - }); - - addContext(test, message.fail_getTransactions_11) - assert.fail(message.fail_getTransactions_11); - } catch (e) { - const errorResponse = JSON.parse(e.message); - if (errorResponse[0].constraints.isAddress === constant.invalid_address_1) { - addContext(test, message.vali_getTransactions_7) - console.log(message.vali_getTransactions_7); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_getTransactions_11); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.getTransaction_insufficientBalance); - } - }); -}); diff --git a/test/specs/testnet/transferringFunds/goerli.spec.js b/test/specs/testnet/transferringFunds/goerli.spec.js deleted file mode 100644 index b9196e7..0000000 --- a/test/specs/testnet/transferringFunds/goerli.spec.js +++ /dev/null @@ -1,3616 +0,0 @@ -import * as dotenv from 'dotenv'; -dotenv.config(); // init dotenv -import { PrimeSdk, DataUtils } from '@etherspot/prime-sdk'; -import { ethers, utils, providers } from 'ethers'; -import { assert } from 'chai'; -import { ERC20_ABI } from '@etherspot/prime-sdk/dist/sdk/helpers/abi/ERC20_ABI.js'; -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 abi from '../../../data/nftabi.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, when transfer a token 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: 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: Perform the transfer native token 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 - let transactionBatch; - try { - transactionBatch = await goerliTestNetSdk.addUserOpsToBatch({ - to: data.recipient, - value: ethers.utils.parseEther(data.value), - }); - - try { - assert.isNotEmpty( - transactionBatch.to, - message.vali_addTransaction_to); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactionBatch.data, - message.vali_addTransaction_data); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactionBatch.value, - message.vali_addTransaction_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_addTransaction_1); - } - - // get balance of the account address - let balance; - try { - balance = await goerliTestNetSdk.getNativeBalance(); - - try { - assert.isNotEmpty( - balance, - message.vali_getBalance_balance); - } 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_getBalance_1); - } - - // estimate transactions added to the batch and get the fee data for the UserOp - let op; - try { - op = await goerliTestNetSdk.estimate(); - - try { - assert.isNotEmpty( - op.sender, - message.vali_estimateTransaction_sender); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.nonce, - message.vali_estimateTransaction_nonce); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.initCode, - message.vali_estimateTransaction_initCode); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.callData, - message.vali_estimateTransaction_callData); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.callGasLimit, - message.vali_estimateTransaction_callGasLimit); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.verificationGasLimit, - message.vali_estimateTransaction_verificationGasLimit); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.maxFeePerGas, - message.vali_estimateTransaction_maxFeePerGas); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.maxPriorityFeePerGas, - message.vali_estimateTransaction_maxPriorityFeePerGas); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.paymasterAndData, - message.vali_estimateTransaction_paymasterAndData); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.preVerificationGas, - message.vali_estimateTransaction_preVerificationGas); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.signature, - message.vali_estimateTransaction_signature); - } 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_estimateTransaction_1); - } - - // sign the UserOp and sending to the bundler - let uoHash; - try { - uoHash = await goerliTestNetSdk.send(op); - - try { - assert.isNotEmpty( - uoHash, - message.vali_submitTransaction_uoHash); - } 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_submitTransaction_1); - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.nativeTransaction_insufficientBalance); - } - }); - - it('SMOKE: Perform the transfer ERC20 token with valid details on the goerli network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - // get the respective provider details - let provider; - try { - provider = new ethers.providers.JsonRpcProvider( - data.providerNetwork_goerli); - - try { - assert.isTrue( - provider._isProvider, - message.vali_erc20Transfer_provider); - } 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_erc20Transfer_provider); - } - - // get erc20 Contract Interface - let erc20Instance; - try { - erc20Instance = new ethers.Contract( - data.tokenAddress_goerliUSDC, - ERC20_ABI, - provider); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Transfer_contractInterface); - } - - // get decimals from erc20 contract - let decimals; - try { - decimals = await erc20Instance.functions.decimals(); - - try { - assert.isNotEmpty( - decimals, - message.vali_erc20Contract_decimals); - } 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_erc20Contract_decimals); - } - - // get transferFrom encoded data - let transactionData; - try { - transactionData = erc20Instance.interface.encodeFunctionData( - 'transfer', - [data.recipient, ethers.utils.parseUnits(data.erc20_value, decimals)]); - - try { - assert.isNotEmpty( - transactionData, - message.vali_erc20Contract_transferFrom); - } 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_erc20Contract_transferFrom); - } - - // 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 - let userOpsBatch; - try { - userOpsBatch = await goerliTestNetSdk.addUserOpsToBatch({ - to: data.tokenAddress_goerliUSDC, - data: transactionData, - }); - - try { - assert.isNotEmpty( - userOpsBatch.to, - message.vali_addTransaction_to); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - userOpsBatch.data, - message.vali_addTransaction_data); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - userOpsBatch.value[0], - message.vali_addTransaction_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_clearTransaction_1); - } - - // estimate transactions added to the batch and get the fee data for the UserOp - let op; - try { - op = await goerliTestNetSdk.estimate(); - - try { - assert.isNotEmpty( - op.sender, - message.vali_estimateTransaction_sender); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.nonce, - message.vali_estimateTransaction_nonce); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.initCode, - message.vali_estimateTransaction_initCode); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.callData, - message.vali_estimateTransaction_callData); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.callGasLimit, - message.vali_estimateTransaction_callGasLimit); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.verificationGasLimit, - message.vali_estimateTransaction_verificationGasLimit); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.maxFeePerGas, - message.vali_estimateTransaction_maxFeePerGas); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.maxPriorityFeePerGas, - message.vali_estimateTransaction_maxPriorityFeePerGas); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.paymasterAndData, - message.vali_estimateTransaction_paymasterAndData); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.preVerificationGas, - message.vali_estimateTransaction_preVerificationGas); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.signature, - message.vali_estimateTransaction_signature); - } 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_estimateTransaction_1); - } - - // sign the UserOp and sending to the bundler - let uoHash; - try { - uoHash = await goerliTestNetSdk.send(op); - - try { - assert.isNotEmpty( - uoHash, - message.vali_submitTransaction_uoHash); - } 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_submitTransaction_1); - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.erc20Transaction_insufficientBalance); - } - }); - - it('SMOKE: Perform the transfer ERC721 NFT token with valid details on the goerli network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - // get erc721 Contract Interface - let erc721Interface; - let erc721Data; - try { - erc721Interface = new ethers.utils.Interface(abi.abi); - - erc721Data = erc721Interface.encodeFunctionData('transferFrom', [ - data.sender, - data.recipient, - data.tokenId, - ]); - - try { - assert.isNotEmpty( - erc721Data, - message.vali_erc721Transfer_contractInterface); - } 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_erc721Transfer_contractInterface); - } - - // 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 - let userOpsBatch; - try { - userOpsBatch = await goerliTestNetSdk.addUserOpsToBatch({ - to: data.nft_tokenAddress, - data: erc721Data, - }); - - try { - assert.isNotEmpty( - userOpsBatch.to[0], - message.vali_addTransaction_to); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - userOpsBatch.data[0], - message.vali_addTransaction_data); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - userOpsBatch.value[0], - message.vali_addTransaction_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_clearTransaction_1); - } - - // estimate transactions added to the batch - let op; - try { - op = await goerliTestNetSdk.estimate(); - - try { - assert.isNotEmpty( - op.sender, - message.vali_estimateTransaction_sender); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.nonce, - message.vali_estimateTransaction_nonce); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.initCode, - message.vali_estimateTransaction_initCode); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.callData, - message.vali_estimateTransaction_callData); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.callGasLimit, - message.vali_estimateTransaction_callGasLimit); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.verificationGasLimit, - message.vali_estimateTransaction_verificationGasLimit); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.maxFeePerGas, - message.vali_estimateTransaction_maxFeePerGas); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.maxPriorityFeePerGas, - message.vali_estimateTransaction_maxPriorityFeePerGas); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.paymasterAndData, - message.vali_estimateTransaction_paymasterAndData); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.preVerificationGas, - message.vali_estimateTransaction_preVerificationGas); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.signature, - message.vali_estimateTransaction_signature); - } 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_estimateTransaction_1); - } - - // sending to the bundler - let uoHash; - try { - uoHash = await goerliTestNetSdk.send(op); - - try { - assert.isNotEmpty( - uoHash, - message.vali_submitTransaction_uoHash); - } 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_submitTransaction_1); - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.erc721Transaction_insufficientBalance); - } - }); - - xit('SMOKE: Perform the transfer native token by passing callGasLimit 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 - let transactionBatch; - try { - transactionBatch = await goerliTestNetSdk.addUserOpsToBatch({ - to: data.recipient, - value: ethers.utils.parseEther(data.value), - }); - - try { - assert.isNotEmpty( - transactionBatch.to, - message.vali_addTransaction_to); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactionBatch.data, - message.vali_addTransaction_data); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactionBatch.value, - message.vali_addTransaction_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_addTransaction_1); - } - - // get balance of the account address - let balance; - try { - balance = await goerliTestNetSdk.getNativeBalance(); - - try { - assert.isNotEmpty( - balance, - message.vali_getBalance_balance); - } 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_getBalance_1); - } - - // estimate transactions added to the batch and get the fee data for the UserOp - // passing callGasLimit as 40000 to manually set it - let op; - try { - op = await goerliTestNetSdk.estimate({ callGasLimit: 40000 }); - - try { - assert.isNotEmpty( - op.sender, - message.vali_estimateTransaction_sender); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.nonce, - message.vali_estimateTransaction_nonce); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.initCode, - message.vali_estimateTransaction_initCode); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.callData, - message.vali_estimateTransaction_callData); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.callGasLimit, - message.vali_estimateTransaction_callGasLimit); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.verificationGasLimit, - message.vali_estimateTransaction_verificationGasLimit); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.maxFeePerGas, - message.vali_estimateTransaction_maxFeePerGas); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.maxPriorityFeePerGas, - message.vali_estimateTransaction_maxPriorityFeePerGas); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.paymasterAndData, - message.vali_estimateTransaction_paymasterAndData); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.preVerificationGas, - message.vali_estimateTransaction_preVerificationGas); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.signature, - message.vali_estimateTransaction_signature); - } 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_estimateTransaction_1); - } - - // sign the UserOp and sending to the bundler - let uoHash; - try { - uoHash = await goerliTestNetSdk.send(op); - - try { - assert.isNotEmpty( - uoHash, - message.vali_submitTransaction_uoHash); - } 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_submitTransaction_1); - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.nativeTransaction_insufficientBalance); - } - }); - - it('SMOKE: Perform the concurrent userops with valid details on the goerli network', async function () { - // NOTE: assume the sender wallet is deployed - - var test = this; - if (runTest) { - - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - const provider = new providers.JsonRpcProvider(); - - // 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 - let transactionBatch; - try { - transactionBatch = await goerliTestNetSdk.addUserOpsToBatch({ - to: data.recipient, - value: ethers.utils.parseEther(data.value), - }); - - try { - assert.isNotEmpty( - transactionBatch.to, - message.vali_addTransaction_to); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactionBatch.data, - message.vali_addTransaction_data); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactionBatch.value, - message.vali_addTransaction_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_addTransaction_1); - } - - // get balance of the account address - let balance; - try { - balance = await goerliTestNetSdk.getNativeBalance(); - - try { - assert.isNotEmpty( - balance, - message.vali_getBalance_balance); - } 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_getBalance_1); - } - - // Note that usually Bundlers do not allow sending more than 10 concurrent userops from an unstaked entites (wallets, factories, paymaster) - // Staked entities can send as many userops as they want - let concurrentUseropsCount = 1; - const userops = []; - const uoHashes = []; - - try { - while (--concurrentUseropsCount >= 0) { - const op = await goerliTestNetSdk.estimate({ key: concurrentUseropsCount }); - userops.push(op); - } - - console.log("Sending userops..."); - for (const op of userops) { - const uoHash = await goerliTestNetSdk.send(op); - uoHashes.push(uoHash); - } - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_submitTransaction_1) - } - - try { - console.log('Waiting for transactions...'); - const userOpsReceipts = new Array(uoHashes.length).fill(null); - const timeout = Date.now() + 60000; // 1 minute timeout - while ((userOpsReceipts.some(receipt => receipt == null)) && (Date.now() < timeout)) { - helper.wait(2000) - for (let i = 0; i < uoHashes.length; ++i) { - if (userOpsReceipts[i]) continue; - const uoHash = uoHashes[i]; - userOpsReceipts[i] = await goerliTestNetSdk.getUserOpReceipt(uoHash); - } - } - - if (userOpsReceipts.some(receipt => receipt != null)) { - for (const uoReceipt of userOpsReceipts) { - if (!uoReceipt) continue; - addContext(test, message.vali_submitTransaction_1) - console.log(message.vali_submitTransaction_1); - } - } else { - addContext(test, message.vali_submitTransaction_2) - console.log(message.vali_submitTransaction_2); - } - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_getUserOpReceipt_1) - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.nativeTransaction_insufficientBalance); - } - }); - - it('REGRESSION: Perform the transfer native token with the incorrect To Address while estimate the added transactions to the batch 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); - } - - // add transactions to the batch - try { - await goerliTestNetSdk.addUserOpsToBatch({ - to: data.incorrectRecipient, // incorrect to address - 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 - try { - await goerliTestNetSdk.estimate(); - - addContext(test, message.fail_estimateTransaction_9) - assert.fail(message.fail_estimateTransaction_9); - } catch (e) { - let error = e.reason; - if (error.includes(constant.invalid_address_6)) { - addContext(test, message.vali_estimateTransaction_8) - console.log(message.vali_estimateTransaction_8); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_estimateTransaction_9); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.nativeTransaction_insufficientBalance); - } - }); - - it('REGRESSION: Perform the transfer native token with the invalid To Address i.e. missing character while estimate the added transactions to the batch 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); - } - - // add transactions to the batch - try { - await goerliTestNetSdk.addUserOpsToBatch({ - to: data.invalidRecipient, // invalid to address - 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 - try { - await goerliTestNetSdk.estimate(); - - addContext(test, message.fail_estimateTransaction_10) - assert.fail(message.fail_estimateTransaction_10); - } catch (e) { - let error = e.reason; - if (error.includes(constant.invalid_address_4)) { - addContext(test, message.vali_estimateTransaction_9) - console.log(message.vali_estimateTransaction_9); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_estimateTransaction_10); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.nativeTransaction_insufficientBalance); - } - }); - - it('REGRESSION: Perform the transfer native token with the invalid Value while estimate the added transactions to the batch 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); - } - - // add transactions to the batch - try { - await goerliTestNetSdk.addUserOpsToBatch({ - to: data.recipient, - value: ethers.utils.parseUnits(data.invalidValue), // invalid value - }); - - addContext(test, message.fail_estimateTransaction_11) - assert.fail(message.fail_estimateTransaction_11); - } catch (e) { - if (e.reason === constant.invalid_value_1) { - addContext(test, message.vali_estimateTransaction_10) - console.log(message.vali_estimateTransaction_10); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_estimateTransaction_11); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.nativeTransaction_insufficientBalance); - } - }); - - it('REGRESSION: Perform the transfer native token with the very small Value while estimate the added transactions to the batch 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); - } - - // add transactions to the batch - try { - await goerliTestNetSdk.addUserOpsToBatch({ - to: data.recipient, - value: ethers.utils.parseUnits(data.smallValue), // very small value - }); - - addContext(test, message.fail_estimateTransaction_12) - assert.fail(message.fail_estimateTransaction_12); - } catch (e) { - if (e.reason === constant.invalid_value_2) { - addContext(test, message.vali_estimateTransaction_11) - console.log(message.vali_estimateTransaction_11); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_estimateTransaction_12); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.nativeTransaction_insufficientBalance); - } - }); - - it('REGRESSION: Perform the transfer native token without adding transaction to the batch while estimate the added transactions to the batch 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); - } - - // 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 - try { - await goerliTestNetSdk.estimate(); - - addContext(test, message.fail_estimateTransaction_13) - assert.fail(message.fail_estimateTransaction_13); - } catch (e) { - if (e.message === constant.invalid_parameter) { - addContext(test, message.vali_estimateTransaction_12) - console.log(message.vali_estimateTransaction_12); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_estimateTransaction_13); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.nativeTransaction_insufficientBalance); - } - }); - - xit('REGRESSION: Perform the transfer native token by passing callGasLimit with the incorrect To Address while estimate the added transactions to the batch 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); - } - - // add transactions to the batch - try { - await goerliTestNetSdk.addUserOpsToBatch({ - to: data.incorrectRecipient, // incorrect to address - 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 - // passing callGasLimit as 40000 to manually set it - try { - await goerliTestNetSdk.estimate({ callGasLimit: 40000 }); - - addContext(test, message.fail_estimateTransaction_9) - assert.fail(message.fail_estimateTransaction_9); - } catch (e) { - let error = e.reason; - if (error.includes(constant.invalid_address_6)) { - addContext(test, message.vali_estimateTransaction_8) - console.log(message.vali_estimateTransaction_8); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_estimateTransaction_9); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.nativeTransaction_insufficientBalance); - } - }); - - xit('REGRESSION: Perform the transfer native token by passing callGasLimit with the invalid To Address i.e. missing character while estimate the added transactions to the batch 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); - } - - // add transactions to the batch - try { - await goerliTestNetSdk.addUserOpsToBatch({ - to: data.invalidRecipient, // invalid to address - 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 - // passing callGasLimit as 40000 to manually set it - try { - await goerliTestNetSdk.estimate({ callGasLimit: 40000 }); - - addContext(test, message.fail_estimateTransaction_10) - assert.fail(message.fail_estimateTransaction_10); - } catch (e) { - let error = e.reason; - if (error.includes(constant.invalid_address_4)) { - addContext(test, message.vali_estimateTransaction_8) - console.log(message.vali_estimateTransaction_8); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_estimateTransaction_10); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.nativeTransaction_insufficientBalance); - } - }); - - xit('REGRESSION: Perform the transfer native token by passing callGasLimit without adding transaction to the batch while estimate the added transactions to the batch 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); - } - - // 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 - // passing callGasLimit as 40000 to manually set it - try { - await goerliTestNetSdk.estimate({ callGasLimit: 40000 }); - - addContext(test, message.fail_estimateTransaction_13) - assert.fail(message.fail_estimateTransaction_13); - } catch (e) { - if (e.message === constant.empty_batch) { - addContext(test, message.vali_estimateTransaction_12) - console.log(message.vali_estimateTransaction_12); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_estimateTransaction_13); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.nativeTransaction_insufficientBalance); - } - }); - - it('REGRESSION: Perform the transfer ERC20 token with invalid provider netowrk details while Getting the Decimal from ERC20 Contract on the goerli network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - // get the respective provider details - let provider; - try { - provider = new ethers.providers.JsonRpcProvider( - data.invalidProviderNetwork_goerli, // invalid provider - ); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Transfer_provider); - } - - // get erc20 Contract Interface - let erc20Instance; - try { - erc20Instance = new ethers.Contract( - data.tokenAddress_goerliUSDC, - ERC20_ABI, - provider); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Transfer_contractInterface); - } - - // get decimals from erc20 contract - try { - await erc20Instance.functions.decimals(); - - addContext(test, message.fail_estimateTransaction_14) - assert.fail(message.fail_estimateTransaction_14); - } catch (e) { - if (e.reason === constant.invalid_network_2) { - addContext(test, message.vali_estimateTransaction_13) - console.log(message.vali_estimateTransaction_13); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_estimateTransaction_14); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.erc20Transaction_insufficientBalance); - } - }); - - it('REGRESSION: Perform the transfer ERC20 token without provider netowrk details while Getting the Decimal from ERC20 Contract on the goerli network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - // get the respective provider details - let provider; - try { - provider = new ethers.providers.JsonRpcProvider(); // without provider - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Transfer_provider); - } - - // get erc20 Contract Interface - let erc20Instance; - try { - erc20Instance = new ethers.Contract( - data.tokenAddress_goerliUSDC, - ERC20_ABI, - provider); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Transfer_contractInterface); - } - - // get decimals from erc20 contract - try { - await erc20Instance.functions.decimals(); - - addContext(test, message.fail_estimateTransaction_14) - assert.fail(message.fail_estimateTransaction_14); - } catch (e) { - if (e.reason === constant.invalid_network_2) { - addContext(test, message.vali_estimateTransaction_13) - console.log(message.vali_estimateTransaction_13); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_estimateTransaction_14); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.erc20Transaction_insufficientBalance); - } - }); - - it('REGRESSION: Perform the transfer ERC20 token with other provider netowrk details while Getting the Decimal from ERC20 Contract on the goerli network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - // get the respective provider details - let provider; - try { - provider = new ethers.providers.JsonRpcProvider( - data.otherProviderNetwork_goerli, // other provider - ); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Transfer_provider); - } - - // get erc20 Contract Interface - let erc20Instance; - try { - erc20Instance = new ethers.Contract( - data.tokenAddress_goerliUSDC, - ERC20_ABI, - provider); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Transfer_contractInterface); - } - - // get decimals from erc20 contract - try { - await erc20Instance.functions.decimals(); - - addContext(test, message.fail_estimateTransaction_15) - assert.fail(message.fail_estimateTransaction_15); - } catch (e) { - let error = e.message; - if (error.includes(constant.invalid_value_3)) { - addContext(test, message.vali_estimateTransaction_14) - console.log(message.vali_estimateTransaction_14); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_estimateTransaction_15); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.erc20Transaction_insufficientBalance); - } - }); - - it('REGRESSION: Perform the transfer ERC20 token with incorrect Token Address details while Getting the Decimal from ERC20 Contract on the goerli network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - // get the respective provider details - let provider; - try { - provider = new ethers.providers.JsonRpcProvider( - data.providerNetwork_goerli); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Transfer_provider); - } - - // get erc20 Contract Interface - let erc20Instance; - try { - erc20Instance = new ethers.Contract( - data.incorrectTokenAddress_goerliUSDC, // incorrect token address - ERC20_ABI, - provider); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Transfer_contractInterface); - } - - // get decimals from erc20 contract - try { - await erc20Instance.functions.decimals(); - - addContext(message.fail_erc20Transfer_1) - assert.fail(message.fail_erc20Transfer_1); - } catch (e) { - if (e.reason === constant.invalid_address_6) { - addContext(test, message.vali_erc20Transfer_1) - console.log(message.vali_erc20Transfer_1); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Transfer_1); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.erc20Transaction_insufficientBalance); - } - }); - - it('REGRESSION: Perform the transfer ERC20 token with invalid Token Address i.e. missing character details while Getting the Decimal from ERC20 Contract on the goerli network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - // get the respective provider details - let provider; - try { - provider = new ethers.providers.JsonRpcProvider( - data.providerNetwork_goerli); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Transfer_provider); - } - - // get erc20 Contract Interface - let erc20Instance; - try { - erc20Instance = new ethers.Contract( - data.invalidTokenAddress_goerliUSDC, // invalid token address - ERC20_ABI, - provider); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Transfer_contractInterface); - } - - // get decimals from erc20 contract - try { - await erc20Instance.functions.decimals(); - - addContext(test, message.fail_erc20Transfer_2) - assert.fail(message.fail_erc20Transfer_2); - } catch (e) { - if (e.reason === constant.invalid_address_4) { - addContext(test, message.vali_erc20Transfer_2) - console.log(message.vali_erc20Transfer_2); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Transfer_2); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.erc20Transaction_insufficientBalance); - } - }); - - it('REGRESSION: Perform the transfer ERC20 token with null Token Address details while Getting the Decimal from ERC20 Contract on the goerli network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - // get the respective provider details - let provider; - try { - provider = new ethers.providers.JsonRpcProvider( - data.providerNetwork_goerli); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Transfer_provider); - } - - // get erc20 Contract Interface - try { - new ethers.Contract(null, ERC20_ABI, provider); // null token address - - addContext(test, message.fail_erc20Transfer_3) - assert.fail(message.fail_erc20Transfer_3); - } catch (e) { - if (e.reason === constant.contract_address_2) { - addContext(test, message.vali_erc20Transfer_3) - console.log(message.vali_erc20Transfer_3); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Transfer_3); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.erc20Transaction_insufficientBalance); - } - }); - - it('REGRESSION: Perform the transfer ERC20 token with incorrect transfer method name while Getting the transferFrom encoded data on the goerli network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - // get the respective provider details - let provider; - try { - provider = new ethers.providers.JsonRpcProvider( - data.providerNetwork_goerli); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Transfer_provider); - } - - // get erc20 Contract Interface - let erc20Instance; - try { - erc20Instance = new ethers.Contract( - data.tokenAddress_goerliUSDC, - ERC20_ABI, - provider); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Transfer_contractInterface); - } - - // get decimals from erc20 contract - let decimals; - try { - decimals = await erc20Instance.functions.decimals(); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Contract_decimals); - } - - // get transferFrom encoded data - try { - erc20Instance.interface.encodeFunctionData('transferr', [ - data.recipient, - ethers.utils.parseUnits(data.erc20_value, decimals), - ]); - - addContext(test, message.fail_erc20Transfer_4) - assert.fail(message.fail_erc20Transfer_4); - } catch (e) { - if (e.reason === constant.no_function) { - addContext(test, message.vali_erc20Transfer_4) - console.log(message.vali_erc20Transfer_4); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Transfer_4); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.erc20Transaction_insufficientBalance); - } - }); - - it('REGRESSION: Perform the transfer ERC20 token with invalid value while Getting the transferFrom encoded data on the goerli network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - // get the respective provider details - let provider; - try { - provider = new ethers.providers.JsonRpcProvider( - data.providerNetwork_goerli); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Transfer_provider); - } - - // get erc20 Contract Interface - let erc20Instance; - try { - erc20Instance = new ethers.Contract( - data.tokenAddress_goerliUSDC, - ERC20_ABI, - provider); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Transfer_contractInterface); - } - - // get decimals from erc20 contract - let decimals; - try { - decimals = await erc20Instance.functions.decimals(); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Contract_decimals); - } - - // get transferFrom encoded data - try { - erc20Instance.interface.encodeFunctionData('transfer', [ - data.recipient, - ethers.utils.parseUnits(data.invalidValue, decimals), // invalid value - ]); - - addContext(test, message.fail_erc20Transfer_5) - assert.fail(message.fail_erc20Transfer_5); - } catch (e) { - if (e.reason === constant.invalid_value_1) { - addContext(test, message.vali_erc20Transfer_5) - console.log(message.vali_erc20Transfer_5); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Transfer_5); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.erc20Transaction_insufficientBalance); - } - }); - - it('REGRESSION: Perform the transfer ERC20 token with very small value while Getting the transferFrom encoded data on the goerli network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - // get the respective provider details - let provider; - try { - provider = new ethers.providers.JsonRpcProvider( - data.providerNetwork_goerli); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Transfer_provider); - } - - // get erc20 Contract Interface - let erc20Instance; - try { - erc20Instance = new ethers.Contract( - data.tokenAddress_goerliUSDC, - ERC20_ABI, - provider); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Transfer_contractInterface); - } - - // get decimals from erc20 contract - let decimals; - try { - decimals = await erc20Instance.functions.decimals(); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Contract_decimals); - } - - // get transferFrom encoded data - try { - erc20Instance.interface.encodeFunctionData('transfer', [ - data.recipient, - ethers.utils.parseUnits(data.smallValue, decimals), // very small value - ]); - - addContext(test, message.fail_erc20Transfer_6) - assert.fail(message.fail_erc20Transfer_6); - } catch (e) { - if (e.reason === constant.invalid_value_2) { - addContext(test, message.vali_erc20Transfer_6) - console.log(message.vali_erc20Transfer_6); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Transfer_6); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.erc20Transaction_insufficientBalance); - } - }); - - it('REGRESSION: Perform the transfer ERC20 token without value while Getting the transferFrom encoded data on the goerli network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - // get the respective provider details - let provider; - try { - provider = new ethers.providers.JsonRpcProvider( - data.providerNetwork_goerli); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Transfer_provider); - } - - // get erc20 Contract Interface - let erc20Instance; - try { - erc20Instance = new ethers.Contract( - data.tokenAddress_goerliUSDC, - ERC20_ABI, - provider); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Transfer_contractInterface); - } - - // get decimals from erc20 contract - try { - await erc20Instance.functions.decimals(); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Contract_decimals); - } - - // get transferFrom encoded data - try { - erc20Instance.interface.encodeFunctionData('transfer', [ - data.recipient, - ]); - - addContext(test, message.fail_erc20Transfer_7) - assert.fail(message.fail_erc20Transfer_7); - } catch (e) { - if (e.reason === constant.invalid_value_4) { - addContext(test, message.vali_erc20Transfer_7) - console.log(message.vali_erc20Transfer_7); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Transfer_7); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.erc20Transaction_insufficientBalance); - } - }); - - it('REGRESSION: Perform the transfer ERC20 token with incorrect recipient while Getting the transferFrom encoded data on the goerli network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - // get the respective provider details - let provider; - try { - provider = new ethers.providers.JsonRpcProvider( - data.providerNetwork_goerli); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Transfer_provider); - } - - // get erc20 Contract Interface - let erc20Instance; - try { - erc20Instance = new ethers.Contract( - data.tokenAddress_goerliUSDC, - ERC20_ABI, - provider); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Transfer_contractInterface); - } - - // get decimals from erc20 contract - let decimals; - try { - decimals = await erc20Instance.functions.decimals(); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Contract_decimals); - } - - // get transferFrom encoded data - try { - erc20Instance.interface.encodeFunctionData('transfer', [ - data.incorrectRecipient, // incorrect recipient address - ethers.utils.parseUnits(data.erc20_value, decimals), - ]); - - addContext(test, message.fail_erc20Transfer_8) - assert.fail(message.fail_erc20Transfer_8); - } catch (e) { - let error = e.reason; - if (error.includes(constant.invalid_address_6)) { - addContext(test, message.vali_erc20Transfer_8) - console.log(message.vali_erc20Transfer_8); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Transfer_8); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.erc20Transaction_insufficientBalance); - } - }); - - it('REGRESSION: Perform the transfer ERC20 token with invalid recipient i.e. missing character while Getting the transferFrom encoded data on the goerli network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - // get the respective provider details - let provider; - try { - provider = new ethers.providers.JsonRpcProvider( - data.providerNetwork_goerli); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Transfer_provider); - } - - // get erc20 Contract Interface - let erc20Instance; - try { - erc20Instance = new ethers.Contract( - data.tokenAddress_goerliUSDC, - ERC20_ABI, - provider); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Transfer_contractInterface); - } - - // get decimals from erc20 contract - let decimals; - try { - decimals = await erc20Instance.functions.decimals(); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Contract_decimals); - } - - // get transferFrom encoded data - try { - erc20Instance.interface.encodeFunctionData('transfer', [ - data.invalidRecipient, // invalid recipient address - ethers.utils.parseUnits(data.erc20_value, decimals), - ]); - - addContext(test, message.fail_erc20Transfer_9) - assert.fail(message.fail_erc20Transfer_9); - } catch (e) { - let error = e.reason; - if (error.includes(constant.invalid_address_4)) { - addContext(test, message.vali_erc20Transfer_9) - console.log(message.vali_erc20Transfer_9); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Transfer_9); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.erc20Transaction_insufficientBalance); - } - }); - - it('REGRESSION: Perform the transfer ERC20 token without recipient while Getting the transferFrom encoded data on the goerli network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - // get the respective provider details - let provider; - try { - provider = new ethers.providers.JsonRpcProvider( - data.providerNetwork_goerli); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Transfer_provider); - } - - // get erc20 Contract Interface - let erc20Instance; - try { - erc20Instance = new ethers.Contract( - data.tokenAddress_goerliUSDC, - ERC20_ABI, - provider); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Transfer_contractInterface); - } - - // get decimals from erc20 contract - let decimals; - try { - decimals = await erc20Instance.functions.decimals(); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Contract_decimals); - } - - // get transferFrom encoded data - try { - erc20Instance.interface.encodeFunctionData('transfer', [ - ethers.utils.parseUnits(data.erc20_value, decimals), - ]); - - addContext(test, message.fail_erc20Transfer_10) - assert.fail(message.fail_erc20Transfer_10); - } catch (e) { - if (e.reason === constant.invalid_value_4) { - addContext(test, message.vali_erc20Transfer_10) - console.log(message.vali_erc20Transfer_10); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Transfer_10); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.erc20Transaction_insufficientBalance); - } - }); - - it('REGRESSION: Perform the transfer ERC20 token with the incorrect Token Address while adding transactions to the batch on the goerli network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - // get the respective provider details - let provider; - try { - provider = new ethers.providers.JsonRpcProvider( - data.providerNetwork_goerli); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Transfer_provider); - } - - // get erc20 Contract Interface - let erc20Instance; - try { - erc20Instance = new ethers.Contract( - data.tokenAddress_goerliUSDC, - ERC20_ABI, - provider); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Transfer_contractInterface); - } - - // get decimals from erc20 contract - let decimals; - try { - decimals = await erc20Instance.functions.decimals(); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Contract_decimals); - } - - // get transferFrom encoded data - let transactionData; - try { - transactionData = erc20Instance.interface.encodeFunctionData( - 'transfer', - [data.recipient, ethers.utils.parseUnits(data.erc20_value, decimals)]); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Contract_decimals); - } - - // 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.incorrectTokenAddress_goerliUSDC, // Incorrect Token Address - data: transactionData, - }); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_clearTransaction_1); - } - - // estimate transactions added to the batch - try { - await goerliTestNetSdk.estimate(); - - addContext(test, message.fail_estimateTransaction_16) - assert.fail(message.fail_estimateTransaction_16); - } catch (e) { - let error = e.reason; - if (error.includes(constant.invalid_address_6)) { - addContext(test, message.vali_estimateTransaction_15) - console.log(message.vali_estimateTransaction_15); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_estimateTransaction_16); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.erc20Transaction_insufficientBalance); - } - }); - - it('REGRESSION: Perform the transfer ERC20 token with the invalid Token Address i.e. missing character while adding transactions to the batch on the goerli network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - // get the respective provider details - let provider; - try { - provider = new ethers.providers.JsonRpcProvider( - data.providerNetwork_goerli); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Transfer_provider); - } - - // get erc20 Contract Interface - let erc20Instance; - try { - erc20Instance = new ethers.Contract( - data.tokenAddress_goerliUSDC, - ERC20_ABI, - provider); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Transfer_contractInterface); - } - - // get decimals from erc20 contract - let decimals; - try { - decimals = await erc20Instance.functions.decimals(); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Contract_decimals); - } - - // get transferFrom encoded data - let transactionData; - try { - transactionData = erc20Instance.interface.encodeFunctionData( - 'transfer', - [data.recipient, ethers.utils.parseUnits(data.erc20_value, decimals)]); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Contract_decimals); - } - - // 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.invalidTokenAddress_goerliUSDC, // Invalid Token Address - data: transactionData, - }); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_clearTransaction_1); - } - - // estimate transactions added to the batch - try { - await goerliTestNetSdk.estimate(); - - addContext(test, message.fail_estimateTransaction_17) - assert.fail(message.fail_estimateTransaction_17); - } catch (e) { - let error = e.reason; - if (error.includes(constant.invalid_address_4)) { - addContext(test, message.vali_estimateTransaction_16) - console.log(message.vali_estimateTransaction_16); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_estimateTransaction_17); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.erc20Transaction_insufficientBalance); - } - }); - - it('REGRESSION: Perform the transfer ERC20 token with the null Token Address while adding transactions to the batch on the goerli network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - // get the respective provider details - let provider; - try { - provider = new ethers.providers.JsonRpcProvider( - data.providerNetwork_goerli); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Transfer_provider); - } - - // get erc20 Contract Interface - let erc20Instance; - try { - erc20Instance = new ethers.Contract( - data.tokenAddress_goerliUSDC, - ERC20_ABI, - provider); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Transfer_contractInterface); - } - - // get decimals from erc20 contract - let decimals; - try { - decimals = await erc20Instance.functions.decimals(); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Contract_decimals); - } - - // get transferFrom encoded data - let transactionData; - try { - transactionData = erc20Instance.interface.encodeFunctionData( - 'transfer', - [data.recipient, ethers.utils.parseUnits(data.erc20_value, decimals)]); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Contract_decimals); - } - - // 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: null, // Null Token Address - data: transactionData, - }); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_clearTransaction_1); - } - - // estimate transactions added to the batch - try { - await goerliTestNetSdk.estimate(); - - addContext(test, message.fail_estimateTransaction_18) - assert.fail(message.fail_estimateTransaction_18); - } catch (e) { - if (e.reason.includes(constant.invalid_address_4)) { - addContext(test, message.vali_estimateTransaction_17) - console.log(message.vali_estimateTransaction_17); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_estimateTransaction_18); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.erc20Transaction_insufficientBalance); - } - }); - - it('REGRESSION: Perform the transfer ERC20 token without Token Address while adding transactions to the batch on the goerli network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - // get the respective provider details - let provider; - try { - provider = new ethers.providers.JsonRpcProvider( - data.providerNetwork_goerli); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Transfer_provider); - } - - // get erc20 Contract Interface - let erc20Instance; - try { - erc20Instance = new ethers.Contract( - data.tokenAddress_goerliUSDC, - ERC20_ABI, - provider); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Transfer_contractInterface); - } - - // get decimals from erc20 contract - let decimals; - try { - decimals = await erc20Instance.functions.decimals(); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Contract_decimals); - } - - // get transferFrom encoded data - let transactionData; - try { - transactionData = erc20Instance.interface.encodeFunctionData( - 'transfer', - [data.recipient, ethers.utils.parseUnits(data.erc20_value, decimals)]); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Contract_decimals); - } - - // 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({ - data: transactionData, // without tokenAddress - }); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_clearTransaction_1); - } - - // estimate transactions added to the batch - try { - await goerliTestNetSdk.estimate(); - - addContext(test, message.fail_estimateTransaction_19) - assert.fail(message.fail_estimateTransaction_19); - } catch (e) { - if (e.reason.includes(constant.invalid_address_4)) { - addContext(test, message.vali_estimateTransaction_18) - console.log(message.vali_estimateTransaction_18); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_estimateTransaction_19); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.erc20Transaction_insufficientBalance); - } - }); - - it('REGRESSION: Perform the transfer ERC20 token without adding transaction to the batch while estimate the added transactions to the batch on the goerli network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - // get the respective provider details - let provider; - try { - provider = new ethers.providers.JsonRpcProvider( - data.providerNetwork_goerli); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Transfer_provider); - } - - // get erc20 Contract Interface - let erc20Instance; - try { - erc20Instance = new ethers.Contract( - data.tokenAddress_goerliUSDC, - ERC20_ABI, - provider); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Transfer_contractInterface); - } - - // get decimals from erc20 contract - let decimals; - try { - decimals = await erc20Instance.functions.decimals(); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Contract_decimals); - } - - // get transferFrom encoded data - try { - erc20Instance.interface.encodeFunctionData('transfer', [ - data.recipient, - ethers.utils.parseUnits(data.erc20_value, decimals), - ]); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Contract_decimals); - } - - // 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); - } - - // estimate transactions added to the batch - try { - await goerliTestNetSdk.estimate(); - - assert.fail(message.fail_estimateTransaction_13); - } catch (e) { - if (e.message === constant.invalid_parameter) { - addContext(test, message.vali_estimateTransaction_12) - console.log(message.vali_estimateTransaction_12); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_estimateTransaction_13); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.erc20Transaction_insufficientBalance); - } - }); - - it('REGRESSION: Perform the transfer ERC721 NFT token with incorrect Sender Address while creating the NFT Data on the goerli network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - // get erc721 Contract Interface - let erc721Interface; - try { - erc721Interface = new ethers.utils.Interface(abi.abi); - - erc721Interface.encodeFunctionData('transferFrom', [ - data.incorrectSender, // incorrect sender address - data.recipient, - data.tokenId, - ]); - - addContext(test, message.fail_erc721Transfer_1) - assert.fail(message.fail_erc721Transfer_1); - } catch (e) { - if (e.reason.includes(constant.invalid_address_6)) { - addContext(test, message.vali_erc721Transfer_1) - console.log(message.vali_erc721Transfer_1); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc721Transfer_1); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.erc721Transaction_insufficientBalance); - } - }); - - it('REGRESSION: Perform the transfer ERC721 NFT token with invalid Sender Address i.e. missing character while creating the NFT Data on the goerli network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - // get erc721 Contract Interface - let erc721Interface; - try { - erc721Interface = new ethers.utils.Interface(abi.abi); - - erc721Interface.encodeFunctionData('transferFrom', [ - data.invalidSender, // invalid sender address - data.recipient, - data.tokenId, - ]); - - addContext(test, message.fail_erc721Transfer_2) - assert.fail(message.fail_erc721Transfer_2); - } catch (e) { - if (e.reason.includes(constant.invalid_address_4)) { - addContext(test, message.vali_erc721Transfer_2) - console.log(message.vali_erc721Transfer_2); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc721Transfer_2); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.erc721Transaction_insufficientBalance); - } - }); - - it('REGRESSION: Perform the transfer ERC721 NFT token without Sender Address while creating the NFT Data on the goerli network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - // get erc721 Contract Interface - let erc721Interface; - try { - erc721Interface = new ethers.utils.Interface(abi.abi); - - erc721Interface.encodeFunctionData('transferFrom', [ - data.recipient, // not added sender address - data.tokenId, - ]); - - addContext(test, message.fail_erc721Transfer_3) - assert.fail(message.fail_erc721Transfer_3); - } catch (e) { - if (e.reason === constant.invalid_value_4) { - addContext(test, message.vali_erc721Transfer_3) - console.log(message.vali_erc721Transfer_3); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc721Transfer_3); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.erc721Transaction_insufficientBalance); - } - }); - - it('REGRESSION: Perform the transfer ERC721 NFT token with incorrect Recipient Address while creating the NFT Data on the goerli network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - // get erc721 Contract Interface - let erc721Interface; - try { - erc721Interface = new ethers.utils.Interface(abi.abi); - - erc721Interface.encodeFunctionData('transferFrom', [ - data.sender, - data.incorrectRecipient, // incorrect recipient address - data.tokenId, - ]); - - addContext(test, message.fail_erc721Transfer_4) - assert.fail(message.fail_erc721Transfer_4); - } catch (e) { - if (e.reason.includes(constant.invalid_address_6)) { - addContext(test, message.vali_erc721Transfer_4) - console.log(message.vali_erc721Transfer_4); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc721Transfer_4); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.erc721Transaction_insufficientBalance); - } - }); - - it('REGRESSION: Perform the transfer ERC721 NFT token with invalid Recipient Address i.e. missing character while creating the NFT Data on the goerli network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - // get erc721 Contract Interface - let erc721Interface; - try { - erc721Interface = new ethers.utils.Interface(abi.abi); - - erc721Interface.encodeFunctionData('transferFrom', [ - data.sender, - data.invalidRecipient, // invalid recipient address - data.tokenId, - ]); - - addContext(test, message.fail_erc721Transfer_5) - assert.fail(message.fail_erc721Transfer_5); - } catch (e) { - if (e.reason.includes(constant.invalid_address_4)) { - addContext(test, message.vali_erc721Transfer_5) - console.log(message.vali_erc721Transfer_5); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc721Transfer_5); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.erc721Transaction_insufficientBalance); - } - }); - - it('REGRESSION: Perform the transfer ERC721 NFT token without Recipient Address while creating the NFT Data on the goerli network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - // get erc721 Contract Interface - let erc721Interface; - try { - erc721Interface = new ethers.utils.Interface(abi.abi); - - erc721Interface.encodeFunctionData('transferFrom', [ - data.sender, // not added recipient address - data.tokenId, - ]); - - addContext(test, message.fail_erc721Transfer_6) - assert.fail(message.fail_erc721Transfer_6); - } catch (e) { - if (e.reason === constant.invalid_value_4) { - addContext(test, message.vali_erc721Transfer_6) - console.log(message.vali_erc721Transfer_6); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc721Transfer_6); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.erc721Transaction_insufficientBalance); - } - }); - - it('REGRESSION: Perform the transfer ERC721 NFT token with incorrect tokenId while creating the NFT Data on the goerli network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - // get erc721 Contract Interface - let erc721Interface; - try { - erc721Interface = new ethers.utils.Interface(abi.abi); - - erc721Interface.encodeFunctionData('transferFrom', [ - data.sender, - data.recipient, - data.incorrectTokenId, // incorrect tokenid - ]); - - addContext(message.fail_erc721Transfer_7) - assert.fail(message.fail_erc721Transfer_7); - } catch (e) { - if (e.reason === constant.invalid_bignumber_1) { - addContext(test, message.vali_erc721Transfer_7) - console.log(message.vali_erc721Transfer_7); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc721Transfer_7); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.erc721Transaction_insufficientBalance); - } - }); - - it('REGRESSION: Perform the transfer ERC721 NFT token without tokenId while creating the NFT Data on the goerli network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - // get erc721 Contract Interface - let erc721Interface; - try { - erc721Interface = new ethers.utils.Interface(abi.abi); - - erc721Interface.encodeFunctionData('transferFrom', [ - data.sender, - data.recipient, // not added tokenid - ]); - - addContext(test, message.fail_erc721Transfer_8) - assert.fail(message.fail_erc721Transfer_8); - } catch (e) { - if (e.reason === constant.invalid_value_4) { - addContext(test, message.vali_erc721Transfer_8) - console.log(message.vali_erc721Transfer_8); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc721Transfer_8); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.erc721Transaction_insufficientBalance); - } - }); - - it('REGRESSION: Perform the transfer ERC721 NFT Token without adding transaction to the batch while estimate the added transactions to the batch on the goerli network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - // get erc721 Contract Interface - let erc721Interface; - try { - erc721Interface = new ethers.utils.Interface(abi.abi); - - erc721Interface.encodeFunctionData('transferFrom', [ - data.sender, - data.recipient, - data.tokenId, - ]); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc721Transfer_contractInterface); - } - - // 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); - } - - // 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 - try { - await goerliTestNetSdk.estimate(); - - addContext(test, message.fail_estimateTransaction_13) - assert.fail(message.fail_estimateTransaction_13); - } catch (e) { - if (e.message === constant.invalid_parameter) { - addContext(test, message.vali_estimateTransaction_12) - console.log(message.vali_estimateTransaction_12); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_estimateTransaction_13); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.erc721Transaction_insufficientBalance); - } - }); - - it('REGRESSION: Perform the concurrent userops with invalid concurrentUseropsCount on the goerli network', async function () { - // NOTE: assume the sender wallet is deployed - - var test = this; - if (runTest) { - - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - const provider = new providers.JsonRpcProvider(); - - // 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 - let transactionBatch; - try { - transactionBatch = 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 - let balance; - try { - balance = await goerliTestNetSdk.getNativeBalance(); - - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_getBalance_1); - } - - // Note that usually Bundlers do not allow sending more than 10 concurrent userops from an unstaked entites (wallets, factories, paymaster) - // Staked entities can send as many userops as they want - let concurrentUseropsCount = -5; // invalid concurrent userops - const userops = []; - const uoHashes = []; - - try { - while (--concurrentUseropsCount >= 0) { - const op = await goerliTestNetSdk.estimate({ key: concurrentUseropsCount }); - userops.push(op); - } - - console.log("Sending userops..."); - for (const op of userops) { - const uoHash = await goerliTestNetSdk.send(op); - uoHashes.push(uoHash); - } - } catch (e) { - addContext(test, message.fail_submitTransaction_1) - assert.fail(message.fail_submitTransaction_1) - } - - try { - console.log('Waiting for transactions...'); - const userOpsReceipts = new Array(uoHashes.length).fill(null); - const timeout = Date.now() + 60000; // 1 minute timeout - while ((userOpsReceipts.some(receipt => receipt == null)) && (Date.now() < timeout)) { - helper.wait(2000) - for (let i = 0; i < uoHashes.length; ++i) { - if (userOpsReceipts[i]) continue; - const uoHash = uoHashes[i]; - userOpsReceipts[i] = await goerliTestNetSdk.getUserOpReceipt(uoHash); - } - } - - if (userOpsReceipts.some(receipt => receipt != null)) { - for (const uoReceipt of userOpsReceipts) { - if (!uoReceipt) continue; - addContext(test, message.vali_submitTransaction_1) - console.log(message.vali_submitTransaction_1); - } - } else { - addContext(test, message.vali_submitTransaction_2) - console.log(message.vali_submitTransaction_2); - } - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_getUserOpReceipt_1) - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.nativeTransaction_insufficientBalance); - } - }); - - it('REGRESSION: Perform the concurrent userops without concurrentUseropsCount on the goerli network', async function () { - // NOTE: assume the sender wallet is deployed - - var test = this; - if (runTest) { - - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - const provider = new providers.JsonRpcProvider(); - - // 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 - let transactionBatch; - try { - transactionBatch = 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 - let balance; - try { - balance = await goerliTestNetSdk.getNativeBalance(); - - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_getBalance_1); - } - - // Note that usually Bundlers do not allow sending more than 10 concurrent userops from an unstaked entites (wallets, factories, paymaster) - // Staked entities can send as many userops as they want - let concurrentUseropsCount; // invalid concurrent userops - const userops = []; - const uoHashes = []; - - try { - while (--concurrentUseropsCount >= 0) { - const op = await goerliTestNetSdk.estimate({ key: concurrentUseropsCount }); - userops.push(op); - } - - console.log("Sending userops..."); - for (const op of userops) { - const uoHash = await goerliTestNetSdk.send(op); - uoHashes.push(uoHash); - } - } catch (e) { - addContext(test, message.fail_submitTransaction_1) - assert.fail(message.fail_submitTransaction_1) - } - - try { - console.log('Waiting for transactions...'); - const userOpsReceipts = new Array(uoHashes.length).fill(null); - const timeout = Date.now() + 60000; // 1 minute timeout - while ((userOpsReceipts.some(receipt => receipt == null)) && (Date.now() < timeout)) { - helper.wait(2000) - for (let i = 0; i < uoHashes.length; ++i) { - if (userOpsReceipts[i]) continue; - const uoHash = uoHashes[i]; - userOpsReceipts[i] = await goerliTestNetSdk.getUserOpReceipt(uoHash); - } - } - - if (userOpsReceipts.some(receipt => receipt != null)) { - for (const uoReceipt of userOpsReceipts) { - if (!uoReceipt) continue; - addContext(test, message.vali_submitTransaction_1) - console.log(message.vali_submitTransaction_1); - } - } else { - addContext(test, message.vali_submitTransaction_2) - console.log(message.vali_submitTransaction_2); - } - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_getUserOpReceipt_1) - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.nativeTransaction_insufficientBalance); - } - }); - - it('REGRESSION: Perform the concurrent userops with non deployed address on the goerli network', async function () { - var test = this; - if (runTest) { - - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - const provider = new providers.JsonRpcProvider(); - - try { - if ((await provider.getCode(data.eoaAddress)).length <= 2) { - addContext(test, message.vali_deployAddress_1) - console.log(message.vali_deployAddress_1); - return; - } - - addContext(test, message.fail_deployAddress_1) - assert.fail(message.fail_deployAddress_1) - } catch (e) { - const errorMessage = e.message; - if (errorMessage.includes(constant.invalid_network_2)) { - addContext(test, message.vali_deployAddress_2) - console.log(message.vali_deployAddress_2); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_deployAddress_1); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.nativeTransaction_insufficientBalance); - } - }); -}); diff --git a/test/specs/testnet/transferringFunds/mumbai.spec.js b/test/specs/testnet/transferringFunds/mumbai.spec.js deleted file mode 100644 index 8f8f438..0000000 --- a/test/specs/testnet/transferringFunds/mumbai.spec.js +++ /dev/null @@ -1,3616 +0,0 @@ -import * as dotenv from 'dotenv'; -dotenv.config(); // init dotenv -import { PrimeSdk, DataUtils } from '@etherspot/prime-sdk'; -import { ethers, utils, providers } from 'ethers'; -import { assert } from 'chai'; -import { ERC20_ABI } from '@etherspot/prime-sdk/dist/sdk/helpers/abi/ERC20_ABI.js'; -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 abi from '../../../data/nftabi.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, when transfer a token 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: 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: Perform the transfer native token 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 - let transactionBatch; - try { - transactionBatch = await mumbaiTestNetSdk.addUserOpsToBatch({ - to: data.recipient, - value: ethers.utils.parseEther(data.value), - }); - - try { - assert.isNotEmpty( - transactionBatch.to, - message.vali_addTransaction_to); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactionBatch.data, - message.vali_addTransaction_data); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactionBatch.value, - message.vali_addTransaction_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_addTransaction_1); - } - - // get balance of the account address - let balance; - try { - balance = await mumbaiTestNetSdk.getNativeBalance(); - - try { - assert.isNotEmpty( - balance, - message.vali_getBalance_balance); - } 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_getBalance_1); - } - - // estimate transactions added to the batch and get the fee data for the UserOp - let op; - try { - op = await mumbaiTestNetSdk.estimate(); - - try { - assert.isNotEmpty( - op.sender, - message.vali_estimateTransaction_sender); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.nonce, - message.vali_estimateTransaction_nonce); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.initCode, - message.vali_estimateTransaction_initCode); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.callData, - message.vali_estimateTransaction_callData); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.callGasLimit, - message.vali_estimateTransaction_callGasLimit); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.verificationGasLimit, - message.vali_estimateTransaction_verificationGasLimit); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.maxFeePerGas, - message.vali_estimateTransaction_maxFeePerGas); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.maxPriorityFeePerGas, - message.vali_estimateTransaction_maxPriorityFeePerGas); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.paymasterAndData, - message.vali_estimateTransaction_paymasterAndData); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.preVerificationGas, - message.vali_estimateTransaction_preVerificationGas); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.signature, - message.vali_estimateTransaction_signature); - } 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_estimateTransaction_1); - } - - // sign the UserOp and sending to the bundler - let uoHash; - try { - uoHash = await mumbaiTestNetSdk.send(op); - - try { - assert.isNotEmpty( - uoHash, - message.vali_submitTransaction_uoHash); - } 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_submitTransaction_1); - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.nativeTransaction_insufficientBalance); - } - }); - - it('SMOKE: Perform the transfer ERC20 token with valid details on the mumbai network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - // get the respective provider details - let provider; - try { - provider = new ethers.providers.JsonRpcProvider( - data.providerNetwork_mumbai); - - try { - assert.isTrue( - provider._isProvider, - message.vali_erc20Transfer_provider); - } 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_erc20Transfer_provider); - } - - // get erc20 Contract Interface - let erc20Instance; - try { - erc20Instance = new ethers.Contract( - data.tokenAddress_mumbaiUSDC, - ERC20_ABI, - provider); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Transfer_contractInterface); - } - - // get decimals from erc20 contract - let decimals; - try { - decimals = await erc20Instance.functions.decimals(); - - try { - assert.isNotEmpty( - decimals, - message.vali_erc20Contract_decimals); - } 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_erc20Contract_decimals); - } - - // get transferFrom encoded data - let transactionData; - try { - transactionData = erc20Instance.interface.encodeFunctionData( - 'transfer', - [data.recipient, ethers.utils.parseUnits(data.erc20_value, decimals)]); - - try { - assert.isNotEmpty( - transactionData, - message.vali_erc20Contract_transferFrom); - } 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_erc20Contract_transferFrom); - } - - // 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 - let userOpsBatch; - try { - userOpsBatch = await mumbaiTestNetSdk.addUserOpsToBatch({ - to: data.tokenAddress_mumbaiUSDC, - data: transactionData, - }); - - try { - assert.isNotEmpty( - userOpsBatch.to, - message.vali_addTransaction_to); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - userOpsBatch.data, - message.vali_addTransaction_data); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - userOpsBatch.value[0], - message.vali_addTransaction_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_clearTransaction_1); - } - - // estimate transactions added to the batch and get the fee data for the UserOp - let op; - try { - op = await mumbaiTestNetSdk.estimate(); - - try { - assert.isNotEmpty( - op.sender, - message.vali_estimateTransaction_sender); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.nonce, - message.vali_estimateTransaction_nonce); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.initCode, - message.vali_estimateTransaction_initCode); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.callData, - message.vali_estimateTransaction_callData); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.callGasLimit, - message.vali_estimateTransaction_callGasLimit); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.verificationGasLimit, - message.vali_estimateTransaction_verificationGasLimit); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.maxFeePerGas, - message.vali_estimateTransaction_maxFeePerGas); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.maxPriorityFeePerGas, - message.vali_estimateTransaction_maxPriorityFeePerGas); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.paymasterAndData, - message.vali_estimateTransaction_paymasterAndData); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.preVerificationGas, - message.vali_estimateTransaction_preVerificationGas); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.signature, - message.vali_estimateTransaction_signature); - } 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_estimateTransaction_1); - } - - // sign the UserOp and sending to the bundler - let uoHash; - try { - uoHash = await mumbaiTestNetSdk.send(op); - - try { - assert.isNotEmpty( - uoHash, - message.vali_submitTransaction_uoHash); - } 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_submitTransaction_1); - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.erc20Transaction_insufficientBalance); - } - }); - - it('SMOKE: Perform the transfer ERC721 NFT token with valid details on the mumbai network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - // get erc721 Contract Interface - let erc721Interface; - let erc721Data; - try { - erc721Interface = new ethers.utils.Interface(abi.abi); - - erc721Data = erc721Interface.encodeFunctionData('transferFrom', [ - data.sender, - data.recipient, - data.tokenId, - ]); - - try { - assert.isNotEmpty( - erc721Data, - message.vali_erc721Transfer_contractInterface); - } 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_erc721Transfer_contractInterface); - } - - // 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 - let userOpsBatch; - try { - userOpsBatch = await mumbaiTestNetSdk.addUserOpsToBatch({ - to: data.nft_tokenAddress, - data: erc721Data, - }); - - try { - assert.isNotEmpty( - userOpsBatch.to[0], - message.vali_addTransaction_to); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - userOpsBatch.data[0], - message.vali_addTransaction_data); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - userOpsBatch.value[0], - message.vali_addTransaction_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_clearTransaction_1); - } - - // estimate transactions added to the batch - let op; - try { - op = await mumbaiTestNetSdk.estimate(); - - try { - assert.isNotEmpty( - op.sender, - message.vali_estimateTransaction_sender); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.nonce, - message.vali_estimateTransaction_nonce); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.initCode, - message.vali_estimateTransaction_initCode); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.callData, - message.vali_estimateTransaction_callData); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.callGasLimit, - message.vali_estimateTransaction_callGasLimit); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.verificationGasLimit, - message.vali_estimateTransaction_verificationGasLimit); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.maxFeePerGas, - message.vali_estimateTransaction_maxFeePerGas); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.maxPriorityFeePerGas, - message.vali_estimateTransaction_maxPriorityFeePerGas); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.paymasterAndData, - message.vali_estimateTransaction_paymasterAndData); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.preVerificationGas, - message.vali_estimateTransaction_preVerificationGas); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.signature, - message.vali_estimateTransaction_signature); - } 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_estimateTransaction_1); - } - - // sending to the bundler - let uoHash; - try { - uoHash = await mumbaiTestNetSdk.send(op); - - try { - assert.isNotEmpty( - uoHash, - message.vali_submitTransaction_uoHash); - } 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_submitTransaction_1); - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.erc721Transaction_insufficientBalance); - } - }); - - xit('SMOKE: Perform the transfer native token by passing callGasLimit 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 - let transactionBatch; - try { - transactionBatch = await mumbaiTestNetSdk.addUserOpsToBatch({ - to: data.recipient, - value: ethers.utils.parseEther(data.value), - }); - - try { - assert.isNotEmpty( - transactionBatch.to, - message.vali_addTransaction_to); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactionBatch.data, - message.vali_addTransaction_data); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactionBatch.value, - message.vali_addTransaction_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_addTransaction_1); - } - - // get balance of the account address - let balance; - try { - balance = await mumbaiTestNetSdk.getNativeBalance(); - - try { - assert.isNotEmpty( - balance, - message.vali_getBalance_balance); - } 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_getBalance_1); - } - - // estimate transactions added to the batch and get the fee data for the UserOp - // passing callGasLimit as 40000 to manually set it - let op; - try { - op = await mumbaiTestNetSdk.estimate({ callGasLimit: 40000 }); - - try { - assert.isNotEmpty( - op.sender, - message.vali_estimateTransaction_sender); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.nonce, - message.vali_estimateTransaction_nonce); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.initCode, - message.vali_estimateTransaction_initCode); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.callData, - message.vali_estimateTransaction_callData); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.callGasLimit, - message.vali_estimateTransaction_callGasLimit); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.verificationGasLimit, - message.vali_estimateTransaction_verificationGasLimit); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.maxFeePerGas, - message.vali_estimateTransaction_maxFeePerGas); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.maxPriorityFeePerGas, - message.vali_estimateTransaction_maxPriorityFeePerGas); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.paymasterAndData, - message.vali_estimateTransaction_paymasterAndData); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.preVerificationGas, - message.vali_estimateTransaction_preVerificationGas); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - op.signature, - message.vali_estimateTransaction_signature); - } 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_estimateTransaction_1); - } - - // sign the UserOp and sending to the bundler - let uoHash; - try { - uoHash = await mumbaiTestNetSdk.send(op); - - try { - assert.isNotEmpty( - uoHash, - message.vali_submitTransaction_uoHash); - } 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_submitTransaction_1); - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.nativeTransaction_insufficientBalance); - } - }); - - it('SMOKE: Perform the concurrent userops with valid details on the mumbai network', async function () { - // NOTE: assume the sender wallet is deployed - - var test = this; - if (runTest) { - - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - const provider = new providers.JsonRpcProvider(); - - // 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 - let transactionBatch; - try { - transactionBatch = await mumbaiTestNetSdk.addUserOpsToBatch({ - to: data.recipient, - value: ethers.utils.parseEther(data.value), - }); - - try { - assert.isNotEmpty( - transactionBatch.to, - message.vali_addTransaction_to); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactionBatch.data, - message.vali_addTransaction_data); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - } - - try { - assert.isNotEmpty( - transactionBatch.value, - message.vali_addTransaction_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_addTransaction_1); - } - - // get balance of the account address - let balance; - try { - balance = await mumbaiTestNetSdk.getNativeBalance(); - - try { - assert.isNotEmpty( - balance, - message.vali_getBalance_balance); - } 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_getBalance_1); - } - - // Note that usually Bundlers do not allow sending more than 10 concurrent userops from an unstaked entites (wallets, factories, paymaster) - // Staked entities can send as many userops as they want - let concurrentUseropsCount = 1; - const userops = []; - const uoHashes = []; - - try { - while (--concurrentUseropsCount >= 0) { - const op = await mumbaiTestNetSdk.estimate({ key: concurrentUseropsCount }); - userops.push(op); - } - - console.log("Sending userops..."); - for (const op of userops) { - const uoHash = await mumbaiTestNetSdk.send(op); - uoHashes.push(uoHash); - } - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_submitTransaction_1) - } - - try { - console.log('Waiting for transactions...'); - const userOpsReceipts = new Array(uoHashes.length).fill(null); - const timeout = Date.now() + 60000; // 1 minute timeout - while ((userOpsReceipts.some(receipt => receipt == null)) && (Date.now() < timeout)) { - helper.wait(2000) - for (let i = 0; i < uoHashes.length; ++i) { - if (userOpsReceipts[i]) continue; - const uoHash = uoHashes[i]; - userOpsReceipts[i] = await mumbaiTestNetSdk.getUserOpReceipt(uoHash); - } - } - - if (userOpsReceipts.some(receipt => receipt != null)) { - for (const uoReceipt of userOpsReceipts) { - if (!uoReceipt) continue; - addContext(test, message.vali_submitTransaction_1) - console.log(message.vali_submitTransaction_1); - } - } else { - addContext(test, message.vali_submitTransaction_2) - console.log(message.vali_submitTransaction_2); - } - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_getUserOpReceipt_1) - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.nativeTransaction_insufficientBalance); - } - }); - - it('REGRESSION: Perform the transfer native token with the incorrect To Address while estimate the added transactions to the batch 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); - } - - // add transactions to the batch - try { - await mumbaiTestNetSdk.addUserOpsToBatch({ - to: data.incorrectRecipient, // incorrect to address - 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 - try { - await mumbaiTestNetSdk.estimate(); - - addContext(test, message.fail_estimateTransaction_9) - assert.fail(message.fail_estimateTransaction_9); - } catch (e) { - let error = e.reason; - if (error.includes(constant.invalid_address_6)) { - addContext(test, message.vali_estimateTransaction_8) - console.log(message.vali_estimateTransaction_8); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_estimateTransaction_9); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.nativeTransaction_insufficientBalance); - } - }); - - it('REGRESSION: Perform the transfer native token with the invalid To Address i.e. missing character while estimate the added transactions to the batch 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); - } - - // add transactions to the batch - try { - await mumbaiTestNetSdk.addUserOpsToBatch({ - to: data.invalidRecipient, // invalid to address - 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 - try { - await mumbaiTestNetSdk.estimate(); - - addContext(test, message.fail_estimateTransaction_10) - assert.fail(message.fail_estimateTransaction_10); - } catch (e) { - let error = e.reason; - if (error.includes(constant.invalid_address_4)) { - addContext(test, message.vali_estimateTransaction_9) - console.log(message.vali_estimateTransaction_9); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_estimateTransaction_10); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.nativeTransaction_insufficientBalance); - } - }); - - it('REGRESSION: Perform the transfer native token with the invalid Value while estimate the added transactions to the batch 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); - } - - // add transactions to the batch - try { - await mumbaiTestNetSdk.addUserOpsToBatch({ - to: data.recipient, - value: ethers.utils.parseUnits(data.invalidValue), // invalid value - }); - - addContext(test, message.fail_estimateTransaction_11) - assert.fail(message.fail_estimateTransaction_11); - } catch (e) { - if (e.reason === constant.invalid_value_1) { - addContext(test, message.vali_estimateTransaction_10) - console.log(message.vali_estimateTransaction_10); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_estimateTransaction_11); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.nativeTransaction_insufficientBalance); - } - }); - - it('REGRESSION: Perform the transfer native token with the very small Value while estimate the added transactions to the batch 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); - } - - // add transactions to the batch - try { - await mumbaiTestNetSdk.addUserOpsToBatch({ - to: data.recipient, - value: ethers.utils.parseUnits(data.smallValue), // very small value - }); - - addContext(test, message.fail_estimateTransaction_12) - assert.fail(message.fail_estimateTransaction_12); - } catch (e) { - if (e.reason === constant.invalid_value_2) { - addContext(test, message.vali_estimateTransaction_11) - console.log(message.vali_estimateTransaction_11); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_estimateTransaction_12); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.nativeTransaction_insufficientBalance); - } - }); - - it('REGRESSION: Perform the transfer native token without adding transaction to the batch while estimate the added transactions to the batch 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); - } - - // 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 - try { - await mumbaiTestNetSdk.estimate(); - - addContext(test, message.fail_estimateTransaction_13) - assert.fail(message.fail_estimateTransaction_13); - } catch (e) { - if (e.message === constant.invalid_parameter) { - addContext(test, message.vali_estimateTransaction_12) - console.log(message.vali_estimateTransaction_12); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_estimateTransaction_13); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.nativeTransaction_insufficientBalance); - } - }); - - xit('REGRESSION: Perform the transfer native token by passing callGasLimit with the incorrect To Address while estimate the added transactions to the batch 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); - } - - // add transactions to the batch - try { - await mumbaiTestNetSdk.addUserOpsToBatch({ - to: data.incorrectRecipient, // incorrect to address - 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 - // passing callGasLimit as 40000 to manually set it - try { - await mumbaiTestNetSdk.estimate({ callGasLimit: 40000 }); - - addContext(test, message.fail_estimateTransaction_9) - assert.fail(message.fail_estimateTransaction_9); - } catch (e) { - let error = e.reason; - if (error.includes(constant.invalid_address_6)) { - addContext(test, message.vali_estimateTransaction_8) - console.log(message.vali_estimateTransaction_8); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_estimateTransaction_9); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.nativeTransaction_insufficientBalance); - } - }); - - xit('REGRESSION: Perform the transfer native token by passing callGasLimit with the invalid To Address i.e. missing character while estimate the added transactions to the batch 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); - } - - // add transactions to the batch - try { - await mumbaiTestNetSdk.addUserOpsToBatch({ - to: data.invalidRecipient, // invalid to address - 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 - // passing callGasLimit as 40000 to manually set it - try { - await mumbaiTestNetSdk.estimate({ callGasLimit: 40000 }); - - addContext(test, message.fail_estimateTransaction_10) - assert.fail(message.fail_estimateTransaction_10); - } catch (e) { - let error = e.reason; - if (error.includes(constant.invalid_address_4)) { - addContext(test, message.vali_estimateTransaction_8) - console.log(message.vali_estimateTransaction_8); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_estimateTransaction_10); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.nativeTransaction_insufficientBalance); - } - }); - - xit('REGRESSION: Perform the transfer native token by passing callGasLimit without adding transaction to the batch while estimate the added transactions to the batch 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); - } - - // 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 - // passing callGasLimit as 40000 to manually set it - try { - await mumbaiTestNetSdk.estimate({ callGasLimit: 40000 }); - - addContext(test, message.fail_estimateTransaction_13) - assert.fail(message.fail_estimateTransaction_13); - } catch (e) { - if (e.message === constant.empty_batch) { - addContext(test, message.vali_estimateTransaction_12) - console.log(message.vali_estimateTransaction_12); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_estimateTransaction_13); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.nativeTransaction_insufficientBalance); - } - }); - - it('REGRESSION: Perform the transfer ERC20 token with invalid provider netowrk details while Getting the Decimal from ERC20 Contract on the mumbai network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - // get the respective provider details - let provider; - try { - provider = new ethers.providers.JsonRpcProvider( - data.invalidProviderNetwork_mumbai, // invalid provider - ); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Transfer_provider); - } - - // get erc20 Contract Interface - let erc20Instance; - try { - erc20Instance = new ethers.Contract( - data.tokenAddress_mumbaiUSDC, - ERC20_ABI, - provider); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Transfer_contractInterface); - } - - // get decimals from erc20 contract - try { - await erc20Instance.functions.decimals(); - - addContext(test, message.fail_estimateTransaction_14) - assert.fail(message.fail_estimateTransaction_14); - } catch (e) { - if (e.reason === constant.invalid_network_2) { - addContext(test, message.vali_estimateTransaction_13) - console.log(message.vali_estimateTransaction_13); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_estimateTransaction_14); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.erc20Transaction_insufficientBalance); - } - }); - - it('REGRESSION: Perform the transfer ERC20 token without provider netowrk details while Getting the Decimal from ERC20 Contract on the mumbai network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - // get the respective provider details - let provider; - try { - provider = new ethers.providers.JsonRpcProvider(); // without provider - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Transfer_provider); - } - - // get erc20 Contract Interface - let erc20Instance; - try { - erc20Instance = new ethers.Contract( - data.tokenAddress_mumbaiUSDC, - ERC20_ABI, - provider); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Transfer_contractInterface); - } - - // get decimals from erc20 contract - try { - await erc20Instance.functions.decimals(); - - addContext(test, message.fail_estimateTransaction_14) - assert.fail(message.fail_estimateTransaction_14); - } catch (e) { - if (e.reason === constant.invalid_network_2) { - addContext(test, message.vali_estimateTransaction_13) - console.log(message.vali_estimateTransaction_13); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_estimateTransaction_14); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.erc20Transaction_insufficientBalance); - } - }); - - it('REGRESSION: Perform the transfer ERC20 token with other provider netowrk details while Getting the Decimal from ERC20 Contract on the mumbai network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - // get the respective provider details - let provider; - try { - provider = new ethers.providers.JsonRpcProvider( - data.otherProviderNetwork_mumbai, // other provider - ); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Transfer_provider); - } - - // get erc20 Contract Interface - let erc20Instance; - try { - erc20Instance = new ethers.Contract( - data.tokenAddress_mumbaiUSDC, - ERC20_ABI, - provider); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Transfer_contractInterface); - } - - // get decimals from erc20 contract - try { - await erc20Instance.functions.decimals(); - - addContext(test, message.fail_estimateTransaction_15) - assert.fail(message.fail_estimateTransaction_15); - } catch (e) { - let error = e.message; - if (error.includes(constant.invalid_value_3)) { - addContext(test, message.vali_estimateTransaction_14) - console.log(message.vali_estimateTransaction_14); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_estimateTransaction_15); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.erc20Transaction_insufficientBalance); - } - }); - - it('REGRESSION: Perform the transfer ERC20 token with incorrect Token Address details while Getting the Decimal from ERC20 Contract on the mumbai network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - // get the respective provider details - let provider; - try { - provider = new ethers.providers.JsonRpcProvider( - data.providerNetwork_mumbai); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Transfer_provider); - } - - // get erc20 Contract Interface - let erc20Instance; - try { - erc20Instance = new ethers.Contract( - data.incorrectTokenAddress_mumbaiUSDC, // incorrect token address - ERC20_ABI, - provider); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Transfer_contractInterface); - } - - // get decimals from erc20 contract - try { - await erc20Instance.functions.decimals(); - - addContext(message.fail_erc20Transfer_1) - assert.fail(message.fail_erc20Transfer_1); - } catch (e) { - if (e.reason === constant.invalid_address_6) { - addContext(test, message.vali_erc20Transfer_1) - console.log(message.vali_erc20Transfer_1); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Transfer_1); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.erc20Transaction_insufficientBalance); - } - }); - - it('REGRESSION: Perform the transfer ERC20 token with invalid Token Address i.e. missing character details while Getting the Decimal from ERC20 Contract on the mumbai network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - // get the respective provider details - let provider; - try { - provider = new ethers.providers.JsonRpcProvider( - data.providerNetwork_mumbai); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Transfer_provider); - } - - // get erc20 Contract Interface - let erc20Instance; - try { - erc20Instance = new ethers.Contract( - data.invalidTokenAddress_mumbaiUSDC, // invalid token address - ERC20_ABI, - provider); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Transfer_contractInterface); - } - - // get decimals from erc20 contract - try { - await erc20Instance.functions.decimals(); - - addContext(test, message.fail_erc20Transfer_2) - assert.fail(message.fail_erc20Transfer_2); - } catch (e) { - if (e.reason === constant.invalid_address_4) { - addContext(test, message.vali_erc20Transfer_2) - console.log(message.vali_erc20Transfer_2); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Transfer_2); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.erc20Transaction_insufficientBalance); - } - }); - - it('REGRESSION: Perform the transfer ERC20 token with null Token Address details while Getting the Decimal from ERC20 Contract on the mumbai network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - // get the respective provider details - let provider; - try { - provider = new ethers.providers.JsonRpcProvider( - data.providerNetwork_mumbai); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Transfer_provider); - } - - // get erc20 Contract Interface - try { - new ethers.Contract(null, ERC20_ABI, provider); // null token address - - addContext(test, message.fail_erc20Transfer_3) - assert.fail(message.fail_erc20Transfer_3); - } catch (e) { - if (e.reason === constant.contract_address_2) { - addContext(test, message.vali_erc20Transfer_3) - console.log(message.vali_erc20Transfer_3); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Transfer_3); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.erc20Transaction_insufficientBalance); - } - }); - - it('REGRESSION: Perform the transfer ERC20 token with incorrect transfer method name while Getting the transferFrom encoded data on the mumbai network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - // get the respective provider details - let provider; - try { - provider = new ethers.providers.JsonRpcProvider( - data.providerNetwork_mumbai); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Transfer_provider); - } - - // get erc20 Contract Interface - let erc20Instance; - try { - erc20Instance = new ethers.Contract( - data.tokenAddress_mumbaiUSDC, - ERC20_ABI, - provider); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Transfer_contractInterface); - } - - // get decimals from erc20 contract - let decimals; - try { - decimals = await erc20Instance.functions.decimals(); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Contract_decimals); - } - - // get transferFrom encoded data - try { - erc20Instance.interface.encodeFunctionData('transferr', [ - data.recipient, - ethers.utils.parseUnits(data.erc20_value, decimals), - ]); - - addContext(test, message.fail_erc20Transfer_4) - assert.fail(message.fail_erc20Transfer_4); - } catch (e) { - if (e.reason === constant.no_function) { - addContext(test, message.vali_erc20Transfer_4) - console.log(message.vali_erc20Transfer_4); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Transfer_4); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.erc20Transaction_insufficientBalance); - } - }); - - it('REGRESSION: Perform the transfer ERC20 token with invalid value while Getting the transferFrom encoded data on the mumbai network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - // get the respective provider details - let provider; - try { - provider = new ethers.providers.JsonRpcProvider( - data.providerNetwork_mumbai); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Transfer_provider); - } - - // get erc20 Contract Interface - let erc20Instance; - try { - erc20Instance = new ethers.Contract( - data.tokenAddress_mumbaiUSDC, - ERC20_ABI, - provider); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Transfer_contractInterface); - } - - // get decimals from erc20 contract - let decimals; - try { - decimals = await erc20Instance.functions.decimals(); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Contract_decimals); - } - - // get transferFrom encoded data - try { - erc20Instance.interface.encodeFunctionData('transfer', [ - data.recipient, - ethers.utils.parseUnits(data.invalidValue, decimals), // invalid value - ]); - - addContext(test, message.fail_erc20Transfer_5) - assert.fail(message.fail_erc20Transfer_5); - } catch (e) { - if (e.reason === constant.invalid_value_1) { - addContext(test, message.vali_erc20Transfer_5) - console.log(message.vali_erc20Transfer_5); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Transfer_5); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.erc20Transaction_insufficientBalance); - } - }); - - it('REGRESSION: Perform the transfer ERC20 token with very small value while Getting the transferFrom encoded data on the mumbai network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - // get the respective provider details - let provider; - try { - provider = new ethers.providers.JsonRpcProvider( - data.providerNetwork_mumbai); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Transfer_provider); - } - - // get erc20 Contract Interface - let erc20Instance; - try { - erc20Instance = new ethers.Contract( - data.tokenAddress_mumbaiUSDC, - ERC20_ABI, - provider); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Transfer_contractInterface); - } - - // get decimals from erc20 contract - let decimals; - try { - decimals = await erc20Instance.functions.decimals(); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Contract_decimals); - } - - // get transferFrom encoded data - try { - erc20Instance.interface.encodeFunctionData('transfer', [ - data.recipient, - ethers.utils.parseUnits(data.smallValue, decimals), // very small value - ]); - - addContext(test, message.fail_erc20Transfer_6) - assert.fail(message.fail_erc20Transfer_6); - } catch (e) { - if (e.reason === constant.invalid_value_2) { - addContext(test, message.vali_erc20Transfer_6) - console.log(message.vali_erc20Transfer_6); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Transfer_6); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.erc20Transaction_insufficientBalance); - } - }); - - it('REGRESSION: Perform the transfer ERC20 token without value while Getting the transferFrom encoded data on the mumbai network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - // get the respective provider details - let provider; - try { - provider = new ethers.providers.JsonRpcProvider( - data.providerNetwork_mumbai); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Transfer_provider); - } - - // get erc20 Contract Interface - let erc20Instance; - try { - erc20Instance = new ethers.Contract( - data.tokenAddress_mumbaiUSDC, - ERC20_ABI, - provider); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Transfer_contractInterface); - } - - // get decimals from erc20 contract - try { - await erc20Instance.functions.decimals(); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Contract_decimals); - } - - // get transferFrom encoded data - try { - erc20Instance.interface.encodeFunctionData('transfer', [ - data.recipient, - ]); - - addContext(test, message.fail_erc20Transfer_7) - assert.fail(message.fail_erc20Transfer_7); - } catch (e) { - if (e.reason === constant.invalid_value_4) { - addContext(test, message.vali_erc20Transfer_7) - console.log(message.vali_erc20Transfer_7); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Transfer_7); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.erc20Transaction_insufficientBalance); - } - }); - - it('REGRESSION: Perform the transfer ERC20 token with incorrect recipient while Getting the transferFrom encoded data on the mumbai network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - // get the respective provider details - let provider; - try { - provider = new ethers.providers.JsonRpcProvider( - data.providerNetwork_mumbai); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Transfer_provider); - } - - // get erc20 Contract Interface - let erc20Instance; - try { - erc20Instance = new ethers.Contract( - data.tokenAddress_mumbaiUSDC, - ERC20_ABI, - provider); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Transfer_contractInterface); - } - - // get decimals from erc20 contract - let decimals; - try { - decimals = await erc20Instance.functions.decimals(); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Contract_decimals); - } - - // get transferFrom encoded data - try { - erc20Instance.interface.encodeFunctionData('transfer', [ - data.incorrectRecipient, // incorrect recipient address - ethers.utils.parseUnits(data.erc20_value, decimals), - ]); - - addContext(test, message.fail_erc20Transfer_8) - assert.fail(message.fail_erc20Transfer_8); - } catch (e) { - let error = e.reason; - if (error.includes(constant.invalid_address_6)) { - addContext(test, message.vali_erc20Transfer_8) - console.log(message.vali_erc20Transfer_8); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Transfer_8); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.erc20Transaction_insufficientBalance); - } - }); - - it('REGRESSION: Perform the transfer ERC20 token with invalid recipient i.e. missing character while Getting the transferFrom encoded data on the mumbai network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - // get the respective provider details - let provider; - try { - provider = new ethers.providers.JsonRpcProvider( - data.providerNetwork_mumbai); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Transfer_provider); - } - - // get erc20 Contract Interface - let erc20Instance; - try { - erc20Instance = new ethers.Contract( - data.tokenAddress_mumbaiUSDC, - ERC20_ABI, - provider); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Transfer_contractInterface); - } - - // get decimals from erc20 contract - let decimals; - try { - decimals = await erc20Instance.functions.decimals(); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Contract_decimals); - } - - // get transferFrom encoded data - try { - erc20Instance.interface.encodeFunctionData('transfer', [ - data.invalidRecipient, // invalid recipient address - ethers.utils.parseUnits(data.erc20_value, decimals), - ]); - - addContext(test, message.fail_erc20Transfer_9) - assert.fail(message.fail_erc20Transfer_9); - } catch (e) { - let error = e.reason; - if (error.includes(constant.invalid_address_4)) { - addContext(test, message.vali_erc20Transfer_9) - console.log(message.vali_erc20Transfer_9); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Transfer_9); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.erc20Transaction_insufficientBalance); - } - }); - - it('REGRESSION: Perform the transfer ERC20 token without recipient while Getting the transferFrom encoded data on the mumbai network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - // get the respective provider details - let provider; - try { - provider = new ethers.providers.JsonRpcProvider( - data.providerNetwork_mumbai); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Transfer_provider); - } - - // get erc20 Contract Interface - let erc20Instance; - try { - erc20Instance = new ethers.Contract( - data.tokenAddress_mumbaiUSDC, - ERC20_ABI, - provider); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Transfer_contractInterface); - } - - // get decimals from erc20 contract - let decimals; - try { - decimals = await erc20Instance.functions.decimals(); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Contract_decimals); - } - - // get transferFrom encoded data - try { - erc20Instance.interface.encodeFunctionData('transfer', [ - ethers.utils.parseUnits(data.erc20_value, decimals), - ]); - - addContext(test, message.fail_erc20Transfer_10) - assert.fail(message.fail_erc20Transfer_10); - } catch (e) { - if (e.reason === constant.invalid_value_4) { - addContext(test, message.vali_erc20Transfer_10) - console.log(message.vali_erc20Transfer_10); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Transfer_10); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.erc20Transaction_insufficientBalance); - } - }); - - it('REGRESSION: Perform the transfer ERC20 token with the incorrect Token Address while adding transactions to the batch on the mumbai network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - // get the respective provider details - let provider; - try { - provider = new ethers.providers.JsonRpcProvider( - data.providerNetwork_mumbai); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Transfer_provider); - } - - // get erc20 Contract Interface - let erc20Instance; - try { - erc20Instance = new ethers.Contract( - data.tokenAddress_mumbaiUSDC, - ERC20_ABI, - provider); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Transfer_contractInterface); - } - - // get decimals from erc20 contract - let decimals; - try { - decimals = await erc20Instance.functions.decimals(); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Contract_decimals); - } - - // get transferFrom encoded data - let transactionData; - try { - transactionData = erc20Instance.interface.encodeFunctionData( - 'transfer', - [data.recipient, ethers.utils.parseUnits(data.erc20_value, decimals)]); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Contract_decimals); - } - - // 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.incorrectTokenAddress_mumbaiUSDC, // Incorrect Token Address - data: transactionData, - }); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_clearTransaction_1); - } - - // estimate transactions added to the batch - try { - await mumbaiTestNetSdk.estimate(); - - addContext(test, message.fail_estimateTransaction_16) - assert.fail(message.fail_estimateTransaction_16); - } catch (e) { - let error = e.reason; - if (error.includes(constant.invalid_address_6)) { - addContext(test, message.vali_estimateTransaction_15) - console.log(message.vali_estimateTransaction_15); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_estimateTransaction_16); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.erc20Transaction_insufficientBalance); - } - }); - - it('REGRESSION: Perform the transfer ERC20 token with the invalid Token Address i.e. missing character while adding transactions to the batch on the mumbai network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - // get the respective provider details - let provider; - try { - provider = new ethers.providers.JsonRpcProvider( - data.providerNetwork_mumbai); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Transfer_provider); - } - - // get erc20 Contract Interface - let erc20Instance; - try { - erc20Instance = new ethers.Contract( - data.tokenAddress_mumbaiUSDC, - ERC20_ABI, - provider); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Transfer_contractInterface); - } - - // get decimals from erc20 contract - let decimals; - try { - decimals = await erc20Instance.functions.decimals(); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Contract_decimals); - } - - // get transferFrom encoded data - let transactionData; - try { - transactionData = erc20Instance.interface.encodeFunctionData( - 'transfer', - [data.recipient, ethers.utils.parseUnits(data.erc20_value, decimals)]); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Contract_decimals); - } - - // 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.invalidTokenAddress_mumbaiUSDC, // Invalid Token Address - data: transactionData, - }); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_clearTransaction_1); - } - - // estimate transactions added to the batch - try { - await mumbaiTestNetSdk.estimate(); - - addContext(test, message.fail_estimateTransaction_17) - assert.fail(message.fail_estimateTransaction_17); - } catch (e) { - let error = e.reason; - if (error.includes(constant.invalid_address_4)) { - addContext(test, message.vali_estimateTransaction_16) - console.log(message.vali_estimateTransaction_16); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_estimateTransaction_17); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.erc20Transaction_insufficientBalance); - } - }); - - it('REGRESSION: Perform the transfer ERC20 token with the null Token Address while adding transactions to the batch on the mumbai network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - // get the respective provider details - let provider; - try { - provider = new ethers.providers.JsonRpcProvider( - data.providerNetwork_mumbai); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Transfer_provider); - } - - // get erc20 Contract Interface - let erc20Instance; - try { - erc20Instance = new ethers.Contract( - data.tokenAddress_mumbaiUSDC, - ERC20_ABI, - provider); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Transfer_contractInterface); - } - - // get decimals from erc20 contract - let decimals; - try { - decimals = await erc20Instance.functions.decimals(); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Contract_decimals); - } - - // get transferFrom encoded data - let transactionData; - try { - transactionData = erc20Instance.interface.encodeFunctionData( - 'transfer', - [data.recipient, ethers.utils.parseUnits(data.erc20_value, decimals)]); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Contract_decimals); - } - - // 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: null, // Null Token Address - data: transactionData, - }); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_clearTransaction_1); - } - - // estimate transactions added to the batch - try { - await mumbaiTestNetSdk.estimate(); - - addContext(test, message.fail_estimateTransaction_18) - assert.fail(message.fail_estimateTransaction_18); - } catch (e) { - if (e.reason.includes(constant.invalid_address_4)) { - addContext(test, message.vali_estimateTransaction_17) - console.log(message.vali_estimateTransaction_17); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_estimateTransaction_18); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.erc20Transaction_insufficientBalance); - } - }); - - it('REGRESSION: Perform the transfer ERC20 token without Token Address while adding transactions to the batch on the mumbai network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - // get the respective provider details - let provider; - try { - provider = new ethers.providers.JsonRpcProvider( - data.providerNetwork_mumbai); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Transfer_provider); - } - - // get erc20 Contract Interface - let erc20Instance; - try { - erc20Instance = new ethers.Contract( - data.tokenAddress_mumbaiUSDC, - ERC20_ABI, - provider); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Transfer_contractInterface); - } - - // get decimals from erc20 contract - let decimals; - try { - decimals = await erc20Instance.functions.decimals(); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Contract_decimals); - } - - // get transferFrom encoded data - let transactionData; - try { - transactionData = erc20Instance.interface.encodeFunctionData( - 'transfer', - [data.recipient, ethers.utils.parseUnits(data.erc20_value, decimals)]); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Contract_decimals); - } - - // 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({ - data: transactionData, // without tokenAddress - }); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_clearTransaction_1); - } - - // estimate transactions added to the batch - try { - await mumbaiTestNetSdk.estimate(); - - addContext(test, message.fail_estimateTransaction_19) - assert.fail(message.fail_estimateTransaction_19); - } catch (e) { - if (e.reason.includes(constant.invalid_address_4)) { - addContext(test, message.vali_estimateTransaction_18) - console.log(message.vali_estimateTransaction_18); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_estimateTransaction_19); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.erc20Transaction_insufficientBalance); - } - }); - - it('REGRESSION: Perform the transfer ERC20 token without adding transaction to the batch while estimate the added transactions to the batch on the mumbai network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - // get the respective provider details - let provider; - try { - provider = new ethers.providers.JsonRpcProvider( - data.providerNetwork_mumbai); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Transfer_provider); - } - - // get erc20 Contract Interface - let erc20Instance; - try { - erc20Instance = new ethers.Contract( - data.tokenAddress_mumbaiUSDC, - ERC20_ABI, - provider); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Transfer_contractInterface); - } - - // get decimals from erc20 contract - let decimals; - try { - decimals = await erc20Instance.functions.decimals(); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Contract_decimals); - } - - // get transferFrom encoded data - try { - erc20Instance.interface.encodeFunctionData('transfer', [ - data.recipient, - ethers.utils.parseUnits(data.erc20_value, decimals), - ]); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc20Contract_decimals); - } - - // 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); - } - - // estimate transactions added to the batch - try { - await mumbaiTestNetSdk.estimate(); - - assert.fail(message.fail_estimateTransaction_13); - } catch (e) { - if (e.message === constant.invalid_parameter) { - addContext(test, message.vali_estimateTransaction_12) - console.log(message.vali_estimateTransaction_12); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_estimateTransaction_13); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.erc20Transaction_insufficientBalance); - } - }); - - it('REGRESSION: Perform the transfer ERC721 NFT token with incorrect Sender Address while creating the NFT Data on the mumbai network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - // get erc721 Contract Interface - let erc721Interface; - try { - erc721Interface = new ethers.utils.Interface(abi.abi); - - erc721Interface.encodeFunctionData('transferFrom', [ - data.incorrectSender, // incorrect sender address - data.recipient, - data.tokenId, - ]); - - addContext(test, message.fail_erc721Transfer_1) - assert.fail(message.fail_erc721Transfer_1); - } catch (e) { - if (e.reason.includes(constant.invalid_address_6)) { - addContext(test, message.vali_erc721Transfer_1) - console.log(message.vali_erc721Transfer_1); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc721Transfer_1); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.erc721Transaction_insufficientBalance); - } - }); - - it('REGRESSION: Perform the transfer ERC721 NFT token with invalid Sender Address i.e. missing character while creating the NFT Data on the mumbai network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - // get erc721 Contract Interface - let erc721Interface; - try { - erc721Interface = new ethers.utils.Interface(abi.abi); - - erc721Interface.encodeFunctionData('transferFrom', [ - data.invalidSender, // invalid sender address - data.recipient, - data.tokenId, - ]); - - addContext(test, message.fail_erc721Transfer_2) - assert.fail(message.fail_erc721Transfer_2); - } catch (e) { - if (e.reason.includes(constant.invalid_address_4)) { - addContext(test, message.vali_erc721Transfer_2) - console.log(message.vali_erc721Transfer_2); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc721Transfer_2); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.erc721Transaction_insufficientBalance); - } - }); - - it('REGRESSION: Perform the transfer ERC721 NFT token without Sender Address while creating the NFT Data on the mumbai network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - // get erc721 Contract Interface - let erc721Interface; - try { - erc721Interface = new ethers.utils.Interface(abi.abi); - - erc721Interface.encodeFunctionData('transferFrom', [ - data.recipient, // not added sender address - data.tokenId, - ]); - - addContext(test, message.fail_erc721Transfer_3) - assert.fail(message.fail_erc721Transfer_3); - } catch (e) { - if (e.reason === constant.invalid_value_4) { - addContext(test, message.vali_erc721Transfer_3) - console.log(message.vali_erc721Transfer_3); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc721Transfer_3); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.erc721Transaction_insufficientBalance); - } - }); - - it('REGRESSION: Perform the transfer ERC721 NFT token with incorrect Recipient Address while creating the NFT Data on the mumbai network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - // get erc721 Contract Interface - let erc721Interface; - try { - erc721Interface = new ethers.utils.Interface(abi.abi); - - erc721Interface.encodeFunctionData('transferFrom', [ - data.sender, - data.incorrectRecipient, // incorrect recipient address - data.tokenId, - ]); - - addContext(test, message.fail_erc721Transfer_4) - assert.fail(message.fail_erc721Transfer_4); - } catch (e) { - if (e.reason.includes(constant.invalid_address_6)) { - addContext(test, message.vali_erc721Transfer_4) - console.log(message.vali_erc721Transfer_4); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc721Transfer_4); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.erc721Transaction_insufficientBalance); - } - }); - - it('REGRESSION: Perform the transfer ERC721 NFT token with invalid Recipient Address i.e. missing character while creating the NFT Data on the mumbai network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - // get erc721 Contract Interface - let erc721Interface; - try { - erc721Interface = new ethers.utils.Interface(abi.abi); - - erc721Interface.encodeFunctionData('transferFrom', [ - data.sender, - data.invalidRecipient, // invalid recipient address - data.tokenId, - ]); - - addContext(test, message.fail_erc721Transfer_5) - assert.fail(message.fail_erc721Transfer_5); - } catch (e) { - if (e.reason.includes(constant.invalid_address_4)) { - addContext(test, message.vali_erc721Transfer_5) - console.log(message.vali_erc721Transfer_5); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc721Transfer_5); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.erc721Transaction_insufficientBalance); - } - }); - - it('REGRESSION: Perform the transfer ERC721 NFT token without Recipient Address while creating the NFT Data on the mumbai network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - // get erc721 Contract Interface - let erc721Interface; - try { - erc721Interface = new ethers.utils.Interface(abi.abi); - - erc721Interface.encodeFunctionData('transferFrom', [ - data.sender, // not added recipient address - data.tokenId, - ]); - - addContext(test, message.fail_erc721Transfer_6) - assert.fail(message.fail_erc721Transfer_6); - } catch (e) { - if (e.reason === constant.invalid_value_4) { - addContext(test, message.vali_erc721Transfer_6) - console.log(message.vali_erc721Transfer_6); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc721Transfer_6); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.erc721Transaction_insufficientBalance); - } - }); - - it('REGRESSION: Perform the transfer ERC721 NFT token with incorrect tokenId while creating the NFT Data on the mumbai network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - // get erc721 Contract Interface - let erc721Interface; - try { - erc721Interface = new ethers.utils.Interface(abi.abi); - - erc721Interface.encodeFunctionData('transferFrom', [ - data.sender, - data.recipient, - data.incorrectTokenId, // incorrect tokenid - ]); - - addContext(message.fail_erc721Transfer_7) - assert.fail(message.fail_erc721Transfer_7); - } catch (e) { - if (e.reason === constant.invalid_bignumber_1) { - addContext(test, message.vali_erc721Transfer_7) - console.log(message.vali_erc721Transfer_7); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc721Transfer_7); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.erc721Transaction_insufficientBalance); - } - }); - - it('REGRESSION: Perform the transfer ERC721 NFT token without tokenId while creating the NFT Data on the mumbai network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - // get erc721 Contract Interface - let erc721Interface; - try { - erc721Interface = new ethers.utils.Interface(abi.abi); - - erc721Interface.encodeFunctionData('transferFrom', [ - data.sender, - data.recipient, // not added tokenid - ]); - - addContext(test, message.fail_erc721Transfer_8) - assert.fail(message.fail_erc721Transfer_8); - } catch (e) { - if (e.reason === constant.invalid_value_4) { - addContext(test, message.vali_erc721Transfer_8) - console.log(message.vali_erc721Transfer_8); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc721Transfer_8); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.erc721Transaction_insufficientBalance); - } - }); - - it('REGRESSION: Perform the transfer ERC721 NFT Token without adding transaction to the batch while estimate the added transactions to the batch on the mumbai network', async function () { - var test = this; - if (runTest) { - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - // get erc721 Contract Interface - let erc721Interface; - try { - erc721Interface = new ethers.utils.Interface(abi.abi); - - erc721Interface.encodeFunctionData('transferFrom', [ - data.sender, - data.recipient, - data.tokenId, - ]); - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_erc721Transfer_contractInterface); - } - - // 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); - } - - // 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 - try { - await mumbaiTestNetSdk.estimate(); - - addContext(test, message.fail_estimateTransaction_13) - assert.fail(message.fail_estimateTransaction_13); - } catch (e) { - if (e.message === constant.invalid_parameter) { - addContext(test, message.vali_estimateTransaction_12) - console.log(message.vali_estimateTransaction_12); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_estimateTransaction_13); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.erc721Transaction_insufficientBalance); - } - }); - - it('REGRESSION: Perform the concurrent userops with invalid concurrentUseropsCount on the mumbai network', async function () { - // NOTE: assume the sender wallet is deployed - - var test = this; - if (runTest) { - - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - const provider = new providers.JsonRpcProvider(); - - // 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 - let transactionBatch; - try { - transactionBatch = 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 - let balance; - try { - balance = await mumbaiTestNetSdk.getNativeBalance(); - - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_getBalance_1); - } - - // Note that usually Bundlers do not allow sending more than 10 concurrent userops from an unstaked entites (wallets, factories, paymaster) - // Staked entities can send as many userops as they want - let concurrentUseropsCount = -5; // invalid concurrent userops - const userops = []; - const uoHashes = []; - - try { - while (--concurrentUseropsCount >= 0) { - const op = await mumbaiTestNetSdk.estimate({ key: concurrentUseropsCount }); - userops.push(op); - } - - console.log("Sending userops..."); - for (const op of userops) { - const uoHash = await mumbaiTestNetSdk.send(op); - uoHashes.push(uoHash); - } - } catch (e) { - addContext(test, message.fail_submitTransaction_1) - assert.fail(message.fail_submitTransaction_1) - } - - try { - console.log('Waiting for transactions...'); - const userOpsReceipts = new Array(uoHashes.length).fill(null); - const timeout = Date.now() + 60000; // 1 minute timeout - while ((userOpsReceipts.some(receipt => receipt == null)) && (Date.now() < timeout)) { - helper.wait(2000) - for (let i = 0; i < uoHashes.length; ++i) { - if (userOpsReceipts[i]) continue; - const uoHash = uoHashes[i]; - userOpsReceipts[i] = await mumbaiTestNetSdk.getUserOpReceipt(uoHash); - } - } - - if (userOpsReceipts.some(receipt => receipt != null)) { - for (const uoReceipt of userOpsReceipts) { - if (!uoReceipt) continue; - addContext(test, message.vali_submitTransaction_1) - console.log(message.vali_submitTransaction_1); - } - } else { - addContext(test, message.vali_submitTransaction_2) - console.log(message.vali_submitTransaction_2); - } - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_getUserOpReceipt_1) - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.nativeTransaction_insufficientBalance); - } - }); - - it('REGRESSION: Perform the concurrent userops without concurrentUseropsCount on the mumbai network', async function () { - // NOTE: assume the sender wallet is deployed - - var test = this; - if (runTest) { - - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - const provider = new providers.JsonRpcProvider(); - - // 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 - let transactionBatch; - try { - transactionBatch = 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 - let balance; - try { - balance = await mumbaiTestNetSdk.getNativeBalance(); - - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_getBalance_1); - } - - // Note that usually Bundlers do not allow sending more than 10 concurrent userops from an unstaked entites (wallets, factories, paymaster) - // Staked entities can send as many userops as they want - let concurrentUseropsCount; // invalid concurrent userops - const userops = []; - const uoHashes = []; - - try { - while (--concurrentUseropsCount >= 0) { - const op = await mumbaiTestNetSdk.estimate({ key: concurrentUseropsCount }); - userops.push(op); - } - - console.log("Sending userops..."); - for (const op of userops) { - const uoHash = await mumbaiTestNetSdk.send(op); - uoHashes.push(uoHash); - } - } catch (e) { - addContext(test, message.fail_submitTransaction_1) - assert.fail(message.fail_submitTransaction_1) - } - - try { - console.log('Waiting for transactions...'); - const userOpsReceipts = new Array(uoHashes.length).fill(null); - const timeout = Date.now() + 60000; // 1 minute timeout - while ((userOpsReceipts.some(receipt => receipt == null)) && (Date.now() < timeout)) { - helper.wait(2000) - for (let i = 0; i < uoHashes.length; ++i) { - if (userOpsReceipts[i]) continue; - const uoHash = uoHashes[i]; - userOpsReceipts[i] = await mumbaiTestNetSdk.getUserOpReceipt(uoHash); - } - } - - if (userOpsReceipts.some(receipt => receipt != null)) { - for (const uoReceipt of userOpsReceipts) { - if (!uoReceipt) continue; - addContext(test, message.vali_submitTransaction_1) - console.log(message.vali_submitTransaction_1); - } - } else { - addContext(test, message.vali_submitTransaction_2) - console.log(message.vali_submitTransaction_2); - } - } catch (e) { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_getUserOpReceipt_1) - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.nativeTransaction_insufficientBalance); - } - }); - - it('REGRESSION: Perform the concurrent userops with non deployed address on the mumbai network', async function () { - var test = this; - if (runTest) { - - await customRetryAsync(async function () { - - helper.wait(data.mediumTimeout); - - const provider = new providers.JsonRpcProvider(); - - try { - if ((await provider.getCode(data.eoaAddress)).length <= 2) { - addContext(test, message.vali_deployAddress_1) - console.log(message.vali_deployAddress_1); - return; - } - - addContext(test, message.fail_deployAddress_1) - assert.fail(message.fail_deployAddress_1) - } catch (e) { - const errorMessage = e.message; - if (errorMessage.includes(constant.invalid_network_2)) { - addContext(test, message.vali_deployAddress_2) - console.log(message.vali_deployAddress_2); - } else { - console.error(e); - const eString = e.toString(); - addContext(test, eString); - assert.fail(message.fail_deployAddress_1); - } - } - }, data.retry); // Retry this async test up to 5 times - } else { - console.warn(message.nativeTransaction_insufficientBalance); - } - }); -}); diff --git a/test/utils/baseTest.js b/test/utils/baseTest.js index a3d5b93..3fbe5af 100644 --- a/test/utils/baseTest.js +++ b/test/utils/baseTest.js @@ -3,7 +3,7 @@ import helper from "./helper.js"; function customRetryAsync(fn, maxRetries) { return new Promise((resolve, reject) => { let retries = 0; - const retryDelay = 3000; // You can adjust the delay as needed + const retryDelay = 10000; // You can adjust the delay as needed async function run() { try { @@ -19,13 +19,11 @@ function customRetryAsync(fn, maxRetries) { await new Promise((resolve) => setTimeout(resolve, retryDelay)); retries++; run(); // Retry the test - helper.wait(10000); } else { reject(error); // Reject the promise if all retries fail } } } - run(); }); }