Prefer const in test files (#1117)
* Removed all instances of var. * Sorted eslintrc rules. * Made eslint rule severity explicit. * Now prefering const over let.
This commit is contained in:
@ -1,53 +1,53 @@
|
||||
const { assertRevert } = require('./helpers/assertRevert');
|
||||
const { ethGetBalance } = require('./helpers/web3');
|
||||
|
||||
var LimitBalanceMock = artifacts.require('LimitBalanceMock');
|
||||
const LimitBalanceMock = artifacts.require('LimitBalanceMock');
|
||||
|
||||
contract('LimitBalance', function (accounts) {
|
||||
let lb;
|
||||
let limitBalance;
|
||||
|
||||
beforeEach(async function () {
|
||||
lb = await LimitBalanceMock.new();
|
||||
limitBalance = await LimitBalanceMock.new();
|
||||
});
|
||||
|
||||
let LIMIT = 1000;
|
||||
const LIMIT = 1000;
|
||||
|
||||
it('should expose limit', async function () {
|
||||
let limit = await lb.limit();
|
||||
const limit = await limitBalance.limit();
|
||||
assert.equal(limit, LIMIT);
|
||||
});
|
||||
|
||||
it('should allow sending below limit', async function () {
|
||||
let amount = 1;
|
||||
await lb.limitedDeposit({ value: amount });
|
||||
const amount = 1;
|
||||
await limitBalance.limitedDeposit({ value: amount });
|
||||
|
||||
const balance = await ethGetBalance(lb.address);
|
||||
const balance = await ethGetBalance(limitBalance.address);
|
||||
assert.equal(balance, amount);
|
||||
});
|
||||
|
||||
it('shouldnt allow sending above limit', async function () {
|
||||
let amount = 1110;
|
||||
await assertRevert(lb.limitedDeposit({ value: amount }));
|
||||
const amount = 1110;
|
||||
await assertRevert(limitBalance.limitedDeposit({ value: amount }));
|
||||
});
|
||||
|
||||
it('should allow multiple sends below limit', async function () {
|
||||
let amount = 500;
|
||||
await lb.limitedDeposit({ value: amount });
|
||||
const amount = 500;
|
||||
await limitBalance.limitedDeposit({ value: amount });
|
||||
|
||||
const balance = await ethGetBalance(lb.address);
|
||||
const balance = await ethGetBalance(limitBalance.address);
|
||||
assert.equal(balance, amount);
|
||||
|
||||
await lb.limitedDeposit({ value: amount });
|
||||
const updatedBalance = await ethGetBalance(lb.address);
|
||||
await limitBalance.limitedDeposit({ value: amount });
|
||||
const updatedBalance = await ethGetBalance(limitBalance.address);
|
||||
assert.equal(updatedBalance, amount * 2);
|
||||
});
|
||||
|
||||
it('shouldnt allow multiple sends above limit', async function () {
|
||||
let amount = 500;
|
||||
await lb.limitedDeposit({ value: amount });
|
||||
const amount = 500;
|
||||
await limitBalance.limitedDeposit({ value: amount });
|
||||
|
||||
const balance = await ethGetBalance(lb.address);
|
||||
const balance = await ethGetBalance(limitBalance.address);
|
||||
assert.equal(balance, amount);
|
||||
await assertRevert(lb.limitedDeposit({ value: amount + 1 }));
|
||||
await assertRevert(limitBalance.limitedDeposit({ value: amount + 1 }));
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user