Skip to content

Commit

Permalink
test: added e2e test for EXTENDED and PRIVILEGED tier users (#3147)
Browse files Browse the repository at this point in the history
* test: added e2e test for privileged tier users

Signed-off-by: Logan Nguyen <[email protected]>

* fix: generalized test cases

Signed-off-by: Logan Nguyen <[email protected]>

* fix: renamed test suite

Signed-off-by: Logan Nguyen <[email protected]>

Co-authored-by: Victor Yanev <[email protected]>
Signed-off-by: Logan Nguyen <[email protected]>

* chore: renamed test suite

Signed-off-by: Logan Nguyen <[email protected]>

Co-authored-by: Victor Yanev <[email protected]>
Signed-off-by: Logan Nguyen <[email protected]>

* fix: fixed preconfigured plans test logic

Signed-off-by: Logan Nguyen <[email protected]>

* chore: added more evmAddresses to config file

Signed-off-by: Logan Nguyen <[email protected]>

* fix: moved confirming plan's validity logic to createAliasForNonBasicPlans()

Signed-off-by: Logan Nguyen <[email protected]>

* chore: renamed test case

Signed-off-by: Logan Nguyen <[email protected]>

Co-authored-by: Victor Yanev <[email protected]>
Signed-off-by: Logan Nguyen <[email protected]>

* chore: added tolerance var

Signed-off-by: Logan Nguyen <[email protected]>

Co-authored-by: Victor Yanev <[email protected]>
Signed-off-by: Logan Nguyen <[email protected]>

* chore: reused fileAppendChunkSize

Signed-off-by: Logan Nguyen <[email protected]>

* fix: added reusable test cases for both EXTENDED and PRIVILEGED tiers

Signed-off-by: Logan Nguyen <[email protected]>

* fix: override spending limit env vars in acceptancetest:hbarlimiter script, with lower HBAR limits, to improve test performance

Override spending limit environment variables in the `acceptancetest:hbarlimiter` script to set lower HBAR limits at boot time. The HbarLimiter test suite includes several tests that exhaust the total HBAR limit for multiple plans, and using high spending limits can generate unnecessary traffic on the local node and extend the test duration. Overriding with lower limit values improves performance and reduces test execution time.

Signed-off-by: Logan Nguyen <[email protected]>

* chore: added more information to HBAR Rate Limit warning log

Signed-off-by: Logan Nguyen <[email protected]>

* test: added checks to make sure tiered users can deploy a certain amount of large contracts

Signed-off-by: Logan Nguyen <[email protected]>

---------

Signed-off-by: Logan Nguyen <[email protected]>
Signed-off-by: Logan Nguyen <[email protected]>
Co-authored-by: Victor Yanev <[email protected]>
  • Loading branch information
quiet-node and victor-yanev authored Oct 25, 2024
1 parent 5ca6f63 commit 9afe7c2
Show file tree
Hide file tree
Showing 7 changed files with 220 additions and 21 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"acceptancetest:api_batch3": "nyc ts-mocha packages/server/tests/acceptance/index.spec.ts -g '@api-batch-3' --exit",
"acceptancetest:erc20": "nyc ts-mocha packages/server/tests/acceptance/index.spec.ts -g '@erc20' --exit",
"acceptancetest:ratelimiter": "nyc ts-mocha packages/ws-server/tests/acceptance/index.spec.ts -g '@web-socket-ratelimiter' --exit && ts-mocha packages/server/tests/acceptance/index.spec.ts -g '@ratelimiter' --exit",
"acceptancetest:hbarlimiter": "nyc ts-mocha packages/server/tests/acceptance/index.spec.ts -g '@hbarlimiter' --exit",
"acceptancetest:hbarlimiter": "HBAR_RATE_LIMIT_TINYBAR=5000000000 HBAR_RATE_LIMIT_BASIC=1000000000 HBAR_RATE_LIMIT_EXTENDED=1500000000 HBAR_RATE_LIMIT_PRIVILEGED=2000000000 nyc ts-mocha packages/server/tests/acceptance/index.spec.ts -g '@hbarlimiter' --exit",
"acceptancetest:tokencreate": "nyc ts-mocha packages/server/tests/acceptance/index.spec.ts -g '@tokencreate' --exit",
"acceptancetest:tokenmanagement": "nyc ts-mocha packages/server/tests/acceptance/index.spec.ts -g '@tokenmanagement' --exit",
"acceptancetest:htsprecompilev1": "nyc ts-mocha packages/server/tests/acceptance/index.spec.ts -g '@htsprecompilev1' --exit",
Expand Down
6 changes: 5 additions & 1 deletion packages/relay/src/lib/services/hbarLimitService/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,11 @@ export class HbarLimitService implements IHbarLimitService {
exceedsLimit ? 'has' : 'has NOT'
} exceeded HBAR rate limit threshold: user=${user}, amountSpent=${
spendingPlan.amountSpent
}, estimatedTxFee=${estimatedTxFee}, spendingLimit=${spendingLimit}, txConstructorName=${txConstructorName}, mode=${mode}, methodName=${methodName}`,
}, estimatedTxFee=${estimatedTxFee}, spendingLimit=${spendingLimit}, spandingPlanId=${
spendingPlan.id
}, subscriptionTier=${
spendingPlan.subscriptionTier
}, txConstructorName=${txConstructorName}, mode=${mode}, methodName=${methodName}`,
);

return exceedsLimit;
Expand Down
198 changes: 179 additions & 19 deletions packages/server/tests/acceptance/hbarLimiter.spec.ts

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions packages/server/tests/localAcceptance.env
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@ WRITE_SNAPSHOT_ON_MEMORY_LEAK=false
HBAR_RATE_LIMIT_TINYBAR=5000000000# 50 HBARs
HBAR_RATE_LIMIT_DURATION=80000# 80 seconds
HBAR_RATE_LIMIT_BASIC=4000000000# 40 HBARs
HBAR_SPENDING_PLANS_CONFIG_FILE=./packages/server/tests/testSpendingPlansConfig.json
1 change: 1 addition & 0 deletions packages/server/tests/previewnetAcceptance.env
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ TEST_INITIAL_ACCOUNT_STARTING_BALANCE=500
HBAR_RATE_LIMIT_TINYBAR=5000000000# 50 HBARs
HBAR_RATE_LIMIT_DURATION=80000# 80 seconds
HBAR_RATE_LIMIT_BASIC=4000000000# 40 HBARs

32 changes: 32 additions & 0 deletions packages/server/tests/testSpendingPlansConfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
[
{
"id": "c758c095-342c-4607-9db5-867d7e90ab9d",
"name": "PRIVILEGED_ALPHA",
"ethAddresses": ["0x7d102fe71af42790fe31b126c1f49766376ca2b5"],
"ipAddresses": ["127.0.0.1"],
"subscriptionTier": "PRIVILEGED"
},
{
"id": "a68488b0-6f7d-44a0-87c1-774ad64615f2",
"name": "PRIVILEGED_BETA",
"ethAddresses": ["0x40183ec818c1826114767391989ff2eaebc2b91e", "0xcdad5844f865f379bea057fb435aefef38361b68"],
"subscriptionTier": "PRIVILEGED"
},
{
"id": "af13d6ed-d676-4d33-8b9d-cf05d1ad7134",
"name": "EXTENDED_ALPHA",
"ethAddresses": [
"0x149294f355f62827748988071de70ab195d0eb23",
"0x17b2b8c63fa35402088640e426c6709a254c7ffb",
"0x6e5d3858f53fc66727188690946631bde0466b1a"
],
"ipAddresses": ["127.0.0.2"],
"subscriptionTier": "EXTENDED"
},
{
"id": "7f665aa3-6b73-41d7-bf9b-92d04cdab96b",
"name": "EXTENDED_BETA",
"ipAddresses": ["127.0.0.3"],
"subscriptionTier": "EXTENDED"
}
]
1 change: 1 addition & 0 deletions packages/server/tests/testnetAcceptance.env
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ TEST_INITIAL_ACCOUNT_STARTING_BALANCE=500
HBAR_RATE_LIMIT_TINYBAR=5000000000# 50 HBARs
HBAR_RATE_LIMIT_DURATION=80000# 80 seconds
HBAR_RATE_LIMIT_BASIC=4000000000# 40 HBARs

0 comments on commit 9afe7c2

Please sign in to comment.