...by Daniel Szego
quote
"On a long enough timeline we will all become Satoshi Nakamoto.."
Daniel Szego

Saturday, January 6, 2018

Solidity and Truffle Tips and Tricks - testing events in unit tests


Supposing you want to check if an event has been raised during a unit test, you can simply use parts of the result variable. As an example result.logs[0].event shows the name of the raised event. 

 return Contract.functionCall(<parameters>);             
        }).then(function(result) {
            event = result.logs[0].event;
    assert.equal(event, "EventName", "Event raised");