Rename AutoIncrementing to Counter (#1307)

This commit is contained in:
Leo Arias
2018-09-13 02:51:22 -06:00
committed by Nicolás Venturo
parent 225b492109
commit b4f87bb8fc
4 changed files with 34 additions and 33 deletions

40
test/Counter.test.js Normal file
View File

@ -0,0 +1,40 @@
const Counter = artifacts.require('CounterImpl');
require('chai')
.use(require('chai-bignumber')(web3.BigNumber))
.should();
const EXPECTED = [1, 2, 3, 4];
const KEY1 = web3.sha3('key1');
const KEY2 = web3.sha3('key2');
contract('Counter', function ([_, owner]) {
beforeEach(async function () {
this.mock = await Counter.new({ from: owner });
});
context('custom key', async function () {
it('should return expected values', async function () {
for (const expectedId of EXPECTED) {
await this.mock.doThing(KEY1, { from: owner });
const actualId = await this.mock.theId();
actualId.should.be.bignumber.equal(expectedId);
}
});
});
context('parallel keys', async function () {
it('should return expected values for each counter', async function () {
for (const expectedId of EXPECTED) {
await this.mock.doThing(KEY1, { from: owner });
let actualId = await this.mock.theId();
actualId.should.be.bignumber.equal(expectedId);
await this.mock.doThing(KEY2, { from: owner });
actualId = await this.mock.theId();
actualId.should.be.bignumber.equal(expectedId);
}
});
});
});