From 55732ee7203af324e6b5d248dd9258c616a51a46 Mon Sep 17 00:00:00 2001 From: Jineshdarjee Date: Thu, 19 Oct 2023 14:51:34 +0530 Subject: [PATCH] Added new test cases for xdai network and added api test cases --- .env | 6 +- package-lock.json | 190 +- package.json | 16 +- test/data/api_testData.json | 19 + test/data/testData.json | 22 +- test/specs/mainnet-api/arka/mumbai.spec.js | 275 ++ test/specs/mainnet-api/skandha/mumbai.spec.js | 549 +++ .../01_TransferringFunds/Arbitrum.spec.js | 504 +-- .../01_TransferringFunds/Matic.spec.js | 980 +---- .../01_TransferringFunds/Optimism.spec.js | 2 +- .../mainnet/01_TransferringFunds/Xdai.spec.js | 3826 +++++++++++++++++ .../02_TransactionHistory/Arbitrum.spec.js | 4 +- .../02_TransactionHistory/Matic.spec.js | 2 +- .../02_TransactionHistory/Optimism.spec.js | 2 +- .../02_TransactionHistory/Xdai.spec.js | 1581 +++++++ test/specs/mainnet/03_Swap/Arbitrum.spec.js | 2 +- test/specs/mainnet/03_Swap/Matic.spec.js | 2 +- test/specs/mainnet/03_Swap/Optimism.spec.js | 2 +- test/specs/mainnet/03_Swap/Xdai.spec.js | 1056 +++++ 19 files changed, 7689 insertions(+), 1351 deletions(-) create mode 100644 test/data/api_testData.json create mode 100644 test/specs/mainnet-api/arka/mumbai.spec.js create mode 100644 test/specs/mainnet-api/skandha/mumbai.spec.js create mode 100644 test/specs/mainnet/01_TransferringFunds/Xdai.spec.js create mode 100644 test/specs/mainnet/02_TransactionHistory/Xdai.spec.js create mode 100644 test/specs/mainnet/03_Swap/Xdai.spec.js diff --git a/.env b/.env index 484af75..3f2ea5d 100644 --- a/.env +++ b/.env @@ -3,6 +3,10 @@ INVALID_ARBITRUM_CHAINID="42511" OPTIMISM_CHAINID="10" INVALID_OPTIMISM_CHAINID="09" POLYGON_CHAINID="137" +POLYGON_CHAINID_TESTNET="80001" INVALID_POLYGON_CHAINID="189" +XDAI_CHAINID="100" +INVALID_XDAI_CHAINID="105" PRIVATE_KEY=_private_key_ -PROJECT_KEY=_project_key_ \ No newline at end of file +PROJECT_KEY=_project_key_ +API_KEY=_api_key_ \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 2113df8..7255e07 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,7 +12,7 @@ "@babel/eslint-parser": "^7.22.9", "@babel/plugin-syntax-import-assertions": "^7.22.5", "@etherspot/contracts": "^2.0.1", - "@etherspot/prime-sdk": "1.2.10", + "@etherspot/prime-sdk": "1.2.11", "@reactivex/rxjs": "^6.6.7", "axios": "^1.4.0", "chai": "^4.3.7", @@ -27,6 +27,7 @@ "mochawesome": "^7.1.3", "mochawesome-report-generator": "^6.2.0", "prettier": "^3.0.0", + "reflect-metadata": "^0.1.13", "rxjs": "^7.8.1", "ws": "^8.13.0" }, @@ -100,18 +101,18 @@ } }, "node_modules/@babel/compat-data": { - "version": "7.22.20", - "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.22.20.tgz", - "integrity": "sha512-BQYjKbpXjoXwFW5jGqiizJQQT/aC7pFm9Ok1OWssonuguICi264lbgMzRp2ZMmRSlfkX6DsWDDcsrctK8Rwfiw==", + "version": "7.23.2", + "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.23.2.tgz", + "integrity": "sha512-0S9TQMmDHlqAZ2ITT95irXKfxN9bncq8ZCoJhun3nHL/lLUxd2NKBJYoNGWH7S0hz6fRQwWlAWn/ILM0C70KZQ==", "peer": true, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/core": { - "version": "7.23.0", - "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.23.0.tgz", - "integrity": "sha512-97z/ju/Jy1rZmDxybphrBuI+jtJjFVoz7Mr9yUQVVVi+DNZE333uFQeMOqcCIy1x3WYBIbWftUSLmbNXNT7qFQ==", + "version": "7.23.2", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.23.2.tgz", + "integrity": "sha512-n7s51eWdaWZ3vGT2tD4T7J6eJs3QoBXydv7vkUM06Bf1cbVD2Kc2UrkzhiQwobfV7NwOnQXYL7UBJ5VPU+RGoQ==", "peer": true, "dependencies": { "@ampproject/remapping": "^2.2.0", @@ -119,10 +120,10 @@ "@babel/generator": "^7.23.0", "@babel/helper-compilation-targets": "^7.22.15", "@babel/helper-module-transforms": "^7.23.0", - "@babel/helpers": "^7.23.0", + "@babel/helpers": "^7.23.2", "@babel/parser": "^7.23.0", "@babel/template": "^7.22.15", - "@babel/traverse": "^7.23.0", + "@babel/traverse": "^7.23.2", "@babel/types": "^7.23.0", "convert-source-map": "^2.0.0", "debug": "^4.1.0", @@ -304,13 +305,13 @@ } }, "node_modules/@babel/helpers": { - "version": "7.23.1", - "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.23.1.tgz", - "integrity": "sha512-chNpneuK18yW5Oxsr+t553UZzzAs3aZnFm4bxhebsNTeshrC95yA7l5yl7GBAG+JG1rF0F7zzD2EixK9mWSDoA==", + "version": "7.23.2", + "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.23.2.tgz", + "integrity": "sha512-lzchcp8SjTSVe/fPmLwtWVBFC7+Tbn8LGHDVfDp9JGxpAY5opSaEFgt8UQvrnECWOTdji2mOWMz1rOhkHscmGQ==", "peer": true, "dependencies": { "@babel/template": "^7.22.15", - "@babel/traverse": "^7.23.0", + "@babel/traverse": "^7.23.2", "@babel/types": "^7.23.0" }, "engines": { @@ -369,9 +370,9 @@ } }, "node_modules/@babel/traverse": { - "version": "7.23.0", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.23.0.tgz", - "integrity": "sha512-t/QaEvyIoIkwzpiZ7aoSKK8kObQYeF7T2v+dazAYCb8SXtp58zEVkWW7zAnju8FNKNdr4ScAOEDmMItbyOmEYw==", + "version": "7.23.2", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.23.2.tgz", + "integrity": "sha512-azpe59SQ48qG6nu2CzcMLbxUudtN+dOM9kDbUqGq3HXUJRlo7i8fvPoxQUzYgLZ4cMVmuZgm8vvBpNeRhd6XSw==", "dependencies": { "@babel/code-frame": "^7.22.13", "@babel/generator": "^7.23.0", @@ -427,9 +428,9 @@ } }, "node_modules/@eslint-community/regexpp": { - "version": "4.9.0", - "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.9.0.tgz", - "integrity": "sha512-zJmuCWj2VLBt4c25CfBIbMZLGLyhkvs7LznyVX5HfpzeocThgIj5XQK4L+g3U36mMcx8bPMhGyPpwCATamC4jQ==", + "version": "4.9.1", + "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.9.1.tgz", + "integrity": "sha512-Y27x+MBLjXa+0JWDhykM3+JE+il3kHKAEqabfEWq3SDhZjLYb6/BHL/JKFnH3fe207JaXkyDo685Oc2Glt6ifA==", "engines": { "node": "^12.0.0 || ^14.0.0 || >=16.0.0" } @@ -457,9 +458,9 @@ } }, "node_modules/@eslint/eslintrc/node_modules/globals": { - "version": "13.22.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-13.22.0.tgz", - "integrity": "sha512-H1Ddc/PbZHTDVJSnj8kWptIRSD6AM3pK+mKytuIVF4uoBV7rshFlhhvA58ceJ5wp3Er58w6zj7bykMpYXt3ETw==", + "version": "13.23.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.23.0.tgz", + "integrity": "sha512-XAmF0RjlrjY23MA51q3HltdlGxUpXPvg0GioKiD9X6HD28iMjo2dKC8Vqwm7lne4GNr78+RHTfliktR6ZH09wA==", "dependencies": { "type-fest": "^0.20.2" }, @@ -471,9 +472,9 @@ } }, "node_modules/@eslint/js": { - "version": "8.50.0", - "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.50.0.tgz", - "integrity": "sha512-NCC3zz2+nvYd+Ckfh87rA47zfu2QsQpvc6k1yzTk+b9KzRj0wkGa8LSoGOXN6Zv4lRf/EIoZ80biDh9HOI+RNQ==", + "version": "8.51.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.51.0.tgz", + "integrity": "sha512-HxjQ8Qn+4SI3/AFv6sOrDB+g6PpUTDwSJiQqOrnneEk8L71161srI9gjzzZvYVbzHiVg/BvcH95+cK/zfIt4pg==", "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" } @@ -484,9 +485,9 @@ "integrity": "sha512-m1tlrr7Ou//GFC8G3+Lg7VfjbsnhRY3CPVRSmtksQFRbLJnJtyURSrJdUN4tj+18vgn+Dyxi/yXfKPUsgQU5DQ==" }, "node_modules/@etherspot/prime-sdk": { - "version": "1.2.10", - "resolved": "https://registry.npmjs.org/@etherspot/prime-sdk/-/prime-sdk-1.2.10.tgz", - "integrity": "sha512-NMxbabmkTPPNodMAC2BJFKz08FjZiUMGfZuRyPZ0HZvx5CVj4KLUr7dUara6ZWP8mSgNBZpMYi+rFGpRy9Viyg==", + "version": "1.2.11", + "resolved": "https://registry.npmjs.org/@etherspot/prime-sdk/-/prime-sdk-1.2.11.tgz", + "integrity": "sha512-TxCNUjZd5RVHosPOhDrunpSZLJN5+PQpe5mZGU2wK/ahY+pKE8JhM6sedCvla49d48+afq0ucCzKXrKJOZizvA==", "dependencies": { "@apollo/client": "3.4.0", "@lifi/sdk": "2.2.3", @@ -500,8 +501,8 @@ "commander": "10.0.1", "cross-fetch": "3.1.5", "ethers": "5.7.0", - "prettier": "2.8.8", - "reflect-metadata": "0.1.13" + "graphql-ws": "5.14.0", + "prettier": "2.8.8" } }, "node_modules/@etherspot/prime-sdk/node_modules/prettier": { @@ -1786,9 +1787,12 @@ "integrity": "sha512-Vrjz5N5Ia4SEzWWgIVwnHNEnb1UE1XMkvY5DGXrAeOGE9imk0hgTHh5GyDjLDJi9OTCn9oo9dXH1uToK1VRfrg==" }, "node_modules/@types/node": { - "version": "20.7.0", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.7.0.tgz", - "integrity": "sha512-zI22/pJW2wUZOVyguFaUL1HABdmSVxpXrzIqkjsHmyUjNhPoWM1CKfvVuXfetHhIok4RY573cqS0mZ1SJEnoTg==" + "version": "20.8.4", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.8.4.tgz", + "integrity": "sha512-ZVPnqU58giiCjSxjVUESDtdPk4QR5WQhhINbc9UBrKLU68MX5BF6kbQzTrkwbolyr0X8ChBpXfavr5mZFKZQ5A==", + "dependencies": { + "undici-types": "~5.25.1" + } }, "node_modules/@types/uuid": { "version": "7.0.6", @@ -2673,9 +2677,9 @@ "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==" }, "node_modules/browserslist": { - "version": "4.22.0", - "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.22.0.tgz", - "integrity": "sha512-v+Jcv64L2LbfTC6OnRcaxtqJNJuQAVhZKSJfR/6hn7lhnChUXl4amwVviqN1k411BB+3rRoKMitELRn1CojeRA==", + "version": "4.22.1", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.22.1.tgz", + "integrity": "sha512-FEVc202+2iuClEhZhrWy6ZiAcRLvNMyYcxZ8raemul1DYVOVdFsbqckWLdsixQZCpJlwe77Z3UTalE7jsjnKfQ==", "funding": [ { "type": "opencollective", @@ -2692,8 +2696,8 @@ ], "peer": true, "dependencies": { - "caniuse-lite": "^1.0.30001539", - "electron-to-chromium": "^1.4.530", + "caniuse-lite": "^1.0.30001541", + "electron-to-chromium": "^1.4.535", "node-releases": "^2.0.13", "update-browserslist-db": "^1.0.13" }, @@ -2773,9 +2777,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001540", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001540.tgz", - "integrity": "sha512-9JL38jscuTJBTcuETxm8QLsFr/F6v0CYYTEU6r5+qSM98P2Q0Hmu0eG1dTG5GBUmywU3UlcVOUSIJYY47rdFSw==", + "version": "1.0.30001547", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001547.tgz", + "integrity": "sha512-W7CrtIModMAxobGhz8iXmDfuJiiKg1WADMO/9x7/CLNin5cpSbuBjooyoIUVB5eyCc36QuTVlkVa1iB2S5+/eA==", "funding": [ { "type": "opencollective", @@ -2793,17 +2797,17 @@ "peer": true }, "node_modules/chai": { - "version": "4.3.9", - "resolved": "https://registry.npmjs.org/chai/-/chai-4.3.9.tgz", - "integrity": "sha512-tH8vhfA1CfuYMkALXj+wmZcqiwqOfshU9Gry+NYiiLqIddrobkBhALv6XD4yDz68qapphYI4vSaqhqAdThCAAA==", + "version": "4.3.10", + "resolved": "https://registry.npmjs.org/chai/-/chai-4.3.10.tgz", + "integrity": "sha512-0UXG04VuVbruMUYbJ6JctvH0YnC/4q3/AkT18q4NaITo91CUm0liMS9VqzT9vZhVQ/1eqPanMWjBM+Juhfb/9g==", "dependencies": { "assertion-error": "^1.1.0", "check-error": "^1.0.3", - "deep-eql": "^4.1.2", - "get-func-name": "^2.0.0", - "loupe": "^2.3.1", + "deep-eql": "^4.1.3", + "get-func-name": "^2.0.2", + "loupe": "^2.3.6", "pathval": "^1.1.1", - "type-detect": "^4.0.5" + "type-detect": "^4.0.8" }, "engines": { "node": ">=4" @@ -3169,9 +3173,9 @@ } }, "node_modules/electron-to-chromium": { - "version": "1.4.531", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.531.tgz", - "integrity": "sha512-H6gi5E41Rn3/mhKlPaT1aIMg/71hTAqn0gYEllSuw9igNWtvQwu185jiCZoZD29n7Zukgh7GVZ3zGf0XvkhqjQ==", + "version": "1.4.551", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.551.tgz", + "integrity": "sha512-/Ng/W/kFv7wdEHYzxdK7Cv0BHEGSkSB3M0Ssl8Ndr1eMiYeas/+Mv4cNaDqamqWx6nd2uQZfPz6g25z25M/sdw==", "peer": true }, "node_modules/elliptic": { @@ -3322,14 +3326,14 @@ } }, "node_modules/eslint": { - "version": "8.50.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.50.0.tgz", - "integrity": "sha512-FOnOGSuFuFLv/Sa+FDVRZl4GGVAAFFi8LecRsI5a1tMO5HIE8nCm4ivAlzt4dT3ol/PaaGC0rJEEXQmHJBGoOg==", + "version": "8.51.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.51.0.tgz", + "integrity": "sha512-2WuxRZBrlwnXi+/vFSJyjMqrNjtJqiasMzehF0shoLaW7DzS3/9Yvrmq5JiT66+pNjiX4UBnLDiKHcWAr/OInA==", "dependencies": { "@eslint-community/eslint-utils": "^4.2.0", "@eslint-community/regexpp": "^4.6.1", "@eslint/eslintrc": "^2.1.2", - "@eslint/js": "8.50.0", + "@eslint/js": "8.51.0", "@humanwhocodes/config-array": "^0.11.11", "@humanwhocodes/module-importer": "^1.0.1", "@nodelib/fs.walk": "^1.2.8", @@ -4218,9 +4222,9 @@ } }, "node_modules/eslint-plugin-prettier": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-5.0.0.tgz", - "integrity": "sha512-AgaZCVuYDXHUGxj/ZGu1u8H8CYgDY3iG6w5kUFw4AzMVXzB7VvbKgYR4nATIN+OvUrghMbiDLeimVjVY5ilq3w==", + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-5.0.1.tgz", + "integrity": "sha512-m3u5RnR56asrwV/lDC4GHorlW75DsFfmUcjfCYylTUs85dBRnB7VM6xG8eCMJdeDRnppzmxZVf1GEPJvl1JmNg==", "dependencies": { "prettier-linter-helpers": "^1.0.0", "synckit": "^0.8.5" @@ -4386,9 +4390,9 @@ } }, "node_modules/eslint/node_modules/globals": { - "version": "13.22.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-13.22.0.tgz", - "integrity": "sha512-H1Ddc/PbZHTDVJSnj8kWptIRSD6AM3pK+mKytuIVF4uoBV7rshFlhhvA58ceJ5wp3Er58w6zj7bykMpYXt3ETw==", + "version": "13.23.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.23.0.tgz", + "integrity": "sha512-XAmF0RjlrjY23MA51q3HltdlGxUpXPvg0GioKiD9X6HD28iMjo2dKC8Vqwm7lne4GNr78+RHTfliktR6ZH09wA==", "dependencies": { "type-fest": "^0.20.2" }, @@ -4790,11 +4794,11 @@ } }, "node_modules/flat-cache": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-3.1.0.tgz", - "integrity": "sha512-OHx4Qwrrt0E4jEIcI5/Xb+f+QmJYNj2rrK8wiIdQOIrB9WrrJL8cjZvXdXuBTkkEwEqLycb5BeZDV1o2i9bTew==", + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-3.1.1.tgz", + "integrity": "sha512-/qM2b3LUIaIgviBQovTLvijfyOQXPtSRnRK26ksj2J7rzPIecePUIpJsZ4T02Qg+xiAEKIs5K8dsHEd+VaKa/Q==", "dependencies": { - "flatted": "^3.2.7", + "flatted": "^3.2.9", "keyv": "^4.5.3", "rimraf": "^3.0.2" }, @@ -4865,6 +4869,19 @@ "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==" }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "hasInstallScript": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, "node_modules/fsu": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/fsu/-/fsu-1.1.1.tgz", @@ -5065,13 +5082,21 @@ "graphql": "^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0" } }, - "node_modules/has": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", - "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", - "dependencies": { - "function-bind": "^1.1.1" + "node_modules/graphql-ws": { + "version": "5.14.0", + "resolved": "https://registry.npmjs.org/graphql-ws/-/graphql-ws-5.14.0.tgz", + "integrity": "sha512-itrUTQZP/TgswR4GSSYuwWUzrE/w5GhbwM2GX3ic2U7aw33jgEsayfIlvaj7/GcIvZgNMzsPTrE5hqPuFUiE5g==", + "engines": { + "node": ">=10" }, + "peerDependencies": { + "graphql": ">=0.11 <=16" + } + }, + "node_modules/has": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/has/-/has-1.0.4.tgz", + "integrity": "sha512-qdSAmqLF6209RFj4VVItywPMbm3vWylknmB3nvNiUIs72xAimcM8nVYxYr7ncvZq5qzk9MKIZR8ijqD/1QuYjQ==", "engines": { "node": ">= 0.4.0" } @@ -5784,9 +5809,9 @@ } }, "node_modules/keyv": { - "version": "4.5.3", - "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.3.tgz", - "integrity": "sha512-QCiSav9WaX1PgETJ+SpNnx2PRRapJ/oRSXM4VO5OGYGSjrxbKPVFVhB3l2OCbLCk329N8qyAtsJjSjvVBWzEug==", + "version": "4.5.4", + "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.4.tgz", + "integrity": "sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw==", "dependencies": { "json-buffer": "3.0.1" } @@ -5809,9 +5834,9 @@ } }, "node_modules/libphonenumber-js": { - "version": "1.10.45", - "resolved": "https://registry.npmjs.org/libphonenumber-js/-/libphonenumber-js-1.10.45.tgz", - "integrity": "sha512-eeHcvGafEYCaKB4fo2uBINfG7j7PcGwBHUaTVfbwl/6KcjCgIKNlIOsSXVRp9BH10NQwmvvk+nQ1e/Yp4BGB7w==" + "version": "1.10.47", + "resolved": "https://registry.npmjs.org/libphonenumber-js/-/libphonenumber-js-1.10.47.tgz", + "integrity": "sha512-b4t7VQDV29xx/ni+58yl9KWPGjnDLDXCeCTLrD4V8vDpObXZRZBrg7uX/HWZ7YXiJKqdBDGgc+barUUTNB6Slw==" }, "node_modules/locate-path": { "version": "6.0.0", @@ -6984,9 +7009,9 @@ } }, "node_modules/resolve": { - "version": "1.22.6", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.6.tgz", - "integrity": "sha512-njhxM7mV12JfufShqGy3Rz8j11RPdLy4xi15UurGJeoHLfJpVXKdh3ueuOqbYUcDZnffr6X739JBo5LzyahEsw==", + "version": "1.22.8", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.8.tgz", + "integrity": "sha512-oKWePCxqpd6FlLvGV1VU0x7bkPmmCNolxzjMf4NczoDnQcIWrAF+cPtZn5i6n+RfD2d9i0tzpKnG6Yk168yIyw==", "dependencies": { "is-core-module": "^2.13.0", "path-parse": "^1.0.7", @@ -7894,6 +7919,11 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/undici-types": { + "version": "5.25.3", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.25.3.tgz", + "integrity": "sha512-Ga1jfYwRn7+cP9v8auvEXN1rX3sWqlayd4HP7OKk4mZWylEmu3KzXDUGrQUN6Ol7qo1gPvB2e5gX6udnyEPgdA==" + }, "node_modules/universalify": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz", diff --git a/package.json b/package.json index f594476..f319696 100644 --- a/package.json +++ b/package.json @@ -5,20 +5,25 @@ "main": "index.js", "type": "module", "scripts": { - "test": "mocha --timeout 600000", + "test": "mocha --timeout 600000 --spec test/specs/mainnet-api/arka/mumbai.spec.js", "test-mainnet": "mocha --timeout 600000 --spec test/specs/mainnet/*/Arbitrum.spec.js --spec test/specs/mainnet/*/Matic.spec.js --reporter mochawesome --reporter-options charts=true,code=false", "test-mainnet-transfertoken-arbitrum": "mocha --timeout 600000 --spec test/specs/mainnet/01_TransferringFunds/Arbitrum.spec.js --reporter mochawesome --reporter-options charts=true,code=false", "test-mainnet-transfertoken-matic": "mocha --timeout 600000 --spec test/specs/mainnet/01_TransferringFunds/Matic.spec.js --reporter mochawesome --reporter-options charts=true,code=false", "test-mainnet-transfertoken-optimism": "mocha --timeout 600000 --spec test/specs/mainnet/01_TransferringFunds/Optimism.spec.js --reporter mochawesome --reporter-options charts=true,code=false", + "test-mainnet-transfertoken-xdai": "mocha --timeout 600000 --spec test/specs/mainnet/01_TransferringFunds/Xdai.spec.js --reporter mochawesome --reporter-options charts=true,code=false", "test-mainnet-transfertoken": "mocha --timeout 600000 --spec test/specs/mainnet/01_TransferringFunds/*.spec.js --reporter mochawesome --reporter-options charts=true,code=false", "test-mainnet-transactionhistory-arbitrum": "mocha --timeout 600000 --spec test/specs/mainnet/02_TransactionHistory/Arbitrum.spec.js --reporter mochawesome --reporter-options charts=true,code=false", "test-mainnet-transactionhistory-matic": "mocha --timeout 600000 --spec test/specs/mainnet/02_TransactionHistory/Matic.spec.js --reporter mochawesome --reporter-options charts=true,code=false", "test-mainnet-transactionhistory-optimism": "mocha --timeout 600000 --spec test/specs/mainnet/02_TransactionHistory/Optimism.spec.js --reporter mochawesome --reporter-options charts=true,code=false", + "test-mainnet-transactionhistory-xdai": "mocha --timeout 600000 --spec test/specs/mainnet/02_TransactionHistory/Xdai.spec.js --reporter mochawesome --reporter-options charts=true,code=false", "test-mainnet-transactionhistory": "mocha --timeout 600000 --spec test/specs/mainnet/02_TransactionHistory/*.spec.js --reporter mochawesome --reporter-options charts=true,code=false", "test-mainnet-swap-arbitrum": "mocha --timeout 600000 --spec test/specs/mainnet/03_Swap/Arbitrum.spec.js --reporter mochawesome --reporter-options charts=true,code=false", "test-mainnet-swap-matic": "mocha --timeout 600000 --spec test/specs/mainnet/03_Swap/Matic.spec.js --reporter mochawesome --reporter-options charts=true,code=false", "test-mainnet-swap-optimism": "mocha --timeout 600000 --spec test/specs/mainnet/03_Swap/Optimism.spec.js --reporter mochawesome --reporter-options charts=true,code=false", - "test-mainnet-swap": "mocha --timeout 600000 --spec test/specs/mainnet/03_Swap/*.spec.js --reporter mochawesome --reporter-options charts=true,code=false" + "test-mainnet-swap-xdai": "mocha --timeout 600000 --spec test/specs/mainnet/03_Swap/Xdai.spec.js --reporter mochawesome --reporter-options charts=true,code=false", + "test-mainnet-swap": "mocha --timeout 600000 --spec test/specs/mainnet/03_Swap/*.spec.js --reporter mochawesome --reporter-options charts=true,code=false", + "test_arka": "mocha --timeout 600000 --spec test/specs/mainnet-api/arka/mumbai.spec.js", + "test_skandha": "mocha --timeout 600000 --spec test/specs/mainnet-api/skandha/mumbai.spec.js" }, "author": "", "license": "ISC", @@ -38,11 +43,12 @@ "eslint-plugin-prettier": "^5.0.0", "ethers": "5.7.0", "mocha": "^10.2.0", + "mochawesome": "^7.1.3", + "mochawesome-report-generator": "^6.2.0", "prettier": "^3.0.0", + "reflect-metadata": "^0.1.13", "rxjs": "^7.8.1", - "ws": "^8.13.0", - "mochawesome": "^7.1.3", - "mochawesome-report-generator": "^6.2.0" + "ws": "^8.13.0" }, "devDependencies": { "eslint": "^8.45.0" diff --git a/test/data/api_testData.json b/test/data/api_testData.json new file mode 100644 index 0000000..f3297de --- /dev/null +++ b/test/data/api_testData.json @@ -0,0 +1,19 @@ +{ + "eoaAddress": "0xa5494Ed2eB09F37b4b0526a8e4789565c226C84f", + "sender": "0x684E10D67dc4159B813Db70a1DAeB5FcC98bd034", + "recipient": "0x71Bec2309cC6BDD5F1D73474688A6154c28Db4B5", + "amount": 0.000001, + "arbitrum_chainid_mainnet": 42161, + "matic_chainid_mainnet": 137, + "optimism_chainid_mainnet": 10, + "xdai_chainid_mainnet": 100, + "mumbai_chainid_testnet": 80001, + "xdai_chainid_testnet": 5, + "arka_deposit": "https://arka.etherspot.io/deposit", + "arka_whitelist": "https://arka.etherspot.io/whitelist", + "arka_checkwhitelist": "https://arka.etherspot.io/checkWhitelist", + "arka_pimlico": "https://arka.etherspot.io/pimlicoAddress", + "address": "0x684E10D67dc4159B813Db70a1DAeB5FcC98bd034", + "entryPointAddress": "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789", + "usdc_token": "USDC" +} diff --git a/test/data/testData.json b/test/data/testData.json index e2a3a7b..bb6d89e 100644 --- a/test/data/testData.json +++ b/test/data/testData.json @@ -39,26 +39,22 @@ "providerNetwork_optimism": "https://optimism-bundler.etherspot.io", "invalidProviderNetwork_optimism": "http://optimism-bundler.etherspot.io", "otherProviderNetwork_optimism": "https://polygon-bundler.etherspot.io", + "tokenAddress_xdaiUSDC": "0xDDAfbb505ad214D7b80b1f830fcCc89B60fb7A83", + "incorrectTokenAddress_xdaiUSDC": "0xD2AAbb505a5214D7b30b1f830fcfc89B60fb7783", + "invalidTokenAddress_xdaiUSDC": "0xDDAfbb505ad214D7b80b1f830fcCc89B60fb7A8", + "providerNetwork_xdai": "https://gnosis-bundler.etherspot.io", + "invalidProviderNetwork_xdai": "http://gnosis-bundler.etherspot.io", + "otherProviderNetwork_xdai": "https://xdai-bundler.etherspot.io", "incorrect_hash": "0x3df9fe91b29f4b2bf1b148baf2f9E207e98137F8318ccf39eDc930d1ceA551df", "invalid_hash": "0x3df9fe91b29f4b2bf1b148baf2f9E207e98137F8z18ccf39eDc930d1ceA551df", "arbitrum_chainid": 42161, "matic_chainid": 137, "optimism_chainid": 10, + "xdai_chainid": 100, "invalid_arbitrum_chainid": 42656, "invalid_matic_chainid": 19, "invalid_optimism_chainid": 158, + "invalid_xdai_chainid": 105, "minimum_token_balance": 0.0001, - "minimum_native_balance": 0.0001, - "arbitrumUsdcAddress": "0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8", - "invalid_arbitrumUsdcAddress": "0xFe970C61A04b1cA11834A43f5dE4433eBDDB5CC8", - "arbitrumUsdtAddress": "0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9", - "invalid_arbitrumUsdtAddress": "0xFD006bC7CDcC481DCC9Cc5ebE478A110b69Ffbb9", - "maticUsdcAddress": "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174", - "invalid_maticUsdcAddress": "0x28a1Bca1f22e4661Ee88A30C9997a9449Aa84474", - "maticUsdtAddress": "0xc2132D05D31c914a87C6611C10748AEb04B58e8F", - "invalid_maticUsdtAddress": "0xcE112D05D31cd14a87Cc611C10788AEb04458e8F", - "optimismUsdcAddress": "0x7F5c764cBc14f9669B88837ca1490cCa17c31607", - "invalid_optimismUsdcAddress": "0x7755764cBc1cf9669B88b37ca14a0cCa17c33607", - "optimismUsdtAddress": "0x94b008aA00579c1307B0EF2c499aD98a8ce58e58", - "invalid_optimismUsdtAddress": "0x99b000aA00579c4307B0EF2cc99aD98a8cc58e58" + "minimum_native_balance": 0.0001 } diff --git a/test/specs/mainnet-api/arka/mumbai.spec.js b/test/specs/mainnet-api/arka/mumbai.spec.js new file mode 100644 index 0000000..3e7faed --- /dev/null +++ b/test/specs/mainnet-api/arka/mumbai.spec.js @@ -0,0 +1,275 @@ +import { PrimeSdk } from '@etherspot/prime-sdk'; +import { ethers } from 'ethers'; +import { assert } from 'chai'; +import Helper from '../../../utils/Helper.js'; +import data from '../../../data/api_testData.json' assert { type: 'json' }; +import * as dotenv from 'dotenv'; +dotenv.config(); // init dotenv + +let mumbaiTestNetSdk; + +/* eslint-disable prettier/prettier */ +describe('Performance testing of Arka Endpoints with Mumbai Network', () => { + it('SMOKE: Validate the Deposit endpoint of Arka on Mumbai Network', async () => { + const startTime = performance.now(); + + try { + const response = await fetch(data.arka_deposit, { + method: 'POST', + headers: { + Accept: 'application/json', + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ + params: [ + data.amount, + data.mumbai_chainid_testnet, + process.env.API_KEY, + ], + }), + }); + if (!response.ok) { + console.error('Response status:', response.status); + const errorResponse = await response.text(); + console.error('Error response:', errorResponse); + assert.fail('Getting an error'); + } else { + console.log('Response status:', response.status); + const ttfb_ms = performance.now() - startTime; // Calculate TTFB in milliseconds + const ttfb_s = (ttfb_ms / 1000).toFixed(2); + console.log('Time to First Byte (TTFB):', ttfb_s + ' second'); + + const returnedValue = await response.json(); + console.log('Value returned:', returnedValue); + } + } catch (error) { + console.error('Fetch error:', error); + assert.fail('Getting an error'); + } + }); + + it('SMOKE: Validate the Whitelist endpoint of Arka on Mumbai Network', async () => { + const addresses = [data.address]; + const startTime = performance.now(); + + try { + const response = await fetch(data.arka_whitelist, { + method: 'POST', + headers: { + Accept: 'application/json', + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ + params: [addresses, data.mumbai_chainid_testnet, process.env.API_KEY], + }), + }); + if (!response.ok) { + console.error('Response status:', response.status); + const errorResponse = await response.text(); + console.error('Error response:', errorResponse); + assert.fail('Getting an error'); + } else { + console.log('Response status:', response.status); + const ttfb_ms = performance.now() - startTime; // Calculate TTFB in milliseconds + const ttfb_s = (ttfb_ms / 1000).toFixed(2); + console.log('Time to First Byte (TTFB):', ttfb_s + ' second'); + + const returnedValue = await response.json(); + console.log('Value returned:', returnedValue); + } + } catch (error) { + console.error('Fetch error:', error); + assert.fail('Getting an error'); + } + }); + + it('SMOKE: Validate the Check an Address is Whitelist endpoint of Arka on Mumbai Network', async () => { + const sponsorAddress = data.address; + const addresses = '0xE05FB316eB8C4ba7288D43c1bd87BE8a8d16761C'; + const startTime = performance.now(); + + try { + const response = await fetch(data.arka_checkwhitelist, { + method: 'POST', + headers: { + Accept: 'application/json', + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ + params: [ + sponsorAddress, + addresses, + data.mumbai_chainid_testnet, + process.env.API_KEY, + ], + }), + }); + if (!response.ok) { + console.error('Response status:', response.status); + const errorResponse = await response.text(); + console.error('Error response:', errorResponse); + assert.fail('Getting an error'); + } else { + console.log('Response status:', response.status); + const ttfb_ms = performance.now() - startTime; // Calculate TTFB in milliseconds + const ttfb_s = (ttfb_ms / 1000).toFixed(2); + console.log('Time to First Byte (TTFB):', ttfb_s + ' second'); + + const returnedValue = await response.json(); + console.log('Value returned:', returnedValue); + } + } catch (error) { + console.error('Fetch error:', error); + assert.fail('Getting an error'); + } + }); + + it('SMOKE: Validate the Pimlico Paymaster endpoint of Arka on Mumbai Network', async () => { + const context = { token: data.usdc_token }; + const startTime = performance.now(); + + try { + const response = await fetch(data.arka_pimlico, { + method: 'POST', + headers: { + Accept: 'application/json', + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ + params: [ + entryPointAddress, + context, + data.mumbai_chainid_testnet, + process.env.API_KEY, + ], + }), + }); + if (!response.ok) { + console.error('Response status:', response.status); + const errorResponse = await response.text(); + console.error('Error response:', errorResponse); + assert.fail('Getting an error'); + } else { + console.log('Response status:', response.status); + const ttfb_ms = performance.now() - startTime; // Calculate TTFB in milliseconds + const ttfb_s = (ttfb_ms / 1000).toFixed(2); + console.log('Time to First Byte (TTFB):', ttfb_s + ' second'); + + const returnedValue = await response.json(); + console.log('Value returned:', returnedValue); + } + } catch (error) { + console.error('Fetch error:', error); + assert.fail('Getting an error'); + } + }); + + it('SMOKE: Perform the Sponsor a Transaction with Arka and PrimeSDK on the Mumbai network', async () => { + const startTime = performance.now(); + + // initializating sdk + try { + mumbaiTestNetSdk = new PrimeSdk( + { privateKey: process.env.PRIVATE_KEY }, + { + chainId: Number(process.env.POLYGON_CHAINID_TESTNET), + projectKey: process.env.PROJECT_KEY, + }, + ); + + try { + assert.strictEqual( + mumbaiTestNetSdk.state.walletAddress, + data.eoaAddress, + 'The EOA Address is not calculated correctly.', + ); + } catch (e) { + console.error(e); + } + } catch (e) { + console.error(e); + assert.fail('The SDK is not initialled successfully.'); + } + + // get EtherspotWallet address + try { + await mumbaiTestNetSdk.getCounterFactualAddress(); + } catch (e) { + console.error(e); + assert.fail( + 'The Etherspot Wallet Address is not displayed successfully.', + ); + } + + // clear the transaction batch + try { + await mumbaiTestNetSdk.clearUserOpsFromBatch(); + } catch (e) { + console.error(e); + assert.fail('The transaction of the batch is not clear correctly.'); + } + + // add transactions to the batch + try { + await mumbaiTestNetSdk.addUserOpsToBatch({ + to: data.recipient, + value: ethers.utils.parseEther('0.000001'), + }); + } catch (e) { + console.error(e); + assert.fail('The addition of transaction in the batch is not performed.'); + } + + // get balance of the account address + try { + await mumbaiTestNetSdk.getNativeBalance(); + } catch (e) { + console.error(e); + assert.fail('The balance of the native token is not displayed.'); + } + + // estimate transactions added to the batch and get the fee data for the UserOp + let op; + try { + op = await mumbaiTestNetSdk.estimate({ + url: 'https://arka.etherspot.io/', + api_key: process.env.API_KEY, + context: { mode: 'sponsor' }, + }); + } catch (e) { + console.error(e); + assert.fail( + 'The estimate transactions added to the batch and get the fee data for the UserOp is not performed.', + ); + } + + // sign the UserOp and sending to the bundler + let uoHash; + try { + uoHash = await mumbaiTestNetSdk.send(op); + } catch (e) { + console.error(e); + assert.fail( + 'The sign the UserOp and sending to the bundler action is not performed.', + ); + } + + // 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(2000); + userOpsReceipt = await mumbaiTestNetSdk.getUserOpReceipt(uoHash); + } + } catch (e) { + console.error(e); + assert.fail('The get transaction hash action is not performed.'); + } + + const ttfb_ms = performance.now() - startTime; // Calculate TTFB in milliseconds + const ttfb_s = (ttfb_ms / 1000).toFixed(2); + console.log('Time to First Byte (TTFB):', ttfb_s + ' second'); + }); +}); diff --git a/test/specs/mainnet-api/skandha/mumbai.spec.js b/test/specs/mainnet-api/skandha/mumbai.spec.js new file mode 100644 index 0000000..11f6fbb --- /dev/null +++ b/test/specs/mainnet-api/skandha/mumbai.spec.js @@ -0,0 +1,549 @@ +import { PrimeSdk } from '@etherspot/prime-sdk'; +import { ethers } from 'ethers'; +import { assert } from 'chai'; +// import Helper from '../../../utils/Helper.js'; +import data from '../../../data/api_testData.json' assert { type: 'json' }; +import * as dotenv from 'dotenv'; +dotenv.config(); // init dotenv + +let mumbaiTestNetSdk; + +/* eslint-disable prettier/prettier */ +describe('Performance testing of Skandha Endpoints with Mumbai Network', () => { + it('SMOKE: Validate the skandha_getGasPrice method of the skandha with valid details on Mumbai Network', async () => { + const startTime = performance.now(); + + try { + const response = await fetch('https://mumbai-bundler.etherspot.io/', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ + method: 'skandha_getGasPrice', + params: [], + id: 46, + jsonrpc: '2.0', + }), + }); + if (!response.ok) { + console.error('Response status:', response.status); + const errorResponse = await response.text(); + console.error('Error response:', errorResponse); + assert.fail('Getting an error'); + } else { + console.log('Response status:', response.status); + const ttfb_ms = performance.now() - startTime; // Calculate TTFB in milliseconds + const ttfb_s = (ttfb_ms / 1000).toFixed(2); + console.log('Time to First Byte (TTFB):', ttfb_s + ' second'); + + const returnedValue = await response.json(); + console.log('Value returned:', returnedValue); + + try { + assert.isNotEmpty( + returnedValue.result, + 'The result value is empty in the skandha_getGasPrice response.', + ); + } catch (e) { + console.error(e); + assert.fail('Not getting correct response.'); + } + } + } catch (error) { + console.error('Fetch error:', error); + assert.fail('Getting an error'); + } + }); + + it('SMOKE: Validate the skandha_config method of the skandha with valid details on Mumbai Network', async () => { + const startTime = performance.now(); + + try { + const response = await fetch('https://mumbai-bundler.etherspot.io/', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ + method: 'skandha_config', + params: [], + id: 46, + jsonrpc: '2.0', + }), + }); + if (!response.ok) { + console.error('Response status:', response.status); + const errorResponse = await response.text(); + console.error('Error response:', errorResponse); + assert.fail('Getting an error'); + } else { + console.log('Response status:', response.status); + const ttfb_ms = performance.now() - startTime; // Calculate TTFB in milliseconds + const ttfb_s = (ttfb_ms / 1000).toFixed(2); + console.log('Time to First Byte (TTFB):', ttfb_s + ' second'); + + const returnedValue = await response.json(); + console.log('Value returned:', returnedValue); + + try { + assert.isNotEmpty( + returnedValue.result, + 'The result value is empty in the skandha_config response.', + ); + } catch (e) { + console.error(e); + assert.fail('Not getting correct response.'); + } + } + } catch (error) { + console.error('Fetch error:', error); + assert.fail('Getting an error'); + } + }); + + xit('SMOKE: Validate the skandha_feeHistory method of the skandha with valid details on Mumbai Network', async () => { + const startTime = performance.now(); + + try { + const response = await fetch('https://mumbai-bundler.etherspot.io/', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ + method: 'skandha_feeHistory', + params: [], + id: 46, + jsonrpc: '2.0', + }), + }); + if (!response.ok) { + console.error('Response status:', response.status); + const errorResponse = await response.text(); + console.error('Error response:', errorResponse); + assert.fail('Getting an error'); + } else { + console.log('Response status:', response.status); + const ttfb_ms = performance.now() - startTime; // Calculate TTFB in milliseconds + const ttfb_s = (ttfb_ms / 1000).toFixed(2); + console.log('Time to First Byte (TTFB):', ttfb_s + ' second'); + + const returnedValue = await response.json(); + console.log('Value returned:', returnedValue); + + try { + assert.isNotEmpty( + returnedValue.result, + 'The result value is empty in the skandha_feeHistory response.', + ); + } catch (e) { + console.error(e); + assert.fail('Not getting correct response.'); + } + } + } catch (error) { + console.error('Fetch error:', error); + assert.fail('Getting an error'); + } + }); + + it('SMOKE: Validate the eth_chainId method of the skandha with valid details on Mumbai Network', async () => { + const startTime = performance.now(); + + try { + const response = await fetch('https://mumbai-bundler.etherspot.io/', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ + method: 'eth_chainId', + params: [], + id: 46, + jsonrpc: '2.0', + }), + }); + if (!response.ok) { + console.error('Response status:', response.status); + const errorResponse = await response.text(); + console.error('Error response:', errorResponse); + assert.fail('Getting an error'); + } else { + console.log('Response status:', response.status); + const ttfb_ms = performance.now() - startTime; // Calculate TTFB in milliseconds + const ttfb_s = (ttfb_ms / 1000).toFixed(2); + console.log('Time to First Byte (TTFB):', ttfb_s + ' second'); + + const returnedValue = await response.json(); + console.log('Value returned:', returnedValue); + + try { + assert.isNotEmpty( + returnedValue.result, + 'The result value is empty in the eth_chainId response.', + ); + } catch (e) { + console.error(e); + assert.fail('Not getting correct response.'); + } + } + } catch (error) { + console.error('Fetch error:', error); + assert.fail('Getting an error'); + } + }); + + it('SMOKE: Validate the eth_supportedEntryPoints method of the skandha with valid details on Mumbai Network', async () => { + const startTime = performance.now(); + + try { + const response = await fetch('https://mumbai-bundler.etherspot.io/', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ + method: 'eth_supportedEntryPoints', + params: [], + id: 46, + jsonrpc: '2.0', + }), + }); + if (!response.ok) { + console.error('Response status:', response.status); + const errorResponse = await response.text(); + console.error('Error response:', errorResponse); + assert.fail('Getting an error'); + } else { + console.log('Response status:', response.status); + const ttfb_ms = performance.now() - startTime; // Calculate TTFB in milliseconds + const ttfb_s = (ttfb_ms / 1000).toFixed(2); + console.log('Time to First Byte (TTFB):', ttfb_s + ' second'); + + const returnedValue = await response.json(); + console.log('Value returned:', returnedValue); + + try { + assert.isNotEmpty( + returnedValue.result, + 'The result value is empty in the eth_supportedEntryPoints response.', + ); + } catch (e) { + console.error(e); + assert.fail('Not getting correct response.'); + } + } + } catch (error) { + console.error('Fetch error:', error); + assert.fail('Getting an error'); + } + }); + + it.only('SMOKE: Perform the transfer native token with valid details on the Mumbai network', async () => { + const startTime = performance.now(); + + // initializating sdk + try { + mumbaiTestNetSdk = new PrimeSdk( + { privateKey: process.env.PRIVATE_KEY }, + { + chainId: Number(process.env.POLYGON_CHAINID_TESTNET), + projectKey: process.env.PROJECT_KEY, + }, + ); + + try { + assert.strictEqual( + mumbaiTestNetSdk.state.walletAddress, + data.eoaAddress, + 'The EOA Address is not calculated correctly.', + ); + } catch (e) { + console.error(e); + } + } catch (e) { + console.error(e); + assert.fail('The SDK is not initialled successfully.'); + } + + // get EtherspotWallet address + try { + await mumbaiTestNetSdk.getCounterFactualAddress(); + } catch (e) { + console.error(e); + assert.fail( + 'The Etherspot Wallet Address is not displayed successfully.', + ); + } + + // clear the transaction batch + try { + await mumbaiTestNetSdk.clearUserOpsFromBatch(); + } catch (e) { + console.error(e); + assert.fail('The transaction of the batch is not clear correctly.'); + } + + // add transactions to the batch + try { + await mumbaiTestNetSdk.addUserOpsToBatch({ + to: data.recipient, + value: ethers.utils.parseEther('0.000001'), + }); + } catch (e) { + console.error(e); + assert.fail('The addition of transaction in the batch is not performed.'); + } + + // get balance of the account address + try { + await mumbaiTestNetSdk.getNativeBalance(); + } catch (e) { + console.error(e); + assert.fail('The balance of the native token is not displayed.'); + } + + // 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); + assert.fail( + 'The estimate transactions added to the batch and get the fee data for the UserOp is not performed.', + ); + } + + // validate the eth_estimateUserOperationGas method of skandha + try { + const response = await fetch('https://mumbai-bundler.etherspot.io/', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ + method: 'eth_estimateUserOperationGas', + params: [op, data.entryPointAddress], + id: 46, + jsonrpc: '2.0', + }), + }); + if (!response.ok) { + console.error('Response status:', response.status); + const errorResponse = await response.text(); + console.error('Error response:', errorResponse); + assert.fail('Getting an error'); + } else { + console.log('Response status:', response.status); + const ttfb_ms = performance.now() - startTime; // Calculate TTFB in milliseconds + const ttfb_s = (ttfb_ms / 1000).toFixed(2); + console.log('Time to First Byte (TTFB):', ttfb_s + ' second'); + + const returnedValue = await response.json(); + console.log('Value returned:', returnedValue); + + try { + assert.isNotEmpty( + returnedValue.result, + 'The result value is empty in the skandha_getGasPrice response.', + ); + } catch (e) { + console.error(e); + assert.fail('Not getting correct response.'); + } + } + } catch (error) { + console.error('Fetch error:', error); + assert.fail('Getting an error'); + } + + // validate the eth_sendUserOperation method of skandha + try { + const response = await fetch('https://mumbai-bundler.etherspot.io/', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ + method: 'eth_sendUserOperation', + params: [op], + id: 46, + jsonrpc: '2.0', + }), + }); + if (!response.ok) { + console.error('Response status:', response.status); + const errorResponse = await response.text(); + console.error('Error response:', errorResponse); + assert.fail('Getting an error'); + } else { + console.log('Response status:', response.status); + const ttfb_ms = performance.now() - startTime; // Calculate TTFB in milliseconds + const ttfb_s = (ttfb_ms / 1000).toFixed(2); + console.log('Time to First Byte (TTFB):', ttfb_s + ' second'); + + const returnedValue = await response.json(); + console.log('Value returned:', returnedValue); + + try { + assert.isNotEmpty( + returnedValue.result, + 'The result value is empty in the skandha_getGasPrice response.', + ); + } catch (e) { + console.error(e); + assert.fail('Not getting correct response.'); + } + } + } catch (error) { + console.error('Fetch error:', error); + assert.fail('Getting an error'); + } + }); + + it('SMOKE: Perform the transfer native token with valid details on the Mumbai network', async () => { + const startTime = performance.now(); + + // initializating sdk + try { + mumbaiTestNetSdk = new PrimeSdk( + { privateKey: process.env.PRIVATE_KEY }, + { + chainId: Number(process.env.POLYGON_CHAINID_TESTNET), + projectKey: process.env.PROJECT_KEY, + }, + ); + + try { + assert.strictEqual( + mumbaiTestNetSdk.state.walletAddress, + data.eoaAddress, + 'The EOA Address is not calculated correctly.', + ); + } catch (e) { + console.error(e); + } + } catch (e) { + console.error(e); + assert.fail('The SDK is not initialled successfully.'); + } + + // get EtherspotWallet address + try { + await mumbaiTestNetSdk.getCounterFactualAddress(); + } catch (e) { + console.error(e); + assert.fail( + 'The Etherspot Wallet Address is not displayed successfully.', + ); + } + + // clear the transaction batch + try { + await mumbaiTestNetSdk.clearUserOpsFromBatch(); + } catch (e) { + console.error(e); + assert.fail('The transaction of the batch is not clear correctly.'); + } + + // add transactions to the batch + try { + await mumbaiTestNetSdk.addUserOpsToBatch({ + to: data.recipient, + value: ethers.utils.parseEther('0.000001'), + }); + } catch (e) { + console.error(e); + assert.fail('The addition of transaction in the batch is not performed.'); + } + + // get balance of the account address + try { + await mumbaiTestNetSdk.getNativeBalance(); + } catch (e) { + console.error(e); + assert.fail('The balance of the native token is not displayed.'); + } + + // 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); + assert.fail( + 'The estimate transactions added to the batch and get the fee data for the UserOp is not performed.', + ); + } + + // sign the UserOp and sending to the bundler + let uoHash; + try { + uoHash = await mumbaiTestNetSdk.send(op); + } catch (e) { + console.error(e); + assert.fail( + 'The sign the UserOp and sending to the bundler action is not performed.', + ); + } + + // validate the eth_sendUserOperation method of skandha + try { + const response = await fetch('https://mumbai-bundler.etherspot.io/', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ + method: 'eth_estimateUserOperationGas', + params: [uoHash], + id: 46, + jsonrpc: '2.0', + }), + }); + if (!response.ok) { + console.error('Response status:', response.status); + const errorResponse = await response.text(); + console.error('Error response:', errorResponse); + assert.fail('Getting an error'); + } else { + console.log('Response status:', response.status); + const ttfb_ms = performance.now() - startTime; // Calculate TTFB in milliseconds + const ttfb_s = (ttfb_ms / 1000).toFixed(2); + console.log('Time to First Byte (TTFB):', ttfb_s + ' second'); + + const returnedValue = await response.json(); + console.log('Value returned:', returnedValue); + + try { + assert.isNotEmpty( + returnedValue.result, + 'The result value is empty in the skandha_getGasPrice response.', + ); + } catch (e) { + console.error(e); + assert.fail('Not getting correct response.'); + } + } + } catch (error) { + console.error('Fetch error:', error); + assert.fail('Getting an error'); + } + + // // 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(2000); + // userOpsReceipt = await mumbaiTestNetSdk.getUserOpReceipt(uoHash); + // } + // } catch (e) { + // console.error(e); + // assert.fail('The get transaction hash action is not performed.'); + // } + }); +}); diff --git a/test/specs/mainnet/01_TransferringFunds/Arbitrum.spec.js b/test/specs/mainnet/01_TransferringFunds/Arbitrum.spec.js index 8b9e942..fa26023 100644 --- a/test/specs/mainnet/01_TransferringFunds/Arbitrum.spec.js +++ b/test/specs/mainnet/01_TransferringFunds/Arbitrum.spec.js @@ -77,7 +77,7 @@ describe('The PrimeSDK, when transfer a token with arbitrum network on the MainN if (tokenAddress === arbitrumNativeAddress) { native_balance = output.items[i].balance; native_final = utils.formatUnits(native_balance, 18); - } else if (tokenAddress === data.arbitrumUsdcAddress) { + } else if (tokenAddress === data.tokenAddress_arbitrumUSDC) { usdc_balance = output.items[i].balance; usdc_final = utils.formatUnits(usdc_balance, 6); } @@ -1601,63 +1601,6 @@ describe('The PrimeSDK, when transfer a token with arbitrum network on the MainN } }); - xit('REGRESSION: Perform the transfer native token with the same To Address i.e. sender address while estimate the added transactions to the batch on the arbitrum network', async () => { - if (runTest) { - // clear the transaction batch - try { - await arbitrumMainNetSdk.clearUserOpsFromBatch(); - } catch (e) { - console.error(e); - } - - // add transactions to the batch - try { - await arbitrumMainNetSdk.addUserOpsToBatch({ - to: data.sender, // same to address - value: ethers.utils.parseEther(data.value), - }); - } catch (e) { - console.error(e); - assert.fail( - 'The addition of transaction in the batch is not performed.', - ); - } - - // get balance of the account address - try { - await arbitrumMainNetSdk.getNativeBalance(); - } catch (e) { - console.error(e); - assert.fail('The balance of the native token is not displayed.'); - } - - // estimate transactions added to the batch - try { - await arbitrumMainNetSdk.estimate(); - - assert.fail( - 'The expected validation is not displayed when entered the same To Address i.e. sender address while estimate the added transactions to the batch.', - ); - } catch (e) { - let error = e.reason; - if (error.includes('invalid address')) { - console.log( - 'The validation for the same To Address i.e. sender address is displayed as expected while estimate the added transactions to the batch.', - ); - } else { - console.error(e); - assert.fail( - 'The expected validation is not displayed when entered the the same To Address i.e. sender address while estimate the added transactions to the batch.', - ); - } - } - } else { - console.warn( - 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE SEND NATIVE TOKEN WITH INVALID TO ADDRESS ON THE ARBITRUM NETWORK', - ); - } - }); - it('REGRESSION: Perform the transfer native token with the invalid Value while estimate the added transactions to the batch on the arbitrum network', async () => { if (runTest) { // clear the transaction batch @@ -1734,63 +1677,6 @@ describe('The PrimeSDK, when transfer a token with arbitrum network on the MainN } }); - xit('REGRESSION: Perform the transfer native token with the exceeded Value while estimate the added transactions to the batch on the arbitrum network', async () => { - if (runTest) { - // clear the transaction batch - try { - await arbitrumMainNetSdk.clearUserOpsFromBatch(); - } catch (e) { - console.error(e); - } - - // add transactions to the batch - try { - await arbitrumMainNetSdk.addUserOpsToBatch({ - to: data.recipient, - value: data.exceededValue, // exceeded value - }); - } catch (e) { - console.error(e); - assert.fail( - 'The addition of transaction in the batch is not performed.', - ); - } - - // get balance of the account address - try { - await arbitrumMainNetSdk.getNativeBalance(); - } catch (e) { - console.error(e); - assert.fail('The balance of the native token is not displayed.'); - } - - // estimate transactions added to the batch - try { - await arbitrumMainNetSdk.estimate(); - - assert.fail( - 'The expected validation is not displayed when entered the exceeded value while estimate the added transactions to the batch.', - ); - } catch (e) { - console.log(e); - if (e.reason === 'Transaction reverted') { - console.log( - 'The validation for value is displayed as expected while estimate the added transactions to the batch.', - ); - } else { - console.error(e); - assert.fail( - 'The expected validation is not displayed when entered the exceeded value while estimate the added transactions to the batch.', - ); - } - } - } else { - console.warn( - 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE SEND NATIVE TOKEN WITH EXCEEDED VALUE ON THE ARBITRUM NETWORK', - ); - } - }); - it('REGRESSION: Perform the transfer native token without adding transaction to the batch while estimate the added transactions to the batch on the arbitrum network', async () => { if (runTest) { // clear the transaction batch @@ -2480,82 +2366,6 @@ describe('The PrimeSDK, when transfer a token with arbitrum network on the MainN } }); - xit('REGRESSION: Perform the transfer ERC20 token with exceeded value while Getting the transferFrom encoded data on the arbitrum network', async () => { - if (runTest) { - // get the respective provider details - let provider; - try { - provider = new ethers.providers.JsonRpcProvider( - data.providerNetwork_arbitrum, - ); - } catch (e) { - console.error(e); - assert.fail('The provider response is not displayed correctly.'); - } - - // get erc20 Contract Interface - let erc20Instance; - try { - erc20Instance = new ethers.Contract( - data.tokenAddress_arbitrumUSDC, - ERC20_ABI, - provider, - ); - } catch (e) { - console.error(e); - assert.fail('The get erc20 Contract Interface is not performed.'); - } - - // get decimals from erc20 contract - let decimals; - try { - decimals = await erc20Instance.functions.decimals(); - } catch (e) { - console.error(e); - assert.fail( - 'The decimals from erc20 contract is not displayed correctly.', - ); - } - - // get transferFrom encoded data - try { - erc20Instance.interface.encodeFunctionData('transfer', [ - data.recipient, - ethers.utils.parseUnits(data.exceededValue, decimals), // exceeded value - ]); - } catch (e) { - console.error(e); - assert.fail( - 'The expected validation is not displayed when entered the exceeded value while Getting the transferFrom encoded data.', - ); - } - - // estimate transactions added to the batch - try { - await arbitrumMainNetSdk.estimate(); - - assert.fail( - 'The expected validation is not displayed when entered the exceeded value while estimate the added transactions to the batch.', - ); - } catch (e) { - if (e.reason === 'Transaction reverted') { - console.log( - 'The validation for value is displayed as expected while estimate the added transactions to the batch.', - ); - } else { - console.error(e); - assert.fail( - 'The expected validation is not displayed when entered the exceeded value while estimate the added transactions to the batch.', - ); - } - } - } else { - console.warn( - 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE SEND ERC20 TOKEN WITH EXCEEDED VALUE WHILE GETTING THE TRANSFERFROM ENCODED DATA ON THE ARBITRUM NETWORK', - ); - } - }); - it('REGRESSION: Perform the transfer ERC20 token without value while Getting the transferFrom encoded data on the arbitrum network', async () => { if (runTest) { // get the respective provider details @@ -2754,73 +2564,6 @@ describe('The PrimeSDK, when transfer a token with arbitrum network on the MainN } }); - xit('REGRESSION: Perform the transfer ERC20 token with same recipient i.e. sender address while Getting the transferFrom encoded data on the arbitrum network', async () => { - if (runTest) { - // get the respective provider details - let provider; - try { - provider = new ethers.providers.JsonRpcProvider( - data.providerNetwork_arbitrum, - ); - } catch (e) { - console.error(e); - assert.fail('The provider response is not displayed correctly.'); - } - - // get erc20 Contract Interface - let erc20Instance; - try { - erc20Instance = new ethers.Contract( - data.tokenAddress_arbitrumUSDC, - ERC20_ABI, - provider, - ); - } catch (e) { - console.error(e); - assert.fail('The get erc20 Contract Interface is not performed.'); - } - - // get decimals from erc20 contract - let decimals; - try { - decimals = await erc20Instance.functions.decimals(); - } catch (e) { - console.error(e); - assert.fail( - 'The decimals from erc20 contract is not displayed correctly.', - ); - } - - // get transferFrom encoded data - try { - erc20Instance.interface.encodeFunctionData('transfer', [ - data.sender, // same recipient address - ethers.utils.parseUnits(data.value, decimals), - ]); - - assert.fail( - 'The expected validation is not displayed when entered the invalid recipient while Getting the transferFrom encoded data.', - ); - } catch (e) { - let error = e.reason; - if (error.includes('invalid address')) { - console.log( - 'The validation for Recipient is displayed as expected while Getting the transferFrom encoded data.', - ); - } else { - console.error(e); - assert.fail( - 'The expected validation is not displayed when entered the invalid recipient while Getting the transferFrom encoded data.', - ); - } - } - } else { - console.warn( - 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE SEND ERC20 TOKEN WITH SAME RECEPIENT WHILE GETTING THE TRANSFERFROM ENCODED DATA ON THE ARBITRUM NETWORK', - ); - } - }); - it('REGRESSION: Perform the transfer ERC20 token without recipient while Getting the transferFrom encoded data on the arbitrum network', async () => { if (runTest) { // get the respective provider details @@ -3269,100 +3012,6 @@ describe('The PrimeSDK, when transfer a token with arbitrum network on the MainN } }); - xit('REGRESSION: Perform the transfer ERC20 token without transactionData while adding transactions to the batch on the arbitrum network', async () => { - if (runTest) { - // get the respective provider details - let provider; - try { - provider = new ethers.providers.JsonRpcProvider( - data.providerNetwork_arbitrum, - ); - } catch (e) { - console.error(e); - assert.fail('The provider response is not displayed correctly.'); - } - - // get erc20 Contract Interface - let erc20Instance; - try { - erc20Instance = new ethers.Contract( - data.tokenAddress_arbitrumUSDC, - ERC20_ABI, - provider, - ); - } catch (e) { - console.error(e); - assert.fail('The get erc20 Contract Interface is not performed.'); - } - - // get decimals from erc20 contract - let decimals; - try { - decimals = await erc20Instance.functions.decimals(); - } catch (e) { - console.error(e); - assert.fail( - 'The decimals from erc20 contract is not displayed correctly.', - ); - } - - // get transferFrom encoded data - try { - erc20Instance.interface.encodeFunctionData('transfer', [ - data.recipient, - ethers.utils.parseUnits(data.value, decimals), - ]); - } catch (e) { - console.error(e); - assert.fail( - 'The decimals from erc20 contract is not displayed correctly.', - ); - } - - // clear the transaction batch - try { - await arbitrumMainNetSdk.clearUserOpsFromBatch(); - } catch (e) { - console.error(e); - assert.fail('The transaction of the batch is not clear correctly.'); - } - - // add transactions to the batch - try { - await arbitrumMainNetSdk.addUserOpsToBatch({ - to: data.tokenAddress_arbitrumUSDC, // without transactionData - }); - } catch (e) { - console.error(e); - assert.fail('The transaction of the batch is not clear correctly.'); - } - - // estimate transactions added to the batch - try { - await arbitrumMainNetSdk.estimate(); - - assert.fail( - 'The expected validation is not displayed when not entered the transactionData while estimate the added transactions to the batch.', - ); - } catch (e) { - if (e.reason === 'bad response') { - console.log( - 'The validation for transactionData is displayed as expected while estimate the added transactions to the batch.', - ); - } else { - console.error(e); - assert.fail( - 'The expected validation is not displayed when not entered the transactionData while estimate the added transactions to the batch.', - ); - } - } - } else { - console.warn( - 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE SEND ERC20 TOKEN WITHOUT TRANSACTIONDATA WHILE ADDING TRANSACTION TO THE BATCH ON THE ARBITRUM NETWORK', - ); - } - }); - it('REGRESSION: Perform the transfer ERC20 token without adding transaction to the batch while estimate the added transactions to the batch on the arbitrum network', async () => { if (runTest) { // get the respective provider details @@ -3952,157 +3601,6 @@ describe('The PrimeSDK, when transfer a token with arbitrum network on the MainN } }); - xit('REGRESSION: Perform the transfer ERC721 NFT token with same sender address while creating the NFT Data on the arbitrum network', async () => { - if (runTest) { - // get erc721 Contract Interface - let erc721Interface; - let erc721Data; - try { - erc721Interface = new ethers.utils.Interface(abi.abi); - - erc721Data = erc721Interface.encodeFunctionData('transferFrom', [ - data.sender, - data.sender, - data.tokenId, - ]); - } catch (e) { - console.error(e); - assert.fail('The get erc721 Contract Interface is not performed.'); - } - - // clear the transaction batch - try { - await arbitrumMainNetSdk.clearUserOpsFromBatch(); - } catch (e) { - console.error(e); - assert.fail('The transaction of the batch is not clear correctly.'); - } - - // add transactions to the batch - try { - await arbitrumMainNetSdk.addUserOpsToBatch({ - to: data.nft_tokenAddress, - data: erc721Data, - }); - } catch (e) { - console.error(e); - assert.fail('The transaction of the batch is not clear correctly.'); - } - - // estimate transactions added to the batch - let op; - try { - op = await arbitrumMainNetSdk.estimate(); - } catch (e) { - console.error(e); - assert.fail( - 'The estimate transactions added to the batch is not performed.', - ); - } - - // sending to the bundler - try { - await arbitrumMainNetSdk.send(op); - - assert.fail( - 'The expected validation is not displayed when entered the same sender address while estimate the added transactions to the batch.', - ); - } catch (e) { - let error = e.reason; - if (error.includes('invalid address')) { - console.log( - 'The validation for sender address is displayed as expected while estimate the added transactions to the batch.', - ); - } else { - console.error(e); - assert.fail( - 'The expected validation is not displayed when entered the same sender address while estimate the added transactions to the batch.', - ); - } - } - } else { - console.warn( - 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE SEND ERC721 TOKEN WITH SAME SENDER ADDRESS WHILE ESTIMATE THE ADDED THE TRANSACTIONS TO THE BATCH ON THE ARBITRUM NETWORK', - ); - } - }); - - xit('REGRESSION: Perform the transfer ERC721 NFT token with same recipient address while creating the NFT Data on the arbitrum network', async () => { - if (runTest) { - // get erc721 Contract Interface - let erc721Interface; - let erc721Data; - try { - erc721Interface = new ethers.utils.Interface(abi.abi); - - erc721Data = erc721Interface.encodeFunctionData('transferFrom', [ - data.recipient, - data.recipient, - data.tokenId, - ]); - } catch (e) { - console.error(e); - assert.fail('The get erc721 Contract Interface is not performed.'); - } - - // clear the transaction batch - try { - await arbitrumMainNetSdk.clearUserOpsFromBatch(); - } catch (e) { - console.error(e); - assert.fail('The transaction of the batch is not clear correctly.'); - } - - // add transactions to the batch - try { - await arbitrumMainNetSdk.addUserOpsToBatch({ - to: data.nft_tokenAddress, - data: erc721Data, - }); - } catch (e) { - console.error(e); - assert.fail('The transaction of the batch is not clear correctly.'); - } - - // estimate transactions added to the batch - let op; - try { - op = await arbitrumMainNetSdk.estimate(); - } catch (e) { - console.error(e); - assert.fail( - 'The estimate transactions added to the batch is not performed.', - ); - } - - // sending to the bundler - try { - await arbitrumMainNetSdk.send(op); - - assert.fail( - 'The expected validation is not displayed when entered the same recipient address while estimate the added transactions to the batch.', - ); - } catch (e) { - console.error(e); - let error = e.reason; - if (error.includes('invalid address')) { - console.log( - 'The validation for recipient address is displayed as expected while estimate the added transactions to the batch.', - ); - } else { - console.error(e); - assert.fail( - 'The expected validation is not displayed when entered the same recipient address while estimate the added transactions to the batch.', - ); - } - } - } else { - console.warn( - 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE SEND ERC721 TOKEN WITH SAME RECEPIENT ADDRESS WHILE ESTIMATE THE ADDED THE TRANSACTIONS TO THE BATCH ON THE ARBITRUM NETWORK', - ); - } - }); - it('REGRESSION: Perform the transfer ERC721 NFT Token without adding transaction to the batch while estimate the added transactions to the batch on the arbitrum network', async () => { if (runTest) { // get erc721 Contract Interface diff --git a/test/specs/mainnet/01_TransferringFunds/Matic.spec.js b/test/specs/mainnet/01_TransferringFunds/Matic.spec.js index 747bc3b..b427820 100644 --- a/test/specs/mainnet/01_TransferringFunds/Matic.spec.js +++ b/test/specs/mainnet/01_TransferringFunds/Matic.spec.js @@ -77,7 +77,7 @@ describe('The PrimeSDK, when transfer a token with matic network on the MainNet' if (tokenAddress === maticNativeAddress) { native_balance = output.items[i].balance; native_final = utils.formatUnits(native_balance, 18); - } else if (tokenAddress === data.maticUsdcAddress) { + } else if (tokenAddress === data.tokenAddress_maticUSDC) { usdc_balance = output.items[i].balance; usdc_final = utils.formatUnits(usdc_balance, 6); } @@ -309,228 +309,228 @@ describe('The PrimeSDK, when transfer a token with matic network on the MainNet' ); } - // sign the UserOp and sending to the bundler - let uoHash; - try { - uoHash = await maticMainNetSdk.send(op); - - try { - assert.isNotEmpty( - uoHash, - 'The uoHash value is empty in the sending bundler response.', - ); - } catch (e) { - console.error(e); - } - } catch (e) { - console.error(e); - assert.fail( - 'The sign the UserOp and sending to the bundler action is not performed.', - ); - } - - // 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(2000); - userOpsReceipt = await maticMainNetSdk.getUserOpReceipt(uoHash); - } - - try { - assert.isNotEmpty( - userOpsReceipt.userOpHash, - 'The userOpHash value is empty in the get transaction hash response.', - ); - } catch (e) { - console.error(e); - } - - try { - assert.isNotEmpty( - userOpsReceipt.sender, - 'The sender value is empty in the get transaction hash response.', - ); - } catch (e) { - console.error(e); - } - - try { - assert.isNotEmpty( - userOpsReceipt.nonce, - 'The nonce value is empty in the get transaction hash response.', - ); - } catch (e) { - console.error(e); - } - - try { - assert.isNotEmpty( - userOpsReceipt.actualGasCost, - 'The actualGasCost value is empty in the get transaction hash response.', - ); - } catch (e) { - console.error(e); - } - - try { - assert.isNotEmpty( - userOpsReceipt.actualGasUsed, - 'The actualGasUsed value is empty in the get transaction hash response.', - ); - } catch (e) { - console.error(e); - } - - try { - assert.isTrue( - userOpsReceipt.success, - 'The success value is false in the get transaction hash response.', - ); - } catch (e) { - console.error(e); - } - - try { - assert.isNotEmpty( - userOpsReceipt.receipt.to, - 'The to value of the receipt is empty in the get transaction hash response.', - ); - } catch (e) { - console.error(e); - } - - try { - assert.isNotEmpty( - userOpsReceipt.receipt.from, - 'The from value of the receipt is empty in the get transaction hash response.', - ); - } catch (e) { - console.error(e); - } - - try { - assert.isNotEmpty( - userOpsReceipt.receipt.transactionIndex, - 'The transactionIndex value of the receipt is empty in the get transaction hash response.', - ); - } catch (e) { - console.error(e); - } - - try { - assert.isNotEmpty( - userOpsReceipt.receipt.gasUsed, - 'The gasUsed value of the receipt is empty in the get transaction hash response.', - ); - } catch (e) { - console.error(e); - } - - try { - assert.isNotEmpty( - userOpsReceipt.receipt.logsBloom, - 'The logsBloom value of the receipt is empty in the get transaction hash response.', - ); - } catch (e) { - console.error(e); - } - - try { - assert.isNotEmpty( - userOpsReceipt.receipt.blockHash, - 'The blockHash value of the receipt is empty in the get transaction hash response.', - ); - } catch (e) { - console.error(e); - } - - try { - assert.isNotEmpty( - userOpsReceipt.receipt.transactionHash, - 'The transactionHash value of the receipt is empty in the get transaction hash response.', - ); - } catch (e) { - console.error(e); - } - - try { - assert.isNotEmpty( - userOpsReceipt.receipt.logs, - 'The logs value of the receipt is empty in the get transaction hash response.', - ); - } catch (e) { - console.error(e); - } - - try { - assert.isNotEmpty( - userOpsReceipt.receipt.blockNumber, - 'The blockNumber value of the receipt is empty in the get transaction hash response.', - ); - } catch (e) { - console.error(e); - } - - try { - assert.isNotEmpty( - userOpsReceipt.receipt.confirmations, - 'The confirmations value of the receipt is empty in the get transaction hash response.', - ); - } catch (e) { - console.error(e); - } - - try { - assert.isNotEmpty( - userOpsReceipt.receipt.cumulativeGasUsed, - 'The cumulativeGasUsed value of the receipt is empty in the get transaction hash response.', - ); - } catch (e) { - console.error(e); - } - - try { - assert.isNotEmpty( - userOpsReceipt.receipt.effectiveGasPrice, - 'The effectiveGasPrice value of the receipt is empty in the get transaction hash response.', - ); - } catch (e) { - console.error(e); - } - - try { - assert.isNotEmpty( - userOpsReceipt.receipt.status, - 'The status value of the receipt is empty in the get transaction hash response.', - ); - } catch (e) { - console.error(e); - } - - try { - assert.isNotEmpty( - userOpsReceipt.receipt.type, - 'The type value of the receipt is empty in the get transaction hash response.', - ); - } catch (e) { - console.error(e); - } - - try { - assert.isTrue( - userOpsReceipt.receipt.byzantium, - 'The byzantium value of the receipt is false in the get transaction hash response.', - ); - } catch (e) { - console.error(e); - } - } catch (e) { - console.error(e); - assert.fail('The get transaction hash action is not performed.'); - } + // // sign the UserOp and sending to the bundler + // let uoHash; + // try { + // uoHash = await maticMainNetSdk.send(op); + + // try { + // assert.isNotEmpty( + // uoHash, + // 'The uoHash value is empty in the sending bundler response.', + // ); + // } catch (e) { + // console.error(e); + // } + // } catch (e) { + // console.error(e); + // assert.fail( + // 'The sign the UserOp and sending to the bundler action is not performed.', + // ); + // } + + // // 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(2000); + // userOpsReceipt = await maticMainNetSdk.getUserOpReceipt(uoHash); + // } + + // try { + // assert.isNotEmpty( + // userOpsReceipt.userOpHash, + // 'The userOpHash value is empty in the get transaction hash response.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isNotEmpty( + // userOpsReceipt.sender, + // 'The sender value is empty in the get transaction hash response.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isNotEmpty( + // userOpsReceipt.nonce, + // 'The nonce value is empty in the get transaction hash response.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isNotEmpty( + // userOpsReceipt.actualGasCost, + // 'The actualGasCost value is empty in the get transaction hash response.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isNotEmpty( + // userOpsReceipt.actualGasUsed, + // 'The actualGasUsed value is empty in the get transaction hash response.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isTrue( + // userOpsReceipt.success, + // 'The success value is false in the get transaction hash response.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isNotEmpty( + // userOpsReceipt.receipt.to, + // 'The to value of the receipt is empty in the get transaction hash response.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isNotEmpty( + // userOpsReceipt.receipt.from, + // 'The from value of the receipt is empty in the get transaction hash response.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isNotEmpty( + // userOpsReceipt.receipt.transactionIndex, + // 'The transactionIndex value of the receipt is empty in the get transaction hash response.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isNotEmpty( + // userOpsReceipt.receipt.gasUsed, + // 'The gasUsed value of the receipt is empty in the get transaction hash response.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isNotEmpty( + // userOpsReceipt.receipt.logsBloom, + // 'The logsBloom value of the receipt is empty in the get transaction hash response.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isNotEmpty( + // userOpsReceipt.receipt.blockHash, + // 'The blockHash value of the receipt is empty in the get transaction hash response.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isNotEmpty( + // userOpsReceipt.receipt.transactionHash, + // 'The transactionHash value of the receipt is empty in the get transaction hash response.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isNotEmpty( + // userOpsReceipt.receipt.logs, + // 'The logs value of the receipt is empty in the get transaction hash response.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isNotEmpty( + // userOpsReceipt.receipt.blockNumber, + // 'The blockNumber value of the receipt is empty in the get transaction hash response.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isNotEmpty( + // userOpsReceipt.receipt.confirmations, + // 'The confirmations value of the receipt is empty in the get transaction hash response.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isNotEmpty( + // userOpsReceipt.receipt.cumulativeGasUsed, + // 'The cumulativeGasUsed value of the receipt is empty in the get transaction hash response.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isNotEmpty( + // userOpsReceipt.receipt.effectiveGasPrice, + // 'The effectiveGasPrice value of the receipt is empty in the get transaction hash response.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isNotEmpty( + // userOpsReceipt.receipt.status, + // 'The status value of the receipt is empty in the get transaction hash response.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isNotEmpty( + // userOpsReceipt.receipt.type, + // 'The type value of the receipt is empty in the get transaction hash response.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isTrue( + // userOpsReceipt.receipt.byzantium, + // 'The byzantium value of the receipt is false in the get transaction hash response.', + // ); + // } catch (e) { + // console.error(e); + // } + // } catch (e) { + // console.error(e); + // assert.fail('The get transaction hash action is not performed.'); + // } } else { console.warn( 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE SEND NATIVE TOKEN ON THE matic NETWORK', @@ -1601,63 +1601,6 @@ describe('The PrimeSDK, when transfer a token with matic network on the MainNet' } }); - xit('REGRESSION: Perform the transfer native token with the same To Address i.e. sender address while estimate the added transactions to the batch on the matic network', async () => { - if (runTest) { - // clear the transaction batch - try { - await maticMainNetSdk.clearUserOpsFromBatch(); - } catch (e) { - console.error(e); - } - - // add transactions to the batch - try { - await maticMainNetSdk.addUserOpsToBatch({ - to: data.sender, // same to address - value: ethers.utils.parseEther(data.value), - }); - } catch (e) { - console.error(e); - assert.fail( - 'The addition of transaction in the batch is not performed.', - ); - } - - // get balance of the account address - try { - await maticMainNetSdk.getNativeBalance(); - } catch (e) { - console.error(e); - assert.fail('The balance of the native token is not displayed.'); - } - - // estimate transactions added to the batch - try { - await maticMainNetSdk.estimate(); - - assert.fail( - 'The expected validation is not displayed when entered the same To Address i.e. sender address while estimate the added transactions to the batch.', - ); - } catch (e) { - let error = e.reason; - if (error.includes('invalid address')) { - console.log( - 'The validation for the same To Address i.e. sender address is displayed as expected while estimate the added transactions to the batch.', - ); - } else { - console.error(e); - assert.fail( - 'The expected validation is not displayed when entered the the same To Address i.e. sender address while estimate the added transactions to the batch.', - ); - } - } - } else { - console.warn( - 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE SEND NATIVE TOKEN WITH INVALID TO ADDRESS ON THE matic NETWORK', - ); - } - }); - it('REGRESSION: Perform the transfer native token with the invalid Value while estimate the added transactions to the batch on the matic network', async () => { if (runTest) { // clear the transaction batch @@ -1734,63 +1677,6 @@ describe('The PrimeSDK, when transfer a token with matic network on the MainNet' } }); - xit('REGRESSION: Perform the transfer native token with the exceeded Value while estimate the added transactions to the batch on the matic network', async () => { - if (runTest) { - // clear the transaction batch - try { - await maticMainNetSdk.clearUserOpsFromBatch(); - } catch (e) { - console.error(e); - } - - // add transactions to the batch - try { - await maticMainNetSdk.addUserOpsToBatch({ - to: data.recipient, - value: data.exceededValue, // exceeded value - }); - } catch (e) { - console.error(e); - assert.fail( - 'The addition of transaction in the batch is not performed.', - ); - } - - // get balance of the account address - try { - await maticMainNetSdk.getNativeBalance(); - } catch (e) { - console.error(e); - assert.fail('The balance of the native token is not displayed.'); - } - - // estimate transactions added to the batch - try { - await maticMainNetSdk.estimate(); - - assert.fail( - 'The expected validation is not displayed when entered the exceeded value while estimate the added transactions to the batch.', - ); - } catch (e) { - console.log(e); - if (e.reason === 'Transaction reverted') { - console.log( - 'The validation for value is displayed as expected while estimate the added transactions to the batch.', - ); - } else { - console.error(e); - assert.fail( - 'The expected validation is not displayed when entered the exceeded value while estimate the added transactions to the batch.', - ); - } - } - } else { - console.warn( - 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE SEND NATIVE TOKEN WITH EXCEEDED VALUE ON THE matic NETWORK', - ); - } - }); - it('REGRESSION: Perform the transfer native token without adding transaction to the batch while estimate the added transactions to the batch on the matic network', async () => { if (runTest) { // clear the transaction batch @@ -2480,82 +2366,6 @@ describe('The PrimeSDK, when transfer a token with matic network on the MainNet' } }); - xit('REGRESSION: Perform the transfer ERC20 token with exceeded value while Getting the transferFrom encoded data on the matic network', async () => { - if (runTest) { - // get the respective provider details - let provider; - try { - provider = new ethers.providers.JsonRpcProvider( - data.providerNetwork_matic, - ); - } catch (e) { - console.error(e); - assert.fail('The provider response is not displayed correctly.'); - } - - // get erc20 Contract Interface - let erc20Instance; - try { - erc20Instance = new ethers.Contract( - data.tokenAddress_maticUSDC, - ERC20_ABI, - provider, - ); - } catch (e) { - console.error(e); - assert.fail('The get erc20 Contract Interface is not performed.'); - } - - // get decimals from erc20 contract - let decimals; - try { - decimals = await erc20Instance.functions.decimals(); - } catch (e) { - console.error(e); - assert.fail( - 'The decimals from erc20 contract is not displayed correctly.', - ); - } - - // get transferFrom encoded data - try { - erc20Instance.interface.encodeFunctionData('transfer', [ - data.recipient, - ethers.utils.parseUnits(data.exceededValue, decimals), // exceeded value - ]); - } catch (e) { - console.error(e); - assert.fail( - 'The expected validation is not displayed when entered the exceeded value while Getting the transferFrom encoded data.', - ); - } - - // estimate transactions added to the batch - try { - await maticMainNetSdk.estimate(); - - assert.fail( - 'The expected validation is not displayed when entered the exceeded value while estimate the added transactions to the batch.', - ); - } catch (e) { - if (e.reason === 'Transaction reverted') { - console.log( - 'The validation for value is displayed as expected while estimate the added transactions to the batch.', - ); - } else { - console.error(e); - assert.fail( - 'The expected validation is not displayed when entered the exceeded value while estimate the added transactions to the batch.', - ); - } - } - } else { - console.warn( - 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE SEND ERC20 TOKEN WITH EXCEEDED VALUE WHILE GETTING THE TRANSFERFROM ENCODED DATA ON THE matic NETWORK', - ); - } - }); - it('REGRESSION: Perform the transfer ERC20 token without value while Getting the transferFrom encoded data on the matic network', async () => { if (runTest) { // get the respective provider details @@ -2584,72 +2394,7 @@ describe('The PrimeSDK, when transfer a token with matic network on the MainNet' // get decimals from erc20 contract try { - await erc20Instance.functions.decimals(); - } catch (e) { - console.error(e); - assert.fail( - 'The decimals from erc20 contract is not displayed correctly.', - ); - } - - // get transferFrom encoded data - try { - erc20Instance.interface.encodeFunctionData('transfer', [ - data.recipient, - ]); - - assert.fail( - 'The expected validation is not displayed when not entered the value while Getting the transferFrom encoded data.', - ); - } catch (e) { - if (e.reason === 'types/values length mismatch') { - console.log( - 'The validation for value is displayed as expected while Getting the transferFrom encoded data.', - ); - } else { - console.error(e); - assert.fail( - 'The expected validation is not displayed when not entered the value while Getting the transferFrom encoded data.', - ); - } - } - } else { - console.warn( - 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE SEND ERC20 TOKEN WITHOUT VALUE WHILE GETTING THE TRANSFERFROM ENCODED DATA ON THE matic NETWORK', - ); - } - }); - - it('REGRESSION: Perform the transfer ERC20 token with incorrect recipient while Getting the transferFrom encoded data on the matic network', async () => { - if (runTest) { - // get the respective provider details - let provider; - try { - provider = new ethers.providers.JsonRpcProvider( - data.providerNetwork_matic, - ); - } catch (e) { - console.error(e); - assert.fail('The provider response is not displayed correctly.'); - } - - // get erc20 Contract Interface - let erc20Instance; - try { - erc20Instance = new ethers.Contract( - data.tokenAddress_maticUSDC, - ERC20_ABI, - provider, - ); - } catch (e) { - console.error(e); - assert.fail('The get erc20 Contract Interface is not performed.'); - } - - // get decimals from erc20 contract - let decimals; - try { - decimals = await erc20Instance.functions.decimals(); + await erc20Instance.functions.decimals(); } catch (e) { console.error(e); assert.fail( @@ -2660,34 +2405,32 @@ describe('The PrimeSDK, when transfer a token with matic network on the MainNet' // get transferFrom encoded data try { erc20Instance.interface.encodeFunctionData('transfer', [ - data.incorrectRecipient, // incorrect recipient address - ethers.utils.parseUnits(data.value, decimals), + data.recipient, ]); assert.fail( - 'The expected validation is not displayed when entered the incorrect recipient while Getting the transferFrom encoded data.', + 'The expected validation is not displayed when not entered the value while Getting the transferFrom encoded data.', ); } catch (e) { - let error = e.reason; - if (error.includes('bad address checksum')) { + if (e.reason === 'types/values length mismatch') { console.log( - 'The validation for Recipient is displayed as expected while Getting the transferFrom encoded data.', + 'The validation for value is displayed as expected while Getting the transferFrom encoded data.', ); } else { console.error(e); assert.fail( - 'The expected validation is not displayed when entered the incorrect recipient while Getting the transferFrom encoded data.', + 'The expected validation is not displayed when not entered the value while Getting the transferFrom encoded data.', ); } } } else { console.warn( - 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE SEND ERC20 TOKEN WITH INCORRECT RECEPIENT WHILE GETTING THE TRANSFERFROM ENCODED DATA ON THE matic NETWORK', + 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE SEND ERC20 TOKEN WITHOUT VALUE WHILE GETTING THE TRANSFERFROM ENCODED DATA ON THE matic NETWORK', ); } }); - it('REGRESSION: Perform the transfer ERC20 token with invalid recipient i.e. missing character while Getting the transferFrom encoded data on the matic network', async () => { + it('REGRESSION: Perform the transfer ERC20 token with incorrect recipient while Getting the transferFrom encoded data on the matic network', async () => { if (runTest) { // get the respective provider details let provider; @@ -2727,34 +2470,34 @@ describe('The PrimeSDK, when transfer a token with matic network on the MainNet' // get transferFrom encoded data try { erc20Instance.interface.encodeFunctionData('transfer', [ - data.invalidRecipient, // invalid recipient address + data.incorrectRecipient, // incorrect recipient address ethers.utils.parseUnits(data.value, decimals), ]); assert.fail( - 'The expected validation is not displayed when entered the invalid recipient while Getting the transferFrom encoded data.', + 'The expected validation is not displayed when entered the incorrect recipient while Getting the transferFrom encoded data.', ); } catch (e) { let error = e.reason; - if (error.includes('invalid address')) { + if (error.includes('bad address checksum')) { console.log( 'The validation for Recipient is displayed as expected while Getting the transferFrom encoded data.', ); } else { console.error(e); assert.fail( - 'The expected validation is not displayed when entered the invalid recipient while Getting the transferFrom encoded data.', + 'The expected validation is not displayed when entered the incorrect recipient while Getting the transferFrom encoded data.', ); } } } else { console.warn( - 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE SEND ERC20 TOKEN WITH INVALID RECEPIENT WHILE GETTING THE TRANSFERFROM ENCODED DATA ON THE matic NETWORK', + 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE SEND ERC20 TOKEN WITH INCORRECT RECEPIENT WHILE GETTING THE TRANSFERFROM ENCODED DATA ON THE matic NETWORK', ); } }); - xit('REGRESSION: Perform the transfer ERC20 token with same recipient i.e. sender address while Getting the transferFrom encoded data on the matic network', async () => { + it('REGRESSION: Perform the transfer ERC20 token with invalid recipient i.e. missing character while Getting the transferFrom encoded data on the matic network', async () => { if (runTest) { // get the respective provider details let provider; @@ -2794,7 +2537,7 @@ describe('The PrimeSDK, when transfer a token with matic network on the MainNet' // get transferFrom encoded data try { erc20Instance.interface.encodeFunctionData('transfer', [ - data.sender, // same recipient address + data.invalidRecipient, // invalid recipient address ethers.utils.parseUnits(data.value, decimals), ]); @@ -2816,7 +2559,7 @@ describe('The PrimeSDK, when transfer a token with matic network on the MainNet' } } else { console.warn( - 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE SEND ERC20 TOKEN WITH SAME RECEPIENT WHILE GETTING THE TRANSFERFROM ENCODED DATA ON THE matic NETWORK', + 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE SEND ERC20 TOKEN WITH INVALID RECEPIENT WHILE GETTING THE TRANSFERFROM ENCODED DATA ON THE matic NETWORK', ); } }); @@ -3269,100 +3012,6 @@ describe('The PrimeSDK, when transfer a token with matic network on the MainNet' } }); - xit('REGRESSION: Perform the transfer ERC20 token without transactionData while adding transactions to the batch on the matic network', async () => { - if (runTest) { - // get the respective provider details - let provider; - try { - provider = new ethers.providers.JsonRpcProvider( - data.providerNetwork_matic, - ); - } catch (e) { - console.error(e); - assert.fail('The provider response is not displayed correctly.'); - } - - // get erc20 Contract Interface - let erc20Instance; - try { - erc20Instance = new ethers.Contract( - data.tokenAddress_maticUSDC, - ERC20_ABI, - provider, - ); - } catch (e) { - console.error(e); - assert.fail('The get erc20 Contract Interface is not performed.'); - } - - // get decimals from erc20 contract - let decimals; - try { - decimals = await erc20Instance.functions.decimals(); - } catch (e) { - console.error(e); - assert.fail( - 'The decimals from erc20 contract is not displayed correctly.', - ); - } - - // get transferFrom encoded data - try { - erc20Instance.interface.encodeFunctionData('transfer', [ - data.recipient, - ethers.utils.parseUnits(data.value, decimals), - ]); - } catch (e) { - console.error(e); - assert.fail( - 'The decimals from erc20 contract is not displayed correctly.', - ); - } - - // clear the transaction batch - try { - await maticMainNetSdk.clearUserOpsFromBatch(); - } catch (e) { - console.error(e); - assert.fail('The transaction of the batch is not clear correctly.'); - } - - // add transactions to the batch - try { - await maticMainNetSdk.addUserOpsToBatch({ - to: data.tokenAddress_maticUSDC, // without transactionData - }); - } catch (e) { - console.error(e); - assert.fail('The transaction of the batch is not clear correctly.'); - } - - // estimate transactions added to the batch - try { - await maticMainNetSdk.estimate(); - - assert.fail( - 'The expected validation is not displayed when not entered the transactionData while estimate the added transactions to the batch.', - ); - } catch (e) { - if (e.reason === 'bad response') { - console.log( - 'The validation for transactionData is displayed as expected while estimate the added transactions to the batch.', - ); - } else { - console.error(e); - assert.fail( - 'The expected validation is not displayed when not entered the transactionData while estimate the added transactions to the batch.', - ); - } - } - } else { - console.warn( - 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE SEND ERC20 TOKEN WITHOUT TRANSACTIONDATA WHILE ADDING TRANSACTION TO THE BATCH ON THE matic NETWORK', - ); - } - }); - it('REGRESSION: Perform the transfer ERC20 token without adding transaction to the batch while estimate the added transactions to the batch on the matic network', async () => { if (runTest) { // get the respective provider details @@ -3952,157 +3601,6 @@ describe('The PrimeSDK, when transfer a token with matic network on the MainNet' } }); - xit('REGRESSION: Perform the transfer ERC721 NFT token with same sender address while creating the NFT Data on the matic network', async () => { - if (runTest) { - // get erc721 Contract Interface - let erc721Interface; - let erc721Data; - try { - erc721Interface = new ethers.utils.Interface(abi.abi); - - erc721Data = erc721Interface.encodeFunctionData('transferFrom', [ - data.sender, - data.sender, - data.tokenId, - ]); - } catch (e) { - console.error(e); - assert.fail('The get erc721 Contract Interface is not performed.'); - } - - // clear the transaction batch - try { - await maticMainNetSdk.clearUserOpsFromBatch(); - } catch (e) { - console.error(e); - assert.fail('The transaction of the batch is not clear correctly.'); - } - - // add transactions to the batch - try { - await maticMainNetSdk.addUserOpsToBatch({ - to: data.nft_tokenAddress, - data: erc721Data, - }); - } catch (e) { - console.error(e); - assert.fail('The transaction of the batch is not clear correctly.'); - } - - // estimate transactions added to the batch - let op; - try { - op = await maticMainNetSdk.estimate(); - } catch (e) { - console.error(e); - assert.fail( - 'The estimate transactions added to the batch is not performed.', - ); - } - - // sending to the bundler - try { - await maticMainNetSdk.send(op); - - assert.fail( - 'The expected validation is not displayed when entered the same sender address while estimate the added transactions to the batch.', - ); - } catch (e) { - let error = e.reason; - if (error.includes('invalid address')) { - console.log( - 'The validation for sender address is displayed as expected while estimate the added transactions to the batch.', - ); - } else { - console.error(e); - assert.fail( - 'The expected validation is not displayed when entered the same sender address while estimate the added transactions to the batch.', - ); - } - } - } else { - console.warn( - 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE SEND ERC721 TOKEN WITH SAME SENDER ADDRESS WHILE ESTIMATE THE ADDED THE TRANSACTIONS TO THE BATCH ON THE matic NETWORK', - ); - } - }); - - xit('REGRESSION: Perform the transfer ERC721 NFT token with same recipient address while creating the NFT Data on the matic network', async () => { - if (runTest) { - // get erc721 Contract Interface - let erc721Interface; - let erc721Data; - try { - erc721Interface = new ethers.utils.Interface(abi.abi); - - erc721Data = erc721Interface.encodeFunctionData('transferFrom', [ - data.recipient, - data.recipient, - data.tokenId, - ]); - } catch (e) { - console.error(e); - assert.fail('The get erc721 Contract Interface is not performed.'); - } - - // clear the transaction batch - try { - await maticMainNetSdk.clearUserOpsFromBatch(); - } catch (e) { - console.error(e); - assert.fail('The transaction of the batch is not clear correctly.'); - } - - // add transactions to the batch - try { - await maticMainNetSdk.addUserOpsToBatch({ - to: data.nft_tokenAddress, - data: erc721Data, - }); - } catch (e) { - console.error(e); - assert.fail('The transaction of the batch is not clear correctly.'); - } - - // estimate transactions added to the batch - let op; - try { - op = await maticMainNetSdk.estimate(); - } catch (e) { - console.error(e); - assert.fail( - 'The estimate transactions added to the batch is not performed.', - ); - } - - // sending to the bundler - try { - await maticMainNetSdk.send(op); - - assert.fail( - 'The expected validation is not displayed when entered the same recipient address while estimate the added transactions to the batch.', - ); - } catch (e) { - console.error(e); - let error = e.reason; - if (error.includes('invalid address')) { - console.log( - 'The validation for recipient address is displayed as expected while estimate the added transactions to the batch.', - ); - } else { - console.error(e); - assert.fail( - 'The expected validation is not displayed when entered the same recipient address while estimate the added transactions to the batch.', - ); - } - } - } else { - console.warn( - 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE SEND ERC721 TOKEN WITH SAME RECEPIENT ADDRESS WHILE ESTIMATE THE ADDED THE TRANSACTIONS TO THE BATCH ON THE matic NETWORK', - ); - } - }); - it('REGRESSION: Perform the transfer ERC721 NFT Token without adding transaction to the batch while estimate the added transactions to the batch on the matic network', async () => { if (runTest) { // get erc721 Contract Interface diff --git a/test/specs/mainnet/01_TransferringFunds/Optimism.spec.js b/test/specs/mainnet/01_TransferringFunds/Optimism.spec.js index 649694f..6a278e3 100644 --- a/test/specs/mainnet/01_TransferringFunds/Optimism.spec.js +++ b/test/specs/mainnet/01_TransferringFunds/Optimism.spec.js @@ -77,7 +77,7 @@ describe('The PrimeSDK, when transfer a token with optimism network on the MainN if (tokenAddress === optimismNativeAddress) { native_balance = output.items[i].balance; native_final = utils.formatUnits(native_balance, 18); - } else if (tokenAddress === data.optimismUsdcAddress) { + } else if (tokenAddress === data.tokenAddress_optimismUSDC) { usdc_balance = output.items[i].balance; usdc_final = utils.formatUnits(usdc_balance, 6); } diff --git a/test/specs/mainnet/01_TransferringFunds/Xdai.spec.js b/test/specs/mainnet/01_TransferringFunds/Xdai.spec.js new file mode 100644 index 0000000..bc11235 --- /dev/null +++ b/test/specs/mainnet/01_TransferringFunds/Xdai.spec.js @@ -0,0 +1,3826 @@ +import { PrimeSdk } 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 Helper from '../../../utils/Helper.js'; +import data from '../../../data/testData.json' assert { type: 'json' }; +import abi from '../../../data/NFTabi.json' assert { type: 'json' }; +import * as dotenv from 'dotenv'; +dotenv.config(); // init dotenv + +let xdaiMainNetSdk; +let xdaiEtherspotWalletAddress; +let xdaiNativeAddress = null; +let runTest; + +describe('The PrimeSDK, when transfer a token with xdai network on the MainNet', () => { + beforeEach(async () => { + // added timeout + Helper.wait(data.mediumTimeout); + + // initializating sdk + try { + xdaiMainNetSdk = new PrimeSdk( + { privateKey: process.env.PRIVATE_KEY }, + { + chainId: Number(process.env.XDAI_CHAINID), + projectKey: process.env.PROJECT_KEY, + rpcProviderUrl: data.providerNetwork_xdai, + bundlerRpcUrl: data.providerNetwork_xdai, + }, + ); + + try { + assert.strictEqual( + xdaiMainNetSdk.state.walletAddress, + data.eoaAddress, + 'The EOA Address is not calculated correctly.', + ); + } catch (e) { + console.error(e); + } + } catch (e) { + console.error(e); + assert.fail('The SDK is not initialled successfully.'); + } + + // get EtherspotWallet address + try { + xdaiEtherspotWalletAddress = + await xdaiMainNetSdk.getCounterFactualAddress(); + + try { + assert.strictEqual( + xdaiEtherspotWalletAddress, + data.sender, + 'The Etherspot Wallet Address is not calculated correctly.', + ); + } catch (e) { + console.error(e); + } + } catch (e) { + console.error(e); + assert.fail( + 'The Etherspot Wallet Address is not displayed successfully.', + ); + } + + let output = await xdaiMainNetSdk.getAccountBalances({ + account: data.sender, + chainId: Number(process.env.XDAI_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 === xdaiNativeAddress) { + native_balance = output.items[i].balance; + native_final = utils.formatUnits(native_balance, 18); + } else if (tokenAddress === data.tokenAddress_xdaiUSDC) { + 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; + } + }); + + it('SMOKE: Perform the transfer native token with valid details on the xdai network', async () => { + if (runTest) { + // clear the transaction batch + try { + await xdaiMainNetSdk.clearUserOpsFromBatch(); + } catch (e) { + console.error(e); + assert.fail('The transaction of the batch is not clear correctly.'); + } + + // add transactions to the batch + let transactionBatch; + try { + transactionBatch = await xdaiMainNetSdk.addUserOpsToBatch({ + to: data.recipient, + value: ethers.utils.parseEther(data.value), + }); + + try { + assert.isNotEmpty( + transactionBatch.to, + 'The To Address value is empty in the add transactions to batch response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isNotEmpty( + transactionBatch.data, + 'The data value is empty in the add transactions to batch response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isNotEmpty( + transactionBatch.value, + 'The value value is empty in the add transactions to batch response.', + ); + } catch (e) { + console.error(e); + } + } catch (e) { + console.error(e); + assert.fail( + 'The addition of transaction in the batch is not performed.', + ); + } + + // get balance of the account address + let balance; + try { + balance = await xdaiMainNetSdk.getNativeBalance(); + + try { + assert.isNotEmpty( + balance, + 'The balance is not number in the get native balance response.', + ); + } catch (e) { + console.error(e); + } + } catch (e) { + console.error(e); + assert.fail('The balance of the native token is not displayed.'); + } + + // estimate transactions added to the batch and get the fee data for the UserOp + let op; + try { + op = await xdaiMainNetSdk.estimate(); + + try { + assert.strictEqual( + op.sender, + data.sender, + 'The sender value is not correct in the estimate transactions added to the batch response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isNotEmpty( + op.nonce._hex, + 'The hex value of the nonce is empty in the estimate transactions added to the batch response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isTrue( + op.nonce._isBigNumber, + 'The isBigNumber value of the nonce is false in the estimate transactions added to the batch response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isNotEmpty( + op.initCode, + 'The initCode value is empty in the estimate transactions added to the batch response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isNotEmpty( + op.callData, + 'The callData value is empty in the estimate transactions added to the batch response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isNotEmpty( + op.callGasLimit._hex, + 'The hex value of the callGasLimit is empty in the estimate transactions added to the batch response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isTrue( + op.callGasLimit._isBigNumber, + 'The isBigNumber value of the callGasLimit is false in the estimate transactions added to the batch response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isNotEmpty( + op.verificationGasLimit._hex, + 'The hex value of the verificationGasLimit is empty in the estimate transactions added to the batch response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isTrue( + op.verificationGasLimit._isBigNumber, + 'The isBigNumber value of the verificationGasLimit is false in the estimate transactions added to the batch response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isNotEmpty( + op.maxFeePerGas, + 'The maxFeePerGas is empty in the estimate transactions added to the batch response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isNotEmpty( + op.maxPriorityFeePerGas, + 'The maxPriorityFeePerGas is empty in the estimate transactions added to the batch response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isNotEmpty( + op.paymasterAndData, + 'The paymasterAndData value is empty in the estimate transactions added to the batch response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isNotEmpty( + op.preVerificationGas._hex, + 'The hex value of the preVerificationGas is empty in the estimate transactions added to the batch response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isTrue( + op.preVerificationGas._isBigNumber, + 'The isBigNumber value of the preVerificationGas is false in the estimate transactions added to the batch response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isNotEmpty( + op.signature, + 'The signature value is empty in the estimate transactions added to the batch response.', + ); + } catch (e) { + console.error(e); + } + } catch (e) { + console.error(e); + assert.fail( + 'The estimate transactions added to the batch and get the fee data for the UserOp is not performed.', + ); + } + + // // sign the UserOp and sending to the bundler + // let uoHash; + // try { + // uoHash = await xdaiMainNetSdk.send(op); + + // try { + // assert.isNotEmpty( + // uoHash, + // 'The uoHash value is empty in the sending bundler response.', + // ); + // } catch (e) { + // console.error(e); + // } + // } catch (e) { + // console.error(e); + // assert.fail( + // 'The sign the UserOp and sending to the bundler action is not performed.', + // ); + // } + + // // 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(2000); + // userOpsReceipt = await xdaiMainNetSdk.getUserOpReceipt(uoHash); + // } + + // try { + // assert.isNotEmpty( + // userOpsReceipt.userOpHash, + // 'The userOpHash value is empty in the get transaction hash response.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isNotEmpty( + // userOpsReceipt.sender, + // 'The sender value is empty in the get transaction hash response.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isNotEmpty( + // userOpsReceipt.nonce, + // 'The nonce value is empty in the get transaction hash response.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isNotEmpty( + // userOpsReceipt.actualGasCost, + // 'The actualGasCost value is empty in the get transaction hash response.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isNotEmpty( + // userOpsReceipt.actualGasUsed, + // 'The actualGasUsed value is empty in the get transaction hash response.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isTrue( + // userOpsReceipt.success, + // 'The success value is false in the get transaction hash response.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isNotEmpty( + // userOpsReceipt.receipt.to, + // 'The to value of the receipt is empty in the get transaction hash response.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isNotEmpty( + // userOpsReceipt.receipt.from, + // 'The from value of the receipt is empty in the get transaction hash response.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isNotEmpty( + // userOpsReceipt.receipt.transactionIndex, + // 'The transactionIndex value of the receipt is empty in the get transaction hash response.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isNotEmpty( + // userOpsReceipt.receipt.gasUsed, + // 'The gasUsed value of the receipt is empty in the get transaction hash response.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isNotEmpty( + // userOpsReceipt.receipt.logsBloom, + // 'The logsBloom value of the receipt is empty in the get transaction hash response.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isNotEmpty( + // userOpsReceipt.receipt.blockHash, + // 'The blockHash value of the receipt is empty in the get transaction hash response.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isNotEmpty( + // userOpsReceipt.receipt.transactionHash, + // 'The transactionHash value of the receipt is empty in the get transaction hash response.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isNotEmpty( + // userOpsReceipt.receipt.logs, + // 'The logs value of the receipt is empty in the get transaction hash response.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isNotEmpty( + // userOpsReceipt.receipt.blockNumber, + // 'The blockNumber value of the receipt is empty in the get transaction hash response.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isNotEmpty( + // userOpsReceipt.receipt.confirmations, + // 'The confirmations value of the receipt is empty in the get transaction hash response.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isNotEmpty( + // userOpsReceipt.receipt.cumulativeGasUsed, + // 'The cumulativeGasUsed value of the receipt is empty in the get transaction hash response.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isNotEmpty( + // userOpsReceipt.receipt.effectiveGasPrice, + // 'The effectiveGasPrice value of the receipt is empty in the get transaction hash response.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isNotEmpty( + // userOpsReceipt.receipt.status, + // 'The status value of the receipt is empty in the get transaction hash response.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isNotEmpty( + // userOpsReceipt.receipt.type, + // 'The type value of the receipt is empty in the get transaction hash response.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isTrue( + // userOpsReceipt.receipt.byzantium, + // 'The byzantium value of the receipt is false in the get transaction hash response.', + // ); + // } catch (e) { + // console.error(e); + // } + // } catch (e) { + // console.error(e); + // assert.fail('The get transaction hash action is not performed.'); + // } + } else { + console.warn( + 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE SEND NATIVE TOKEN ON THE xdai NETWORK', + ); + } + }); + + it('SMOKE: Perform the transfer ERC20 token with valid details on the xdai network', async () => { + if (runTest) { + // get the respective provider details + let provider; + try { + provider = new ethers.providers.JsonRpcProvider( + data.providerNetwork_xdai, + ); + + try { + assert.isTrue( + provider._isProvider, + 'The isProvider value is false in the provider response.', + ); + } catch (e) { + console.error(e); + } + } catch (e) { + console.error(e); + assert.fail('The provider response is not displayed correctly.'); + } + + // get erc20 Contract Interface + let erc20Instance; + try { + erc20Instance = new ethers.Contract( + data.tokenAddress_xdaiUSDC, + ERC20_ABI, + provider, + ); + } catch (e) { + console.error(e); + assert.fail('The get erc20 Contract Interface is not performed.'); + } + + // get decimals from erc20 contract + let decimals; + try { + decimals = await erc20Instance.functions.decimals(); + + try { + assert.isNotEmpty( + decimals, + 'The decimals value is empty in the get decimals from erc20 contract response.', + ); + } catch (e) { + console.error(e); + } + } catch (e) { + console.error(e); + assert.fail( + 'The decimals from erc20 contract is not displayed correctly.', + ); + } + + // get transferFrom encoded data + let transactionData; + try { + transactionData = erc20Instance.interface.encodeFunctionData( + 'transfer', + [data.recipient, ethers.utils.parseUnits(data.value, decimals)], + ); + + try { + assert.isNotEmpty( + transactionData, + 'The decimals value is empty in the get decimals from erc20 contract response.', + ); + } catch (e) { + console.error(e); + } + } catch (e) { + console.error(e); + assert.fail( + 'The decimals from erc20 contract is not displayed correctly.', + ); + } + + // clear the transaction batch + try { + await xdaiMainNetSdk.clearUserOpsFromBatch(); + } catch (e) { + console.error(e); + assert.fail('The transaction of the batch is not clear correctly.'); + } + + // add transactions to the batch + let userOpsBatch; + try { + userOpsBatch = await xdaiMainNetSdk.addUserOpsToBatch({ + to: data.tokenAddress_xdaiUSDC, + data: transactionData, + }); + + try { + assert.isNotEmpty( + userOpsBatch.to, + 'The To Address value is empty in the userops batch response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isNotEmpty( + userOpsBatch.data, + 'The data value is empty in the userops batch response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isNotEmpty( + userOpsBatch.value[0]._hex, + 'The hex value of the userOpsBatch is empty in the userops batch response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isTrue( + userOpsBatch.value[0]._isBigNumber, + 'The isBigNumber value of the userOpsBatch is false in the userops batch response.', + ); + } catch (e) { + console.error(e); + } + } catch (e) { + console.error(e); + assert.fail('The transaction of the batch is not clear correctly.'); + } + + // estimate transactions added to the batch and get the fee data for the UserOp + let op; + try { + op = await xdaiMainNetSdk.estimate(); + + try { + assert.strictEqual( + op.sender, + data.sender, + 'The sender value is not correct in the estimate transactions added to the batch response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isNotEmpty( + op.nonce._hex, + 'The hex value of the nonce is empty in the estimate transactions added to the batch response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isTrue( + op.nonce._isBigNumber, + 'The isBigNumber value of the nonce is false in the estimate transactions added to the batch response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isNotEmpty( + op.initCode, + 'The initCode value is empty in the estimate transactions added to the batch response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isNotEmpty( + op.callData, + 'The callData value is empty in the estimate transactions added to the batch response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isNotEmpty( + op.callGasLimit._hex, + 'The hex value of the callGasLimit is empty in the estimate transactions added to the batch response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isTrue( + op.callGasLimit._isBigNumber, + 'The isBigNumber value of the callGasLimit is false in the estimate transactions added to the batch response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isNotEmpty( + op.verificationGasLimit._hex, + 'The hex value of the verificationGasLimit is empty in the estimate transactions added to the batch response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isTrue( + op.verificationGasLimit._isBigNumber, + 'The isBigNumber value of the verificationGasLimit is false in the estimate transactions added to the batch response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isNotEmpty( + op.maxFeePerGas, + 'The maxFeePerGas is empty in the estimate transactions added to the batch response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isNotEmpty( + op.maxPriorityFeePerGas, + 'The maxPriorityFeePerGas is empty in the estimate transactions added to the batch response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isNotEmpty( + op.paymasterAndData, + 'The paymasterAndData value is empty in the estimate transactions added to the batch response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isNotEmpty( + op.preVerificationGas._hex, + 'The hex value of the preVerificationGas is empty in the estimate transactions added to the batch response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isTrue( + op.preVerificationGas._isBigNumber, + 'The isBigNumber value of the preVerificationGas is false in the estimate transactions added to the batch response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isNotEmpty( + op.signature, + 'The signature value is empty in the estimate transactions added to the batch response.', + ); + } catch (e) { + console.error(e); + } + } catch (e) { + console.error(e); + assert.fail( + 'The estimate transactions added to the batch is not performed.', + ); + } + + // // sign the UserOp and sending to the bundler + // let uoHash; + // try { + // uoHash = await xdaiMainNetSdk.send(op); + + // assert.isNotEmpty( + // uoHash, + // 'The uoHash value is empty in the sending bundler response.', + // ); + // } catch (e) { + // console.error(e); + // assert.fail('The sending to the bundler action is not performed.'); + // } + + // // 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(2000); + // userOpsReceipt = await xdaiMainNetSdk.getUserOpReceipt(uoHash); + // } + + // try { + // assert.isNotEmpty( + // userOpsReceipt.userOpHash, + // 'The userOpHash value is empty in the get transaction hash response.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isNotEmpty( + // userOpsReceipt.sender, + // 'The sender value is empty in the get transaction hash response.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isNotEmpty( + // userOpsReceipt.nonce, + // 'The nonce value is empty in the get transaction hash response.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isNotEmpty( + // userOpsReceipt.actualGasCost, + // 'The actualGasCost value is empty in the get transaction hash response.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isNotEmpty( + // userOpsReceipt.actualGasUsed, + // 'The actualGasUsed value is empty in the get transaction hash response.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isTrue( + // userOpsReceipt.success, + // 'The success value is false in the get transaction hash response.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isNotEmpty( + // userOpsReceipt.receipt.to, + // 'The to value of the receipt is empty in the get transaction hash response.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isNotEmpty( + // userOpsReceipt.receipt.from, + // 'The from value of the receipt is empty in the get transaction hash response.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isNotEmpty( + // userOpsReceipt.receipt.transactionIndex, + // 'The transactionIndex value of the receipt is empty in the get transaction hash response.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isNotEmpty( + // userOpsReceipt.receipt.gasUsed, + // 'The gasUsed value of the receipt is empty in the get transaction hash response.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isNotEmpty( + // userOpsReceipt.receipt.logsBloom, + // 'The logsBloom value of the receipt is empty in the get transaction hash response.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isNotEmpty( + // userOpsReceipt.receipt.blockHash, + // 'The blockHash value of the receipt is empty in the get transaction hash response.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isNotEmpty( + // userOpsReceipt.receipt.transactionHash, + // 'The transactionHash value of the receipt is empty in the get transaction hash response.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isNotEmpty( + // userOpsReceipt.receipt.logs, + // 'The logs value of the receipt is empty in the get transaction hash response.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isNotEmpty( + // userOpsReceipt.receipt.blockNumber, + // 'The blockNumber value of the receipt is empty in the get transaction hash response.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isNotEmpty( + // userOpsReceipt.receipt.confirmations, + // 'The confirmations value of the receipt is empty in the get transaction hash response.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isNotEmpty( + // userOpsReceipt.receipt.cumulativeGasUsed, + // 'The cumulativeGasUsed value of the receipt is empty in the get transaction hash response.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isNotEmpty( + // userOpsReceipt.receipt.effectiveGasPrice, + // 'The effectiveGasPrice value of the receipt is empty in the get transaction hash response.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isNotEmpty( + // userOpsReceipt.receipt.status, + // 'The status value of the receipt is empty in the get transaction hash response.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isNotEmpty( + // userOpsReceipt.receipt.type, + // 'The type value of the receipt is empty in the get transaction hash response.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isTrue( + // userOpsReceipt.receipt.byzantium, + // 'The byzantium value of the receipt is false in the get transaction hash response.', + // ); + // } catch (e) { + // console.error(e); + // } + // } catch (e) { + // console.error(e); + // assert.fail('The get transaction hash action is not performed.'); + // } + } else { + console.warn( + 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE SEND ERC20 TOKEN ON THE xdai NETWORK', + ); + } + }); + + it('SMOKE: Perform the transfer ERC721 NFT token with valid details on the xdai network', async () => { + if (runTest) { + // 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, + 'The erc721 Contract Interface value is empty in the erc721 Contract Interface response.', + ); + } catch (e) { + console.error(e); + } + } catch (e) { + console.error(e); + assert.fail('The get erc721 Contract Interface is not performed.'); + } + + // clear the transaction batch + try { + await xdaiMainNetSdk.clearUserOpsFromBatch(); + } catch (e) { + console.error(e); + assert.fail('The transaction of the batch is not clear correctly.'); + } + + // add transactions to the batch + let userOpsBatch; + try { + userOpsBatch = await xdaiMainNetSdk.addUserOpsToBatch({ + to: data.nft_tokenAddress, + data: erc721Data, + }); + + try { + assert.isNotEmpty( + userOpsBatch.to[0], + 'The To Address value is empty in the userops batch response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isNotEmpty( + userOpsBatch.data[0], + 'The data value is empty in the userops batch response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isNotEmpty( + userOpsBatch.value[0]._hex, + 'The hex value of the userOpsBatch is empty in the userops batch response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isTrue( + userOpsBatch.value[0]._isBigNumber, + 'The isBigNumber value of the userOpsBatch is false in the userops batch response.', + ); + } catch (e) { + console.error(e); + } + } catch (e) { + console.error(e); + assert.fail('The transaction of the batch is not clear correctly.'); + } + + // estimate transactions added to the batch + let op; + try { + op = await xdaiMainNetSdk.estimate(); + + try { + assert.strictEqual( + op.sender, + data.sender, + 'The sender value is not correct in the estimate transactions added to the batch response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isNotEmpty( + op.nonce._hex, + 'The hex value of the nonce is empty in the estimate transactions added to the batch response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isTrue( + op.nonce._isBigNumber, + 'The isBigNumber value of the nonce is false in the estimate transactions added to the batch response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isNotEmpty( + op.initCode, + 'The initCode value is empty in the estimate transactions added to the batch response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isNotEmpty( + op.callData, + 'The callData value is empty in the estimate transactions added to the batch response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isNotEmpty( + op.callGasLimit._hex, + 'The hex value of the callGasLimit is empty in the estimate transactions added to the batch response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isTrue( + op.callGasLimit._isBigNumber, + 'The isBigNumber value of the callGasLimit is false in the estimate transactions added to the batch response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isNotEmpty( + op.verificationGasLimit._hex, + 'The hex value of the verificationGasLimit is empty in the estimate transactions added to the batch response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isTrue( + op.verificationGasLimit._isBigNumber, + 'The isBigNumber value of the verificationGasLimit is false in the estimate transactions added to the batch response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isNotEmpty( + op.maxFeePerGas, + 'The maxFeePerGas is empty in the estimate transactions added to the batch response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isNotEmpty( + op.maxPriorityFeePerGas, + 'The maxPriorityFeePerGas is empty in the estimate transactions added to the batch response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isNotEmpty( + op.paymasterAndData, + 'The paymasterAndData value is empty in the estimate transactions added to the batch response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isNotEmpty( + op.preVerificationGas._hex, + 'The hex value of the preVerificationGas is empty in the estimate transactions added to the batch response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isTrue( + op.preVerificationGas._isBigNumber, + 'The isBigNumber value of the preVerificationGas is false in the estimate transactions added to the batch response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isNotEmpty( + op.signature, + 'The signature value is empty in the estimate transactions added to the batch response.', + ); + } catch (e) { + console.error(e); + } + } catch (e) { + console.error(e); + assert.fail( + 'The estimate transactions added to the batch is not performed.', + ); + } + + // // sending to the bundler + // let uoHash; + // try { + // uoHash = await xdaiMainNetSdk.send(op); + + // assert.isNotEmpty( + // uoHash, + // 'The uoHash value is empty in the sending bundler response.', + // ); + // } catch (e) { + // console.error(e); + // assert.fail('The sending to the bundler action is not performed.'); + // } + + // // 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(2000); + // userOpsReceipt = await xdaiMainNetSdk.getUserOpReceipt(uoHash); + // } + + // try { + // assert.isNotEmpty( + // userOpsReceipt.userOpHash, + // 'The userOpHash value is empty in the get transaction hash response.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.strictEqual( + // userOpsReceipt.sender, + // data.sender, + // 'The sender value is empty in the get transaction hash response.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isNotEmpty( + // userOpsReceipt.nonce, + // 'The nonce value is empty in the get transaction hash response.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isNotEmpty( + // userOpsReceipt.actualGasCost, + // 'The actualGasCost value is empty in the get transaction hash response.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isNotEmpty( + // userOpsReceipt.actualGasUsed, + // 'The actualGasUsed value is empty in the get transaction hash response.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isTrue( + // userOpsReceipt.success, + // 'The success value is false in the get transaction hash response.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isNotEmpty( + // userOpsReceipt.receipt.to, + // 'The to value of the receipt is empty in the get transaction hash response.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isNotEmpty( + // userOpsReceipt.receipt.from, + // 'The from value of the receipt is empty in the get transaction hash response.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isNotEmpty( + // userOpsReceipt.receipt.transactionIndex, + // 'The transactionIndex value of the receipt is empty in the get transaction hash response.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isNotEmpty( + // userOpsReceipt.receipt.gasUsed, + // 'The gasUsed value of the receipt is empty in the get transaction hash response.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isNotEmpty( + // userOpsReceipt.receipt.logsBloom, + // 'The logsBloom value of the receipt is empty in the get transaction hash response.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isNotEmpty( + // userOpsReceipt.receipt.blockHash, + // 'The blockHash value of the receipt is empty in the get transaction hash response.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isNotEmpty( + // userOpsReceipt.receipt.transactionHash, + // 'The transactionHash value of the receipt is empty in the get transaction hash response.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isNotEmpty( + // userOpsReceipt.receipt.logs, + // 'The logs value of the receipt is empty in the get transaction hash response.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isNotEmpty( + // userOpsReceipt.receipt.blockNumber, + // 'The blockNumber value of the receipt is empty in the get transaction hash response.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isNotEmpty( + // userOpsReceipt.receipt.confirmations, + // 'The confirmations value of the receipt is empty in the get transaction hash response.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isNotEmpty( + // userOpsReceipt.receipt.cumulativeGasUsed, + // 'The cumulativeGasUsed value of the receipt is empty in the get transaction hash response.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isNotEmpty( + // userOpsReceipt.receipt.effectiveGasPrice, + // 'The effectiveGasPrice value of the receipt is empty in the get transaction hash response.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isNotEmpty( + // userOpsReceipt.receipt.status, + // 'The status value of the receipt is empty in the get transaction hash response.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isNotEmpty( + // userOpsReceipt.receipt.type, + // 'The type value of the receipt is empty in the get transaction hash response.', + // ); + // } catch (e) { + // console.error(e); + // } + // } catch (e) { + // console.error(e); + // assert.fail('The get transaction hash action is not performed.'); + // } + } else { + console.warn( + 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE SEND ERC721 TOKEN ON THE xdai NETWORK', + ); + } + }); + + it('REGRESSION: Perform the transfer native token with the incorrect To Address while estimate the added transactions to the batch on the xdai network', async () => { + if (runTest) { + // clear the transaction batch + try { + await xdaiMainNetSdk.clearUserOpsFromBatch(); + } catch (e) { + console.error(e); + } + + // add transactions to the batch + try { + await xdaiMainNetSdk.addUserOpsToBatch({ + to: data.incorrectRecipient, // incorrect to address + value: ethers.utils.parseEther(data.value), + }); + } catch (e) { + console.error(e); + assert.fail( + 'The addition of transaction in the batch is not performed.', + ); + } + + // get balance of the account address + try { + await xdaiMainNetSdk.getNativeBalance(); + } catch (e) { + console.error(e); + assert.fail('The balance of the native token is not displayed.'); + } + + // estimate transactions added to the batch + try { + await xdaiMainNetSdk.estimate(); + + assert.fail( + 'The expected validation is not displayed when entered the incorrect To Address while estimate the added transactions to the batch.', + ); + } catch (e) { + let error = e.reason; + if (error.includes('bad address checksum')) { + console.log( + 'The validation for To Address is displayed as expected while estimate the added transactions to the batch.', + ); + } else { + console.error(e); + assert.fail( + 'The expected validation is not displayed when entered the incorrect To Address while estimate the added transactions to the batch.', + ); + } + } + } else { + console.warn( + 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE SEND NATIVE TOKEN WITH INCORRECT TO ADDRESS ON THE xdai NETWORK', + ); + } + }); + + 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 xdai network', async () => { + if (runTest) { + // clear the transaction batch + try { + await xdaiMainNetSdk.clearUserOpsFromBatch(); + } catch (e) { + console.error(e); + } + + // add transactions to the batch + try { + await xdaiMainNetSdk.addUserOpsToBatch({ + to: data.invalidRecipient, // invalid to address + value: ethers.utils.parseEther(data.value), + }); + } catch (e) { + console.error(e); + assert.fail( + 'The addition of transaction in the batch is not performed.', + ); + } + + // get balance of the account address + try { + await xdaiMainNetSdk.getNativeBalance(); + } catch (e) { + console.error(e); + assert.fail('The balance of the native token is not displayed.'); + } + + // estimate transactions added to the batch + try { + await xdaiMainNetSdk.estimate(); + + assert.fail( + 'The expected validation is not displayed when entered the invalid To Address while estimate the added transactions to the batch.', + ); + } catch (e) { + let error = e.reason; + if (error.includes('invalid address')) { + console.log( + 'The validation for To Address is displayed as expected while estimate the added transactions to the batch.', + ); + } else { + console.error(e); + assert.fail( + 'The expected validation is not displayed when entered the invalid To Address while estimate the added transactions to the batch.', + ); + } + } + } else { + console.warn( + 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE SEND NATIVE TOKEN WITH INVALID TO ADDRESS ON THE xdai NETWORK', + ); + } + }); + + it('REGRESSION: Perform the transfer native token with the invalid Value while estimate the added transactions to the batch on the xdai network', async () => { + if (runTest) { + // clear the transaction batch + try { + await xdaiMainNetSdk.clearUserOpsFromBatch(); + } catch (e) { + console.error(e); + } + + // add transactions to the batch + try { + await xdaiMainNetSdk.addUserOpsToBatch({ + to: data.recipient, + value: ethers.utils.parseUnits(data.invalidValue), // invalid value + }); + + assert.fail( + 'The expected validation is not displayed when entered the invalid value while adding the transactions to the batch.', + ); + } catch (e) { + if (e.reason === 'invalid decimal value') { + console.log( + 'The validation for value is displayed as expected while adding the transactions to the batch.', + ); + } else { + console.error(e); + assert.fail( + 'The expected validation is not displayed when entered the invalid value while adding the transactions to the batch.', + ); + } + } + } else { + console.warn( + 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE SEND NATIVE TOKEN WITH INVALID VALUE ON THE xdai NETWORK', + ); + } + }); + + it('REGRESSION: Perform the transfer native token with the very small Value while estimate the added transactions to the batch on the xdai network', async () => { + if (runTest) { + // clear the transaction batch + try { + await xdaiMainNetSdk.clearUserOpsFromBatch(); + } catch (e) { + console.error(e); + } + + // add transactions to the batch + try { + await xdaiMainNetSdk.addUserOpsToBatch({ + to: data.recipient, + value: ethers.utils.parseUnits(data.smallValue), // very small value + }); + + assert.fail( + 'The expected validation is not displayed when entered the very small value while adding the transactions to the batch.', + ); + } catch (e) { + if (e.reason === 'fractional component exceeds decimals') { + console.log( + 'The validation for value is displayed as expected while adding the transactions to the batch.', + ); + } else { + console.error(e); + assert.fail( + 'The expected validation is not displayed when entered the very small value while adding the transactions to the batch.', + ); + } + } + } else { + console.warn( + 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE SEND NATIVE TOKEN WITH VERY SMALL VALUE ON THE xdai NETWORK', + ); + } + }); + + it('REGRESSION: Perform the transfer native token without adding transaction to the batch while estimate the added transactions to the batch on the xdai network', async () => { + if (runTest) { + // clear the transaction batch + try { + await xdaiMainNetSdk.clearUserOpsFromBatch(); + } catch (e) { + console.error(e); + assert.fail('The transaction of the batch is not clear correctly.'); + } + + // get balance of the account address + try { + await xdaiMainNetSdk.getNativeBalance(); + } catch (e) { + console.error(e); + assert.fail('The balance of the native token is not displayed.'); + } + + // estimate transactions added to the batch + try { + await xdaiMainNetSdk.estimate(); + + assert.fail( + 'The expected validation is not displayed when not added the transaction to the batch while adding the estimate transactions to the batch.', + ); + } catch (e) { + if (e.message === 'cannot sign empty transaction batch') { + console.log( + 'The validation for transaction batch is displayed as expected while adding the estimate transactions to the batch.', + ); + } else { + console.error(e); + assert.fail( + 'The expected validation is not displayed when not added the transaction to the batch while adding the estimate transactions to the batch.', + ); + } + } + } else { + console.warn( + 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE SEND NATIVE TOKEN WITHOUT ADDED THE TRANSACTION TO THE BATCH ON THE xdai NETWORK', + ); + } + }); + + it('REGRESSION: Perform the transfer native token with the incorrect TxHash while getting the transaction hash on the xdai network', async () => { + if (runTest) { + // clear the transaction batch + try { + await xdaiMainNetSdk.clearUserOpsFromBatch(); + } catch (e) { + console.error(e); + assert.fail('The transaction of the batch is not clear correctly.'); + } + + // add transactions to the batch + try { + await xdaiMainNetSdk.addUserOpsToBatch({ + to: data.recipient, + value: ethers.utils.parseEther(data.value), + }); + } catch (e) { + console.error(e); + assert.fail( + 'The addition of transaction in the batch is not performed.', + ); + } + + // get balance of the account address + try { + await xdaiMainNetSdk.getNativeBalance(); + } catch (e) { + console.error(e); + assert.fail('The balance of the native token is not displayed.'); + } + + // estimate transactions added to the batch + try { + await xdaiMainNetSdk.estimate(); + } catch (e) { + console.error(e); + assert.fail( + 'The estimate transactions added to the batch is not performed.', + ); + } + + // 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(2000); + userOpsReceipt = await xdaiMainNetSdk.getUserOpReceipt( + data.incorrectTxHash, + ); + } + + assert.fail( + 'The expected validation is not displayed when added the incorrect TxHash while getting the transaction hash.', + ); + } catch (e) { + if (e.showDiff === false) { + console.log( + 'The validation for transaction is displayed as expected while getting the transaction hash.', + ); + } else { + console.error(e); + assert.fail( + 'The expected validation is not displayed when added the incorrect TxHash while getting the transaction hash.', + ); + } + } + } else { + console.warn( + 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE SEND NATIVE TOKEN WITH THE INCORRECT TXHASH WHILE GETTING THE TRANSACTION HASH ON THE xdai NETWORK', + ); + } + }); + + it('REGRESSION: Perform the transfer native token with the past TxHash while getting the transaction hash on the xdai network', async () => { + if (runTest) { + // clear the transaction batch + try { + await xdaiMainNetSdk.clearUserOpsFromBatch(); + } catch (e) { + console.error(e); + assert.fail('The transaction of the batch is not clear correctly.'); + } + + // add transactions to the batch + try { + await xdaiMainNetSdk.addUserOpsToBatch({ + to: data.recipient, + value: ethers.utils.parseEther(data.value), + }); + } catch (e) { + console.error(e); + assert.fail( + 'The addition of transaction in the batch is not performed.', + ); + } + + // get balance of the account address + try { + await xdaiMainNetSdk.getNativeBalance(); + } catch (e) { + console.error(e); + assert.fail('The balance of the native token is not displayed.'); + } + + // estimate transactions added to the batch + try { + await xdaiMainNetSdk.estimate(); + } catch (e) { + console.error(e); + assert.fail( + 'The estimate transactions added to the batch is not performed.', + ); + } + + // 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(2000); + userOpsReceipt = await xdaiMainNetSdk.getUserOpReceipt( + data.pastTxHash, + ); + } + + assert.fail( + 'The expected validation is not displayed when added the past TxHash while getting the transaction hash.', + ); + } catch (e) { + if (e.showDiff === false) { + console.log( + 'The validation for transaction is displayed as expected while getting the transaction hash.', + ); + } else { + console.error(e); + assert.fail( + 'The expected validation is not displayed when added the past TxHash while getting the transaction hash.', + ); + } + } + } else { + console.warn( + 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE SEND NATIVE TOKEN WITH THE PAST TXHASH WHILE GETTING THE TRANSACTION HASH ON THE xdai NETWORK', + ); + } + }); + + it('REGRESSION: Perform the transfer ERC20 token with invalid provider netowrk details while Getting the Decimal from ERC20 Contract on the xdai network', async () => { + if (runTest) { + // get the respective provider details + let provider; + try { + provider = new ethers.providers.JsonRpcProvider( + data.invalidProviderNetwork_xdai, // invalid provider + ); + } catch (e) { + console.error(e); + assert.fail('The provider response is not displayed correctly.'); + } + + // get erc20 Contract Interface + let erc20Instance; + try { + erc20Instance = new ethers.Contract( + data.tokenAddress_xdaiUSDC, + ERC20_ABI, + provider, + ); + } catch (e) { + console.error(e); + assert.fail('The get erc20 Contract Interface is not performed.'); + } + + // get decimals from erc20 contract + try { + await erc20Instance.functions.decimals(); + + assert.fail( + 'The expected validation is not displayed when entered the invalid Provider Network while Getting the Decimal from ERC20 Contract.', + ); + } catch (e) { + if (e.reason === 'could not detect network') { + console.log( + 'The validation for Provider Network is displayed as expected while Getting the Decimal from ERC20 Contract.', + ); + } else { + console.error(e); + assert.fail( + 'The expected validation is not displayed when entered the invalid Provider Network while Getting the Decimal from ERC20 Contract.', + ); + } + } + } else { + console.warn( + 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE SEND ERC20 TOKEN WITH INVALID PROVIDER NETWORK WHILE GETTING THE DECIMAL FROM ERC20 CONTRACT ON THE xdai NETWORK', + ); + } + }); + + it('REGRESSION: Perform the transfer ERC20 token without provider netowrk details while Getting the Decimal from ERC20 Contract on the xdai network', async () => { + if (runTest) { + // get the respective provider details + let provider; + try { + provider = new ethers.providers.JsonRpcProvider(); // without provider + } catch (e) { + console.error(e); + assert.fail('The provider response is not displayed correctly.'); + } + + // get erc20 Contract Interface + let erc20Instance; + try { + erc20Instance = new ethers.Contract( + data.tokenAddress_xdaiUSDC, + ERC20_ABI, + provider, + ); + } catch (e) { + console.error(e); + assert.fail('The get erc20 Contract Interface is not performed.'); + } + + // get decimals from erc20 contract + try { + await erc20Instance.functions.decimals(); + + assert.fail( + 'The expected validation is not displayed when entered the invalid Provider Network while Getting the Decimal from ERC20 Contract.', + ); + } catch (e) { + if (e.reason === 'could not detect network') { + console.log( + 'The validation for Provider Network is displayed as expected while Getting the Decimal from ERC20 Contract.', + ); + } else { + console.error(e); + assert.fail( + 'The expected validation is not displayed when entered the invalid Provider Network while Getting the Decimal from ERC20 Contract.', + ); + } + } + } else { + console.warn( + 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE SEND ERC20 TOKEN WITHOUT PROVIDER NETWORK WHILE GETTING THE DECIMAL FROM ERC20 CONTRACT ON THE xdai NETWORK', + ); + } + }); + + it('REGRESSION: Perform the transfer ERC20 token with other provider netowrk details while Getting the Decimal from ERC20 Contract on the xdai network', async () => { + if (runTest) { + // get the respective provider details + let provider; + try { + provider = new ethers.providers.JsonRpcProvider( + data.otherProviderNetwork_xdai, // other provider + ); + } catch (e) { + console.error(e); + assert.fail('The provider response is not displayed correctly.'); + } + + // get erc20 Contract Interface + let erc20Instance; + try { + erc20Instance = new ethers.Contract( + data.tokenAddress_xdaiUSDC, + ERC20_ABI, + provider, + ); + } catch (e) { + console.error(e); + assert.fail('The get erc20 Contract Interface is not performed.'); + } + + // get decimals from erc20 contract + try { + await erc20Instance.functions.decimals(); + + assert.fail( + 'The expected validation is not displayed when entered the other Provider Network while Getting the Decimal from ERC20 Contract.', + ); + } catch (e) { + if (e.code === 'CALL_EXCEPTION') { + console.log( + 'The validation for Provider Network is displayed as expected while Getting the Decimal from ERC20 Contract.', + ); + } else { + console.error(e); + assert.fail( + 'The expected validation is not displayed when entered the other Provider Network while Getting the Decimal from ERC20 Contract.', + ); + } + } + } else { + console.warn( + 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE SEND ERC20 TOKEN WITH OTHER PROVIDER NETWORK WHILE GETTING THE DECIMAL FROM ERC20 CONTRACT ON THE xdai NETWORK', + ); + } + }); + + it('REGRESSION: Perform the transfer ERC20 token with incorrect Token Address details while Getting the Decimal from ERC20 Contract on the xdai network', async () => { + if (runTest) { + // get the respective provider details + let provider; + try { + provider = new ethers.providers.JsonRpcProvider( + data.providerNetwork_xdai, + ); + } catch (e) { + console.error(e); + assert.fail('The provider response is not displayed correctly.'); + } + + // get erc20 Contract Interface + let erc20Instance; + try { + erc20Instance = new ethers.Contract( + data.incorrectTokenAddress_xdaiUSDC, // incorrect token address + ERC20_ABI, + provider, + ); + } catch (e) { + console.error(e); + assert.fail('The get erc20 Contract Interface is not performed.'); + } + + // get decimals from erc20 contract + try { + await erc20Instance.functions.decimals(); + + assert.fail( + 'The expected validation is not displayed when entered the incorrect Token Address while Getting the Decimal from ERC20 Contract.', + ); + } catch (e) { + if (e.reason === 'bad address checksum') { + console.log( + 'The validation for Token Address is displayed as expected while Getting the Decimal from ERC20 Contract.', + ); + } else { + console.error(e); + assert.fail( + 'The expected validation is not displayed when entered the incorrect Token Address while Getting the Decimal from ERC20 Contract.', + ); + } + } + } else { + console.warn( + 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE SEND ERC20 TOKEN WITH INCORRECT TOKEN ADDRESS WHILE GETTING THE DECIMAL FROM ERC20 CONTRACT ON THE xdai NETWORK', + ); + } + }); + + 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 xdai network', async () => { + if (runTest) { + // get the respective provider details + let provider; + try { + provider = new ethers.providers.JsonRpcProvider( + data.providerNetwork_xdai, + ); + } catch (e) { + console.error(e); + assert.fail('The provider response is not displayed correctly.'); + } + + // get erc20 Contract Interface + let erc20Instance; + try { + erc20Instance = new ethers.Contract( + data.invalidTokenAddress_xdaiUSDC, // invalid token address + ERC20_ABI, + provider, + ); + } catch (e) { + console.error(e); + assert.fail('The get erc20 Contract Interface is not performed.'); + } + + // get decimals from erc20 contract + try { + await erc20Instance.functions.decimals(); + + assert.fail( + 'The expected validation is not displayed when entered the invalid Token Address i.e. missing character while Getting the Decimal from ERC20 Contract.', + ); + } catch (e) { + if (e.reason === 'invalid address') { + console.log( + 'The validation for Token Address is displayed as expected while Getting the Decimal from ERC20 Contract.', + ); + } else { + console.error(e); + assert.fail( + 'The expected validation is not displayed when entered the invalid Token Address i.e. missing character while Getting the Decimal from ERC20 Contract.', + ); + } + } + } else { + console.warn( + 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE SEND ERC20 TOKEN WITH INVALID TOKEN ADDRESS WHILE GETTING THE DECIMAL FROM ERC20 CONTRACT ON THE xdai NETWORK', + ); + } + }); + + it('REGRESSION: Perform the transfer ERC20 token with null Token Address details while Getting the Decimal from ERC20 Contract on the xdai network', async () => { + if (runTest) { + // get the respective provider details + let provider; + try { + provider = new ethers.providers.JsonRpcProvider( + data.providerNetwork_xdai, + ); + } catch (e) { + console.error(e); + assert.fail('The provider response is not displayed correctly.'); + } + + // get erc20 Contract Interface + try { + new ethers.Contract(null, ERC20_ABI, provider); // null token address + + assert.fail( + 'The expected validation is not displayed when entered the null Token Address while Getting the Decimal from ERC20 Contract.', + ); + } catch (e) { + if (e.reason === 'invalid contract address or ENS name') { + console.log( + 'The validation for Token Address is displayed as expected while Getting the Decimal from ERC20 Contract.', + ); + } else { + console.error(e); + assert.fail( + 'The expected validation is not displayed when entered the null Token Address while Getting the Decimal from ERC20 Contract.', + ); + } + } + } else { + console.warn( + 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE SEND ERC20 TOKEN WITH NULL TOKEN ADDRESS WHILE GETTING THE DECIMAL FROM ERC20 CONTRACT ON THE xdai NETWORK', + ); + } + }); + + it('REGRESSION: Perform the transfer ERC20 token with incorrect transfer method name while Getting the transferFrom encoded data on the xdai network', async () => { + if (runTest) { + // get the respective provider details + let provider; + try { + provider = new ethers.providers.JsonRpcProvider( + data.providerNetwork_xdai, + ); + } catch (e) { + console.error(e); + assert.fail('The provider response is not displayed correctly.'); + } + + // get erc20 Contract Interface + let erc20Instance; + try { + erc20Instance = new ethers.Contract( + data.tokenAddress_xdaiUSDC, + ERC20_ABI, + provider, + ); + } catch (e) { + console.error(e); + assert.fail('The get erc20 Contract Interface is not performed.'); + } + + // get decimals from erc20 contract + let decimals; + try { + decimals = await erc20Instance.functions.decimals(); + } catch (e) { + console.error(e); + assert.fail( + 'The decimals from erc20 contract is not displayed correctly.', + ); + } + + // get transferFrom encoded data + try { + erc20Instance.interface.encodeFunctionData('transferr', [ + data.recipient, + ethers.utils.parseUnits(data.value, decimals), + ]); + + assert.fail( + 'The expected validation is not displayed when entered the incorrect transfer method name while Getting the transferFrom encoded data.', + ); + } catch (e) { + if (e.reason === 'no matching function') { + console.log( + 'The validation for transfer method name is displayed as expected while Getting the transferFrom encoded data.', + ); + } else { + console.error(e); + assert.fail( + 'The expected validation is not displayed when entered the incorrect transfer method name while Getting the transferFrom encoded data.', + ); + } + } + } else { + console.warn( + 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE SEND ERC20 TOKEN WITH INCORRECT TRANSFER METHOD NAME WHILE GETTING THE TRANSFERFROM ENCODED DATA ON THE xdai NETWORK', + ); + } + }); + + it('REGRESSION: Perform the transfer ERC20 token with invalid value while Getting the transferFrom encoded data on the xdai network', async () => { + if (runTest) { + // get the respective provider details + let provider; + try { + provider = new ethers.providers.JsonRpcProvider( + data.providerNetwork_xdai, + ); + } catch (e) { + console.error(e); + assert.fail('The provider response is not displayed correctly.'); + } + + // get erc20 Contract Interface + let erc20Instance; + try { + erc20Instance = new ethers.Contract( + data.tokenAddress_xdaiUSDC, + ERC20_ABI, + provider, + ); + } catch (e) { + console.error(e); + assert.fail('The get erc20 Contract Interface is not performed.'); + } + + // get decimals from erc20 contract + let decimals; + try { + decimals = await erc20Instance.functions.decimals(); + } catch (e) { + console.error(e); + assert.fail( + 'The decimals from erc20 contract is not displayed correctly.', + ); + } + + // get transferFrom encoded data + try { + erc20Instance.interface.encodeFunctionData('transfer', [ + data.recipient, + ethers.utils.parseUnits(data.invalidValue, decimals), // invalid value + ]); + + assert.fail( + 'The expected validation is not displayed when entered the invalid value while Getting the transferFrom encoded data.', + ); + } catch (e) { + if (e.reason === 'invalid decimal value') { + console.log( + 'The validation for value is displayed as expected while Getting the transferFrom encoded data.', + ); + } else { + console.error(e); + assert.fail( + 'The expected validation is not displayed when entered the invalid value while Getting the transferFrom encoded data.', + ); + } + } + } else { + console.warn( + 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE SEND ERC20 TOKEN WITH INVALID VALUE WHILE GETTING THE TRANSFERFROM ENCODED DATA ON THE xdai NETWORK', + ); + } + }); + + it('REGRESSION: Perform the transfer ERC20 token with very small value while Getting the transferFrom encoded data on the xdai network', async () => { + if (runTest) { + // get the respective provider details + let provider; + try { + provider = new ethers.providers.JsonRpcProvider( + data.providerNetwork_xdai, + ); + } catch (e) { + console.error(e); + assert.fail('The provider response is not displayed correctly.'); + } + + // get erc20 Contract Interface + let erc20Instance; + try { + erc20Instance = new ethers.Contract( + data.tokenAddress_xdaiUSDC, + ERC20_ABI, + provider, + ); + } catch (e) { + console.error(e); + assert.fail('The get erc20 Contract Interface is not performed.'); + } + + // get decimals from erc20 contract + let decimals; + try { + decimals = await erc20Instance.functions.decimals(); + } catch (e) { + console.error(e); + assert.fail( + 'The decimals from erc20 contract is not displayed correctly.', + ); + } + + // get transferFrom encoded data + try { + erc20Instance.interface.encodeFunctionData('transfer', [ + data.recipient, + ethers.utils.parseUnits(data.smallValue, decimals), // very small value + ]); + + assert.fail( + 'The expected validation is not displayed when entered the very small value while Getting the transferFrom encoded data.', + ); + } catch (e) { + if (e.reason === 'fractional component exceeds decimals') { + console.log( + 'The validation for value is displayed as expected while Getting the transferFrom encoded data.', + ); + } else { + console.error(e); + assert.fail( + 'The expected validation is not displayed when entered the very small value while Getting the transferFrom encoded data.', + ); + } + } + } else { + console.warn( + 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE SEND ERC20 TOKEN WITH VERY SMALL VALUE WHILE GETTING THE TRANSFERFROM ENCODED DATA ON THE xdai NETWORK', + ); + } + }); + + it('REGRESSION: Perform the transfer ERC20 token without value while Getting the transferFrom encoded data on the xdai network', async () => { + if (runTest) { + // get the respective provider details + let provider; + try { + provider = new ethers.providers.JsonRpcProvider( + data.providerNetwork_xdai, + ); + } catch (e) { + console.error(e); + assert.fail('The provider response is not displayed correctly.'); + } + + // get erc20 Contract Interface + let erc20Instance; + try { + erc20Instance = new ethers.Contract( + data.tokenAddress_xdaiUSDC, + ERC20_ABI, + provider, + ); + } catch (e) { + console.error(e); + assert.fail('The get erc20 Contract Interface is not performed.'); + } + + // get decimals from erc20 contract + try { + await erc20Instance.functions.decimals(); + } catch (e) { + console.error(e); + assert.fail( + 'The decimals from erc20 contract is not displayed correctly.', + ); + } + + // get transferFrom encoded data + try { + erc20Instance.interface.encodeFunctionData('transfer', [ + data.recipient, + ]); + + assert.fail( + 'The expected validation is not displayed when not entered the value while Getting the transferFrom encoded data.', + ); + } catch (e) { + if (e.reason === 'types/values length mismatch') { + console.log( + 'The validation for value is displayed as expected while Getting the transferFrom encoded data.', + ); + } else { + console.error(e); + assert.fail( + 'The expected validation is not displayed when not entered the value while Getting the transferFrom encoded data.', + ); + } + } + } else { + console.warn( + 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE SEND ERC20 TOKEN WITHOUT VALUE WHILE GETTING THE TRANSFERFROM ENCODED DATA ON THE xdai NETWORK', + ); + } + }); + + it('REGRESSION: Perform the transfer ERC20 token with incorrect recipient while Getting the transferFrom encoded data on the xdai network', async () => { + if (runTest) { + // get the respective provider details + let provider; + try { + provider = new ethers.providers.JsonRpcProvider( + data.providerNetwork_xdai, + ); + } catch (e) { + console.error(e); + assert.fail('The provider response is not displayed correctly.'); + } + + // get erc20 Contract Interface + let erc20Instance; + try { + erc20Instance = new ethers.Contract( + data.tokenAddress_xdaiUSDC, + ERC20_ABI, + provider, + ); + } catch (e) { + console.error(e); + assert.fail('The get erc20 Contract Interface is not performed.'); + } + + // get decimals from erc20 contract + let decimals; + try { + decimals = await erc20Instance.functions.decimals(); + } catch (e) { + console.error(e); + assert.fail( + 'The decimals from erc20 contract is not displayed correctly.', + ); + } + + // get transferFrom encoded data + try { + erc20Instance.interface.encodeFunctionData('transfer', [ + data.incorrectRecipient, // incorrect recipient address + ethers.utils.parseUnits(data.value, decimals), + ]); + + assert.fail( + 'The expected validation is not displayed when entered the incorrect recipient while Getting the transferFrom encoded data.', + ); + } catch (e) { + let error = e.reason; + if (error.includes('bad address checksum')) { + console.log( + 'The validation for Recipient is displayed as expected while Getting the transferFrom encoded data.', + ); + } else { + console.error(e); + assert.fail( + 'The expected validation is not displayed when entered the incorrect recipient while Getting the transferFrom encoded data.', + ); + } + } + } else { + console.warn( + 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE SEND ERC20 TOKEN WITH INCORRECT RECEPIENT WHILE GETTING THE TRANSFERFROM ENCODED DATA ON THE xdai NETWORK', + ); + } + }); + + it('REGRESSION: Perform the transfer ERC20 token with invalid recipient i.e. missing character while Getting the transferFrom encoded data on the xdai network', async () => { + if (runTest) { + // get the respective provider details + let provider; + try { + provider = new ethers.providers.JsonRpcProvider( + data.providerNetwork_xdai, + ); + } catch (e) { + console.error(e); + assert.fail('The provider response is not displayed correctly.'); + } + + // get erc20 Contract Interface + let erc20Instance; + try { + erc20Instance = new ethers.Contract( + data.tokenAddress_xdaiUSDC, + ERC20_ABI, + provider, + ); + } catch (e) { + console.error(e); + assert.fail('The get erc20 Contract Interface is not performed.'); + } + + // get decimals from erc20 contract + let decimals; + try { + decimals = await erc20Instance.functions.decimals(); + } catch (e) { + console.error(e); + assert.fail( + 'The decimals from erc20 contract is not displayed correctly.', + ); + } + + // get transferFrom encoded data + try { + erc20Instance.interface.encodeFunctionData('transfer', [ + data.invalidRecipient, // invalid recipient address + ethers.utils.parseUnits(data.value, decimals), + ]); + + assert.fail( + 'The expected validation is not displayed when entered the invalid recipient while Getting the transferFrom encoded data.', + ); + } catch (e) { + let error = e.reason; + if (error.includes('invalid address')) { + console.log( + 'The validation for Recipient is displayed as expected while Getting the transferFrom encoded data.', + ); + } else { + console.error(e); + assert.fail( + 'The expected validation is not displayed when entered the invalid recipient while Getting the transferFrom encoded data.', + ); + } + } + } else { + console.warn( + 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE SEND ERC20 TOKEN WITH INVALID RECEPIENT WHILE GETTING THE TRANSFERFROM ENCODED DATA ON THE xdai NETWORK', + ); + } + }); + + it('REGRESSION: Perform the transfer ERC20 token without recipient while Getting the transferFrom encoded data on the xdai network', async () => { + if (runTest) { + // get the respective provider details + let provider; + try { + provider = new ethers.providers.JsonRpcProvider( + data.providerNetwork_xdai, + ); + } catch (e) { + console.error(e); + assert.fail('The provider response is not displayed correctly.'); + } + + // get erc20 Contract Interface + let erc20Instance; + try { + erc20Instance = new ethers.Contract( + data.tokenAddress_xdaiUSDC, + ERC20_ABI, + provider, + ); + } catch (e) { + console.error(e); + assert.fail('The get erc20 Contract Interface is not performed.'); + } + + // get decimals from erc20 contract + let decimals; + try { + decimals = await erc20Instance.functions.decimals(); + } catch (e) { + console.error(e); + assert.fail( + 'The decimals from erc20 contract is not displayed correctly.', + ); + } + + // get transferFrom encoded data + try { + erc20Instance.interface.encodeFunctionData('transfer', [ + ethers.utils.parseUnits(data.value, decimals), + ]); + + assert.fail( + 'The expected validation is not displayed when not entered the recepient while Getting the transferFrom encoded data.', + ); + } catch (e) { + if (e.reason === 'types/values length mismatch') { + console.log( + 'The validation for recepient is displayed as expected while Getting the transferFrom encoded data.', + ); + } else { + console.error(e); + assert.fail( + 'The expected validation is not displayed when not entered the recepient while Getting the transferFrom encoded data.', + ); + } + } + } else { + console.warn( + 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE SEND ERC20 TOKEN WITHOUT RECEPIENT WHILE GETTING THE TRANSFERFROM ENCODED DATA ON THE xdai NETWORK', + ); + } + }); + + it('REGRESSION: Perform the transfer ERC20 token with the incorrect Token Address while adding transactions to the batch on the xdai network', async () => { + if (runTest) { + // get the respective provider details + let provider; + try { + provider = new ethers.providers.JsonRpcProvider( + data.providerNetwork_xdai, + ); + } catch (e) { + console.error(e); + assert.fail('The provider response is not displayed correctly.'); + } + + // get erc20 Contract Interface + let erc20Instance; + try { + erc20Instance = new ethers.Contract( + data.tokenAddress_xdaiUSDC, + ERC20_ABI, + provider, + ); + } catch (e) { + console.error(e); + assert.fail('The get erc20 Contract Interface is not performed.'); + } + + // get decimals from erc20 contract + let decimals; + try { + decimals = await erc20Instance.functions.decimals(); + } catch (e) { + console.error(e); + assert.fail( + 'The decimals from erc20 contract is not displayed correctly.', + ); + } + + // get transferFrom encoded data + let transactionData; + try { + transactionData = erc20Instance.interface.encodeFunctionData( + 'transfer', + [data.recipient, ethers.utils.parseUnits(data.value, decimals)], + ); + } catch (e) { + console.error(e); + assert.fail( + 'The decimals from erc20 contract is not displayed correctly.', + ); + } + + // clear the transaction batch + try { + await xdaiMainNetSdk.clearUserOpsFromBatch(); + } catch (e) { + console.error(e); + assert.fail('The transaction of the batch is not clear correctly.'); + } + + // add transactions to the batch + try { + await xdaiMainNetSdk.addUserOpsToBatch({ + to: data.incorrectTokenAddress_xdaiUSDC, // Incorrect Token Address + data: transactionData, + }); + } catch (e) { + console.error(e); + assert.fail('The transaction of the batch is not clear correctly.'); + } + + // estimate transactions added to the batch + try { + await xdaiMainNetSdk.estimate(); + assert.fail( + 'The expected validation is not displayed when entered the incorrect Token Address while added the estimated transaction to the batch.', + ); + } catch (e) { + let error = e.reason; + if (error.includes('bad address checksum')) { + console.log( + 'The validation for Token Address is displayed as expected while added the estimated transaction to the batch.', + ); + } else { + console.error(e); + assert.fail( + 'The expected validation is not displayed when entered the incorrect Token Address while added the estimated transaction to the batch.', + ); + } + } + } else { + console.warn( + 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE SEND ERC20 TOKEN WITH INCORRECT TOKEN ADDRESS WHILE ADDED THE ESTIMATED TRANSACTION TO THE BATCH ON THE xdai NETWORK', + ); + } + }); + + it('REGRESSION: Perform the transfer ERC20 token with the invalid Token Address i.e. missing character while adding transactions to the batch on the xdai network', async () => { + if (runTest) { + // get the respective provider details + let provider; + try { + provider = new ethers.providers.JsonRpcProvider( + data.providerNetwork_xdai, + ); + } catch (e) { + console.error(e); + assert.fail('The provider response is not displayed correctly.'); + } + + // get erc20 Contract Interface + let erc20Instance; + try { + erc20Instance = new ethers.Contract( + data.tokenAddress_xdaiUSDC, + ERC20_ABI, + provider, + ); + } catch (e) { + console.error(e); + assert.fail('The get erc20 Contract Interface is not performed.'); + } + + // get decimals from erc20 contract + let decimals; + try { + decimals = await erc20Instance.functions.decimals(); + } catch (e) { + console.error(e); + assert.fail( + 'The decimals from erc20 contract is not displayed correctly.', + ); + } + + // get transferFrom encoded data + let transactionData; + try { + transactionData = erc20Instance.interface.encodeFunctionData( + 'transfer', + [data.recipient, ethers.utils.parseUnits(data.value, decimals)], + ); + } catch (e) { + console.error(e); + assert.fail( + 'The decimals from erc20 contract is not displayed correctly.', + ); + } + + // clear the transaction batch + try { + await xdaiMainNetSdk.clearUserOpsFromBatch(); + } catch (e) { + console.error(e); + assert.fail('The transaction of the batch is not clear correctly.'); + } + + // add transactions to the batch + try { + await xdaiMainNetSdk.addUserOpsToBatch({ + to: data.invalidTokenAddress_xdaiUSDC, // Invalid Token Address + data: transactionData, + }); + } catch (e) { + console.error(e); + assert.fail('The transaction of the batch is not clear correctly.'); + } + + // estimate transactions added to the batch + try { + await xdaiMainNetSdk.estimate(); + assert.fail( + 'The expected validation is not displayed when entered the invalid Token Address while estimate the added transactions to the batch.', + ); + } catch (e) { + let error = e.reason; + if (error.includes('invalid address')) { + console.log( + 'The validation for Token Address is displayed as expected while estimate the added transactions to the batch.', + ); + } else { + console.error(e); + assert.fail( + 'The expected validation is not displayed when entered the invalid Token Address while estimate the added transactions to the batch.', + ); + } + } + } else { + console.warn( + 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE SEND ERC20 TOKEN WITH INVALID TOKEN ADDRESS WHILE ADDED THE ESTIMATED TRANSACTION TO THE BATCH ON THE xdai NETWORK', + ); + } + }); + + it('REGRESSION: Perform the transfer ERC20 token with the null Token Address while adding transactions to the batch on the xdai network', async () => { + if (runTest) { + // get the respective provider details + let provider; + try { + provider = new ethers.providers.JsonRpcProvider( + data.providerNetwork_xdai, + ); + } catch (e) { + console.error(e); + assert.fail('The provider response is not displayed correctly.'); + } + + // get erc20 Contract Interface + let erc20Instance; + try { + erc20Instance = new ethers.Contract( + data.tokenAddress_xdaiUSDC, + ERC20_ABI, + provider, + ); + } catch (e) { + console.error(e); + assert.fail('The get erc20 Contract Interface is not performed.'); + } + + // get decimals from erc20 contract + let decimals; + try { + decimals = await erc20Instance.functions.decimals(); + } catch (e) { + console.error(e); + assert.fail( + 'The decimals from erc20 contract is not displayed correctly.', + ); + } + + // get transferFrom encoded data + let transactionData; + try { + transactionData = erc20Instance.interface.encodeFunctionData( + 'transfer', + [data.recipient, ethers.utils.parseUnits(data.value, decimals)], + ); + } catch (e) { + console.error(e); + assert.fail( + 'The decimals from erc20 contract is not displayed correctly.', + ); + } + + // clear the transaction batch + try { + await xdaiMainNetSdk.clearUserOpsFromBatch(); + } catch (e) { + console.error(e); + assert.fail('The transaction of the batch is not clear correctly.'); + } + + // add transactions to the batch + try { + await xdaiMainNetSdk.addUserOpsToBatch({ + to: null, // Null Token Address + data: transactionData, + }); + } catch (e) { + console.error(e); + assert.fail('The transaction of the batch is not clear correctly.'); + } + + // estimate transactions added to the batch + try { + await xdaiMainNetSdk.estimate(); + + assert.fail( + 'The expected validation is not displayed when entered the null Token Address while estimate the added transactions to the batch.', + ); + } catch (e) { + if (e.reason.includes('invalid address')) { + console.log( + 'The validation for Token Address is displayed as expected while estimate the added transactions to the batch.', + ); + } else { + console.error(e); + assert.fail( + 'The expected validation is not displayed when entered the null Token Address while estimate the added transactions to the batch.', + ); + } + } + } else { + console.warn( + 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE SEND ERC20 TOKEN WITH NULL TOKEN ADDRESS WHILE ADDED THE ESTIMATED TRANSACTION TO THE BATCH ON THE xdai NETWORK', + ); + } + }); + + it('REGRESSION: Perform the transfer ERC20 token without Token Address while adding transactions to the batch on the xdai network', async () => { + if (runTest) { + // get the respective provider details + let provider; + try { + provider = new ethers.providers.JsonRpcProvider( + data.providerNetwork_xdai, + ); + } catch (e) { + console.error(e); + assert.fail('The provider response is not displayed correctly.'); + } + + // get erc20 Contract Interface + let erc20Instance; + try { + erc20Instance = new ethers.Contract( + data.tokenAddress_xdaiUSDC, + ERC20_ABI, + provider, + ); + } catch (e) { + console.error(e); + assert.fail('The get erc20 Contract Interface is not performed.'); + } + + // get decimals from erc20 contract + let decimals; + try { + decimals = await erc20Instance.functions.decimals(); + } catch (e) { + console.error(e); + assert.fail( + 'The decimals from erc20 contract is not displayed correctly.', + ); + } + + // get transferFrom encoded data + let transactionData; + try { + transactionData = erc20Instance.interface.encodeFunctionData( + 'transfer', + [data.recipient, ethers.utils.parseUnits(data.value, decimals)], + ); + } catch (e) { + console.error(e); + assert.fail( + 'The decimals from erc20 contract is not displayed correctly.', + ); + } + + // clear the transaction batch + try { + await xdaiMainNetSdk.clearUserOpsFromBatch(); + } catch (e) { + console.error(e); + assert.fail('The transaction of the batch is not clear correctly.'); + } + + // add transactions to the batch + try { + await xdaiMainNetSdk.addUserOpsToBatch({ + data: transactionData, // without tokenAddress + }); + } catch (e) { + console.error(e); + assert.fail('The transaction of the batch is not clear correctly.'); + } + + // estimate transactions added to the batch + try { + await xdaiMainNetSdk.estimate(); + + assert.fail( + 'The expected validation is not displayed when not entered the Token Address while estimate the added transactions to the batch.', + ); + } catch (e) { + if (e.reason.includes('invalid address')) { + console.log( + 'The validation for Token Address is displayed as expected while estimate the added transactions to the batch.', + ); + } else { + console.error(e); + assert.fail( + 'The expected validation is not displayed when not entered the Token Address while estimate the added transactions to the batch.', + ); + } + } + } else { + console.warn( + 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE SEND ERC20 TOKEN WITHOUT TOKEN ADDRESS WHILE ADDED THE ESTIMATED TRANSACTION TO THE BATCH ON THE xdai NETWORK', + ); + } + }); + + it('REGRESSION: Perform the transfer ERC20 token without adding transaction to the batch while estimate the added transactions to the batch on the xdai network', async () => { + if (runTest) { + // get the respective provider details + let provider; + try { + provider = new ethers.providers.JsonRpcProvider( + data.providerNetwork_xdai, + ); + } catch (e) { + console.error(e); + assert.fail('The provider response is not displayed correctly.'); + } + + // get erc20 Contract Interface + let erc20Instance; + try { + erc20Instance = new ethers.Contract( + data.tokenAddress_xdaiUSDC, + ERC20_ABI, + provider, + ); + } catch (e) { + console.error(e); + assert.fail('The get erc20 Contract Interface is not performed.'); + } + + // get decimals from erc20 contract + let decimals; + try { + decimals = await erc20Instance.functions.decimals(); + } catch (e) { + console.error(e); + assert.fail( + 'The decimals from erc20 contract is not displayed correctly.', + ); + } + + // get transferFrom encoded data + try { + erc20Instance.interface.encodeFunctionData('transfer', [ + data.recipient, + ethers.utils.parseUnits(data.value, decimals), + ]); + } catch (e) { + console.error(e); + assert.fail( + 'The decimals from erc20 contract is not displayed correctly.', + ); + } + + // clear the transaction batch + try { + await xdaiMainNetSdk.clearUserOpsFromBatch(); + } catch (e) { + console.error(e); + assert.fail('The transaction of the batch is not clear correctly.'); + } + + // estimate transactions added to the batch + try { + await xdaiMainNetSdk.estimate(); + + assert.fail( + 'The expected validation is not displayed when not added the transaction to the batch while adding the estimate transactions to the batch.', + ); + } catch (e) { + if (e.message === 'cannot sign empty transaction batch') { + console.log( + 'The validation for transaction batch is displayed as expected while adding the estimate transactions to the batch.', + ); + } else { + console.error(e); + assert.fail( + 'The expected validation is not displayed when not added the transaction to the batch while adding the estimate transactions to the batch.', + ); + } + } + } else { + console.warn( + 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE SEND ERC20 TOKEN WITHOUT ADDING TRANSACTION TO THE BATCH WHILE ESTIMATE THE ADDED TRANSACTIONS TO THE BATCH ON THE xdai NETWORK', + ); + } + }); + + it('REGRESSION: Perform the transfer ERC20 token with the incorrect TxHash while getting the transaction hash on the xdai network', async () => { + if (runTest) { + // get the respective provider details + let provider; + try { + provider = new ethers.providers.JsonRpcProvider( + data.providerNetwork_xdai, + ); + } catch (e) { + console.error(e); + assert.fail('The provider response is not displayed correctly.'); + } + + // get erc20 Contract Interface + let erc20Instance; + try { + erc20Instance = new ethers.Contract( + data.tokenAddress_xdaiUSDC, + ERC20_ABI, + provider, + ); + } catch (e) { + console.error(e); + assert.fail('The get erc20 Contract Interface is not performed.'); + } + + // get decimals from erc20 contract + let decimals; + try { + decimals = await erc20Instance.functions.decimals(); + } catch (e) { + console.error(e); + assert.fail( + 'The decimals from erc20 contract is not displayed correctly.', + ); + } + + // get transferFrom encoded data + let transactionData; + try { + transactionData = erc20Instance.interface.encodeFunctionData( + 'transfer', + [data.recipient, ethers.utils.parseUnits(data.value, decimals)], + ); + } catch (e) { + console.error(e); + assert.fail( + 'The decimals from erc20 contract is not displayed correctly.', + ); + } + + // clear the transaction batch + try { + await xdaiMainNetSdk.clearUserOpsFromBatch(); + } catch (e) { + console.error(e); + assert.fail('The transaction of the batch is not clear correctly.'); + } + + // add transactions to the batch + try { + await xdaiMainNetSdk.addUserOpsToBatch({ + to: data.tokenAddress_xdaiUSDC, + data: transactionData, + }); + } catch (e) { + console.error(e); + assert.fail('The transaction of the batch is not clear correctly.'); + } + + // estimate transactions added to the batch + try { + await xdaiMainNetSdk.estimate(); + } catch (e) { + console.error(e); + assert.fail( + 'The estimate transactions added to the batch is not performed.', + ); + } + + // 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(2000); + userOpsReceipt = await xdaiMainNetSdk.getUserOpReceipt( + data.incorrectTxHash, + ); + } + + assert.fail( + 'The expected validation is not displayed when added the incorrect TxHash while getting the transaction hash.', + ); + } catch (e) { + if (e.showDiff === false) { + console.log( + 'The validation for transaction is displayed as expected while getting the transaction hash.', + ); + } else { + console.error(e); + assert.fail( + 'The expected validation is not displayed when added the incorrect TxHash while getting the transaction hash.', + ); + } + } + } else { + console.warn( + 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE SEND ERC20 TOKEN WITH INCORRECT TXHASH WHILE GETTING THE TRANSACTION HASH ON THE xdai NETWORK', + ); + } + }); + + it('REGRESSION: Perform the transfer ERC20 token with the past TxHash while getting the transaction hash on the xdai network', async () => { + if (runTest) { + // get the respective provider details + let provider; + try { + provider = new ethers.providers.JsonRpcProvider( + data.providerNetwork_xdai, + ); + } catch (e) { + console.error(e); + assert.fail('The provider response is not displayed correctly.'); + } + + // get erc20 Contract Interface + let erc20Instance; + try { + erc20Instance = new ethers.Contract( + data.tokenAddress_xdaiUSDC, + ERC20_ABI, + provider, + ); + } catch (e) { + console.error(e); + assert.fail('The get erc20 Contract Interface is not performed.'); + } + + // get decimals from erc20 contract + let decimals; + try { + decimals = await erc20Instance.functions.decimals(); + } catch (e) { + console.error(e); + assert.fail( + 'The decimals from erc20 contract is not displayed correctly.', + ); + } + + // get transferFrom encoded data + let transactionData; + try { + transactionData = erc20Instance.interface.encodeFunctionData( + 'transfer', + [data.recipient, ethers.utils.parseUnits(data.value, decimals)], + ); + } catch (e) { + console.error(e); + assert.fail( + 'The decimals from erc20 contract is not displayed correctly.', + ); + } + + // clear the transaction batch + try { + await xdaiMainNetSdk.clearUserOpsFromBatch(); + } catch (e) { + console.error(e); + assert.fail('The transaction of the batch is not clear correctly.'); + } + + // add transactions to the batch + try { + await xdaiMainNetSdk.addUserOpsToBatch({ + to: data.tokenAddress_xdaiUSDC, + data: transactionData, + }); + } catch (e) { + console.error(e); + assert.fail('The transaction of the batch is not clear correctly.'); + } + + // estimate transactions added to the batch + try { + await xdaiMainNetSdk.estimate(); + } catch (e) { + console.error(e); + assert.fail( + 'The estimate transactions added to the batch is not performed.', + ); + } + + // 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(2000); + userOpsReceipt = await xdaiMainNetSdk.getUserOpReceipt( + data.pastTxHash, + ); + } + + assert.fail( + 'The expected validation is not displayed when added the past TxHash while getting the transaction hash.', + ); + } catch (e) { + if (e.showDiff === false) { + console.log( + 'The validation for transaction is displayed as expected while getting the transaction hash.', + ); + } else { + console.error(e); + assert.fail( + 'The expected validation is not displayed when added the past TxHash while getting the transaction hash.', + ); + } + } + } else { + console.warn( + 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE SEND ERC20 TOKEN WITH PAST TXHASH WHILE GETTING THE TRANSACTION HASH ON THE xdai NETWORK', + ); + } + }); + + it('REGRESSION: Perform the transfer ERC721 NFT token with incorrect Sender Address while creating the NFT Data on the xdai network', async () => { + if (runTest) { + // 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, + ]); + + assert.fail( + 'The expected validation is not displayed when added the incorrect sender address while creating the NFT Data.', + ); + } catch (e) { + if (e.reason.includes('bad address checksum')) { + console.log( + 'The validation for sender address is displayed as expected while creating the NFT Data.', + ); + } else { + console.error(e); + assert.fail( + 'The expected validation is not displayed when added the incorrect sender address while creating the NFT Data.', + ); + } + } + } else { + console.warn( + 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE SEND ERC721 TOKEN WITH INCORRECT SENDER ADDRESS WHILE CREATING THE NFT DATA ON THE xdai NETWORK', + ); + } + }); + + it('REGRESSION: Perform the transfer ERC721 NFT token with invalid Sender Address i.e. missing character while creating the NFT Data on the xdai network', async () => { + if (runTest) { + // 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, + ]); + + assert.fail( + 'The expected validation is not displayed when added the invalid Sender Address i.e. missing character while creating the NFT Data.', + ); + } catch (e) { + if (e.reason.includes('invalid address')) { + console.log( + 'The validation for sender address is displayed as expected while creating the NFT Data.', + ); + } else { + console.error(e); + assert.fail( + 'The expected validation is not displayed when added the invalid Sender Address i.e. missing character while creating the NFT Data.', + ); + } + } + } else { + console.warn( + 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE SEND ERC721 TOKEN WITH INVALID SENDER ADDRESS WHILE CREATING THE NFT DATA ON THE xdai NETWORK', + ); + } + }); + + it('REGRESSION: Perform the transfer ERC721 NFT token without Sender Address while creating the NFT Data on the xdai network', async () => { + if (runTest) { + // 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, + ]); + + assert.fail( + 'The expected validation is not displayed when not added the Sender Address while creating the NFT Data.', + ); + } catch (e) { + if (e.reason === 'types/values length mismatch') { + console.log( + 'The validation for sender address is displayed as expected while creating the NFT Data.', + ); + } else { + console.error(e); + assert.fail( + 'The expected validation is not displayed when not added the Sender Address while creating the NFT Data.', + ); + } + } + } else { + console.warn( + 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE SEND ERC721 TOKEN WITHOUT SENDER ADDRESS WHILE CREATING THE NFT DATA ON THE xdai NETWORK', + ); + } + }); + + it('REGRESSION: Perform the transfer ERC721 NFT token with incorrect Recipient Address while creating the NFT Data on the xdai network', async () => { + if (runTest) { + // 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, + ]); + + assert.fail( + 'The expected validation is not displayed when added the incorrect recipient address while creating the NFT Data.', + ); + } catch (e) { + if (e.reason.includes('bad address checksum')) { + console.log( + 'The validation for recipient address is displayed as expected while creating the NFT Data.', + ); + } else { + console.error(e); + assert.fail( + 'The expected validation is not displayed when added the incorrect recipient address while creating the NFT Data.', + ); + } + } + } else { + console.warn( + 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE SEND ERC721 TOKEN WITH INCORRECT RECEPIENT ADDRESS WHILE CREATING THE NFT DATA ON THE xdai NETWORK', + ); + } + }); + + it('REGRESSION: Perform the transfer ERC721 NFT token with invalid Recipient Address i.e. missing character while creating the NFT Data on the xdai network', async () => { + if (runTest) { + // 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, + ]); + + assert.fail( + 'The expected validation is not displayed when added the invalid Recipient Address i.e. missing character while creating the NFT Data.', + ); + } catch (e) { + if (e.reason.includes('invalid address')) { + console.log( + 'The validation for recipient address is displayed as expected while creating the NFT Data.', + ); + } else { + console.error(e); + assert.fail( + 'The expected validation is not displayed when added the invalid Recipient Address i.e. missing character while creating the NFT Data.', + ); + } + } + } else { + console.warn( + 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE SEND ERC721 TOKEN WITH INVALID RECEPIENT ADDRESS WHILE CREATING THE NFT DATA ON THE xdai NETWORK', + ); + } + }); + + it('REGRESSION: Perform the transfer ERC721 NFT token without Recipient Address while creating the NFT Data on the xdai network', async () => { + if (runTest) { + // 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, + ]); + + assert.fail( + 'The expected validation is not displayed when not added the Recipient Address while creating the NFT Data.', + ); + } catch (e) { + if (e.reason === 'types/values length mismatch') { + console.log( + 'The validation for recipient address is displayed as expected while creating the NFT Data.', + ); + } else { + console.error(e); + assert.fail( + 'The expected validation is not displayed when not added the Recipient Address while creating the NFT Data.', + ); + } + } + } else { + console.warn( + 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE SEND ERC721 TOKEN WITHOUT RECEPIENT ADDRESS WHILE CREATING THE NFT DATA ON THE xdai NETWORK', + ); + } + }); + + it('REGRESSION: Perform the transfer ERC721 NFT token with incorrect tokenId while creating the NFT Data on the xdai network', async () => { + if (runTest) { + // 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 + ]); + + assert.fail( + 'The expected validation is not displayed when added the incorrect tokenId while creating the NFT Data.', + ); + } catch (e) { + if (e.reason === 'invalid BigNumber string') { + console.log( + 'The validation for tokenId is displayed as expected while creating the NFT Data.', + ); + } else { + console.error(e); + assert.fail( + 'The expected validation is not displayed when added the incorrect tokenId while creating the NFT Data.', + ); + } + } + } else { + console.warn( + 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE SEND ERC721 TOKEN WITH INCORRECT TOKENID WHILE CREATING THE NFT DATA ON THE xdai NETWORK', + ); + } + }); + + it('REGRESSION: Perform the transfer ERC721 NFT token without tokenId while creating the NFT Data on the xdai network', async () => { + if (runTest) { + // get erc721 Contract Interface + let erc721Interface; + try { + erc721Interface = new ethers.utils.Interface(abi.abi); + + erc721Interface.encodeFunctionData('transferFrom', [ + data.sender, + data.recipient, // not added tokenid + ]); + + assert.fail( + 'The expected validation is not displayed when not added the tokenid while creating the NFT Data.', + ); + } catch (e) { + if (e.reason === 'types/values length mismatch') { + console.log( + 'The validation for tokenid is displayed as expected while creating the NFT Data.', + ); + } else { + console.error(e); + assert.fail( + 'The expected validation is not displayed when not added the tokenid while creating the NFT Data.', + ); + } + } + } else { + console.warn( + 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE SEND ERC721 TOKEN WITHOUT TOKENID WHILE CREATING THE NFT DATA ON THE xdai NETWORK', + ); + } + }); + + it('REGRESSION: Perform the transfer ERC721 NFT Token without adding transaction to the batch while estimate the added transactions to the batch on the xdai network', async () => { + if (runTest) { + // 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); + assert.fail('The get erc721 Contract Interface is not performed.'); + } + + // clear the transaction batch + try { + await xdaiMainNetSdk.clearUserOpsFromBatch(); + } catch (e) { + console.error(e); + assert.fail('The transaction of the batch is not clear correctly.'); + } + + // get balance of the account address + try { + await xdaiMainNetSdk.getNativeBalance(); + } catch (e) { + console.error(e); + assert.fail('The balance of the ERC721 NFT Token is not displayed.'); + } + + // estimate transactions added to the batch + try { + await xdaiMainNetSdk.estimate(); + + assert.fail( + 'The expected validation is not displayed when not added the transaction to the batch while adding the estimate transactions to the batch.', + ); + } catch (e) { + if (e.message === 'cannot sign empty transaction batch') { + console.log( + 'The validation for transaction batch is displayed as expected while adding the estimate transactions to the batch.', + ); + } else { + console.error(e); + assert.fail( + 'The expected validation is not displayed when not added the transaction to the batch while adding the estimate transactions to the batch.', + ); + } + } + } else { + console.warn( + 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE SEND ERC721 TOKEN WITH NOT ADDED THE TRANSACTION TO THE BATCH WHILE ADDING THE ESTIMATE TRANSACTIONS TO THE BATCH ON THE xdai NETWORK', + ); + } + }); + + it('REGRESSION: Perform the transfer ERC721 NFT Token with the incorrect TxHash while getting the transaction hash on the xdai network', async () => { + if (runTest) { + // 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, + ]); + } catch (e) { + console.error(e); + assert.fail('The get erc721 Contract Interface is not performed.'); + } + + // clear the transaction batch + try { + await xdaiMainNetSdk.clearUserOpsFromBatch(); + } catch (e) { + console.error(e); + assert.fail('The transaction of the batch is not clear correctly.'); + } + + // add transactions to the batch + try { + await xdaiMainNetSdk.addUserOpsToBatch({ + to: data.nft_tokenAddress, + data: erc721Data, + }); + } catch (e) { + console.error(e); + assert.fail('The transaction of the batch is not clear correctly.'); + } + + // estimate transactions added to the batch + try { + await xdaiMainNetSdk.estimate(); + } catch (e) { + console.error(e); + assert.fail( + 'The estimate transactions added to the batch is not performed.', + ); + } + + // 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(2000); + userOpsReceipt = await xdaiMainNetSdk.getUserOpReceipt( + data.incorrectTxHash, + ); + } + + assert.fail( + 'The expected validation is not displayed when added the incorrect TxHash while getting the transaction hash.', + ); + } catch (e) { + if (e.showDiff === false) { + console.log( + 'The validation for transaction is displayed as expected while getting the transaction hash.', + ); + } else { + console.error(e); + assert.fail( + 'The expected validation is not displayed when added the incorrect TxHash while getting the transaction hash.', + ); + } + } + } else { + console.warn( + 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE SEND ERC721 TOKEN WITH INCORRECT TXHASH WHILE GETTING THE TRANSACTION HASH ON THE xdai NETWORK', + ); + } + }); + + it('REGRESSION: Perform the transfer ERC721 NFT Token with the past TxHash while getting the transaction hash on the xdai network', async () => { + if (runTest) { + // 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, + ]); + } catch (e) { + console.error(e); + assert.fail('The get erc721 Contract Interface is not performed.'); + } + + // clear the transaction batch + try { + await xdaiMainNetSdk.clearUserOpsFromBatch(); + } catch (e) { + console.error(e); + assert.fail('The transaction of the batch is not clear correctly.'); + } + + // add transactions to the batch + try { + await xdaiMainNetSdk.addUserOpsToBatch({ + to: data.nft_tokenAddress, + data: erc721Data, + }); + } catch (e) { + console.error(e); + assert.fail('The transaction of the batch is not clear correctly.'); + } + + // estimate transactions added to the batch + try { + await xdaiMainNetSdk.estimate(); + } catch (e) { + console.error(e); + assert.fail( + 'The estimate transactions added to the batch is not performed.', + ); + } + + // 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(2000); + userOpsReceipt = await xdaiMainNetSdk.getUserOpReceipt( + data.pastTxHash, + ); + } + + assert.fail( + 'The expected validation is not displayed when added the past TxHash while getting the transaction hash.', + ); + } catch (e) { + if (e.showDiff === false) { + console.log( + 'The validation for transaction is displayed as expected while getting the transaction hash.', + ); + } else { + console.error(e); + assert.fail( + 'The expected validation is not displayed when added the past TxHash while getting the transaction hash.', + ); + } + } + } else { + console.warn( + 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE SEND ERC721 TOKEN WITH PAST TXHASH WHILE GETTING THE TRANSACTION HASH ON THE xdai NETWORK', + ); + } + }); +}); diff --git a/test/specs/mainnet/02_TransactionHistory/Arbitrum.spec.js b/test/specs/mainnet/02_TransactionHistory/Arbitrum.spec.js index 73d73a8..74220f5 100644 --- a/test/specs/mainnet/02_TransactionHistory/Arbitrum.spec.js +++ b/test/specs/mainnet/02_TransactionHistory/Arbitrum.spec.js @@ -75,7 +75,7 @@ describe('The PrimeSDK, when get the single transaction and multiple transaction if (tokenAddress === arbitrumNativeAddress) { native_balance = output.items[i].balance; native_final = utils.formatUnits(native_balance, 18); - } else if (tokenAddress === data.arbitrumUsdcAddress) { + } else if (tokenAddress === data.tokenAddress_arbitrumUSDC) { usdc_balance = output.items[i].balance; usdc_final = utils.formatUnits(usdc_balance, 6); } @@ -91,7 +91,7 @@ describe('The PrimeSDK, when get the single transaction and multiple transaction } }); - it.only('SMOKE: Validate the transaction history of the native token transaction on the arbitrum network', async () => { + it('SMOKE: Validate the transaction history of the native token transaction on the arbitrum network', async () => { if (runTest) { // clear the transaction batch try { diff --git a/test/specs/mainnet/02_TransactionHistory/Matic.spec.js b/test/specs/mainnet/02_TransactionHistory/Matic.spec.js index 45e9a8b..e8fbd34 100644 --- a/test/specs/mainnet/02_TransactionHistory/Matic.spec.js +++ b/test/specs/mainnet/02_TransactionHistory/Matic.spec.js @@ -75,7 +75,7 @@ describe('The PrimeSDK, when get the single transaction and multiple transaction if (tokenAddress === maticNativeAddress) { native_balance = output.items[i].balance; native_final = utils.formatUnits(native_balance, 18); - } else if (tokenAddress === data.maticUsdcAddress) { + } else if (tokenAddress === data.tokenAddress_maticUSDC) { usdc_balance = output.items[i].balance; usdc_final = utils.formatUnits(usdc_balance, 6); } diff --git a/test/specs/mainnet/02_TransactionHistory/Optimism.spec.js b/test/specs/mainnet/02_TransactionHistory/Optimism.spec.js index c90edbb..b545012 100644 --- a/test/specs/mainnet/02_TransactionHistory/Optimism.spec.js +++ b/test/specs/mainnet/02_TransactionHistory/Optimism.spec.js @@ -75,7 +75,7 @@ describe('The PrimeSDK, when get the single transaction and multiple transaction if (tokenAddress === optimismNativeAddress) { native_balance = output.items[i].balance; native_final = utils.formatUnits(native_balance, 18); - } else if (tokenAddress === data.optimismUsdcAddress) { + } else if (tokenAddress === data.tokenAddress_optimismUSDC) { usdc_balance = output.items[i].balance; usdc_final = utils.formatUnits(usdc_balance, 6); } diff --git a/test/specs/mainnet/02_TransactionHistory/Xdai.spec.js b/test/specs/mainnet/02_TransactionHistory/Xdai.spec.js new file mode 100644 index 0000000..d21f4b6 --- /dev/null +++ b/test/specs/mainnet/02_TransactionHistory/Xdai.spec.js @@ -0,0 +1,1581 @@ +import { PrimeSdk } from '@etherspot/prime-sdk'; +import { ethers, utils } from 'ethers'; +import { assert } from 'chai'; +import Helper from '../../../utils/Helper.js'; +import data from '../../../data/testData.json' assert { type: 'json' }; +import * as dotenv from 'dotenv'; +dotenv.config(); // init dotenv + +let xdaiMainNetSdk; +let xdaiEtherspotWalletAddress; +let xdaiNativeAddress = null; +let runTest; + +describe('The PrimeSDK, when get the single transaction and multiple transaction details with xdai network on the MainNet', () => { + beforeEach(async () => { + // added timeout + Helper.wait(data.mediumTimeout); + + // initializating sdk + try { + xdaiMainNetSdk = new PrimeSdk( + { privateKey: process.env.PRIVATE_KEY }, + { + chainId: Number(process.env.XDAI_CHAINID), + projectKey: process.env.PROJECT_KEY, + rpcProviderUrl: data.providerNetwork_xdai, + bundlerRpcUrl: data.providerNetwork_xdai, + }, + ); + + try { + assert.strictEqual( + xdaiMainNetSdk.state.walletAddress, + data.eoaAddress, + 'The EOA Address is not calculated correctly.', + ); + } catch (e) { + console.error(e); + } + } catch (e) { + console.error(e); + assert.fail('The SDK is not initialled successfully.'); + } + + // get EtherspotWallet address + try { + xdaiEtherspotWalletAddress = + await xdaiMainNetSdk.getCounterFactualAddress(); + + try { + assert.strictEqual( + xdaiEtherspotWalletAddress, + data.sender, + 'The Etherspot Wallet Address is not calculated correctly.', + ); + } catch (e) { + console.error(e); + } + } catch (e) { + console.error(e); + assert.fail( + 'The Etherspot Wallet Address is not displayed successfully.', + ); + } + + let output = await xdaiMainNetSdk.getAccountBalances({ + account: data.sender, + chainId: Number(process.env.XDAI_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 === xdaiNativeAddress) { + native_balance = output.items[i].balance; + native_final = utils.formatUnits(native_balance, 18); + } else if (tokenAddress === data.tokenAddress_xdaiUSDC) { + 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; + } + }); + + it('SMOKE: Validate the transaction history of the native token transaction on the xdai network', async () => { + if (runTest) { + // clear the transaction batch + try { + await xdaiMainNetSdk.clearUserOpsFromBatch(); + } catch (e) { + console.error(e); + assert.fail('The transaction of the batch is not clear correctly.'); + } + + // add transactions to the batch + try { + await xdaiMainNetSdk.addUserOpsToBatch({ + to: data.recipient, + value: ethers.utils.parseEther(data.value), + }); + } catch (e) { + console.error(e); + assert.fail( + 'The addition of transaction in the batch is not performed.', + ); + } + + // get balance of the account address + try { + await xdaiMainNetSdk.getNativeBalance(); + } catch (e) { + console.error(e); + assert.fail('The balance of the native token is not displayed.'); + } + + // estimate transactions added to the batch and get the fee data for the UserOp + let op; + try { + op = await xdaiMainNetSdk.estimate(); + } catch (e) { + console.error(e); + assert.fail( + 'The estimate transactions added to the batch and get the fee data for the UserOp is not performed.', + ); + } + + // sign the UserOp and sending to the bundler + let uoHash; + try { + uoHash = await xdaiMainNetSdk.send(op); + } catch (e) { + console.error(e); + assert.fail( + 'The sign the UserOp and sending to the bundler action is not performed.', + ); + } + + // 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(2000); + userOpsReceipt = await xdaiMainNetSdk.getUserOpReceipt(uoHash); + } + + console.log('userOpsReceipt::::::::::', userOpsReceipt); + } catch (e) { + console.error(e); + assert.fail('The get transaction hash action is not performed.'); + } + + // ADDED FEW COMMENTS IN BELOW CODE DUE TO REMOVED GETTRANSACTIONS ENDPOINT IN 1.2.8 RELEASE + + // get single transaction history details + let transactionHash; + let singleTransaction; + // let blockNumber_singleTransaction; + // let from_singleTransaction; + // let gasLimit_singleTransaction; + // let gasPrice_singleTransaction; + // let gasUsed_singleTransaction; + // let hash_singleTransaction; + // let status_singleTransaction; + // let blockExplorerUrl_singleTransaction; + try { + transactionHash = userOpsReceipt.receipt.transactionHash; + singleTransaction = await xdaiMainNetSdk.getTransaction({ + hash: transactionHash, + }); + + try { + assert.isNotEmpty( + singleTransaction.blockHash, + 'The blockHash value is empty in the transaction details response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isNumber( + singleTransaction.blockNumber, + 'The blockNumber value is not number in the transaction details response.', + ); + // blockNumber_singleTransaction = singleTransaction.blockNumber; + } catch (e) { + console.error(e); + } + + try { + assert.isNotEmpty( + singleTransaction.from, + 'The from address value is not correct in the transaction details response.', + ); + // from_singleTransaction = singleTransaction.from; + } catch (e) { + console.error(e); + } + + try { + assert.isNumber( + singleTransaction.gasLimit, + 'The gasLimit value is not number in the transaction details response.', + ); + // gasLimit_singleTransaction = singleTransaction.gasLimit; + } catch (e) { + console.error(e); + } + + try { + assert.isNotEmpty( + singleTransaction.gasPrice, + 'The gasPrice value is empty in the transaction details response.', + ); + // gasPrice_singleTransaction = singleTransaction.gasPrice; + } catch (e) { + console.error(e); + } + + try { + assert.isNumber( + singleTransaction.gasUsed, + 'The gasUsed value is not number in the transaction details response.', + ); + // gasUsed_singleTransaction = singleTransaction.gasUsed; + } catch (e) { + console.error(e); + } + + try { + assert.isNotEmpty( + singleTransaction.hash, + 'The hash value is empty in the transaction details response.', + ); + // hash_singleTransaction = singleTransaction.hash; + } catch (e) { + console.error(e); + } + + try { + assert.isNotEmpty( + singleTransaction.input, + 'The input value is empty in the transaction details response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isNumber( + singleTransaction.logs[0].transactionIndex, + 'The transactionIndex value of the logs is not number in the transaction details response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isNumber( + singleTransaction.logs[0].blockNumber, + 'The blockNumber value of the logs is not number in the transaction details response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isNotEmpty( + singleTransaction.logs[0].transactionHash, + 'The transactionHash value of the logs is empty in the transaction details response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isNotEmpty( + singleTransaction.logs[0].address, + 'The address value of the logs is empty in the transaction details response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isNotEmpty( + singleTransaction.logs[0].topics, + 'The topics value of the logs is empty in the transaction details response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isNotEmpty( + singleTransaction.logs[0].data, + 'The data value of the logs is empty in the transaction details response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isNumber( + singleTransaction.logs[0].logIndex, + 'The logIndex value of the logs is not number in the transaction details response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isNotEmpty( + singleTransaction.logs[0].blockHash, + 'The blockHash value of the logs is empty in the transaction details response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isNumber( + singleTransaction.nonce, + 'The nonce value is not number in the transaction details response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.strictEqual( + singleTransaction.status, + 'Completed', + 'The status value is not correct in the transaction details response.', + ); + + // status_singleTransaction = singleTransaction.status; + } catch (e) { + console.error(e); + } + + try { + assert.isNotEmpty( + singleTransaction.to, + 'The to address value is empty in the transaction details response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isNumber( + singleTransaction.transactionIndex, + 'The transactionIndex value is not number in the transaction details response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isNotEmpty( + singleTransaction.value, + 'The value details is empty in the transaction details response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isNotEmpty( + singleTransaction.blockExplorerUrl, + 'The blockExplorerUrl value is empty in the transaction details response.', + ); + + // blockExplorerUrl_singleTransaction = + // singleTransaction.blockExplorerUrl; + } catch (e) { + console.error(e); + } + } catch (e) { + console.error(e); + assert.fail('The get transaction details is not performed.'); + } + + // REMOVED GETTRANSACTIONS ENDPOINT IN 1.2.8 RELEASE + + // // get transactions history + // let transactions; + // let blockNumber_transactions; + // let from_transactions; + // let gasLimit_transactions; + // let gasPrice_transactions; + // let gasUsed_transactions; + // let hash_transactions; + // let status_transactions; + // let blockExplorerUrl_transactions; + // try { + // transactions = await xdaiMainNetSdk.getTransactions({ + // chainId: Number(process.env.XDAI_CHAINID), + // account: data.sender, + // }); + + // for (let x = 0; x < transactions.items.length; x++) { + // blockNumber_transactions = transactions.items[x].blockNumber; + + // if (blockNumber_singleTransaction == blockNumber_transactions) { + // try { + // assert.isNotEmpty( + // transactions.items[x].blockHash, + // 'The blockHash value is empty in the transaction details response.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isNumber( + // transactions.items[x].blockNumber, + // 'The blockNumber value is not number in the transaction details response.', + // ); + // blockNumber_transactions = transactions.items[x].blockNumber; + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.strictEqual( + // blockNumber_singleTransaction, + // blockNumber_transactions, + // 'The blockNumber of get single transaction response and get transactions response are not matched.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.strictEqual( + // transactions.items[x].from, + // data.sender, + // 'The from address value is not correct in the transaction details response.', + // ); + // from_transactions = transactions.items[x].from; + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.strictEqual( + // from_singleTransaction, + // from_transactions, + // 'The from address of get single transaction response and get transactions response are not matched.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isNumber( + // transactions.items[x].gasLimit, + // 'The gasLimit value is not number in the transaction details response.', + // ); + + // gasLimit_transactions = transactions.items[x].gasLimit; + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.strictEqual( + // gasLimit_singleTransaction, + // gasLimit_transactions, + // 'The gasLimit of get single transaction response and get transactions response are not matched.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isNotEmpty( + // transactions.items[x].gasPrice, + // 'The gasPrice value is empty in the transaction details response.', + // ); + + // gasPrice_transactions = transactions.items[x].gasPrice; + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.strictEqual( + // gasPrice_singleTransaction, + // gasPrice_transactions, + // 'The gasPrice of get single transaction response and get transactions response are not matched.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isNumber( + // transactions.items[x].gasUsed, + // 'The gasUsed value is not number in the transaction details response.', + // ); + // gasUsed_transactions = transactions.items[x].gasUsed; + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.strictEqual( + // gasUsed_singleTransaction, + // gasUsed_transactions, + // 'The gasUsed of get single transaction response and get transactions response are not matched.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isNotEmpty( + // transactions.items[x].hash, + // 'The hash value is empty in the transaction details response.', + // ); + + // hash_transactions = transactions.items[x].hash; + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.strictEqual( + // hash_singleTransaction, + // hash_transactions, + // 'The hash of get single transaction response and get transactions response are not matched.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isNotEmpty( + // transactions.items[x].input, + // 'The input value is empty in the transaction details response.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isNumber( + // transactions.items[x].logs[0].transactionIndex, + // 'The transactionIndex value of the logs is not number in the transaction details response.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isNumber( + // transactions.items[x].logs[0].blockNumber, + // 'The blockNumber value of the logs is not number in the transaction details response.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isNotEmpty( + // transactions.items[x].logs[0].transactionHash, + // 'The transactionHash value of the logs is empty in the transaction details response.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isNotEmpty( + // transactions.items[x].logs[0].address, + // 'The address value of the logs is empty in the transaction details response.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isNotEmpty( + // transactions.items[x].logs[0].topics, + // 'The topics value of the logs is empty in the transaction details response.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isNotEmpty( + // transactions.items[x].logs[0].data, + // 'The data value of the logs is empty in the transaction details response.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isNumber( + // transactions.items[x].logs[0].logIndex, + // 'The logIndex value of the logs is not number in the transaction details response.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isNotEmpty( + // transactions.items[x].logs[0].blockHash, + // 'The blockHash value of the logs is empty in the transaction details response.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isNumber( + // transactions.items[x].nonce, + // 'The nonce value is not number in the transaction details response.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isNotEmpty( + // transactions.items[x].status, + // 'The status value is not correct in the transaction details response.', + // ); + + // status_transactions = transactions.items[x].status; + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.strictEqual( + // status_singleTransaction, + // status_transactions, + // 'The status of get single transaction response and get transactions response are not matched.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isNotEmpty( + // transactions.items[x].to, + // 'The to address value is empty in the transaction details response.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isNumber( + // transactions.items[x].transactionIndex, + // 'The transactionIndex value is not number in the transaction details response.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isNotEmpty( + // transactions.items[x].value, + // 'The value details is empty in the transaction details response.', + // ); + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.isNotEmpty( + // transactions.items[x].blockExplorerUrl, + // 'The blockExplorerUrl value is empty in the transaction details response.', + // ); + + // blockExplorerUrl_transactions = + // transactions.items[x].blockExplorerUrl; + // } catch (e) { + // console.error(e); + // } + + // try { + // assert.strictEqual( + // blockExplorerUrl_singleTransaction, + // blockExplorerUrl_transactions, + // 'The blockExplorerUrl of get single transaction response and get transactions response are not matched.', + // ); + // } catch (e) { + // console.error(e); + // } + // break; + // } + // } + // } catch (e) { + // console.error(e); + // assert.fail( + // 'The history of the transactions of the respective address is not performed correctly.', + // ); + // } + } else { + console.warn( + 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE HISTORY OF THE TRANSACTIONS ON THE xdai NETWORK', + ); + } + }); + + it('SMOKE: Validate the NFT List on the xdai network', async () => { + if (runTest) { + let nfts; + try { + nfts = await xdaiMainNetSdk.getNftList({ + chainId: Number(process.env.XDAI_CHAINID), + account: data.sender, + }); + + if (nfts.items.length > 0) { + console.log('The items are available in the NFT list.'); + + try { + assert.isNotEmpty( + nfts.items[0].contractName, + 'The contractName value is empty in the NFT list response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isNotEmpty( + nfts.items[0].contractAddress, + 'The contractAddress value is empty in the NFT list response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isNotEmpty( + nfts.items[0].tokenType, + 'The tokenType value is empty in the NFT list response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isNotEmpty( + nfts.items[0].nftDescription, + 'The nftDescription value is empty in the NFT list response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isNumber( + nfts.items[0].balance, + 'The balance value is not number in the NFT list response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isNotEmpty( + nfts.items[0].items[0].tokenId, + 'The tokenId value of the items is empty in the NFT list response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isNotEmpty( + nfts.items[0].items[0].name, + 'The name value of the items is empty in the NFT list response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isNumber( + nfts.items[0].items[0].amount, + 'The amount value of the items is not number in the NFT list response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isNotEmpty( + nfts.items[0].items[0].image, + 'The image value of the items is empty in the NFT list response.', + ); + } catch (e) { + console.error(e); + } + } else { + console.log('The items are not available in the NFT list.'); + } + } catch (e) { + console.error(e); + assert.fail('The get NFT list is not performed correctly.'); + } + } else { + console.warn( + 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE NFT LIST ON THE xdai NETWORK', + ); + } + }); + + xit('REGRESSION: Validate the get transactions history response with random hash in xdai network', async () => { + if (runTest) { + // Fetching historical transactions + let transactions; + let randomTransaction; + let randomHash; + let blockNumber_transactions; + let from_transactions; + let gasLimit_transactions; + let gasPrice_transactions; + let gasUsed_transactions; + let hash_transactions; + let status_transactions; + let blockExplorerUrl_transactions; + + try { + transactions = await xdaiMainNetSdk.getTransactions({ + chainId: Number(process.env.XDAI_CHAINID), + account: data.sender, + }); + randomTransaction = + Math.floor(Math.random() * (transactions.items.length - 1)) + 1; + randomHash = transactions.items[randomTransaction].hash; + + try { + assert.isNumber( + transactions.items[randomTransaction].blockNumber, + 'The blockNumber value is not number in the get transactions response.', + ); + blockNumber_transactions = + transactions.items[randomTransaction].blockNumber; + } catch (e) { + console.error(e); + } + + try { + assert.isNotEmpty( + transactions.items[randomTransaction].from, + 'The from address vlaue is empty in the get transactions response.', + ); + from_transactions = transactions.items[randomTransaction].from; + } catch (e) { + console.error(e); + } + + try { + assert.isNumber( + transactions.items[randomTransaction].gasLimit, + 'The gasLimit value is not number in the get transactions response.', + ); + gasLimit_transactions = + transactions.items[randomTransaction].gasLimit; + } catch (e) { + console.error(e); + } + + try { + assert.isNotEmpty( + transactions.items[randomTransaction].gasPrice, + 'The gasPrice value is empty in the get transactions response.', + ); + gasPrice_transactions = + transactions.items[randomTransaction].gasPrice; + } catch (e) { + console.error(e); + } + + try { + assert.isNumber( + transactions.items[randomTransaction].gasUsed, + 'The gasUsed value is not number in the get transactions response.', + ); + gasUsed_transactions = transactions.items[randomTransaction].gasUsed; + } catch (e) { + console.error(e); + } + + try { + assert.isNotEmpty( + transactions.items[randomTransaction].hash, + 'The hash value is empty in the get transactions response.', + ); + hash_transactions = transactions.items[randomTransaction].hash; + } catch (e) { + console.error(e); + } + + try { + assert.strictEqual( + transactions.items[randomTransaction].status, + 'Completed', + 'The status value is empty in the get transactions response.', + ); + status_transactions = transactions.items[randomTransaction].status; + } catch (e) { + console.error(e); + } + + try { + assert.isNotEmpty( + transactions.items[randomTransaction].value, + 'The values value is empty in the get transactions response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.strictEqual( + transactions.items[randomTransaction].direction, + 'Sender', + 'The direction value is not equal in the get transactions response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isNotEmpty( + transactions.items[randomTransaction].batch, + 'The batch value is empty in the get transactions response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isNotEmpty( + transactions.items[randomTransaction].asset, + 'The asset value is empty in the get transactions response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isNotEmpty( + transactions.items[randomTransaction].blockExplorerUrl, + 'The blockExplorerUrl value is empty in the get transactions response.', + ); + blockExplorerUrl_transactions = + transactions.items[randomTransaction].blockExplorerUrl; + } catch (e) { + console.error(e); + } + } catch (e) { + console.error(e); + assert.fail( + 'An error is displayed while Fetching historical transactions.', + ); + } + + // Fetching a single transaction + let singleTransaction; + let blockNumber_singleTransaction; + let from_singleTransaction; + let gasLimit_singleTransaction; + let gasPrice_singleTransaction; + let gasUsed_singleTransaction; + let hash_singleTransaction; + let status_singleTransaction; + let blockExplorerUrl_singleTransaction; + + try { + singleTransaction = await xdaiMainNetSdk.getTransaction({ + hash: randomHash, // Add your transaction hash + }); + + try { + assert.isNotEmpty( + singleTransaction.blockHash, + 'The blockHash value is empty in the get single transaction response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isNumber( + singleTransaction.blockNumber, + 'The blockNumber value is not number in the get single transaction response.', + ); + blockNumber_singleTransaction = singleTransaction.blockNumber; + } catch (e) { + console.error(e); + } + + try { + assert.isNotEmpty( + singleTransaction.from, + 'The from address value is not correct in the het single transaction response.', + ); + from_singleTransaction = singleTransaction.from; + } catch (e) { + console.error(e); + } + + try { + assert.isNumber( + singleTransaction.gasLimit, + 'The gasLimit value is not number in the get single transaction response.', + ); + gasLimit_singleTransaction = singleTransaction.gasLimit; + } catch (e) { + console.error(e); + } + + try { + assert.isNotEmpty( + singleTransaction.gasPrice, + 'The gasPrice value is empty in the get single transaction response.', + ); + gasPrice_singleTransaction = singleTransaction.gasPrice; + } catch (e) { + console.error(e); + } + + try { + assert.isNumber( + singleTransaction.gasUsed, + 'The gasUsed value is not number in the get single transaction response.', + ); + gasUsed_singleTransaction = singleTransaction.gasUsed; + } catch (e) { + console.error(e); + } + + try { + assert.isNotEmpty( + singleTransaction.hash, + 'The hash value is empty in the get single transaction response.', + ); + hash_singleTransaction = singleTransaction.hash; + } catch (e) { + console.error(e); + } + + try { + assert.isNotEmpty( + singleTransaction.input, + 'The input value is empty in the get single transaction response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isNotEmpty( + singleTransaction.input, + 'The input value is empty in the transaction details response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isNumber( + singleTransaction.logs[0].transactionIndex, + 'The transactionIndex value of the logs is not number in the transaction details response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isNumber( + singleTransaction.logs[0].blockNumber, + 'The blockNumber value of the logs is not number in the transaction details response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isNotEmpty( + singleTransaction.logs[0].transactionHash, + 'The transactionHash value of the logs is empty in the transaction details response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isNotEmpty( + singleTransaction.logs[0].address, + 'The address value of the logs is empty in the transaction details response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isNotEmpty( + singleTransaction.logs[0].topics, + 'The topics value of the logs is empty in the transaction details response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isNotEmpty( + singleTransaction.logs[0].data, + 'The data value of the logs is empty in the transaction details response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isNumber( + singleTransaction.logs[0].logIndex, + 'The logIndex value of the logs is not number in the transaction details response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isNotEmpty( + singleTransaction.logs[0].blockHash, + 'The blockHash value of the logs is empty in the transaction details response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isNumber( + singleTransaction.nonce, + 'The nonce value is not number in the get single transaction response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.strictEqual( + singleTransaction.status, + 'Completed', + 'The status value is empty in the get single transaction response.', + ); + status_singleTransaction = singleTransaction.status; + } catch (e) { + console.error(e); + } + + try { + assert.isNotEmpty( + singleTransaction.to, + 'The To Address value is empty in the Get Single Transaction Response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isNumber( + singleTransaction.transactionIndex, + 'The To transactionIndex value is not number in the get single transaction response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isNotEmpty( + singleTransaction.value, + 'The To value value is empty in the get single transaction response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isNotEmpty( + singleTransaction.blockExplorerUrl, + 'The To blockExplorerUrl value is empty in the get single transaction response.', + ); + blockExplorerUrl_singleTransaction = + singleTransaction.blockExplorerUrl; + } catch (e) { + console.error(e); + } + + try { + assert.strictEqual( + blockNumber_singleTransaction, + blockNumber_transactions, + 'The blockNumber of get single transaction response and get transactions response are not matched.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.strictEqual( + from_singleTransaction, + from_transactions, + 'The from address of get single transaction response and get transactions response are not matched.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.strictEqual( + gasLimit_singleTransaction, + gasLimit_transactions, + 'The gasLimit of get single transaction response and get transactions response are not matched.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.strictEqual( + gasPrice_singleTransaction, + gasPrice_transactions, + 'The gasPrice of get single transaction response and get transactions response are not matched.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.strictEqual( + gasUsed_singleTransaction, + gasUsed_transactions, + 'The gasUsed of get single transaction response and get transactions response are not matched.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.strictEqual( + hash_singleTransaction, + hash_transactions, + 'The hash of get single transaction response and get transactions response are not matched.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.strictEqual( + status_singleTransaction, + status_transactions, + 'The status of get single transaction response and get transactions response are not matched.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.strictEqual( + blockExplorerUrl_singleTransaction, + blockExplorerUrl_transactions, + 'The blockExplorerUrl of get single transaction response and get transactions response are not matched.', + ); + } catch (e) { + console.error(e); + } + } catch (e) { + console.error(e); + assert.fail('An error is displayed while Fetching single transaction.'); + } + } else { + console.warn( + 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE HISTORY OF THE TRANSACTIONS WITH RANDOM HASH ON THE xdai NETWORK', + ); + } + }); + + it('REGRESSION: Validate the get transaction history response with invalid hash on xdai network', async () => { + if (runTest) { + // Fetching a single transaction + let transaction; + try { + transaction = await xdaiMainNetSdk.getTransaction({ + hash: data.incorrect_hash, // Incorrect Transaction Hash + }); + + if (transaction == null) { + console.log( + 'The null is received while fetching the transaction history with incorrect hash.', + ); + } else { + console.error(e); + assert.fail( + 'Getting the single transaction history with incorrect Hash.', + ); + } + } catch (e) { + console.error(e); + assert.fail( + 'Getting the single transaction history with incorrect Hash.', + ); + } + } else { + console.warn( + 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE HISTORY OF THE TRANSACTIONS WITH INVALID HASH ON THE xdai NETWORK', + ); + } + }); + + it('REGRESSION: Validate the get transaction history response when hash hex is not with 32 size on xdai network', async () => { + if (runTest) { + // Fetching a single transaction + try { + try { + await xdaiMainNetSdk.getTransaction({ + hash: data.invalid_hash, // Invalid Transaction Hash + }); + assert.fail( + 'The transaction history is fetched with hash which not having 32 size hex.', + ); + } catch (e) { + if ( + e.errors[0].constraints.isHex == 'hash must be hex with 32 size' + ) { + console.log( + 'The validation message is displayed when hash not having 32 size hex while fetching the transaction history.', + ); + } else { + console.error(e); + assert.fail( + 'The transaction history is fetched with hash which not having 32 size hex.', + ); + } + } + } catch (e) { + console.error(e); + assert.fail( + 'The transaction history is fetched with hash which not having 32 size hex.', + ); + } + } else { + console.warn( + 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE HISTORY OF THE TRANSACTIONS WITH HASH SIZE IS NOT 32 HEX ON THE xdai NETWORK', + ); + } + }); + + xit('REGRESSION: Validate the get transactions history response with invalid chainid in xdai network', async () => { + if (runTest) { + try { + await xdaiMainNetSdk.getTransactions({ + chainId: Number(process.env.INVALID_XDAI_CHAINID), + account: data.sender, + }); + assert.fail( + 'Validate the get transactions history response with invalid chainid is performed', + ); + } catch (e) { + const errorResponse = JSON.parse(e.message); + if (errorResponse[0].property === 'chainId') { + console.log( + 'The correct validation is displayed while getting the get transactions history response with invalid chainid', + ); + } else { + assert.fail( + 'The respective validate is not displayed for the get transactions history response with invalid chainid', + ); + } + } + } else { + console.warn( + 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE HISTORY OF THE TRANSACTIONS WITH INVALID CHAINID ON THE xdai NETWORK', + ); + } + }); + + xit('REGRESSION: Validate the get transactions history response with incorrect chainid in xdai network', async () => { + if (runTest) { + try { + await xdaiMainNetSdk.getTransactions({ + chainId: Number(process.env.MATIC_CHAINID), + account: data.sender, + }); + assert.fail( + 'Validate the get transactions history response with incorrect chainid is performed', + ); + } catch (e) { + const errorResponse = JSON.parse(e.message); + if (errorResponse[0].property === 'chainId') { + console.log( + 'The correct validation is displayed while getting the get transactions history response with incorrect chainid', + ); + } else { + assert.fail( + 'The respective validate is not displayed for the get transactions history response with incorrect chainid', + ); + } + } + } else { + console.warn( + 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE HISTORY OF THE TRANSACTIONS WITH INCORRECT CHAINID ON THE xdai NETWORK', + ); + } + }); + + xit('REGRESSION: Validate the get transactions history response with invalid account in xdai network', async () => { + if (runTest) { + try { + await xdaiMainNetSdk.getTransactions({ + chainId: Number(process.env.XDAI_CHAINID), + account: data.invalidSender, + }); + assert.fail( + 'Validate the get transactions history response with invalid account is performed', + ); + } catch (e) { + const errorResponse = JSON.parse(e.message); + if (errorResponse[0].property === 'account') { + console.log( + 'The correct validation is displayed while getting the get transactions history response with invalid account', + ); + } else { + assert.fail( + 'The respective validate is not displayed for the get transactions history response with invalid account', + ); + } + } + } else { + console.warn( + 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE HISTORY OF THE TRANSACTIONS WITH INVALID ACCOUNT ON THE xdai NETWORK', + ); + } + }); + + xit('REGRESSION: Validate the get transactions history response with incorrect account in xdai network', async () => { + if (runTest) { + try { + await xdaiMainNetSdk.getTransactions({ + chainId: Number(process.env.XDAI_CHAINID), + account: data.incorrectSender, + }); + assert.fail( + 'Validate the get transactions history response with incorrect account is performed', + ); + } catch (e) { + const errorResponse = JSON.parse(e.message); + if (errorResponse[0].property === 'account') { + console.log( + 'The correct validation is displayed while getting the get transactions history response with incorrect account', + ); + } else { + assert.fail( + 'The respective validate is not displayed for the get transactions history response with incorrect account', + ); + } + } + } else { + console.warn( + 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE HISTORY OF THE TRANSACTIONS WITH INCORRECT ACCOUNT ON THE xdai NETWORK', + ); + } + }); + + it('REGRESSION: Validate the NFT List with invalid chainid on the xdai network', async () => { + if (runTest) { + try { + await xdaiMainNetSdk.getNftList({ + chainId: process.env.INVALID_XDAI_CHAINID, + account: data.sender, + }); + + assert.fail('Validate the NFT List with invalid chainid is performed'); + } catch (e) { + const errorResponse = JSON.parse(e.message); + if (errorResponse[0].property === 'chainId') { + console.log( + 'The correct validation is displayed while getting the NFT list with invalid chainid', + ); + } else { + assert.fail( + 'The respective validate is not displayed for the NFT List with invalid chainid', + ); + } + } + } else { + console.warn( + 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE HISTORY OF THE NFT LIST WITH INVALID CHAINID ON THE xdai NETWORK', + ); + } + }); + + it('REGRESSION: Validate the NFT List with invalid account address on the xdai network', async () => { + if (runTest) { + try { + await xdaiMainNetSdk.getNftList({ + chainId: Number(process.env.XDAI_CHAINID), + account: data.invalidSender, + }); + + assert.fail( + 'Validate the NFT List with invalid account address is performed', + ); + } catch (e) { + const errorResponse = JSON.parse(e.message); + if (errorResponse[0].property === 'account') { + console.log( + 'The correct validation is displayed while getting the NFT list with invalid account address', + ); + } else { + assert.fail( + 'The respective validate is not displayed for the NFT List with invalid account address', + ); + } + } + } else { + console.warn( + 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE HISTORY OF THE NFT LIST WITH INVALID ACCOUNT ON THE xdai NETWORK', + ); + } + }); + + it('REGRESSION: Validate the NFT List with incorrect account address on the xdai network', async () => { + if (runTest) { + try { + await xdaiMainNetSdk.getNftList({ + chainId: Number(process.env.XDAI_CHAINID), + account: data.incorrectSender, + }); + assert.fail( + 'Validate the NFT List with inncorrect account address is performed', + ); + } catch (e) { + const errorResponse = JSON.parse(e.message); + if (errorResponse[0].property === 'account') { + console.log( + 'The correct validation is displayed while getting the NFT list with inncorrect account address', + ); + } else { + assert.fail( + 'The respective validate is not displayed for the NFT List with incorrect account address', + ); + } + } + } else { + console.warn( + 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE HISTORY OF THE NFT LIST WITH INCORRECT ACCOUNT ON THE xdai NETWORK', + ); + } + }); +}); diff --git a/test/specs/mainnet/03_Swap/Arbitrum.spec.js b/test/specs/mainnet/03_Swap/Arbitrum.spec.js index ad7c09d..c88d38d 100644 --- a/test/specs/mainnet/03_Swap/Arbitrum.spec.js +++ b/test/specs/mainnet/03_Swap/Arbitrum.spec.js @@ -75,7 +75,7 @@ describe('The PrimeSDK, when get cross chain quotes and get advance routes LiFi if (tokenAddress === arbitrumNativeAddress) { native_balance = output.items[i].balance; native_final = utils.formatUnits(native_balance, 18); - } else if (tokenAddress === data.arbitrumUsdcAddress) { + } else if (tokenAddress === data.tokenAddress_arbitrumUSDC) { usdc_balance = output.items[i].balance; usdc_final = utils.formatUnits(usdc_balance, 6); } diff --git a/test/specs/mainnet/03_Swap/Matic.spec.js b/test/specs/mainnet/03_Swap/Matic.spec.js index 153a606..642c120 100644 --- a/test/specs/mainnet/03_Swap/Matic.spec.js +++ b/test/specs/mainnet/03_Swap/Matic.spec.js @@ -75,7 +75,7 @@ describe('The PrimeSDK, when get cross chain quotes and get advance routes LiFi if (tokenAddress === maticNativeAddress) { native_balance = output.items[i].balance; native_final = utils.formatUnits(native_balance, 18); - } else if (tokenAddress === data.maticUsdcAddress) { + } else if (tokenAddress === data.tokenAddress_maticUSDC) { usdc_balance = output.items[i].balance; usdc_final = utils.formatUnits(usdc_balance, 6); } diff --git a/test/specs/mainnet/03_Swap/Optimism.spec.js b/test/specs/mainnet/03_Swap/Optimism.spec.js index aeacf06..aeab6a9 100644 --- a/test/specs/mainnet/03_Swap/Optimism.spec.js +++ b/test/specs/mainnet/03_Swap/Optimism.spec.js @@ -75,7 +75,7 @@ describe('The PrimeSDK, when get cross chain quotes and get advance routes LiFi if (tokenAddress === optimismNativeAddress) { native_balance = output.items[i].balance; native_final = utils.formatUnits(native_balance, 18); - } else if (tokenAddress === data.optimismUsdcAddress) { + } else if (tokenAddress === data.tokenAddress_optimismUSDC) { usdc_balance = output.items[i].balance; usdc_final = utils.formatUnits(usdc_balance, 6); } diff --git a/test/specs/mainnet/03_Swap/Xdai.spec.js b/test/specs/mainnet/03_Swap/Xdai.spec.js new file mode 100644 index 0000000..b22dfde --- /dev/null +++ b/test/specs/mainnet/03_Swap/Xdai.spec.js @@ -0,0 +1,1056 @@ +import { PrimeSdk } from '@etherspot/prime-sdk'; +import { utils } from 'ethers'; +import { assert } from 'chai'; +import data from '../../../data/testData.json' assert { type: 'json' }; +import Helper from '../../../utils/Helper.js'; +import * as dotenv from 'dotenv'; +dotenv.config(); // init dotenv + +let xdaiMainNetSdk; +let xdaiEtherspotWalletAddress; +let xdaiNativeAddress = null; +let runTest; + +describe('The PrimeSDK, when get cross chain quotes and get advance routes LiFi transaction details with xdai network on the MainNet', () => { + beforeEach(async () => { + // added timeout + Helper.wait(data.mediumTimeout); + + // initializating sdk + try { + xdaiMainNetSdk = new PrimeSdk( + { privateKey: process.env.PRIVATE_KEY }, + { + chainId: Number(process.env.XDAI_CHAINID), + projectKey: process.env.PROJECT_KEY, + }, + ); + + try { + assert.strictEqual( + xdaiMainNetSdk.state.walletAddress, + data.eoaAddress, + 'The EOA Address is not calculated correctly.', + ); + } catch (e) { + console.error(e); + } + } catch (e) { + console.error(e); + assert.fail('The SDK is not initialled successfully.'); + } + + // get EtherspotWallet address + try { + xdaiEtherspotWalletAddress = + await xdaiMainNetSdk.getCounterFactualAddress(); + + try { + assert.strictEqual( + xdaiEtherspotWalletAddress, + data.sender, + 'The Etherspot Wallet Address is not calculated correctly.', + ); + } catch (e) { + console.error(e); + } + } catch (e) { + console.error(e); + assert.fail( + 'The Etherspot Wallet Address is not displayed successfully.', + ); + } + + let output = await xdaiMainNetSdk.getAccountBalances({ + account: data.sender, + chainId: Number(process.env.XDAI_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 === xdaiNativeAddress) { + native_balance = output.items[i].balance; + native_final = utils.formatUnits(native_balance, 18); + } else if (tokenAddress === data.tokenAddress_xdaiUSDC) { + 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; + } + }); + + it('SMOKE: Validate the getCrossChainQuotes response with valid details on the xdai network', async () => { + if (runTest) { + let quoteRequestPayload; + let quotes; + try { + quoteRequestPayload = { + fromChainId: data.xdai_chainid, + toChainId: data.matic_chainid, + fromTokenAddress: data.tokenAddress_xdaiUSDC, + toTokenAddress: data.tokenAddress_maticUSDC, + fromAddress: data.sender, + fromAmount: utils.parseUnits(data.swap_value, 6), + }; + + quotes = await xdaiMainNetSdk.getCrossChainQuotes(quoteRequestPayload); + + if (quotes.items.length > 0) { + try { + assert.isNotEmpty( + quotes.items[0].provider, + 'The provider value is empty in the getCrossChainQuotes response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isNotEmpty( + quotes.items[0].transaction.data, + 'The data value of the transaction is empty in the getCrossChainQuotes response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isNotEmpty( + quotes.items[0].transaction.to, + 'The to value of the transaction is empty in the getCrossChainQuotes response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isNotEmpty( + quotes.items[0].transaction.value, + 'The value value of the transaction is empty in the getCrossChainQuotes response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.strictEqual( + quotes.items[0].transaction.from, + data.sender, + 'The from value of the transaction is not correct in the getCrossChainQuotes response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isNumber( + quotes.items[0].transaction.chainId, + 'The chainId value of the transaction is not number in the getCrossChainQuotes response.', + ); + } catch (e) { + console.error(e); + } + } else { + assert.fail( + 'The items are not available in the getCrossChainQuotes response.', + ); + } + } catch (e) { + assert.fail( + 'The quotes are not display in the getCrossChainQuotes response', + ); + } + } else { + console.warn( + 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE GETCROSSCHAINQUOTES RESPONSE ON THE xdai NETWORK', + ); + } + }); + + it('SMOKE: Validate the getAdvanceRoutesLiFi response with valid details on the xdai network', async () => { + if (runTest) { + let quoteRequestPayload; + let quotes; + try { + quoteRequestPayload = { + fromChainId: data.xdai_chainid, + toChainId: data.matic_chainid, + fromTokenAddress: data.tokenAddress_xdaiUSDC, + toTokenAddress: data.tokenAddress_maticUSDC, + fromAmount: utils.parseUnits(data.swap_value, 6), + }; + + quotes = await xdaiMainNetSdk.getAdvanceRoutesLiFi(quoteRequestPayload); + + if (quotes.items.length > 0) { + const quote = quotes.items[0]; // Selected the first route + await xdaiMainNetSdk.getStepTransaction({ + route: quote, + }); + + try { + assert.isNotEmpty( + quotes.items[0].id, + 'The id value of the first item is empty in the getAdvanceRoutesLiFi response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.strictEqual( + quotes.items[0].fromChainId, + data.xdai_chainid, + 'The fromChainId value of the first item is displayed correctly in the getAdvanceRoutesLiFi response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isNotEmpty( + quotes.items[0].fromAmountUSD, + 'The fromAmountUSD value of the first item is empty in the getAdvanceRoutesLiFi response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isNotEmpty( + quotes.items[0].fromAmount, + 'The fromAmount value of the first item is empty in the getAdvanceRoutesLiFi response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isNotEmpty( + quotes.items[0].fromToken, + 'The fromToken value of the first item is empty in the getAdvanceRoutesLiFi response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.strictEqual( + quotes.items[0].fromAddress, + data.sender, + 'The fromAddress value of the first item is displayed correctly in the getAdvanceRoutesLiFi response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.strictEqual( + quotes.items[0].toChainId, + data.matic_chainid, + 'The toChainId value of the first item is displayed correctly in the getAdvanceRoutesLiFi response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isNotEmpty( + quotes.items[0].toAmountUSD, + 'The toAmountUSD value of the first item is empty in the getAdvanceRoutesLiFi response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isNotEmpty( + quotes.items[0].toAmount, + 'The toAmount value of the first item is empty in the getAdvanceRoutesLiFi response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isNotEmpty( + quotes.items[0].toAmountMin, + 'The toAmountMin value of the first item is empty in the getAdvanceRoutesLiFi response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isNotEmpty( + quotes.items[0].toToken, + 'The toToken value of the first item is empty in the getAdvanceRoutesLiFi response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.strictEqual( + quotes.items[0].toAddress, + data.sender, + 'The toAddress value of the first item is displayed correctly in the getAdvanceRoutesLiFi response.', + ); + } catch (e) { + console.error(e); + } + + try { + assert.isNotEmpty( + quotes.items[0].gasCostUSD, + 'The gasCostUSD value of the first item is empty in the getAdvanceRoutesLiFi response.', + ); + } catch (e) { + console.error(e); + } + } else { + assert.fail('The quotes are not display in the quote list'); + } + } catch (e) { + assert.fail('The quotes are not display in the quote list'); + } + } else { + console.warn( + 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE GETADVANCEROUTESLIFI RESPONSE ON THE xdai NETWORK', + ); + } + }); + + it('REGRESSION: Validate the getCrossChainQuotes response without fromChainId detail on the xdai network', async () => { + if (runTest) { + let quoteRequestPayload; + try { + quoteRequestPayload = { + toChainId: data.matic_chainid, + fromTokenAddress: data.tokenAddress_xdaiUSDC, + toTokenAddress: data.tokenAddress_maticUSDC, + fromAddress: data.sender, + fromAmount: utils.parseUnits(data.swap_value, 6), + }; + + await xdaiMainNetSdk.getCrossChainQuotes(quoteRequestPayload); + + assert.fail( + 'The getCrossChainQuotes request allowed to perform without fromchainid detail', + ); + } catch (e) { + const errorResponse = JSON.parse(e.message); + if (errorResponse[0].property === 'fromChainId') { + console.log( + 'The correct validation is displayed when fromchainid detail not added in the getCrossChainQuotes request', + ); + } else { + assert.fail( + 'The respective validate is not displayed when fromchainid detail not added in the getCrossChainQuotes request', + ); + } + } + } else { + console.warn( + 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE GETCROSSCHAINQUOTES RESPONSE WITHOUT FROMCHAINID DETAIL ON THE xdai NETWORK', + ); + } + }); + + it('REGRESSION: Validate the getCrossChainQuotes response without toChainId detail on the xdai network', async () => { + if (runTest) { + let quoteRequestPayload; + try { + quoteRequestPayload = { + fromChainId: data.xdai_chainid, + fromTokenAddress: data.tokenAddress_xdaiUSDC, + toTokenAddress: data.tokenAddress_maticUSDC, + fromAddress: data.sender, + fromAmount: utils.parseUnits(data.swap_value, 6), + }; + + await xdaiMainNetSdk.getCrossChainQuotes(quoteRequestPayload); + + assert.fail( + 'The getCrossChainQuotes request allowed to perform without toChainId detail', + ); + } catch (e) { + const errorResponse = JSON.parse(e.message); + if (errorResponse[0].property === 'toChainId') { + console.log( + 'The correct validation is displayed when toChainId detail not added in the getCrossChainQuotes request', + ); + } else { + assert.fail( + 'The respective validate is not displayed when toChainId detail not added in the getCrossChainQuotes request', + ); + } + } + } else { + console.warn( + 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE GETCROSSCHAINQUOTES RESPONSE WITHOUT TOCHAINID DETAIL ON THE xdai NETWORK', + ); + } + }); + + it('REGRESSION: Validate the getCrossChainQuotes response with invalid fromTokenAddress detail on the xdai network', async () => { + if (runTest) { + let quoteRequestPayload; + try { + quoteRequestPayload = { + fromChainId: data.xdai_chainid, + toChainId: data.matic_chainid, + fromTokenAddress: data.invalidTokenAddress_xdaiUSDC, + toTokenAddress: data.tokenAddress_maticUSDC, + fromAddress: data.sender, + fromAmount: utils.parseUnits(data.swap_value, 6), + }; + + await xdaiMainNetSdk.getCrossChainQuotes(quoteRequestPayload); + + assert.fail( + 'The getCrossChainQuotes request allowed to perform with invalid fromTokenAddress detail', + ); + } catch (e) { + const errorResponse = JSON.parse(e.message); + if (errorResponse[0].property === 'fromTokenAddress') { + console.log( + 'The correct validation is displayed when invalid fromTokenAddress detail added in the getCrossChainQuotes request', + ); + } else { + assert.fail( + 'The respective validate is not displayed when invalid fromTokenAddress detail added in the getCrossChainQuotes request', + ); + } + } + } else { + console.warn( + 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE GETCROSSCHAINQUOTES RESPONSE WITH INVALID FROMTOKENADDRESS DETAIL ON THE xdai NETWORK', + ); + } + }); + + it('REGRESSION: Validate the getCrossChainQuotes response with incorrect fromTokenAddress detail on the xdai network', async () => { + if (runTest) { + let quoteRequestPayload; + try { + quoteRequestPayload = { + fromChainId: data.xdai_chainid, + toChainId: data.matic_chainid, + fromTokenAddress: data.incorrectTokenAddress_xdaiUSDC, + toTokenAddress: data.tokenAddress_maticUSDC, + fromAddress: data.sender, + fromAmount: utils.parseUnits(data.swap_value, 6), + }; + + await xdaiMainNetSdk.getCrossChainQuotes(quoteRequestPayload); + + assert.fail( + 'The getCrossChainQuotes request allowed to perform with incorrect fromTokenAddress detail', + ); + } catch (e) { + const errorResponse = JSON.parse(e.message); + if (errorResponse[0].property === 'fromTokenAddress') { + console.log( + 'The correct validation is displayed when incorrect fromTokenAddress detail added in the getCrossChainQuotes request', + ); + } else { + assert.fail( + 'The respective validate is not displayed when incorrect fromTokenAddress detail added in the getCrossChainQuotes request', + ); + } + } + } else { + console.warn( + 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE GETCROSSCHAINQUOTES RESPONSE WITH INCORRECT FROMTOKENADDRESS DETAIL ON THE xdai NETWORK', + ); + } + }); + + it('REGRESSION: Validate the getCrossChainQuotes response without fromTokenAddress detail on the xdai network', async () => { + if (runTest) { + let quoteRequestPayload; + try { + quoteRequestPayload = { + fromChainId: data.xdai_chainid, + toChainId: data.matic_chainid, + toTokenAddress: data.tokenAddress_maticUSDC, + fromAddress: data.sender, + fromAmount: utils.parseUnits(data.swap_value, 6), + }; + + await xdaiMainNetSdk.getCrossChainQuotes(quoteRequestPayload); + + assert.fail( + 'The getCrossChainQuotes request allowed to perform without fromTokenAddress detail', + ); + } catch (e) { + const errorResponse = JSON.parse(e.message); + if (errorResponse[0].property === 'fromTokenAddress') { + console.log( + 'The correct validation is displayed when fromTokenAddress detail not added in the getCrossChainQuotes request', + ); + } else { + assert.fail( + 'The respective validate is not displayed when fromTokenAddress detail not added in the getCrossChainQuotes request', + ); + } + } + } else { + console.warn( + 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE GETCROSSCHAINQUOTES RESPONSE WITHOUT FROMTOKENADDRESS DETAIL ON THE xdai NETWORK', + ); + } + }); + + it('REGRESSION: Validate the getCrossChainQuotes response with invalid toTokenAddress detail on the xdai network', async () => { + if (runTest) { + let quoteRequestPayload; + try { + quoteRequestPayload = { + fromChainId: data.xdai_chainid, + toChainId: data.matic_chainid, + fromTokenAddress: data.tokenAddress_xdaiUSDC, + toTokenAddress: data.invalidTokenAddress_maticUSDC, + fromAddress: data.sender, + fromAmount: utils.parseUnits(data.swap_value, 6), + }; + + await xdaiMainNetSdk.getCrossChainQuotes(quoteRequestPayload); + + assert.fail( + 'The getCrossChainQuotes request allowed to perform with invalid toTokenAddress detail', + ); + } catch (e) { + const errorResponse = JSON.parse(e.message); + if (errorResponse[0].property === 'toTokenAddress') { + console.log( + 'The correct validation is displayed when invalid toTokenAddress detail added in the getCrossChainQuotes request', + ); + } else { + assert.fail( + 'The respective validate is not displayed when invalid toTokenAddress detail added in the getCrossChainQuotes request', + ); + } + } + } else { + console.warn( + 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE GETCROSSCHAINQUOTES RESPONSE WITH INVALID TOTOKENADDRESS DETAIL ON THE xdai NETWORK', + ); + } + }); + + it('REGRESSION: Validate the getCrossChainQuotes response with incorrect toTokenAddress detail on the xdai network', async () => { + if (runTest) { + let quoteRequestPayload; + try { + quoteRequestPayload = { + fromChainId: data.xdai_chainid, + toChainId: data.matic_chainid, + fromTokenAddress: data.tokenAddress_xdaiUSDC, + toTokenAddress: data.incorrectTokenAddress_maticUSDC, + fromAddress: data.sender, + fromAmount: utils.parseUnits(data.swap_value, 6), + }; + + await xdaiMainNetSdk.getCrossChainQuotes(quoteRequestPayload); + + assert.fail( + 'The getCrossChainQuotes request allowed to perform with incorrect toTokenAddress detail', + ); + } catch (e) { + const errorResponse = JSON.parse(e.message); + if (errorResponse[0].property === 'toTokenAddress') { + console.log( + 'The correct validation is displayed when incorrect toTokenAddress detail added in the getCrossChainQuotes request', + ); + } else { + assert.fail( + 'The respective validate is not displayed when incorrect toTokenAddress detail added in the getCrossChainQuotes request', + ); + } + } + } else { + console.warn( + 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE GETCROSSCHAINQUOTES RESPONSE WITH INCORRECT TOTOKENADDRESS DETAIL ON THE xdai NETWORK', + ); + } + }); + + it('REGRESSION: Validate the getCrossChainQuotes response without toTokenAddress detail on the xdai network', async () => { + if (runTest) { + let quoteRequestPayload; + try { + quoteRequestPayload = { + fromChainId: data.xdai_chainid, + toChainId: data.matic_chainid, + fromTokenAddress: data.tokenAddress_xdaiUSDC, + fromAddress: data.sender, + fromAmount: utils.parseUnits(data.swap_value, 6), + }; + + await xdaiMainNetSdk.getCrossChainQuotes(quoteRequestPayload); + + assert.fail( + 'The getCrossChainQuotes request allowed to perform without toTokenAddress detail', + ); + } catch (e) { + const errorResponse = JSON.parse(e.message); + if (errorResponse[0].property === 'toTokenAddress') { + console.log( + 'The correct validation is displayed when toTokenAddress detail not added in the getCrossChainQuotes request', + ); + } else { + assert.fail( + 'The respective validate is not displayed when toTokenAddress detail not added in the getCrossChainQuotes request', + ); + } + } + } else { + console.warn( + 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE GETCROSSCHAINQUOTES RESPONSE WITHOUT TOTOKENADDRESS DETAIL ON THE xdai NETWORK', + ); + } + }); + + it('REGRESSION: Validate the getCrossChainQuotes response with invalid fromAddress detail on the xdai network', async () => { + if (runTest) { + let quoteRequestPayload; + try { + quoteRequestPayload = { + fromChainId: data.xdai_chainid, + toChainId: data.matic_chainid, + fromTokenAddress: data.tokenAddress_xdaiUSDC, + toTokenAddress: data.tokenAddress_maticUSDC, + fromAddress: data.invalidSender, + fromAmount: utils.parseUnits(data.swap_value, 6), + }; + + await xdaiMainNetSdk.getCrossChainQuotes(quoteRequestPayload); + + assert.fail( + 'The getCrossChainQuotes request allowed to perform with invalid fromAddress detail', + ); + } catch (e) { + const errorResponse = JSON.parse(e.message); + if (errorResponse[0].property === 'fromAddress') { + console.log( + 'The correct validation is displayed when invalid fromAddress detail added in the getCrossChainQuotes request', + ); + } else { + assert.fail( + 'The respective validate is not displayed when invalid fromAddress detail added in the getCrossChainQuotes request', + ); + } + } + } else { + console.warn( + 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE GETCROSSCHAINQUOTES RESPONSE WITH INVALID FROMADDRESS DETAIL ON THE xdai NETWORK', + ); + } + }); + + it('REGRESSION: Validate the getCrossChainQuotes response with incorrect fromAddress detail on the xdai network', async () => { + if (runTest) { + let quoteRequestPayload; + try { + quoteRequestPayload = { + fromChainId: data.xdai_chainid, + toChainId: data.matic_chainid, + fromTokenAddress: data.tokenAddress_xdaiUSDC, + toTokenAddress: data.tokenAddress_maticUSDC, + fromAddress: data.incorrectSender, + fromAmount: utils.parseUnits(data.swap_value, 6), + }; + + await xdaiMainNetSdk.getCrossChainQuotes(quoteRequestPayload); + + assert.fail( + 'The getCrossChainQuotes request allowed to perform with incorrect fromAddress detail', + ); + } catch (e) { + const errorResponse = JSON.parse(e.message); + if (errorResponse[0].property === 'fromAddress') { + console.log( + 'The correct validation is displayed when incorrect fromAddress detail added in the getCrossChainQuotes request', + ); + } else { + assert.fail( + 'The respective validate is not displayed when incorrect fromAddress detail added in the getCrossChainQuotes request', + ); + } + } + } else { + console.warn( + 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE GETCROSSCHAINQUOTES RESPONSE WITH INCORRECT FROMADDRESS DETAIL ON THE xdai NETWORK', + ); + } + }); + + it('REGRESSION: Validate the getCrossChainQuotes response without fromAmount detail on the xdai network', async () => { + if (runTest) { + let quoteRequestPayload; + try { + quoteRequestPayload = { + fromChainId: data.xdai_chainid, + toChainId: data.matic_chainid, + fromTokenAddress: data.tokenAddress_xdaiUSDC, + toTokenAddress: data.tokenAddress_maticUSDC, + fromAddress: data.sender, + }; + + await xdaiMainNetSdk.getCrossChainQuotes(quoteRequestPayload); + + assert.fail( + 'The getCrossChainQuotes request allowed to perform without fromAmount detail', + ); + } catch (e) { + const errorResponse = JSON.parse(e.message); + if (errorResponse[0].property === 'fromAmount') { + console.log( + 'The correct validation is displayed when fromAmount not added in the getCrossChainQuotes request', + ); + } else { + assert.fail( + 'The respective validate is not displayed when fromAmount not added in the getCrossChainQuotes request', + ); + } + } + } else { + console.warn( + 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE GETCROSSCHAINQUOTES RESPONSE WITHOUT FROMADDRESS DETAIL ON THE xdai NETWORK', + ); + } + }); + + it('REGRESSION: Validate the getAdvanceRoutesLiFi response without fromChainId detail on the xdai network', async () => { + if (runTest) { + let quoteRequestPayload; + try { + quoteRequestPayload = { + toChainId: data.matic_chainid, + fromTokenAddress: data.tokenAddress_xdaiUSDC, + toTokenAddress: data.tokenAddress_maticUSDC, + fromAmount: utils.parseUnits(data.swap_value, 6), + }; + + await xdaiMainNetSdk.getAdvanceRoutesLiFi(quoteRequestPayload); + + assert.fail( + 'The getAdvanceRoutesLiFi request allowed to perform without fromchainid detail', + ); + } catch (e) { + const errorResponse = JSON.parse(e.message); + if (errorResponse[0].property === 'fromChainId') { + console.log( + 'The correct validation is displayed when fromchainid detail not added in the getAdvanceRoutesLiFi request', + ); + } else { + assert.fail( + 'The respective validate is not displayed when fromchainid detail not added in the getAdvanceRoutesLiFi request', + ); + } + } + } else { + console.warn( + 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE GETADVANCEROUTESLIFI RESPONSE WITHOUT FROMCHAINID DETAIL ON THE xdai NETWORK', + ); + } + }); + + it('REGRESSION: Validate the getAdvanceRoutesLiFi response without toChainId detail on the xdai network', async () => { + if (runTest) { + let quoteRequestPayload; + try { + quoteRequestPayload = { + fromChainId: data.xdai_chainid, + fromTokenAddress: data.tokenAddress_xdaiUSDC, + toTokenAddress: data.tokenAddress_maticUSDC, + fromAmount: utils.parseUnits(data.swap_value, 6), + }; + + await xdaiMainNetSdk.getAdvanceRoutesLiFi(quoteRequestPayload); + + assert.fail( + 'The getAdvanceRoutesLiFi request allowed to perform without toChainId detail', + ); + } catch (e) { + const errorResponse = JSON.parse(e.message); + if (errorResponse[0].property === 'toChainId') { + console.log( + 'The correct validation is displayed when toChainId detail not added in the getAdvanceRoutesLiFi request', + ); + } else { + assert.fail( + 'The respective validate is not displayed when toChainId detail not added in the getAdvanceRoutesLiFi request', + ); + } + } + } else { + console.warn( + 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE GETADVANCEROUTESLIFI RESPONSE WITHOUT TOCHAINID DETAIL ON THE xdai NETWORK', + ); + } + }); + + it('REGRESSION: Validate the getAdvanceRoutesLiFi response with invalid fromTokenAddress detail on the xdai network', async () => { + if (runTest) { + let quoteRequestPayload; + try { + quoteRequestPayload = { + fromChainId: data.xdai_chainid, + toChainId: data.matic_chainid, + fromTokenAddress: data.invalidTokenAddress_xdaiUSDC, + toTokenAddress: data.tokenAddress_maticUSDC, + fromAmount: utils.parseUnits(data.swap_value, 6), + }; + + await xdaiMainNetSdk.getAdvanceRoutesLiFi(quoteRequestPayload); + + assert.fail( + 'The getAdvanceRoutesLiFi request allowed to perform with invalid fromTokenAddress detail', + ); + } catch (e) { + const errorResponse = JSON.parse(e.message); + if (errorResponse[0].property === 'fromTokenAddress') { + console.log( + 'The correct validation is displayed when invalid fromTokenAddress detail added in the getAdvanceRoutesLiFi request', + ); + } else { + assert.fail( + 'The respective validate is not displayed when invalid fromTokenAddress detail added in the getAdvanceRoutesLiFi request', + ); + } + } + } else { + console.warn( + 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE GETADVANCEROUTESLIFI RESPONSE WITH INVALID FROMTOKENADDRESS DETAIL ON THE xdai NETWORK', + ); + } + }); + + it('REGRESSION: Validate the getAdvanceRoutesLiFi response with incorrect fromTokenAddress detail on the xdai network', async () => { + if (runTest) { + let quoteRequestPayload; + try { + quoteRequestPayload = { + fromChainId: data.xdai_chainid, + toChainId: data.matic_chainid, + fromTokenAddress: data.incorrectTokenAddress_xdaiUSDC, + toTokenAddress: data.tokenAddress_maticUSDC, + fromAmount: utils.parseUnits(data.swap_value, 6), + }; + + await xdaiMainNetSdk.getAdvanceRoutesLiFi(quoteRequestPayload); + + assert.fail( + 'The getAdvanceRoutesLiFi request allowed to perform with incorrect fromTokenAddress detail', + ); + } catch (e) { + const errorResponse = JSON.parse(e.message); + if (errorResponse[0].property === 'fromTokenAddress') { + console.log( + 'The correct validation is displayed when incorrect fromTokenAddress detail added in the getAdvanceRoutesLiFi request', + ); + } else { + assert.fail( + 'The respective validate is not displayed when incorrect fromTokenAddress detail added in the getAdvanceRoutesLiFi request', + ); + } + } + } else { + console.warn( + 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE GETADVANCEROUTESLIFI RESPONSE WITH INCORRECT FROMTOKENADDRESS DETAIL ON THE xdai NETWORK', + ); + } + }); + + it('REGRESSION: Validate the getAdvanceRoutesLiFi response without fromTokenAddress detail on the xdai network', async () => { + if (runTest) { + let quoteRequestPayload; + try { + quoteRequestPayload = { + fromChainId: data.xdai_chainid, + toChainId: data.matic_chainid, + toTokenAddress: data.tokenAddress_maticUSDC, + fromAmount: utils.parseUnits(data.swap_value, 6), + }; + + await xdaiMainNetSdk.getAdvanceRoutesLiFi(quoteRequestPayload); + + assert.fail( + 'The getAdvanceRoutesLiFi request allowed to perform without fromTokenAddress detail', + ); + } catch (e) { + const errorResponse = JSON.parse(e.message); + if (errorResponse[0].property === 'fromTokenAddress') { + console.log( + 'The correct validation is displayed when fromTokenAddress detail not added in the getAdvanceRoutesLiFi request', + ); + } else { + assert.fail( + 'The respective validate is not displayed when fromTokenAddress detail not added in the getAdvanceRoutesLiFi request', + ); + } + } + } else { + console.warn( + 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE GETADVANCEROUTESLIFI RESPONSE WITHOUT FROMTOKENADDRESS DETAIL ON THE xdai NETWORK', + ); + } + }); + + it('REGRESSION: Validate the getAdvanceRoutesLiFi response with invalid toTokenAddress detail on the xdai network', async () => { + if (runTest) { + let quoteRequestPayload; + try { + quoteRequestPayload = { + fromChainId: data.xdai_chainid, + toChainId: data.matic_chainid, + fromTokenAddress: data.tokenAddress_xdaiUSDC, + toTokenAddress: data.invalidTokenAddress_maticUSDC, + fromAmount: utils.parseUnits(data.swap_value, 6), + }; + + await xdaiMainNetSdk.getAdvanceRoutesLiFi(quoteRequestPayload); + + assert.fail( + 'The getAdvanceRoutesLiFi request allowed to perform with invalid toTokenAddress detail', + ); + } catch (e) { + const errorResponse = JSON.parse(e.message); + if (errorResponse[0].property === 'toTokenAddress') { + console.log( + 'The correct validation is displayed when invalid toTokenAddress detail added in the getAdvanceRoutesLiFi request', + ); + } else { + assert.fail( + 'The respective validate is not displayed when invalid toTokenAddress detail added in the getAdvanceRoutesLiFi request', + ); + } + } + } else { + console.warn( + 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE GETADVANCEROUTESLIFI RESPONSE WITH INVALID TOTOKENADDRESS DETAIL ON THE xdai NETWORK', + ); + } + }); + + it('REGRESSION: Validate the getAdvanceRoutesLiFi response with incorrect toTokenAddress detail on the xdai network', async () => { + if (runTest) { + let quoteRequestPayload; + try { + quoteRequestPayload = { + fromChainId: data.xdai_chainid, + toChainId: data.matic_chainid, + fromTokenAddress: data.tokenAddress_xdaiUSDC, + toTokenAddress: data.incorrectTokenAddress_maticUSDC, + fromAmount: utils.parseUnits(data.swap_value, 6), + }; + + await xdaiMainNetSdk.getAdvanceRoutesLiFi(quoteRequestPayload); + + assert.fail( + 'The getAdvanceRoutesLiFi request allowed to perform with incorrect toTokenAddress detail', + ); + } catch (e) { + const errorResponse = JSON.parse(e.message); + if (errorResponse[0].property === 'toTokenAddress') { + console.log( + 'The correct validation is displayed when incorrect toTokenAddress detail added in the getAdvanceRoutesLiFi request', + ); + } else { + assert.fail( + 'The respective validate is not displayed when incorrect toTokenAddress detail added in the getAdvanceRoutesLiFi request', + ); + } + } + } else { + console.warn( + 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE GETADVANCEROUTESLIFI RESPONSE WITH INCORRECT TOTOKENADDRESS DETAIL ON THE xdai NETWORK', + ); + } + }); + + it('REGRESSION: Validate the getAdvanceRoutesLiFi response without toTokenAddress detail on the xdai network', async () => { + if (runTest) { + let quoteRequestPayload; + try { + quoteRequestPayload = { + fromChainId: data.xdai_chainid, + toChainId: data.matic_chainid, + fromTokenAddress: data.tokenAddress_xdaiUSDC, + fromAmount: utils.parseUnits(data.swap_value, 6), + }; + + await xdaiMainNetSdk.getAdvanceRoutesLiFi(quoteRequestPayload); + + assert.fail( + 'The getAdvanceRoutesLiFi request allowed to perform without toTokenAddress detail', + ); + } catch (e) { + const errorResponse = JSON.parse(e.message); + if (errorResponse[0].property === 'toTokenAddress') { + console.log( + 'The correct validation is displayed when toTokenAddress detail not added in the getAdvanceRoutesLiFi request', + ); + } else { + assert.fail( + 'The respective validate is not displayed when toTokenAddress detail not added in the getAdvanceRoutesLiFi request', + ); + } + } + } else { + console.warn( + 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE GETADVANCEROUTESLIFI RESPONSE WITHOUT TOTOKENADDRESS DETAIL ON THE xdai NETWORK', + ); + } + }); + + it('REGRESSION: Validate the getAdvanceRoutesLiFi response without fromAmount detail on the xdai network', async () => { + if (runTest) { + let quoteRequestPayload; + try { + quoteRequestPayload = { + fromChainId: data.xdai_chainid, + toChainId: data.matic_chainid, + fromTokenAddress: data.tokenAddress_xdaiUSDC, + toTokenAddress: data.tokenAddress_maticUSDC, + }; + + await xdaiMainNetSdk.getAdvanceRoutesLiFi(quoteRequestPayload); + + assert.fail( + 'The getAdvanceRoutesLiFi request allowed to perform without fromAmount detail', + ); + } catch (e) { + const errorResponse = JSON.parse(e.message); + if (errorResponse[0].property === 'fromAmount') { + console.log( + 'The correct validation is displayed when fromAmount not added in the getAdvanceRoutesLiFi request', + ); + } else { + assert.fail( + 'The respective validate is not displayed when fromAmount not added in the getAdvanceRoutesLiFi request', + ); + } + } + } else { + console.warn( + 'DUE TO INSUFFICIENT WALLET BALANCE, SKIPPING TEST CASE OF THE GETADVANCEROUTESLIFI RESPONSE WITHOUT FROMADDRESS DETAIL ON THE xdai NETWORK', + ); + } + }); +});