[SimpleSavingsWallet.js] replace assertJump for expectThrow
This commit is contained in:
committed by
Alejandro Santander
parent
c70ee937e6
commit
fe712c678a
@ -1,5 +1,5 @@
|
|||||||
'use strict'
|
'use strict'
|
||||||
import assertJump from './helpers/assertJump'
|
import expectThrow from './helpers/expectThrow';
|
||||||
|
|
||||||
const SimpleSavingsWallet = artifacts.require('../contracts/examples/SimpleSavingsWallet.sol')
|
const SimpleSavingsWallet = artifacts.require('../contracts/examples/SimpleSavingsWallet.sol')
|
||||||
|
|
||||||
@ -24,29 +24,12 @@ contract('SimpleSavingsWallet', function(accounts) {
|
|||||||
it('owner can send funds', async function() {
|
it('owner can send funds', async function() {
|
||||||
// Receive payment so we have some money to spend.
|
// Receive payment so we have some money to spend.
|
||||||
await web3.eth.sendTransaction({from: accounts[9], to: savingsWallet.address, value: 1000000})
|
await web3.eth.sendTransaction({from: accounts[9], to: savingsWallet.address, value: 1000000})
|
||||||
try {
|
await expectThrow(savingsWallet.sendTo(0, paymentAmount, {from: owner}))
|
||||||
await savingsWallet.sendTo(0, paymentAmount, {from: owner})
|
await expectThrow(savingsWallet.sendTo(savingsWallet.address, paymentAmount, {from: owner}))
|
||||||
assert.fail('should have thrown before')
|
await expectThrow(savingsWallet.sendTo(accounts[1], 0, {from: owner}))
|
||||||
} catch(error) {
|
|
||||||
assertJump(error)
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
await savingsWallet.sendTo(savingsWallet.address, paymentAmount, {from: owner})
|
|
||||||
assert.fail('should have thrown before')
|
|
||||||
} catch(error) {
|
|
||||||
assertJump(error)
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
await savingsWallet.sendTo(accounts[1], 0, {from: owner})
|
|
||||||
assert.fail('should have thrown before')
|
|
||||||
} catch(error) {
|
|
||||||
assertJump(error)
|
|
||||||
}
|
|
||||||
|
|
||||||
const balance = web3.eth.getBalance(accounts[1])
|
const balance = web3.eth.getBalance(accounts[1])
|
||||||
await savingsWallet.sendTo(accounts[1], paymentAmount, {from: owner})
|
await savingsWallet.sendTo(accounts[1], paymentAmount, {from: owner})
|
||||||
assert.isTrue(
|
assert.isTrue(balance.plus(paymentAmount).equals(web3.eth.getBalance(accounts[1])))
|
||||||
balance.plus(paymentAmount).equals(web3.eth.getBalance(accounts[1]))
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user