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
af388658
Commit
af388658
authored
Nov 23, 2016
by
Arseniy Klempner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create tests for Killable
parent
032cae05
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
69 additions
and
0 deletions
+69
-0
Killable.js
test/Killable.js
+69
-0
No files found.
test/Killable.js
0 → 100644
View file @
af388658
contract
(
'Killable'
,
function
(
accounts
)
{
//from https://gist.github.com/xavierlepretre/88682e871f4ad07be4534ae560692ee6
web3
.
eth
.
getTransactionReceiptMined
=
function
(
txnHash
,
interval
)
{
var
transactionReceiptAsync
;
interval
=
interval
?
interval
:
500
;
transactionReceiptAsync
=
function
(
txnHash
,
resolve
,
reject
)
{
try
{
var
receipt
=
web3
.
eth
.
getTransactionReceipt
(
txnHash
);
if
(
receipt
==
null
)
{
setTimeout
(
function
()
{
transactionReceiptAsync
(
txnHash
,
resolve
,
reject
);
},
interval
);
}
else
{
resolve
(
receipt
);
}
}
catch
(
e
)
{
reject
(
e
);
}
};
if
(
Array
.
isArray
(
txnHash
))
{
var
promises
=
[];
txnHash
.
forEach
(
function
(
oneTxHash
)
{
promises
.
push
(
web3
.
eth
.
getTransactionReceiptMined
(
oneTxHash
,
interval
));
});
return
Promise
.
all
(
promises
);
}
else
{
return
new
Promise
(
function
(
resolve
,
reject
)
{
transactionReceiptAsync
(
txnHash
,
resolve
,
reject
);
});
}
};
it
(
"should send balance to owner after death"
,
function
(
done
)
{
var
initBalance
,
newBalance
,
owner
,
address
,
killable
,
kBalance
;
web3
.
eth
.
sendTransaction
({
from
:
web3
.
eth
.
coinbase
,
to
:
accounts
[
0
],
value
:
web3
.
toWei
(
'50'
,
'ether'
)},
function
(
err
,
result
)
{
if
(
err
)
console
.
log
(
"ERROR:"
+
err
);
else
{
console
.
log
(
result
);
}
})
return
Killable
.
new
({
from
:
accounts
[
0
],
value
:
web3
.
toWei
(
'10'
,
'ether'
)})
.
then
(
function
(
_killable
)
{
killable
=
_killable
;
return
killable
.
owner
();
})
.
then
(
function
(
_owner
)
{
owner
=
_owner
;
initBalance
=
web3
.
eth
.
getBalance
(
owner
);
kBalance
=
web3
.
eth
.
getBalance
(
killable
.
address
);
})
.
then
(
function
()
{
return
killable
.
kill
.
call
({
from
:
owner
});
})
.
then
(
function
(
txnHash
)
{
return
web3
.
eth
.
getTransactionReceiptMined
(
txnHash
);
})
.
then
(
function
()
{
newBalance
=
web3
.
eth
.
getBalance
(
owner
);
})
.
then
(
function
()
{
assert
.
isTrue
(
newBalance
>
initBalance
);
})
.
then
(
done
);
});
});
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