You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When testing a function that uses fake.address and you have more than one fake declared/deployed, the behaviour of the tests changes according to the order in which these fakes are declared.
For example, let's say we have fakeA and fakeB, and a test that makes function fakeA.myFunction() revert and expects for it to actually revert when called with ethers.provider.call({ to: fakeA.address }). If fakeA is declared after fakeB, the test will pass, but if fakeB is declared after fakeA the test will fail.
Reproduction steps
I've pushed a branch that includes the failing test with this behaviour. In the beforeEach block of the text, you can switch the order in which the fakes are declared to see how the behaviour of the test changes.
Go to this test on the feat/fake-test-at-address branch.
Run yarn test. This test should fail.
Switch the order in which fake and fakeAtAddress are declared in the beforeEach block
Run yarn test. The test should work.
Expected behavior
Test should pass despite the order in which the fakes are declared.
The text was updated successfully, but these errors were encountered:
This bug is actually more insidious than just the order of the functions
if you add this test
it('not call other reverts',async()=>{fake.fallback.reverts();try{awaitethers.provider.call({to: fake.address})}catch{}expect(fakeAtAddress.fallback).not.to.have.been.called;});
The revert function actually references the same underlying object.
Describe the bug
When testing a function that uses
fake.address
and you have more than one fake declared/deployed, the behaviour of the tests changes according to the order in which these fakes are declared.For example, let's say we have
fakeA
andfakeB
, and a test that makes functionfakeA.myFunction()
revert and expects for it to actually revert when called withethers.provider.call({ to: fakeA.address })
. IffakeA
is declared afterfakeB
, the test will pass, but iffakeB
is declared afterfakeA
the test will fail.Reproduction steps
I've pushed a branch that includes the failing test with this behaviour. In the beforeEach block of the text, you can switch the order in which the fakes are declared to see how the behaviour of the test changes.
feat/fake-test-at-address
branch.yarn test
. This test should fail.fake
andfakeAtAddress
are declared in the beforeEach blockyarn test
. The test should work.Expected behavior
Test should pass despite the order in which the fakes are declared.
The text was updated successfully, but these errors were encountered: