defi-wonderland / smock

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

feat request: stop to stop emitting events in mock contracts #71

Open ashhanai opened 3 years ago

ashhanai commented 3 years ago

It would be very useful to have an option to stop emitting events in mock contracts.

Use case

Contract, that calls another contracts, emits an event. I want to test proper emit behaviour (that event is emitted once with correct data).

Current solution

I need to check if other contracts used by my contract transaction emits events and be aware of that in tests of my contract. In case dependency contract change its event behaviour (lets say it stops emitting or start emitting more events), my tests will start failing.

Requested solution

In my contract tests I can mock dependency contracts via smock. If there is an option to stop emitting events on mocks I can better isolate my tests and don't need to count with all events emitted by another contacts.

Workaround

I can use fakes instead of mocks which will not emit events as a workaround. Unfortunately in case I need some contract logic I cannot use this workaround.

0xGorilla commented 3 years ago

It is an interesting request, I wonder how many people do need this. I currently don't have much free time to handle this, come join our discord and let's see if anyone volunteers.

wei3erHase commented 2 years ago

@ashhanai , cannot you just filter the events? and read only the emitted by the contracts you're interested in?