Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
O
openzeppelin-contracts-upgradeable
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
俞永鹏
openzeppelin-contracts-upgradeable
Commits
46736da4
Commit
46736da4
authored
Nov 29, 2017
by
zava
Committed by
Alejandro Santander
Jan 18, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added test for SimpleSavingsWallet
parent
82c85121
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
2 deletions
+38
-2
SimpleSavingsWallet.js
test/SimpleSavingsWallet.js
+38
-2
No files found.
test/SimpleSavingsWallet.js
View file @
46736da4
'use strict'
import
assertJump
from
'./helpers/assertJump'
const
SimpleSavingsWallet
=
artifacts
.
require
(
'../contracts/examples/SimpleSavingsWallet.sol'
)
...
...
@@ -6,11 +7,46 @@ contract('SimpleSavingsWallet', function(accounts) {
let
savingsWallet
let
owner
const
paymentAmount
=
4242
beforeEach
(
async
function
()
{
savingsWallet
=
await
SimpleSavingsWallet
.
new
(
4141
)
owner
=
await
inheritable
.
owner
()
owner
=
await
savingsWallet
.
owner
()
})
it
(
'should receive funds'
,
async
function
()
{
await
web3
.
eth
.
sendTransaction
({
from
:
owner
,
to
:
this
.
contract
.
address
,
value
:
amount
})
await
web3
.
eth
.
sendTransaction
({
from
:
owner
,
to
:
savingsWallet
.
address
,
value
:
paymentAmount
})
assert
.
isTrue
(
(
new
web3
.
BigNumber
(
paymentAmount
)).
equals
(
web3
.
eth
.
getBalance
(
savingsWallet
.
address
))
)
})
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
)
}
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
]))
)
})
})
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment