Skip to content
This repository was archived by the owner on Jun 14, 2018. It is now read-only.

Conversation

@p14n
Copy link

@p14n p14n commented Jun 21, 2017

Flag to show events when tests are passing described in waffle 186.

truffle test --show-events

@robertkeizer
Copy link

I'd love to be able to use this.

@kangarang
Copy link

kangarang commented May 30, 2018

bump!

independently i implemented a similar hack in my code, and i am loving it. effectively it acts as a console.log() in solidity. i just emit a custom event with a specified value whenever i wanna inspect a value while testing -- note: the transaction must succeed to see the event log. it's especially helpful when working with private functions and contracts that send messages to one another.

event _UintLog(string name, uint value);

function resolveChallenge(uint _challengeID) private {
	// grab values from struct in voting contract
    var (,,,votesFor, votesAgainst) = voting.pollMap(_challengeID);

	emit _UintLog("votesFor", votesFor);
	emit _UintLog("votesAgainst", votesAgainst);
	
	// ...
}
Events emitted during test:
    ---------------------------

    # ... other events
    _UintLog(name: votesFor, value: 10)
	_UintLog(name: votesAgainst, value: 15)

@syndac
Copy link

syndac commented Jun 9, 2018

I feel dumb (new to git). But how do I implement this? I have the latest truffle using npm install -g truffle I'm using truffle test --show-events and not getting any events other than those that failed.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants