diff --git a/test/specs/mainnet-api/skandha/mumbai.spec.js b/test/specs/mainnet-api/skandha/mumbai.spec.js index 6a9e7b4..1045982 100644 --- a/test/specs/mainnet-api/skandha/mumbai.spec.js +++ b/test/specs/mainnet-api/skandha/mumbai.spec.js @@ -1,13 +1,8 @@ -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 () => { @@ -285,217 +280,4 @@ describe('Performance testing of Skandha Endpoints with Mumbai Network', () => { assert.fail('Getting an error'); } }); - - it('SMOKE: Perform the transfer native token with valid details on the Mumbai network', async () => { - const startTime = performance.now(); - - // 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: [ - { - jsonrpc: '2.0', - id: 1, - method: 'eth_sendUserOperation', - params: [ - { - sender, // address - nonce, // uint256 - initCode, // bytes - callData, // bytes - callGasLimit, // uint256 - verificationGasLimit, // uint256 - preVerificationGas, // uint256 - maxFeePerGas, // uint256 - maxPriorityFeePerGas, // uint256 - paymasterAndData, // bytes - signature, // bytes - }, - entryPoint, // address - ], - }, - ], - 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 6e3834e..071dac7 100644 --- a/test/specs/mainnet/01_TransferringFunds/Arbitrum.spec.js +++ b/test/specs/mainnet/01_TransferringFunds/Arbitrum.spec.js @@ -2049,7 +2049,7 @@ describe('The PrimeSDK, when transfer a token with arbitrum network on the MainN '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') { + if (e.message === 'cannot sign empty transaction') { console.log( 'The validation for transaction batch is displayed as expected while adding the estimate transactions to the batch.', ); @@ -3662,7 +3662,7 @@ describe('The PrimeSDK, when transfer a token with arbitrum network on the MainN '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') { + if (e.message === 'cannot sign empty transaction') { console.log( 'The validation for transaction batch is displayed as expected while adding the estimate transactions to the batch.', ); @@ -4049,7 +4049,7 @@ describe('The PrimeSDK, when transfer a token with arbitrum network on the MainN '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') { + if (e.message === 'cannot sign empty transaction') { console.log( 'The validation for transaction batch is displayed as expected while adding the estimate transactions to the batch.', ); diff --git a/test/specs/mainnet/01_TransferringFunds/Matic.spec.js b/test/specs/mainnet/01_TransferringFunds/Matic.spec.js index 415ef95..0f5be4d 100644 --- a/test/specs/mainnet/01_TransferringFunds/Matic.spec.js +++ b/test/specs/mainnet/01_TransferringFunds/Matic.spec.js @@ -2017,7 +2017,7 @@ describe('The PrimeSDK, when transfer a token with matic network on the MainNet' } }); - 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 function () { + it.only('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 function () { var test = this; if (runTest) { await customRetryAsync(async function () { @@ -2049,7 +2049,7 @@ describe('The PrimeSDK, when transfer a token with matic network on the MainNet' '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') { + if (e.message === 'cannot sign empty transaction') { console.log( 'The validation for transaction batch is displayed as expected while adding the estimate transactions to the batch.', ); @@ -3584,7 +3584,7 @@ describe('The PrimeSDK, when transfer a token with matic network on the MainNet' } }); - 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 function () { + it.only('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 function () { var test = this; if (runTest) { await customRetryAsync(async function () { @@ -3662,7 +3662,7 @@ describe('The PrimeSDK, when transfer a token with matic network on the MainNet' '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') { + if (e.message === 'cannot sign empty transaction') { console.log( 'The validation for transaction batch is displayed as expected while adding the estimate transactions to the batch.', ); @@ -4000,7 +4000,7 @@ describe('The PrimeSDK, when transfer a token with matic network on the MainNet' } }); - 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 function () { + it.only('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 function () { var test = this; if (runTest) { await customRetryAsync(async function () { @@ -4049,7 +4049,7 @@ describe('The PrimeSDK, when transfer a token with matic network on the MainNet' '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') { + if (e.message === 'cannot sign empty transaction') { console.log( 'The validation for transaction batch is displayed as expected while adding the estimate transactions to the batch.', ); diff --git a/test/specs/mainnet/01_TransferringFunds/Optimism.spec.js b/test/specs/mainnet/01_TransferringFunds/Optimism.spec.js index 310b812..afa0322 100644 --- a/test/specs/mainnet/01_TransferringFunds/Optimism.spec.js +++ b/test/specs/mainnet/01_TransferringFunds/Optimism.spec.js @@ -2185,7 +2185,7 @@ describe('The PrimeSDK, when transfer a token with optimism network on the MainN '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') { + if (e.message === 'cannot sign empty transaction') { console.log( 'The validation for transaction batch is displayed as expected while adding the estimate transactions to the batch.', ); @@ -4076,7 +4076,7 @@ describe('The PrimeSDK, when transfer a token with optimism network on the MainN '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') { + if (e.message === 'cannot sign empty transaction') { console.log( 'The validation for transaction batch is displayed as expected while adding the estimate transactions to the batch.', ); @@ -4908,7 +4908,7 @@ describe('The PrimeSDK, when transfer a token with optimism network on the MainN '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') { + if (e.message === 'cannot sign empty transaction') { console.log( 'The validation for transaction batch is displayed as expected while adding the estimate transactions to the batch.', ); diff --git a/test/specs/mainnet/01_TransferringFunds/Xdai.spec.js b/test/specs/mainnet/01_TransferringFunds/Xdai.spec.js index 80d6283..85fb969 100644 --- a/test/specs/mainnet/01_TransferringFunds/Xdai.spec.js +++ b/test/specs/mainnet/01_TransferringFunds/Xdai.spec.js @@ -2017,7 +2017,7 @@ describe('The PrimeSDK, when transfer a token with xdai network on the MainNet', } }); - 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 function () { + it.only('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 function () { var test = this; if (runTest) { await customRetryAsync(async function () { @@ -2049,8 +2049,7 @@ describe('The PrimeSDK, when transfer a token with xdai network on the MainNet', 'The expected validation is not displayed when not added the transaction to the batch while adding the estimate transactions to the batch.', ); } catch (e) { - console.log('error::::::::', e); - if (e.message === 'cannot sign empty transaction batch') { + if (e.message === 'cannot sign empty transaction') { console.log( 'The validation for transaction batch is displayed as expected while adding the estimate transactions to the batch.', ); @@ -3585,7 +3584,7 @@ describe('The PrimeSDK, when transfer a token with xdai network on the MainNet', } }); - 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 function () { + it.only('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 function () { var test = this; if (runTest) { await customRetryAsync(async function () { @@ -3663,7 +3662,7 @@ describe('The PrimeSDK, when transfer a token with xdai network on the MainNet', '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') { + if (e.message === 'cannot sign empty transaction') { console.log( 'The validation for transaction batch is displayed as expected while adding the estimate transactions to the batch.', ); @@ -4001,7 +4000,7 @@ describe('The PrimeSDK, when transfer a token with xdai network on the MainNet', } }); - 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 function () { + it.only('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 function () { var test = this; if (runTest) { await customRetryAsync(async function () { @@ -4050,7 +4049,7 @@ describe('The PrimeSDK, when transfer a token with xdai network on the MainNet', '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') { + if (e.message === 'cannot sign empty transaction') { console.log( 'The validation for transaction batch is displayed as expected while adding the estimate transactions to the batch.', );