Smock library for contracts

hi sol folks , got some questions for you

background :
i am mocking smart contrct using smock library . and typically i am using their .setVariables() method to set some values into my defined variable . like here :

    it.skip("should revert if the user's voucher balance is equal to zero", async () => {
            await mockPMC.setVariable("userPoolInfo", {
                '0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC' : {
                    1: {
                        cycle: '1',
                        phase: '1',

Here for the first 1 , i set it to be a static value since there are some issues with it , which i want it to be a dynamic key-value here , i.e. mockWethToken.addres , etc

as for each contract deployment , the address would be different ,
so wonder how we can set it dynamically here

You should deploy a plain ERC20 contract which will mock WETH, and then use its address instead.

We can't literally do this , as i mentioned , everytime we run the tests ,
the beforeEach would deploy the asset contract and the address of the asset contract would be changed .

barakman via OpenZeppelin Forum <> 于2023年3月24日周五 16:17写道:

So use the asset contract everywhere in your tests.
Unit-testing should be fully self-contained, i.e., all the data should derive directly from your local chain.
If you want to test against a public chain, then the way to do it is by forking it into your local chain.

1 Like

we don't want this key to be static , but in some form of variables that gather them together , like mockWETH.address .

barakman via OpenZeppelin Forum <> 于2023年3月24日周五 17:27写道: