Created
July 13, 2018 17:49
-
-
Save adrianmcli/9e1ad432e2057edf6264a9f8d713dc1d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { getWeb3, getContractInstance } = require("./helpers") | |
const web3 = getWeb3() | |
const getInstance = getContractInstance(web3) | |
contract("Counter", (accounts) => { | |
it("should initialize with a count of 0", async () => { | |
const counter = getInstance("Counter") | |
const count = await counter.methods.get().call() | |
const expected = 0 | |
assert.equal(count, expected, "count was not intialized with 0") | |
}) | |
it("should increment to a count of 1", async () => { | |
const counter = getInstance("Counter") | |
await counter.methods.increment().send({ from: accounts[0] }) | |
const count = await counter.methods.get().call() | |
const expected = 1 | |
assert.equal(count, expected, "count was not incremented to 1") | |
}) | |
it("should decrement back to a count of 0", async () => { | |
const counter = getInstance("Counter") | |
await counter.methods.decrement().send({ from: accounts[0] }) | |
const count = await counter.methods.get().call() | |
const expected = 0 | |
assert.equal(count, expected, "count was not decremented back to 0") | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment