* Sketch * Migrate all tests to test-env * Finish migration to test-env * Add config * Work on GSN tests * Migrate to newer test-env version and loader syntax * Add GSN setup * Finish test-env migration * Setup coverage using test-env * Migrate to npm package * Fix package.json * Add compile step to CI * Add comment on coverage setup * Remove dependency on @truffle/contract * Fix package-lock merge * Fix linter errors * Upgrade test-environment, depend locally on ganche-coverage * Improve coverage script * Improve sign.js API * Move accounts destructuring to describe block * Switch to prebuilt ethereumjs-vm package * Upgrade test-enviroment version * use workspace in circleci config * remove unnecessary npx
62 lines
1.9 KiB
JavaScript
62 lines
1.9 KiB
JavaScript
const { contract } = require('@openzeppelin/test-environment');
|
|
const { expectRevert } = require('@openzeppelin/test-helpers');
|
|
|
|
const { expect } = require('chai');
|
|
|
|
const CountersImpl = contract.fromArtifact('CountersImpl');
|
|
|
|
describe('Counters', function () {
|
|
beforeEach(async function () {
|
|
this.counter = await CountersImpl.new();
|
|
});
|
|
|
|
it('starts at zero', async function () {
|
|
expect(await this.counter.current()).to.be.bignumber.equal('0');
|
|
});
|
|
|
|
describe('increment', function () {
|
|
it('increments the current value by one', async function () {
|
|
await this.counter.increment();
|
|
expect(await this.counter.current()).to.be.bignumber.equal('1');
|
|
});
|
|
|
|
it('can be called multiple times', async function () {
|
|
await this.counter.increment();
|
|
await this.counter.increment();
|
|
await this.counter.increment();
|
|
|
|
expect(await this.counter.current()).to.be.bignumber.equal('3');
|
|
});
|
|
});
|
|
|
|
describe('decrement', function () {
|
|
beforeEach(async function () {
|
|
await this.counter.increment();
|
|
expect(await this.counter.current()).to.be.bignumber.equal('1');
|
|
});
|
|
|
|
it('decrements the current value by one', async function () {
|
|
await this.counter.decrement();
|
|
expect(await this.counter.current()).to.be.bignumber.equal('0');
|
|
});
|
|
|
|
it('reverts if the current value is 0', async function () {
|
|
await this.counter.decrement();
|
|
await expectRevert(this.counter.decrement(), 'SafeMath: subtraction overflow');
|
|
});
|
|
|
|
it('can be called multiple times', async function () {
|
|
await this.counter.increment();
|
|
await this.counter.increment();
|
|
|
|
expect(await this.counter.current()).to.be.bignumber.equal('3');
|
|
|
|
await this.counter.decrement();
|
|
await this.counter.decrement();
|
|
await this.counter.decrement();
|
|
|
|
expect(await this.counter.current()).to.be.bignumber.equal('0');
|
|
});
|
|
});
|
|
});
|