Waffle icon indicating copy to clipboard operation
Waffle copied to clipboard

Using emit().withArgs with multiple events, only asserts the value of the arguments of the last event

Open jesusholoo opened this issue 4 years ago • 4 comments

I'm using @nomiclabs/hardhat-waffle": "^2.0.3" with "ethereum-waffle": "^3.4.4",

When try to assert the events parameters using emit().withArgs it does correcttly check that ALL events has been emitted and the arguments has the correct types. But only checks the value of the arguments of the last event!

Exmaple:

      await expect(bridgeContract.bridge(wrappedTokenAddress, newDestinationNetwork, destinationAddress, amount))
            .to.emit(bridgeContract, 'BridgeEvent')
            .withArgs("This is bytes i can put whathever and the test will pass anyway ^^") // This is NOT checked
             .to.emit(newWrappedToken, 'Transfer')
             .withArgs(deployer.address, ethers.constants.AddressZero, amount); // This is checked

jesusholoo avatar Jun 30 '22 10:06 jesusholoo

@invocamanman We did a bunch of work related to this in the new Waffle 4 alpha - so it is pending, or you could use the @alpha tag to try it out.

rzadp avatar Jun 30 '22 11:06 rzadp

great! thank you so much! @rzadp

jesusholoo avatar Jun 30 '22 11:06 jesusholoo

@invocamanman I just spent an hour debugging why my test passed

songhobby avatar Jul 11 '22 21:07 songhobby

Waffle 4 is out now, feel free to open new issue if things are not working quite right in 4.

rzadp avatar Aug 01 '22 08:08 rzadp