Skip to content

Commit

Permalink
test: implement smoke & e2e tests
Browse files Browse the repository at this point in the history
Smoke tests atm just check the health of a target bundler instance, e2e tests actually require a
private key and funds to perform the full user opration flow. Refer to the docstrings and .env to
see how to use them
  • Loading branch information
TheDivic committed Dec 5, 2024
1 parent 062ce48 commit 321990d
Show file tree
Hide file tree
Showing 6 changed files with 512 additions and 65 deletions.
40 changes: 26 additions & 14 deletions .env-example
Original file line number Diff line number Diff line change
@@ -1,16 +1,28 @@
# - Core bundler environment variables -

BUNDLER_CONFIG_PASSPHRASE=
BUNDLER_NODE_PATH_INDEX=0
BUNDLER_CHAIN_ID=80001
BUNDLER_MIN_RELAYER_COUNT=5
BUNDLER_MAX_RELAYER_COUNT=10
BUNDLER_FUNDING_BALANCE_THRESHOLD=0.1
BUNDLER_FUNDING_RELAYER_AMOUNT=0.2
BUNDLER_SLACK_JSON='{"token": "","channel": ""}'
BUNDLER_PROVIDER_JSON='{"137": "", "42161": "", "56": "", "10": "", "43114": "", "8453": "", "80001": ""}'
BUNDLER_DATASOURCES_JSON= '{"mongoUrl": "", "redisUrl": ""}'
BUNDLER_QUEUE_URL=""
BUNDLER_IS_TRUSTWALLET_SETUP=true
BUNDLER_FALLBACK_PROVIDER_JSON='{"137": ["", ""], "42161": ["", ""], "56": ["", ""], "10": ["", ""], "43114": ["", ""], "8453": ["", ""], "80001": ["", ""]}'
NODE_PATH_INDEX=0
# 🔥 make sure this is never development when deploying to production 🔥
NODE_ENV=development

# - Smoke tests environment variables -

# You can set the folloowing to a production deployment if you want to run smoke tests against the production environment
SMOKE_TEST_BUNDLER_HOSTNAME=https://bundler.biconomy.io

# - E2E tests environment variables -

# Following are the environment variables required for e2e tests, see the docstrings inside src/test/e2e/nativeTransfer.test.ts for more information
# Set this to the private key of the EOA account that will be used to derive the smart account
PRIVATE_KEY=

# Set this to https://bundler.biconomy.io if you want to test against the production environment
BUNDLER_HOSTNAME=http://localhost:3000

// make sure this is never development when deploying to production, and delete this line
NODE_ENV=
# You don't have to set all of the paymasters, just the ones you want to test e2e
BASE_MAINNET_PAYMASTER_URL=
AVALANCHE_MAINNET_PAYMASTER_URL=
OPTIMISM_MAINNET_PAYMASTER_URL=
POLYGON_MAINNET_PAYMASTER_URL=
BSC_MAINNET_PAYMASTER_URL=
ARBITRUM_MAINNET_PAYMASTER_URL=
44 changes: 3 additions & 41 deletions config/test.json
Original file line number Diff line number Diff line change
@@ -1,50 +1,12 @@
{
"supportedNetworks": [1],
"config": {
"validate": false
},
"relayer": {
"nodePathIndex": 0
},
"dataSources": {
"redisUrl": "test"
},
"clearStaleMessages": {
"supportedNetworks": [1],
"ttlSeconds": 1
},
"chains": {
"providers": {
"1": [
{
"url": "https://thislinkdoesnotexist.rs",
"type": "private"
}
],
"10": [
{
"url": "https://thislinkdoesnotexist.rs",
"type": "private"
}
],
"137": [
{
"url": "https://thislinkdoesnotexist.rs",
"type": "private"
}
],
"11155111": [
{
"url": "https://thislinkdoesnotexist.rs",
"type": "private"
},
{
"url": "https://thislinkdoesnotexist.rs",
"type": "mev-protected"
}
]
}
},
"EVMNetworkService": {
"waitForTransaction": {
"timeoutMs": 2000
}
}
}
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
"build": "tsc -p .",
"start": "node --max_old_space_size=6000 dist/server/index.js",
"start:production": "NODE_ENV=production node --max_old_space_size=6000 dist/server/index.js",
"test": "jest --testPathIgnorePatterns smoke --setupFiles dotenv/config --verbose"
"test": "jest --testPathIgnorePatterns='/smoke|e2e/' --setupFiles dotenv/config --verbose",
"test:smoke": "jest -t smoke --setupFiles dotenv/config --verbose",
"test:e2e": "jest --testPathIgnorePatterns='smoke' -t e2e --setupFiles dotenv/config --verbose"
},
"dependencies": {
"@arbitrum/sdk": "^3.1.3",
Expand Down Expand Up @@ -60,6 +62,7 @@
"viem": "^2.21.28"
},
"devDependencies": {
"@biconomy/account": "^4.5.7",
"@eslint/js": "^9.13.0",
"@types/amqplib": "^0.8.2",
"@types/big.js": "^6.1.5",
Expand Down
Loading

0 comments on commit 321990d

Please sign in to comment.