Skip to content

Instantly share code, notes, and snippets.

@rhlsthrm
Last active May 23, 2020 09:33
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 rhlsthrm/3b9680de7c2694b8a2971d72aeba3b12 to your computer and use it in GitHub Desktop.
Save rhlsthrm/3b9680de7c2694b8a2971d72aeba3b12 to your computer and use it in GitHub Desktop.
import { ethers } from "@nomiclabs/buidler";
import { Signer, Wallet } from "ethers";
import chai from "chai";
import { deployContract, solidity } from "ethereum-waffle";
import CounterArtifact from "../artifacts/Counter.json";
import { Counter } from "../typechain/Counter";
chai.use(solidity);
const { expect } = chai;
describe("Counter", () => {
let counter: Counter;
beforeEach(async () => {
// 1
const signers = await ethers.signers();
// 2
counter = (await deployContract(
<Wallet>signers[0],
CounterArtifact
)) as Counter;
const initialCount = await counter.getCount();
// 3
expect(initialCount).to.eq(0);
expect(counter.address).to.properAddress;
});
// 4
describe("count up", async () => {
it("should count up", async () => {
await counter.countUp();
let count = await counter.getCount();
expect(count).to.eq(1);
});
});
describe("count down", async () => {
// 5
it("should fail", async () => {
await counter.countDown();
});
it("should count down", async () => {
await counter.countUp();
await counter.countDown();
const count = await counter.getCount();
expect(count).to.eq(0);
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment