ProjectOpenSea / operator-filter-registry

MIT License
312 stars 93 forks source link

How to Test in Hardhat? #114

Closed zdenham closed 1 year ago

zdenham commented 1 year ago

We are trying to test the operator filter to ensure royalty enforcement will work in our smart contracts.

We are using UpgradeableRevokable but it seems the registry is hard coded to an address with no way to update it, so we can't deploy a mock registry to see if the thing works.

Curious how do people test this locally?

ryanio commented 1 year ago

In hardhat you can setCode to an address, so in test suite setup would recommend deploying it to any address, then you can getCode then setCode at the constant address

zdenham commented 1 year ago

Oh nice! TIL, here is reference docs if anyone else comes across this.

I will say, hard coding these constants feels a bit odd, why not have internal funcs which return the constants but are overridable?

Would be some gas cost for jump ops but seems worth the flexibility 🤷🏼‍♂️

zdenham commented 1 year ago

Thanks anyhow for the help @ryanio 🙏