[Inheritable.js] replace assertJump for expectThrow

This commit is contained in:
zava
2017-11-30 12:30:52 -03:00
committed by Alejandro Santander
parent 46736da489
commit c70ee937e6

View File

@ -1,9 +1,6 @@
'use strict' 'use strict'
import { advanceBlock } from './helpers/advanceToBlock'
import increaseTime from './helpers/increaseTime' import increaseTime from './helpers/increaseTime'
import { increaseTimeTo, duration } from './helpers/increaseTime' import expectThrow from './helpers/expectThrow';
import assertJump from './helpers/assertJump'
const NULL_ADDRESS = '0x0000000000000000000000000000000000000000' const NULL_ADDRESS = '0x0000000000000000000000000000000000000000'
@ -39,12 +36,7 @@ contract('Inheritable', function(accounts) {
assert.isTrue(owner !== someRandomAddress) assert.isTrue(owner !== someRandomAddress)
await inheritable.setHeir(newHeir, {from: owner}) await inheritable.setHeir(newHeir, {from: owner})
try { await expectThrow(inheritable.setHeir(newHeir, {from: someRandomAddress}))
await inheritable.setHeir(newHeir, {from: someRandomAddress})
assert.fail('should have thrown before')
} catch(error) {
assertJump(error)
}
}) })
it('owner can remove heir', async function() { it('owner can remove heir', async function() {
@ -61,25 +53,15 @@ contract('Inheritable', function(accounts) {
it('heir can inherit only if owner is dead and timeout was reached', async function() { it('heir can inherit only if owner is dead and timeout was reached', async function() {
const heir = accounts[1] const heir = accounts[1]
await inheritable.setHeir(heir, {from: owner}) await inheritable.setHeir(heir, {from: owner})
await expectThrow(inheritable.inherit({from: heir}))
try {
await inheritable.inherit({from: heir})
assert.fail('should have thrown before')
} catch(error) {
assertJump(error)
}
await inheritable.proclaimDeath({from: heir}) await inheritable.proclaimDeath({from: heir})
await increaseTime(1) await increaseTime(1)
try { await expectThrow(inheritable.inherit({from: heir}))
await inheritable.inherit({from: heir})
assert.fail('should have thrown before')
} catch(error) {
assertJump(error)
}
await increaseTime(4141) await increaseTime(4141)
await inheritable.inherit({from: heir}) await inheritable.inherit({from: heir})
assert.isTrue(await inheritable.heir() === heir)
}) })
it('heir can\'t inherit if owner heartbeats', async function() { it('heir can\'t inherit if owner heartbeats', async function() {
@ -88,22 +70,12 @@ contract('Inheritable', function(accounts) {
await inheritable.proclaimDeath({from: heir}) await inheritable.proclaimDeath({from: heir})
await inheritable.heartbeat({from: owner}) await inheritable.heartbeat({from: owner})
try { await expectThrow(inheritable.inherit({from: heir}))
await inheritable.inherit({from: heir})
assert.fail('should have thrown before')
} catch(error) {
assertJump(error)
}
await inheritable.proclaimDeath({from: heir}) await inheritable.proclaimDeath({from: heir})
await increaseTime(4141) await increaseTime(4141)
await inheritable.heartbeat({from: owner}) await inheritable.heartbeat({from: owner})
try { await expectThrow(inheritable.inherit({from: heir}))
await inheritable.inherit({from: heir})
assert.fail('should have thrown before')
} catch(error) {
assertJump(error)
}
}) })
it('should log events appropriately', async function() { it('should log events appropriately', async function() {