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
721d8fbb
Commit
721d8fbb
authored
Oct 26, 2016
by
Makoto Inoue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pass factory address at contract creation phase
parent
a02a8a6e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
8 deletions
+29
-8
SimpleTokenBounty.sol
contracts/bounties/SimpleTokenBounty.sol
+7
-2
Bounty.js
test/Bounty.js
+22
-6
No files found.
contracts/bounties/SimpleTokenBounty.sol
View file @
721d8fbb
...
@@ -16,16 +16,21 @@ contract Target {
...
@@ -16,16 +16,21 @@ contract Target {
function checkInvariant() returns(bool);
function checkInvariant() returns(bool);
}
}
contract Bounty is PullPayment {
contract
SimpleToken
Bounty is PullPayment {
Target target;
Target target;
bool public claimed;
bool public claimed;
address public factoryAddress;
mapping(address => address) public researchers;
mapping(address => address) public researchers;
function() {
function() {
if (claimed) throw;
if (claimed) throw;
}
}
function createTarget(address factoryAddress) returns(Target) {
function SimpleTokenBounty(address _factoryAddress){
factoryAddress = _factoryAddress;
}
function createTarget() returns(Target) {
target = Target(Factory(factoryAddress).deployContract());
target = Target(Factory(factoryAddress).deployContract());
researchers[target] = msg.sender;
researchers[target] = msg.sender;
return target;
return target;
...
...
test/Bounty.js
View file @
721d8fbb
contract
(
'Bounty'
,
function
(
accounts
)
{
contract
(
'Bounty'
,
function
(
accounts
)
{
it
(
"can call checkInvariant for InsecureTargetMock"
,
function
(
done
){
it
(
"can create bounty contract with factory address"
,
function
(
done
){
var
bounty
=
Bounty
.
deployed
();
var
target
=
SecureTargetMock
.
deployed
();
var
target
=
SecureTargetMock
.
deployed
();
bounty
.
createTarget
(
target
.
address
).
SimpleTokenBounty
.
new
(
target
.
address
).
then
(
function
()
{
then
(
function
(
bounty
){
return
bounty
.
checkInvariant
.
call
()
return
bounty
.
factoryAddress
.
call
()
}).
then
(
function
(
address
){
assert
.
equal
(
address
,
target
.
address
)
}).
then
(
done
);
})
it
.
only
(
"can call checkInvariant for SecureTargetMock"
,
function
(
done
){
var
bounty
;
var
target
=
SecureTargetMock
.
deployed
();
SimpleTokenBounty
.
new
(
target
.
address
).
then
(
function
(
_bounty
)
{
bounty
=
_bounty
;
return
bounty
.
createTarget
.
sendTransaction
({
gas
:
200000
});
}).
}).
// then(function() {
// return bounty.checkInvariant.call()
// }).
then
(
function
(
result
)
{
then
(
function
(
result
)
{
assert
.
isTrue
(
result
);
assert
.
isTrue
(
result
);
}).
}).
...
@@ -13,7 +29,7 @@ contract('Bounty', function(accounts) {
...
@@ -13,7 +29,7 @@ contract('Bounty', function(accounts) {
})
})
it
(
"can call checkInvariant for InsecureTargetMock"
,
function
(
done
){
it
(
"can call checkInvariant for InsecureTargetMock"
,
function
(
done
){
var
bounty
=
Bounty
.
deployed
();
var
bounty
=
SimpleToken
Bounty
.
deployed
();
var
target
=
InsecureTargetMock
.
deployed
();
var
target
=
InsecureTargetMock
.
deployed
();
bounty
.
createTarget
(
target
.
address
).
bounty
.
createTarget
(
target
.
address
).
then
(
function
()
{
then
(
function
()
{
...
...
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