Events logs really interesting even when tests pass.
See original GitHub issueTruffle shows events shot by a contract when its test fail. That is really a cool feature that may be interesting even when tests successfully pass.
I personally use Events to understand better how my contract behaves while testing them. For instance:
event Test(uint testID);
function someFunction (address addr, uint _uint) returns (bool) {
if (a) { Test(111); return false;}
if(b)) {Test(112); return false;}
[...] }
// or
for (uint i=0; i<n; i++) {
if (a(i)) {Test(i); return false;}
}
I’m currently adding a assert.equal(1,2) at the end to have access to those events, but might be an interesting feature to have.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:15
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Everything You Ever Wanted to Know About Events and Logs ...
You probably suspect that Events and Logs aren't entirely separate concepts, and you're right. They are interconnected. Remember how the address ...
Read more >Log source test connection is successful, but no events show ...
Log source test connection is successful, but no events show up in log activity even if they get rerieved during the test.
Read more >Important Windows Event IDs: Which Events You Should…
Look for events like Scan failed, Malware detected, and Failed to update signatures. Hackers try to hide their presence. Event ID 104 Event...
Read more >What Event Logs? Part 1: Attacker Tricks to Remove Event Logs
Many analysts rely on Windows Event Logs to help gain context of attacker activity on a system, with log entries serving as the...
Read more >Unit testing that events are raised in C# (in order)
This is very old and probably wont even be read but with some cool new ... which instead of just logging the sequence...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Added in https://github.com/trufflesuite/truffle-core/pull/6
@HCharlanes Good feature. It’d likely need to be added via the console, i.e.,
truffle test --show-events
, or something to that effect. Marking as enhancement and putting on the list of things to work on.