diff --git a/src/account-faucet.js b/src/account-faucet.js index 8526514..35899bf 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' }, + 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 60e3e4c..ce0006a 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,68 @@ describe('POST /transactions', function () { ).toBeFalsy() }) + it.e2eTest('should hit account limit', 'all', async () => { + const testWallet = await ThorWallet.newFunded( + fundingAmounts.bigVetBigVtho, + ) + + 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',