defi-wonderland / smock

The Solidity mocking library
MIT License
319 stars 40 forks source link

Error "getVariable is not a function" when used with OZ upgrade-plugin. #150

Open ddnexus opened 2 years ago

ddnexus commented 2 years ago

I am not sure whether this is a known limitation or it's just that I am missing something, so here is the description:

I try to use it with an OZ UUPS proxy I get: getVariable is not a function

The contract must be deployed using the upgrades.deployProxy() from the OZ upgrades HH plugin, and I managed to get no complaints from typescript:

const ProxyMock = await smock.mock("MyContract");
const proxyMock = await upgrades.deployProxy(ProxyMock as MockContractFactory<MyContract__factory> & MyContract__factory, [...]) as MyContract & MockContract<MyContract>;

However that does not help. How should I hook into the customized deployment of the upgrade-plugin, if that is possible, or how can I get around it with some manual work around?

Thanks

0xlucian commented 1 year ago

Have you resolved this problem? I also got stuck into this one and I need to use same function.

ddnexus commented 1 year ago

Well... I avoided it by not using smock, creating my own infrastructure that tests the real code instead.

More work but a lot better testing in my case.

0xlucian commented 1 year ago

Yeah me too. I still use utilize Fakes to fake external dependencies in contracts, but cannot think of any workaround for this case...