Skip to Main Content
Truffle Quick Start Guide
book

Truffle Quick Start Guide

by Nikhil Bhaskar
June 2018
Beginner to intermediate content levelBeginner to intermediate
170 pages
3h 46m
English
Packt Publishing
Content preview from Truffle Quick Start Guide

Testing for Solidity events

We briefly touched on testing for events but we did not get into much detail. Now is the time.

Events are a great way to let the client (frontend) know what has happened, and they're great for providing metadata about a transaction or public function invocation of your Solidity smart contract. Along with testing the state modifications of a transaction, return value of a view function, and modifiers, we can also test whether an event was emitted with the appropriate metadata.

Right now, our TaskMaster contract has no events. Let's quickly add one.

Inside the TaskMaster.sol file, underneath the state variable declarations and before the constructor, add the following line of code:

event LogRecipientRewarded(address ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Cryptosocial

Cryptosocial

Allen Taylor
Step into the Metaverse

Step into the Metaverse

Mark van Rijmenam

Publisher Resources

ISBN: 9781789132540Supplemental Content