Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/account-faucet.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () => {
Expand Down
65 changes: 64 additions & 1 deletion test/thorest-api/transactions/post-transaction.test.js
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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',
Expand Down