Skip to content

Commit

Permalink
Update tests for batch transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
m-Peter committed May 30, 2024
1 parent 5163f65 commit 1b2318e
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions tests/web3js/eth_batch_retrieval_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,21 @@ const conf = require('./config')
const helpers = require('./helpers')
const web3 = conf.web3

it('retrieve batch transactions', async() => {
// this test relies on the setup of batched transactions found in ../e2e_web3js_test.go
it('retrieve batch transactions', async () => {
// this test relies on the setup of batched transactions found in ../e2e_web3js_test.go

let latestHeight = await web3.eth.getBlockNumber()
let block = await web3.eth.getBlock(latestHeight)
let latestHeight = await web3.eth.getBlockNumber()
let block = await web3.eth.getBlock(latestHeight)

let batchSize = 10
assert.lengthOf(block.transactions, batchSize)
let batchSize = 10
assert.lengthOf(block.transactions, batchSize)

for (let i = 0; i < block.transactions.length; i++) {
let tx = await web3.eth.getTransactionFromBlock(latestHeight, block.number)
console.log(tx)
console.log("-----")
assert.equal(tx.blockNumber, block.number, "wrong block number")
assert.equal(tx.blockHash, block.hash, "wrong block hash")
assert.equal(tx.type, 0, "wrong type")
//assert.equal(tx.transactionIndex, i, "wrong index")
assert.isBelow(i, batchSize, "wrong batch size")
}
})
for (let i = 0; i < block.transactions.length; i++) {
let tx = await web3.eth.getTransactionFromBlock(latestHeight, i)
assert.equal(tx.blockNumber, block.number, "wrong block number")
assert.equal(tx.blockHash, block.hash, "wrong block hash")
assert.equal(tx.type, 0, "wrong type")
assert.equal(tx.transactionIndex, i, "wrong index")
assert.isBelow(i, batchSize, "wrong batch size")
}
})

0 comments on commit 1b2318e

Please sign in to comment.