-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added new test cases for xdai network and added api test cases
- Loading branch information
1 parent
f52ecd7
commit 55732ee
Showing
19 changed files
with
7,689 additions
and
1,351 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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'); | ||
}); | ||
}); |
Oops, something went wrong.