Prefer const in test files (#1117)
* Removed all instances of var. * Sorted eslintrc rules. * Made eslint rule severity explicit. * Now prefering const over let.pull/1121/head
parent
6e19ed47be
commit
567b773242
@ -1,53 +1,53 @@ |
|||||||
const { assertRevert } = require('./helpers/assertRevert'); |
const { assertRevert } = require('./helpers/assertRevert'); |
||||||
const { ethGetBalance } = require('./helpers/web3'); |
const { ethGetBalance } = require('./helpers/web3'); |
||||||
|
|
||||||
var LimitBalanceMock = artifacts.require('LimitBalanceMock'); |
const LimitBalanceMock = artifacts.require('LimitBalanceMock'); |
||||||
|
|
||||||
contract('LimitBalance', function (accounts) { |
contract('LimitBalance', function (accounts) { |
||||||
let lb; |
let limitBalance; |
||||||
|
|
||||||
beforeEach(async function () { |
beforeEach(async function () { |
||||||
lb = await LimitBalanceMock.new(); |
limitBalance = await LimitBalanceMock.new(); |
||||||
}); |
}); |
||||||
|
|
||||||
let LIMIT = 1000; |
const LIMIT = 1000; |
||||||
|
|
||||||
it('should expose limit', async function () { |
it('should expose limit', async function () { |
||||||
let limit = await lb.limit(); |
const limit = await limitBalance.limit(); |
||||||
assert.equal(limit, LIMIT); |
assert.equal(limit, LIMIT); |
||||||
}); |
}); |
||||||
|
|
||||||
it('should allow sending below limit', async function () { |
it('should allow sending below limit', async function () { |
||||||
let amount = 1; |
const amount = 1; |
||||||
await lb.limitedDeposit({ value: amount }); |
await limitBalance.limitedDeposit({ value: amount }); |
||||||
|
|
||||||
const balance = await ethGetBalance(lb.address); |
const balance = await ethGetBalance(limitBalance.address); |
||||||
assert.equal(balance, amount); |
assert.equal(balance, amount); |
||||||
}); |
}); |
||||||
|
|
||||||
it('shouldnt allow sending above limit', async function () { |
it('shouldnt allow sending above limit', async function () { |
||||||
let amount = 1110; |
const amount = 1110; |
||||||
await assertRevert(lb.limitedDeposit({ value: amount })); |
await assertRevert(limitBalance.limitedDeposit({ value: amount })); |
||||||
}); |
}); |
||||||
|
|
||||||
it('should allow multiple sends below limit', async function () { |
it('should allow multiple sends below limit', async function () { |
||||||
let amount = 500; |
const amount = 500; |
||||||
await lb.limitedDeposit({ value: amount }); |
await limitBalance.limitedDeposit({ value: amount }); |
||||||
|
|
||||||
const balance = await ethGetBalance(lb.address); |
const balance = await ethGetBalance(limitBalance.address); |
||||||
assert.equal(balance, amount); |
assert.equal(balance, amount); |
||||||
|
|
||||||
await lb.limitedDeposit({ value: amount }); |
await limitBalance.limitedDeposit({ value: amount }); |
||||||
const updatedBalance = await ethGetBalance(lb.address); |
const updatedBalance = await ethGetBalance(limitBalance.address); |
||||||
assert.equal(updatedBalance, amount * 2); |
assert.equal(updatedBalance, amount * 2); |
||||||
}); |
}); |
||||||
|
|
||||||
it('shouldnt allow multiple sends above limit', async function () { |
it('shouldnt allow multiple sends above limit', async function () { |
||||||
let amount = 500; |
const amount = 500; |
||||||
await lb.limitedDeposit({ value: amount }); |
await limitBalance.limitedDeposit({ value: amount }); |
||||||
|
|
||||||
const balance = await ethGetBalance(lb.address); |
const balance = await ethGetBalance(limitBalance.address); |
||||||
assert.equal(balance, amount); |
assert.equal(balance, amount); |
||||||
await assertRevert(lb.limitedDeposit({ value: amount + 1 })); |
await assertRevert(limitBalance.limitedDeposit({ value: amount + 1 })); |
||||||
}); |
}); |
||||||
}); |
}); |
||||||
|
@ -1,55 +1,51 @@ |
|||||||
const { assertRevert } = require('../helpers/assertRevert'); |
const { assertRevert } = require('../helpers/assertRevert'); |
||||||
|
|
||||||
var DelayedClaimable = artifacts.require('DelayedClaimable'); |
const DelayedClaimable = artifacts.require('DelayedClaimable'); |
||||||
|
|
||||||
contract('DelayedClaimable', function (accounts) { |
contract('DelayedClaimable', function (accounts) { |
||||||
var delayedClaimable; |
beforeEach(async function () { |
||||||
|
this.delayedClaimable = await DelayedClaimable.new(); |
||||||
beforeEach(function () { |
|
||||||
return DelayedClaimable.new().then(function (deployed) { |
|
||||||
delayedClaimable = deployed; |
|
||||||
}); |
|
||||||
}); |
}); |
||||||
|
|
||||||
it('can set claim blocks', async function () { |
it('can set claim blocks', async function () { |
||||||
await delayedClaimable.transferOwnership(accounts[2]); |
await this.delayedClaimable.transferOwnership(accounts[2]); |
||||||
await delayedClaimable.setLimits(0, 1000); |
await this.delayedClaimable.setLimits(0, 1000); |
||||||
let end = await delayedClaimable.end(); |
const end = await this.delayedClaimable.end(); |
||||||
assert.equal(end, 1000); |
assert.equal(end, 1000); |
||||||
let start = await delayedClaimable.start(); |
const start = await this.delayedClaimable.start(); |
||||||
assert.equal(start, 0); |
assert.equal(start, 0); |
||||||
}); |
}); |
||||||
|
|
||||||
it('changes pendingOwner after transfer successful', async function () { |
it('changes pendingOwner after transfer successful', async function () { |
||||||
await delayedClaimable.transferOwnership(accounts[2]); |
await this.delayedClaimable.transferOwnership(accounts[2]); |
||||||
await delayedClaimable.setLimits(0, 1000); |
await this.delayedClaimable.setLimits(0, 1000); |
||||||
let end = await delayedClaimable.end(); |
const end = await this.delayedClaimable.end(); |
||||||
assert.equal(end, 1000); |
assert.equal(end, 1000); |
||||||
let start = await delayedClaimable.start(); |
const start = await this.delayedClaimable.start(); |
||||||
assert.equal(start, 0); |
assert.equal(start, 0); |
||||||
let pendingOwner = await delayedClaimable.pendingOwner(); |
const pendingOwner = await this.delayedClaimable.pendingOwner(); |
||||||
assert.equal(pendingOwner, accounts[2]); |
assert.equal(pendingOwner, accounts[2]); |
||||||
await delayedClaimable.claimOwnership({ from: accounts[2] }); |
await this.delayedClaimable.claimOwnership({ from: accounts[2] }); |
||||||
let owner = await delayedClaimable.owner(); |
const owner = await this.delayedClaimable.owner(); |
||||||
assert.equal(owner, accounts[2]); |
assert.equal(owner, accounts[2]); |
||||||
}); |
}); |
||||||
|
|
||||||
it('changes pendingOwner after transfer fails', async function () { |
it('changes pendingOwner after transfer fails', async function () { |
||||||
await delayedClaimable.transferOwnership(accounts[1]); |
await this.delayedClaimable.transferOwnership(accounts[1]); |
||||||
await delayedClaimable.setLimits(100, 110); |
await this.delayedClaimable.setLimits(100, 110); |
||||||
let end = await delayedClaimable.end(); |
const end = await this.delayedClaimable.end(); |
||||||
assert.equal(end, 110); |
assert.equal(end, 110); |
||||||
let start = await delayedClaimable.start(); |
const start = await this.delayedClaimable.start(); |
||||||
assert.equal(start, 100); |
assert.equal(start, 100); |
||||||
let pendingOwner = await delayedClaimable.pendingOwner(); |
const pendingOwner = await this.delayedClaimable.pendingOwner(); |
||||||
assert.equal(pendingOwner, accounts[1]); |
assert.equal(pendingOwner, accounts[1]); |
||||||
await assertRevert(delayedClaimable.claimOwnership({ from: accounts[1] })); |
await assertRevert(this.delayedClaimable.claimOwnership({ from: accounts[1] })); |
||||||
let owner = await delayedClaimable.owner(); |
const owner = await this.delayedClaimable.owner(); |
||||||
assert.isTrue(owner !== accounts[1]); |
assert.isTrue(owner !== accounts[1]); |
||||||
}); |
}); |
||||||
|
|
||||||
it('set end and start invalid values fail', async function () { |
it('set end and start invalid values fail', async function () { |
||||||
await delayedClaimable.transferOwnership(accounts[1]); |
await this.delayedClaimable.transferOwnership(accounts[1]); |
||||||
await assertRevert(delayedClaimable.setLimits(1001, 1000)); |
await assertRevert(this.delayedClaimable.setLimits(1001, 1000)); |
||||||
}); |
}); |
||||||
}); |
}); |
||||||
|
Loading…
Reference in new issue