Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix testing error throwing
  • Loading branch information
jakub-wojciechowski committed Jul 22, 2017
commit 5e7847537acf68c15052805bc7a47bce6d539435
6 changes: 4 additions & 2 deletions test/Claimable.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ contract('Claimable', function(accounts) {
try {
await claimable.claimOwnership({from: accounts[2]});
} catch(error) {
assertJump(error);
return assertJump(error);
}
assert.fail('should have thrown before');
});

it('should prevent non-owners from transfering', async function() {
Expand All @@ -38,8 +39,9 @@ contract('Claimable', function(accounts) {
try {
await claimable.transferOwnership(other, {from: other});
} catch(error) {
assertJump(error);
return assertJump(error);
}
assert.fail('should have thrown before');
});

describe('after initiating a transfer', function () {
Expand Down
56 changes: 30 additions & 26 deletions test/DayLimit.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ contract('DayLimit', function(accounts) {
try {
await dayLimit.attemptSpend(3);
} catch(error) {
assertJump(error);
return assertJump(error);
}
assert.fail('should have thrown before');
});

it('should allow spending if daily limit is reached and then set higher', async function() {
Expand All @@ -47,17 +48,18 @@ contract('DayLimit', function(accounts) {
assert.equal(spentToday, 8);

try {
await dayLimit.attemptSpend(3);
await dayLimit.attemptSpend(3);
} catch(error) {
assertJump(error);
}
spentToday = await dayLimit.spentToday();
assert.equal(spentToday, 8);
assertJump(error);
spentToday = await dayLimit.spentToday();
assert.equal(spentToday, 8);

await dayLimit.setDailyLimit(15);
await dayLimit.attemptSpend(3);
spentToday = await dayLimit.spentToday();
assert.equal(spentToday, 11);
await dayLimit.setDailyLimit(15);
await dayLimit.attemptSpend(3);
spentToday = await dayLimit.spentToday();
return assert.equal(spentToday, 11);
}
assert.fail('should have thrown before');
});

it('should allow spending if daily limit is reached and then amount spent is reset', async function() {
Expand All @@ -66,17 +68,18 @@ contract('DayLimit', function(accounts) {
assert.equal(spentToday, 8);

try {
await dayLimit.attemptSpend(3);
await dayLimit.attemptSpend(3);
} catch(error) {
assertJump(error);
}
spentToday = await dayLimit.spentToday();
assert.equal(spentToday, 8);
assertJump(error);
spentToday = await dayLimit.spentToday();
assert.equal(spentToday, 8);

await dayLimit.resetSpentToday(15);
await dayLimit.attemptSpend(3);
spentToday = await dayLimit.spentToday();
assert.equal(spentToday, 3);
await dayLimit.resetSpentToday(15);
await dayLimit.attemptSpend(3);
spentToday = await dayLimit.spentToday();
return assert.equal(spentToday, 3);
}
assert.fail('should have thrown before');
});

it('should allow spending if daily limit is reached and then the next has come', async function() {
Expand All @@ -91,15 +94,16 @@ contract('DayLimit', function(accounts) {
await dayLimit.attemptSpend(3);
} catch(error) {
assertJump(error);
}
spentToday = await dayLimit.spentToday();
assert.equal(spentToday, 8);
spentToday = await dayLimit.spentToday();
assert.equal(spentToday, 8);

await timer(day);
await timer(day);

await dayLimit.attemptSpend(3);
spentToday = await dayLimit.spentToday();
assert.equal(spentToday, 3);
await dayLimit.attemptSpend(3);
spentToday = await dayLimit.spentToday();
return assert.equal(spentToday, 3);
}
assert.fail('should have thrown before');
});

});
3 changes: 2 additions & 1 deletion test/Ownable.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ contract('Ownable', function(accounts) {
try {
await ownable.transferOwnership(other, {from: other});
} catch(error) {
assertJump(error);
return assertJump(error);
}
assert.fail('should have thrown before');
});

it('should guard ownership against stuck state', async function() {
Expand Down
15 changes: 8 additions & 7 deletions test/Pausable.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@ contract('Pausable', function(accounts) {
try {
await Pausable.normalProcess();
} catch(error) {
assertJump(error);
let count1 = await Pausable.count();
assert.equal(count1, 0);
return assertJump(error);
}
let count1 = await Pausable.count();
assert.equal(count1, 0);
assert.fail('should have thrown before');
});


Expand All @@ -36,11 +37,11 @@ contract('Pausable', function(accounts) {
try {
await Pausable.drasticMeasure();
} catch(error) {
assertJump(error);
const drasticMeasureTaken = await Pausable.drasticMeasureTaken();
assert.isFalse(drasticMeasureTaken);
return assertJump(error);
}

const drasticMeasureTaken = await Pausable.drasticMeasureTaken();
assert.isFalse(drasticMeasureTaken);
assert.fail('should have thrown before');
});

it('can take a drastic measure in a pause', async function() {
Expand Down