From 0b5239420749fa5a8d9618151ddef92fcfe7a33d Mon Sep 17 00:00:00 2001 From: vanjatomic Date: Fri, 21 Mar 2025 09:54:02 +0000 Subject: [PATCH 1/2] Add tests for increased limit per account --- src/account-faucet.js | 1 + .../transactions/post-transaction.test.js | 57 ++++++++++++++++++- 2 files changed, 57 insertions(+), 1 deletion(-) diff --git a/src/account-faucet.js b/src/account-faucet.js index 8526514..23d44d5 100644 --- a/src/account-faucet.js +++ b/src/account-faucet.js @@ -12,6 +12,7 @@ export const fundingAmounts = { noVetMassiveVtho: { vet: '0x0', vtho: 10000e18 }, noVetSmallVtho: { vet: '0x0', vtho: 5e18 }, noVetTinyVtho: { vet: '0x0', vtho: '0x1' }, + bihVetBigVtho: { vet: '0x9', vtho: 1000e18 }, } export const randomFunder = () => { diff --git a/test/thorest-api/transactions/post-transaction.test.js b/test/thorest-api/transactions/post-transaction.test.js index 60e3e4c..28b4eef 100644 --- a/test/thorest-api/transactions/post-transaction.test.js +++ b/test/thorest-api/transactions/post-transaction.test.js @@ -1,7 +1,8 @@ import { Hex, Transaction } from '@vechain/sdk-core' import { ThorWallet, generateAddress } from '../../../src/wallet' -import { revertedPostTx } from './setup/asserts' +import { revertedPostTx, successfulPostTx } from './setup/asserts' import { TransactionDataDrivenFlow } from './setup/transaction-data-driven-flow' +import { fundingAmounts } from '../../../src/account-faucet' /** * @group api @@ -19,6 +20,60 @@ describe('POST /transactions', function () { ).toBeFalsy() }) + it.e2eTest('should hit account limit', 'all', async () => { + const testWallet = await ThorWallet.newFunded(fundingAmounts.bihVetBigVtho) + + for (let i = 0; i < 128; i++) { + const receivingAddr = await generateAddress() + const clauses = [ + { + value: 1, + data: '0x', + to: receivingAddr, + }, + ] + + const txBody = await testWallet.buildTransaction(clauses) + const tx = new Transaction(txBody) + const signedTx = await testWallet.signTransaction(tx) + + const testPlan = { + postTxStep: { + rawTx: Hex.of(signedTx.encoded).toString(), + expectedResult: (data) => + successfulPostTx(data), + }, + } + + const ddt = new TransactionDataDrivenFlow(testPlan) + await ddt.runTestFlow() + } + const receivingAddr = await generateAddress() + const clauses = [ + { + value: 1, + data: '0x', + to: receivingAddr, + }, + ] + + const txBody = await testWallet.buildTransaction(clauses) + const tx = new Transaction(txBody) + const signedTx = await testWallet.signTransaction(tx) + + const testPlan = { + postTxStep: { + rawTx: Hex.of(signedTx.encoded).toString(), + expectedResult: (data) => + revertedPostTx({ success: data.success, body: data.body, httpCode: 400, httpMessage: data.httpMessage}, + "tx rejected: account quota exceeded"), + }, + } + + const ddt = new TransactionDataDrivenFlow(testPlan) + await ddt.runTestFlow() + }) + it.e2eTest( 'transaction should fail, wrong chain id', 'all', From b047396d623f57a37f24444bf8839b68c5fd2ed3 Mon Sep 17 00:00:00 2001 From: vanjatomic Date: Fri, 21 Mar 2025 10:07:17 +0000 Subject: [PATCH 2/2] Fix typo --- src/account-faucet.js | 2 +- .../transactions/post-transaction.test.js | 18 +++++++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/account-faucet.js b/src/account-faucet.js index 23d44d5..35899bf 100644 --- a/src/account-faucet.js +++ b/src/account-faucet.js @@ -12,7 +12,7 @@ export const fundingAmounts = { noVetMassiveVtho: { vet: '0x0', vtho: 10000e18 }, noVetSmallVtho: { vet: '0x0', vtho: 5e18 }, noVetTinyVtho: { vet: '0x0', vtho: '0x1' }, - bihVetBigVtho: { vet: '0x9', vtho: 1000e18 }, + bigVetBigVtho: { vet: '0x9', vtho: 1000e18 }, } export const randomFunder = () => { diff --git a/test/thorest-api/transactions/post-transaction.test.js b/test/thorest-api/transactions/post-transaction.test.js index 28b4eef..ce0006a 100644 --- a/test/thorest-api/transactions/post-transaction.test.js +++ b/test/thorest-api/transactions/post-transaction.test.js @@ -21,7 +21,9 @@ describe('POST /transactions', function () { }) it.e2eTest('should hit account limit', 'all', async () => { - const testWallet = await ThorWallet.newFunded(fundingAmounts.bihVetBigVtho) + const testWallet = await ThorWallet.newFunded( + fundingAmounts.bigVetBigVtho, + ) for (let i = 0; i < 128; i++) { const receivingAddr = await generateAddress() @@ -40,8 +42,7 @@ describe('POST /transactions', function () { const testPlan = { postTxStep: { rawTx: Hex.of(signedTx.encoded).toString(), - expectedResult: (data) => - successfulPostTx(data), + expectedResult: (data) => successfulPostTx(data), }, } @@ -65,8 +66,15 @@ describe('POST /transactions', function () { postTxStep: { rawTx: Hex.of(signedTx.encoded).toString(), expectedResult: (data) => - revertedPostTx({ success: data.success, body: data.body, httpCode: 400, httpMessage: data.httpMessage}, - "tx rejected: account quota exceeded"), + revertedPostTx( + { + success: data.success, + body: data.body, + httpCode: 400, + httpMessage: data.httpMessage, + }, + 'tx rejected: account quota exceeded', + ), }, }