Open colinsteidtmann opened 2 years ago
Hi!
I don't know why you want to use that specific method... I would suggest you do it like this:
add chai's assert into your test file: const { assert } = require("chai")
add a constructor describe and a getter function in your contract to get the variables you want to check --> get the variables --> assert the variables are equal to a certain value:
describe("constructor", async function(){
it("sets the state variables correctly, async function() {
const yourStateVariable = await contractName.getterFunctionWithStateVarName();
assert.equal(yourStateVariable, whatYouWantItToBe)
})
})
you can create a specific fixture that deploy a specifically configured contract instance.
the deploy fixture are meant to be used to test the deployment itself, so you would not want to configure it
Also stated in https://github.com/wighawag/hardhat-deploy/issues/289, it would be really useful to be able to pass constructor arguments when loading fixtures, sometime we may need to test the contract with specific arguments.
await deployments.fixture()
await deployments.fixture({ 'myContract': [...args] })
Imagine you have a addresses Leaderboard
contract and to test it you need real signers as players. It would be preferable to deploy it with a length of 2 for the tests so that you need 2 signers, and with a length of 100 in production.
for now we have to write a deploy script for each testing case when it comes to arguments
@Sceat for the case you mention you could read the number of signers from a different file for test network, You can also add tags to network so you can differentiate between test network and real network programmatically.
I want to test that state variables are changed after creating a new contract with constructor arguments and setting state variables inside the constructor. I want to do something like openzeppelin's
ERC20Mock.new(args..).
(https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/test/token/ERC20/ERC20.test.js#L23) inside of a test file. However,deployments.fixture
doesn't accept deployment arguments I can pass in. What should I do?