Skip to content

Instantly share code, notes, and snippets.

@stefek99
Created July 12, 2018 07:54
Show Gist options
  • Save stefek99/cca84566128f8f9d4852924d2c682428 to your computer and use it in GitHub Desktop.
Save stefek99/cca84566128f8f9d4852924d2c682428 to your computer and use it in GitHub Desktop.
const SuperSimple = artifacts.require('SuperSimple.sol')
contract('SuperSimple', function (accounts) {
let owner = accounts[0]
let bidderA = accounts[1]
let simple;
beforeEach(async function() {
simple = await SuperSimple.new({from: owner});
});
it('Should emit some events', async function() {
await simple.sendTransaction({ value: 1e18, from: bidderA });
await simple.something();
var result = await simple.second.call();
console.log("Result of the second function: " + result);
assert.equal(true, false); // to automatically list the events
});
});
pragma solidity ^0.4.23;
contract SuperSimple {
event LogNumber(uint number);
event LogText(string text);
event LogAddress(address addr);
constructor() public {
emit LogNumber(1);
emit LogText("constructor");
emit LogAddress(msg.sender);
}
function() public payable {
emit LogNumber(2);
emit LogText("fallback");
emit LogAddress(msg.sender);
}
function something() public {
emit LogNumber(3);
emit LogText("a function");
emit LogAddress(msg.sender);
}
function second() public returns(string) {
emit LogNumber(4);
emit LogText("a second function");
emit LogAddress(msg.sender);
return "I have been called";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment