Problem
Recently I have switched from the Truffle test-environment to the OpenZeppeling test-environment and I am extremely enjoying the features. However, something confuses me. At the top of my test code I write:
require('@openzeppelin/test-helpers/configure')({
provider: 'http://localhost:8545',
defaultGasPrice: 0
});
const { accounts, contract, web3 } = require('@openzeppelin/test-environment');
const {
BN, // Big Number support
constants, // Common constants, like the zero address and largest integers
expectEvent, // Assertions for emitted events
expectRevert, // Assertions for transactions that should fail
} = require('@openzeppelin/test-helpers');
const balance = require('@openzeppelin/test-helpers/src/balance');
const { assert } = require('chai');
require('chai').should();
const Escrow = contract.fromArtifact('Escrow');
After this configuration I start the test:
describe('Escrow', () => {
const [lawyer, payer, payee] = accounts;
const amount = 100;
beforeEach(async () => {
this.escrow = await Escrow.new(payer, payee, amount);
});
it('deposit amount correctly', async () => {
await this.escrow.deposit({ from: payer, value: amount });
let allAccounts = await web3.eth.getAccounts();
const gasPrice = await web3.eth.getGasPrice();
console.log(allAccounts);
console.log(accounts);
console.log(gasPrice);
});
});
The only thing that doesn’t work is the web3 object. When I log the gasPrice it prints 20000000000 even though I have set it to 0 and the variable allAccounts stores 11 addresses and the accounts variable stores 10. I think I initialize web3 incorrectly but I am not sure what I am doing wrong. I think it is something extremely obvious.
Does someone spot the mistake?
Environment
"@nomiclabs/hardhat-web3": "^2.0.0",
"@openzeppelin/test-helpers": "^0.5.9",
"web3": "^1.3.0"
"@openzeppelin/test-environment": "^0.1.8",
"chai": "^4.2.0",
"mocha": "^8.2.1"