In my tests, I deploy contracts with upgrades.deployProxy
since my contracts are UUPSUpgradeable and deploying only the logic doesn't work for me as I have disableInitializers
in the constructor.
In one of my test file(test_file_1.ts)
, which runs first, I have something like this in.
const pluginA_ContractFactory = await ethers.getContractFactory('pluginA');
const plugin = upgrades.deployProxy(pluginA_ContractFactory);
...
// some tests here on plugin instance
Then next runs test_file_2.ts
in which I still need to use deployProxy
with pluginA
, but Instead of deploying it, await ethers.getContractFactory('pluginA');
I need to deploy mock
for which I use wonderland smock
package. So I end up having:
const pluginMock = await smock.mock('pluginA')
// @ts-ignore
plugin = await upgrades.deployProxy(pluginMock);
await plugin.initialize(...);
// One of the test
await someOtherContract.executeProposal(dummyMetadata, dummyActions);
expect(plugin.execute).has.been.calledWith(BigNumber.from(proposalId));
The test fails. The reason is inside test_file_2
, deployProxy
doesn't deploy pluginMock
as the implementation, because, it finds the one already in unknown-1337
file and uses it(the one it finds was deployed by test_file_1
.
Whats the way to fix it ? I thought maybe upgrades
package has a field I can set where I tell it to never check that file. NOTE that useDeployedImplementation
won't fix it as this is something else(Just wanted to point that out).