Skip to content
Closed
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
Prev Previous commit
Next Next commit
[SimpleSavingsWallet.js] replace assertJump for expectThrow
  • Loading branch information
azavalla committed Nov 30, 2017
commit a63fef7cf4966064d9edef4f9d2adf8fe7efc93e
27 changes: 5 additions & 22 deletions test/SimpleSavingsWallet.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use strict'
import assertJump from './helpers/assertJump'
import expectThrow from './helpers/expectThrow';

const SimpleSavingsWallet = artifacts.require('../contracts/examples/SimpleSavingsWallet.sol')

Expand All @@ -24,29 +24,12 @@ contract('SimpleSavingsWallet', function(accounts) {
it('owner can send funds', async function() {
// Receive payment so we have some money to spend.
await web3.eth.sendTransaction({from: accounts[9], to: savingsWallet.address, value: 1000000})
try {
await savingsWallet.sendTo(0, paymentAmount, {from: owner})
assert.fail('should have thrown before')
} 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)
}
await expectThrow(savingsWallet.sendTo(0, paymentAmount, {from: owner}))
await expectThrow(savingsWallet.sendTo(savingsWallet.address, paymentAmount, {from: owner}))
await expectThrow(savingsWallet.sendTo(accounts[1], 0, {from: owner}))

const balance = web3.eth.getBalance(accounts[1])
await savingsWallet.sendTo(accounts[1], paymentAmount, {from: owner})
assert.isTrue(
balance.plus(paymentAmount).equals(web3.eth.getBalance(accounts[1]))
)
assert.isTrue(balance.plus(paymentAmount).equals(web3.eth.getBalance(accounts[1])))
})
})