Skip to content

Commit 7efd90c

Browse files
authored
Organize testing & benchmarking and add default setup (#113)
* Replace benchmarking * Add defaults to benchmark script
1 parent 1d0e046 commit 7efd90c

20 files changed

+433
-425
lines changed

.env.benchmark.example

Lines changed: 45 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,46 @@
1-
THIRDWEB_SDK_SECRET_KEY=
1+
# ============================================================================= #
2+
# This file let's you configure what gets tested by the benchmarking script.
3+
# At minimum, you just need to configure a chain where you have a funded admin
4+
# wallet in order to send transactions.
5+
#
6+
# In addition, there are other optional configuration variables that let you
7+
# customize exactly which endpoints you hit with which payloads.
8+
#
9+
# If optional configuration is left blank, the benchmark script will initially
10+
# deploy a new contract for you to test with.
11+
# ============================================================================= #
212

3-
# benchmark vars
4-
NODE_ENV=benchmark
5-
BENCHMARK_HOST='http://127.0.0.1:3005'
6-
BENCHMARK_URL_PATH='/contract/polygon/0x01De66609582B874FA34ab288859ACC4592aec04/write'
7-
BENCHMARK_POST_BODY='{
8-
"function_name": "mintTo",
9-
"args": ["0xCF3D06a19263976A540CFf8e7Be7b026801C52A6", "0","", "1"]
10-
}'
11-
# Total request has to be more than the total concurrency
12-
BENCHMARK_CONCURRENCY=2
13-
BENCHMARK_REQUESTS=2
14-
SAMPLE_EDITION_CONTRACT_INFO='{
15-
"contractMetadata": {
16-
"name": "TW WEB3API",
17-
"description": "thirdweb web3API sample collection for testing",
18-
"image": "ipfs://QmYxT4LnK8sqLupjbS6eRvu1si7Ly2wFQAqFebxhWntcf6",
19-
"external_link": "",
20-
"app_uri": "",
21-
"seller_fee_basis_points": 0,
22-
"fee_recipient": "0xCF3D06a19263976A540CFf8e7Be7b026801C52A6",
23-
"symbol": "TWT",
24-
"platform_fee_basis_points": 0,
25-
"platform_fee_recipient": "0xCF3D06a19263976A540CFf8e7Be7b026801C52A6",
26-
"primary_sale_recipient": "0xCF3D06a19263976A540CFf8e7Be7b026801C52A6",
27-
"trusted_forwarders": []
28-
}
29-
}'
13+
THIRDWEB_API_SECRET_KEY = ""
14+
15+
# At minimum, you need to configure a chain
16+
# ============================================================================= #
17+
BENCHMARK_CHAIN = "mumbai"
18+
19+
# Then you can configure the contract address and function to call
20+
# NOTE: If you don't configure a contract address and function call, an ERC20
21+
# contract will be deployed by default for testing.
22+
23+
# BENCHMARK_CONTRACT_ADDRESS = "0x365b83D67D5539C6583b9c0266A548926Bf216F4"
24+
# BENCHMARK_FUNCTION_NAME = "mintTo"
25+
# BENCHMARK_FUNCTION_ARGS = '["0x43CAe0d7fe86C713530E679Ce02574743b2Ee9FC", "1000000000"]'
26+
# ============================================================================= #
27+
28+
# Alternatively, you can directly configure the url to hit and the payload body
29+
# ============================================================================= #
30+
# BENCHMARK_PATH = "/contract/mumbai/0x365b83D67D5539C6583b9c0266A548926Bf216F4/write"
31+
# BENCHMARK_BODY = '{
32+
# "function_name": "mintTo",
33+
# "args": ["0x43CAe0d7fe86C713530E679Ce02574743b2Ee9FC", "1000000000"]
34+
# }'
35+
# ============================================================================= #
36+
37+
# And you also need to configure how many requests to make at what concurrency
38+
# ============================================================================= #
39+
BENCHMARK_REQUESTS = 100
40+
BENCHMARK_CONCURRENCY = 10
41+
# ============================================================================= #
42+
43+
# You can also configure a different api url to benchmark against
44+
# ============================================================================= #
45+
# BENCHMARK_HOST = "http://localhost:3005"
46+
# ============================================================================= #

.mocharc.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"require": ["./e2e/setup-init.ts", "./worker/index.ts"],
3-
"spec": "e2e/**/*.test.ts",
2+
"require": ["./test/e2e/setup-init.ts", "./worker/index.ts"],
3+
"spec": "test/e2e/**/*.test.ts",
44
"extension": ["ts"],
55
"node-option": [
66
"experimental-specifier-resolution=node",

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export THIRDWEB_SDK_SECRET_KEY=klRsqmatrdlEpik_pHKgYy_q2YzGe3bTewO1VC26eY_H184Kc
1414

1515
test-evm: FORCE
1616
docker compose -f docker-compose-test.yml up -d
17-
./scripts/waitForHardhatNode.sh
17+
./test/e2e/hardhat/waitForHardhatNode.sh
1818
yarn test:all
1919
docker compose -f docker-compose-test.yml down
2020

docker-compose-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ services:
2020
ports:
2121
- 8545:8545
2222
volumes:
23-
- ./e2e/hardhat.config.js:/hardhat/hardhat.config.js
23+
- ./test/e2e/hardhat/hardhat.config.js:/hardhat/hardhat.config.js

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"lint:fix": "eslint --fix 'server/**/*.ts'",
2525
"test": "make test-evm",
2626
"test:all": "mocha --exit",
27-
"benchmark": "ts-node ./scripts/benchmark/index.ts"
27+
"benchmark": "ts-node ./test/benchmark/index.ts"
2828
},
2929
"dependencies": {
3030
"@aws-sdk/client-kms": "^3.398.0",

scripts/benchmark/benchmark.sh

Lines changed: 0 additions & 15 deletions
This file was deleted.

0 commit comments

Comments
 (0)