fix: made all the tests consistent. now with done.

This commit is contained in:
Angello Pozo
2016-11-30 13:24:02 -08:00
parent f2142545c7
commit 688106e9c3
10 changed files with 108 additions and 59 deletions

View File

@ -1,24 +1,27 @@
contract('LimitBalance', function(accounts) {
var lb;
let lb;
beforeEach(async function() {
beforeEach(async function(done) {
lb = await LimitBalanceMock.new();
done();
});
let LIMIT = 1000;
it("should expose limit", async function() {
it("should expose limit", async function(done) {
let limit = await lb.limit();
assert.equal(limit, LIMIT);
done();
});
it("should allow sending below limit", async function() {
it("should allow sending below limit", async function(done) {
let amount = 1;
let limDeposit = await lb.limitedDeposit({value: amount});
assert.equal(web3.eth.getBalance(lb.address), amount);
done();
});
it("shouldnt allow sending above limit", async function() {
it("shouldnt allow sending above limit", async function(done) {
let amount = 1110;
try {
@ -26,29 +29,31 @@ contract('LimitBalance', function(accounts) {
} catch(error) {
if (error.message.search('invalid JUMP') == -1) throw error
assert.isAbove(error.message.search('invalid JUMP'), -1, 'Invalid JUMP error must be returned');
done();
}
});
it("should allow multiple sends below limit", async function() {
it("should allow multiple sends below limit", async function(done) {
let amount = 500;
let limDeposit = await lb.limitedDeposit({value: amount});
assert.equal(web3.eth.getBalance(lb.address), amount);
let limDeposit2 = await lb.limitedDeposit({value: amount});
assert.equal(web3.eth.getBalance(lb.address), amount*2);
done();
});
it("shouldnt allow multiple sends above limit", async function() {
it("shouldnt allow multiple sends above limit", async function(done) {
let amount = 500;
let limDeposit = await lb.limitedDeposit({value: amount});
assert.equal(web3.eth.getBalance(lb.address), amount);
try {
lb.limitedDeposit({value: amount+1})
await lb.limitedDeposit({value: amount+1})
} catch(error) {
if (error.message.search('invalid JUMP') == -1) throw error
assert.isAbove(error.message.search('invalid JUMP'), -1, 'Invalid JUMP error must be returned');
done();
}
});