Skip to content

Commit

Permalink
[Inheritable.js] replace assertJump for expectThrow
Browse files Browse the repository at this point in the history
  • Loading branch information
azavalla authored and eternauta1337 committed Jan 18, 2018
1 parent 46736da commit c70ee93
Showing 1 changed file with 7 additions and 35 deletions.
42 changes: 7 additions & 35 deletions test/Inheritable.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
'use strict'
import { advanceBlock } from './helpers/advanceToBlock'
import increaseTime from './helpers/increaseTime'
import { increaseTimeTo, duration } from './helpers/increaseTime'
import assertJump from './helpers/assertJump'

import expectThrow from './helpers/expectThrow';

const NULL_ADDRESS = '0x0000000000000000000000000000000000000000'

Expand Down Expand Up @@ -39,12 +36,7 @@ contract('Inheritable', function(accounts) {
assert.isTrue(owner !== someRandomAddress)

await inheritable.setHeir(newHeir, {from: owner})
try {
await inheritable.setHeir(newHeir, {from: someRandomAddress})
assert.fail('should have thrown before')
} catch(error) {
assertJump(error)
}
await expectThrow(inheritable.setHeir(newHeir, {from: someRandomAddress}))
})

it('owner can remove heir', async function() {
Expand All @@ -61,25 +53,15 @@ contract('Inheritable', function(accounts) {
it('heir can inherit only if owner is dead and timeout was reached', async function() {
const heir = accounts[1]
await inheritable.setHeir(heir, {from: owner})

try {
await inheritable.inherit({from: heir})
assert.fail('should have thrown before')
} catch(error) {
assertJump(error)
}
await expectThrow(inheritable.inherit({from: heir}))

await inheritable.proclaimDeath({from: heir})
await increaseTime(1)
try {
await inheritable.inherit({from: heir})
assert.fail('should have thrown before')
} catch(error) {
assertJump(error)
}
await expectThrow(inheritable.inherit({from: heir}))

await increaseTime(4141)
await inheritable.inherit({from: heir})
assert.isTrue(await inheritable.heir() === heir)
})

it('heir can\'t inherit if owner heartbeats', async function() {
Expand All @@ -88,22 +70,12 @@ contract('Inheritable', function(accounts) {

await inheritable.proclaimDeath({from: heir})
await inheritable.heartbeat({from: owner})
try {
await inheritable.inherit({from: heir})
assert.fail('should have thrown before')
} catch(error) {
assertJump(error)
}
await expectThrow(inheritable.inherit({from: heir}))

await inheritable.proclaimDeath({from: heir})
await increaseTime(4141)
await inheritable.heartbeat({from: owner})
try {
await inheritable.inherit({from: heir})
assert.fail('should have thrown before')
} catch(error) {
assertJump(error)
}
await expectThrow(inheritable.inherit({from: heir}))
})

it('should log events appropriately', async function() {
Expand Down

0 comments on commit c70ee93

Please sign in to comment.