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
e318d6d2
Commit
e318d6d2
authored
Oct 22, 2016
by
Makoto Inoue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Swap target contract at test by using abstract interface
parent
8df9925d
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
35 additions
and
9 deletions
+35
-9
SimpleTokenBounty.sol
contracts/bounties/SimpleTokenBounty.sol
+3
-6
InsecureTargetMock.sol
contracts/test-helpers/InsecureTargetMock.sol
+7
-0
SecureTargetMock.sol
contracts/test-helpers/SecureTargetMock.sol
+7
-0
2_deploy_contracts.js
migrations/2_deploy_contracts.js
+2
-0
Bounty.js
test/Bounty.js
+16
-3
No files found.
contracts/bounties/SimpleTokenBounty.sol
View file @
e318d6d2
...
...
@@ -9,9 +9,7 @@ import '../PullPayment.sol';
*/
contract Target {
function checkInvarient() returns(bool){
return true;
}
function checkInvarient() returns(bool);
}
contract Bounty is PullPayment {
...
...
@@ -23,8 +21,8 @@ contract Bounty is PullPayment {
if (claimed) throw;
}
function createTarget() returns(Target) {
target =
new Target(
);
function createTarget(
address targetAddress
) returns(Target) {
target =
Target(targetAddress
);
researchers[target] = msg.sender;
return target;
}
...
...
@@ -37,7 +35,6 @@ contract Bounty is PullPayment {
address researcher = researchers[target];
if (researcher == 0) throw;
// Check Target contract invariants
// Customize this to the specifics of your contract
if (!target.checkInvarient()) {
throw;
}
...
...
contracts/test-helpers/InsecureTargetMock.sol
0 → 100644
View file @
e318d6d2
pragma solidity ^0.4.0;
contract InsecureTargetMock {
function checkInvarient() returns(bool){
return false;
}
}
contracts/test-helpers/SecureTargetMock.sol
0 → 100644
View file @
e318d6d2
pragma solidity ^0.4.0;
contract SecureTargetMock {
function checkInvarient() returns(bool){
return true;
}
}
migrations/2_deploy_contracts.js
View file @
e318d6d2
...
...
@@ -6,4 +6,6 @@ module.exports = function(deployer) {
deployer
.
deploy
(
CrowdsaleTokenBounty
);
deployer
.
deploy
(
Ownable
);
deployer
.
deploy
(
LimitFunds
);
deployer
.
deploy
(
SecureTargetMock
);
deployer
.
deploy
(
InsecureTargetMock
);
};
test/Bounty.js
View file @
e318d6d2
contract
(
'Bounty'
,
function
(
accounts
)
{
it
.
only
(
"c
reate target
"
,
function
(
done
){
it
.
only
(
"c
an call checkInvarient for InsecureTargetMock
"
,
function
(
done
){
var
bounty
=
Bounty
.
deployed
();
bounty
.
createTarget
().
var
target
=
SecureTargetMock
.
deployed
();
bounty
.
createTarget
(
target
.
address
).
then
(
function
()
{
return
bounty
.
checkInvarient
.
call
()
}).
...
...
@@ -11,4 +11,17 @@ contract('Bounty', function(accounts) {
}).
then
(
done
);
})
it
(
"can call checkInvarient for InsecureTargetMock"
,
function
(
done
){
var
bounty
=
Bounty
.
deployed
();
var
target
=
InsecureTargetMock
.
deployed
();
bounty
.
createTarget
(
target
.
address
).
then
(
function
()
{
return
bounty
.
checkInvarient
.
call
()
}).
then
(
function
(
result
)
{
assert
.
isFalse
(
result
);
}).
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