Skip to content

Commit

Permalink
Improve testing for comparison of eth_getBlockReceipts to a transacti…
Browse files Browse the repository at this point in the history
…on receipt
  • Loading branch information
m-Peter committed Sep 12, 2024
1 parent abb20de commit 54534f3
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions tests/web3js/eth_non_interactive_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const web3Utils = require('web3-utils')
const { assert } = require('chai')
const conf = require('./config')
const helpers = require('./helpers')
const web3types = require('web3-types')
const web3 = conf.web3

it('get chain ID', async () => {
Expand Down Expand Up @@ -97,13 +98,18 @@ it('should get block receipts', async () => {
assert.lengthOf(blockReceipts, 3)

for (let blockReceipt of blockReceipts) {
let response = await helpers.callRPCMethod(
'eth_getTransactionReceipt',
[blockReceipt.transactionHash]
let txReceipt = await web3.eth.getTransactionReceipt(
blockReceipt.transactionHash,
web3types.ETH_DATA_FORMAT
)
assert.equal(response.status, 200)
// normalize missing fields from transaction receipt
if (txReceipt.to === undefined) {
txReceipt.to = null
}
if (txReceipt.contractAddress === undefined) {
txReceipt.contractAddress = null
}

let txReceipt = response.body.result
assert.deepEqual(blockReceipt, txReceipt)
}
})
Expand Down

0 comments on commit 54534f3

Please sign in to comment.