forked from OpenZeppelin/openzeppelin-contracts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLimitBalance.test.js
47 lines (35 loc) · 1.31 KB
/
LimitBalance.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import assertRevert from './helpers/assertRevert';
var LimitBalanceMock = artifacts.require('LimitBalanceMock');
contract('LimitBalance', function (accounts) {
let lb;
beforeEach(async function () {
lb = await LimitBalanceMock.new();
});
let LIMIT = 1000;
it('should expose limit', async function () {
let limit = await lb.limit();
assert.equal(limit, LIMIT);
});
it('should allow sending below limit', async function () {
let amount = 1;
await lb.limitedDeposit({ value: amount });
assert.equal(web3.eth.getBalance(lb.address), amount);
});
it('shouldnt allow sending above limit', async function () {
let amount = 1110;
await assertRevert(lb.limitedDeposit({ value: amount }));
});
it('should allow multiple sends below limit', async function () {
let amount = 500;
await lb.limitedDeposit({ value: amount });
assert.equal(web3.eth.getBalance(lb.address), amount);
await lb.limitedDeposit({ value: amount });
assert.equal(web3.eth.getBalance(lb.address), amount * 2);
});
it('shouldnt allow multiple sends above limit', async function () {
let amount = 500;
await lb.limitedDeposit({ value: amount });
assert.equal(web3.eth.getBalance(lb.address), amount);
await assertRevert(lb.limitedDeposit({ value: amount + 1 }));
});
});