Skip to content

Instantly share code, notes, and snippets.

@sogoiii
Created July 22, 2018 22:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sogoiii/b2e2b54f35f00586bc35bc0fa0e4a217 to your computer and use it in GitHub Desktop.
Save sogoiii/b2e2b54f35f00586bc35bc0fa0e4a217 to your computer and use it in GitHub Desktop.
Example of using handleTestFn to make you Web3js function calls with truffle and ganache-cli.
async function handleTestFn(method, inputs) {
try {
return await method(...inputs)
} catch(e) {
return e.receipt
}
}
it('should fail to create an event because eventName is not a string', async function () {
let op1 = await handleTestFn(this.Contract.createEvent, [123456, _eventDescription, _eventWebsite, _eventDate, _location, { from: mainAccount }])
assert.equal(op1.status, hex.fail, 'TX status should complete')
let CreatedList = await handleTestFn(this.Contract.getMyCreatedEvents.call, [4,1])
assert.deepEqual(convertBigNumArr(CreatedList), ['0', '0', '0', '0'])
let EventList = await handleTestFn(this.Contract.getAllEvents.call, [4, 1])
assert.deepEqual(convertBigNumArr(EventList), ['0', '0', '0', '0'])
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment