TrueFiEng / Waffle

Library for writing and testing smart contracts.
https://getwaffle.io
MIT License
960 stars 161 forks source link

[Feature Request] Emit events in mock contracts #809

Closed sthitpragnya-ethosx closed 1 year ago

sthitpragnya-ethosx commented 1 year ago

Is there a way we can specify a mock contract to emit an event when a write function is called? This would come in handy to check whether a particular functions is called or not. A good to have would be to also map the parameters of the event to input params to test the parameters with which the mock's function is called.

rzadp commented 1 year ago

@sthitpragnya-ethosx Thanks for submitting the request.

Is there a way we can specify a mock contract to emit an event when a write function is called?

No, not at the moment. Let's scope out what would be the use cases for it.

This would come in handy to check whether a particular functions is called or not. (...) to test the parameters with which the mock's function is called.

So, it seems like what you would need is not necessarily events, but a way to assert calledOnContract and calledOnContractWith on the mock contract, right?

pawelpolak2 commented 1 year ago

calledOnContract and calledOnContractWith matchers work correctly with mock contracts which seems to resolve this.