Skip to content

Instantly share code, notes, and snippets.

@paulrberg

paulrberg/counter.ts

Last active May 20, 2020
Embed
What would you like to do?
Dummy test file used for reproducing a Buidler bug
import chai from "chai";
import { deployContract, solidity } from "ethereum-waffle";
import { waffle } from "@nomiclabs/buidler";
import CounterArtifact from "../artifacts/Counter.json";
import { Counter } from "../typechain/Counter";
chai.use(solidity);
const { expect } = chai;
describe("Counter", () => {
// 1
const [wallet] = waffle.provider.getWallets();
// 2
let counter: Counter;
beforeEach(async () => {
counter = (await deployContract(wallet, CounterArtifact)) as Counter;
const initialCount = await counter.count();
// 3
expect(initialCount).to.eq(0);
expect(counter.address).to.properAddress;
});
// 4
it("should count up", async () => {
await counter.countUp();
let count = await counter.count();
expect(count).to.eq(1);
await counter.countUp();
count = await counter.count();
expect(count).to.eq(2);
});
it("should count down", async () => {
// 6
await counter.countDown();
const count = await counter.count();
expect(count).to.eq(0);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.