Skip to content

Instantly share code, notes, and snippets.

@adrianmcli
Created July 13, 2018 17:49
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 adrianmcli/9e1ad432e2057edf6264a9f8d713dc1d to your computer and use it in GitHub Desktop.
Save adrianmcli/9e1ad432e2057edf6264a9f8d713dc1d to your computer and use it in GitHub Desktop.
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