Skip to content

Commit 6156140

Browse files
committed
fix(init): update ledger minimum balance constants and validation checks
1 parent 9c80c97 commit 6156140

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

e2e/artillery/src/init.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,13 @@ const _network = process.env['NETWORK'];
1515

1616
// CONFIGURATIONS
1717
const REJECT_BALANCE_THRESHOLD = 0;
18-
const LEDGER_MINIMUM_BALANCE = 10000;
18+
const MASTER_LEDGER_MINIMUM_BALANCE = 10_000;
19+
const PKP_LEDGER_MINIMUM_BALANCE = 10_000;
1920

20-
if (Number.isNaN(LEDGER_MINIMUM_BALANCE) || LEDGER_MINIMUM_BALANCE < 0) {
21-
throw new Error('❌ LEDGER_MINIMUM_BALANCE must be a non-negative number');
21+
if (MASTER_LEDGER_MINIMUM_BALANCE < 0 || PKP_LEDGER_MINIMUM_BALANCE < 0) {
22+
throw new Error(
23+
'❌ Ledger minimum balances must be non-negative numbers'
24+
);
2225
}
2326

2427
const ensureLedgerBalance = async ({
@@ -91,7 +94,7 @@ const ensureLedgerBalance = async ({
9194
masterAccountDetails.paymentManager.getBalance({
9295
userAddress: masterAccount.address,
9396
}),
94-
minimumBalance: LEDGER_MINIMUM_BALANCE,
97+
minimumBalance: MASTER_LEDGER_MINIMUM_BALANCE,
9598
topUp: async (difference) => {
9699
await masterAccountDetails.paymentManager.deposit({
97100
amountInEth: difference.toString(),
@@ -172,7 +175,7 @@ const ensureLedgerBalance = async ({
172175
masterAccountDetails.paymentManager.getBalance({
173176
userAddress: pkpEthAddress,
174177
}),
175-
minimumBalance: LEDGER_MINIMUM_BALANCE,
178+
minimumBalance: PKP_LEDGER_MINIMUM_BALANCE,
176179
topUp: async (difference) => {
177180
await masterAccountDetails.paymentManager.depositForUser({
178181
userAddress: pkpEthAddress,

0 commit comments

Comments
 (0)