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
0aa4d020
Commit
0aa4d020
authored
Nov 16, 2016
by
AugustoL
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DelayedClaimable contract with test added
parent
e1dcab29
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
84 additions
and
1 deletions
+84
-1
Claimable.sol
contracts/Claimable.sol
+1
-1
DelayedClaimable.sol
contracts/DelayedClaimable.sol
+25
-0
DelayedClaimble.js
test/DelayedClaimble.js
+58
-0
No files found.
contracts/Claimable.sol
View file @
0aa4d020
pragma solidity ^0.4.
0
;
pragma solidity ^0.4.
4
;
import './Ownable.sol';
/*
...
...
contracts/DelayedClaimable.sol
0 → 100644
View file @
0aa4d020
pragma solidity ^0.4.4;
import './Ownable.sol';
import './Claimable.sol';
/*
* DelayedClaimable
* Extension for the Claimable contract, where the ownership needs to be claimed before certain time
*/
contract DelayedClaimable is Ownable, Claimable {
uint public claimBefore;
function setDelay(uint _claimBefore) onlyOwner {
claimBefore = _claimBefore;
}
function claimOwnership() onlyPendingOwner {
if (block.number > claimBefore)
throw;
owner = pendingOwner;
pendingOwner = 0x0;
claimBefore = 0;
}
}
test/DelayedClaimble.js
0 → 100644
View file @
0aa4d020
contract
(
'DelayedClaimable'
,
function
(
accounts
)
{
var
delayedClaimable
;
beforeEach
(
function
()
{
return
DelayedClaimable
.
new
().
then
(
function
(
deployed
)
{
delayedClaimable
=
deployed
;
});
});
it
(
"changes pendingOwner after transfer succesful"
,
function
(
done
)
{
var
newOwner
=
accounts
[
2
];
return
delayedClaimable
.
transfer
(
newOwner
)
.
then
(
function
(){
return
delayedClaimable
.
setDelay
(
1000
)
})
.
then
(
function
(){
return
delayedClaimable
.
claimBefore
();
})
.
then
(
function
(
claimBefore
)
{
assert
.
isTrue
(
claimBefore
==
1000
);
return
delayedClaimable
.
pendingOwner
();
})
.
then
(
function
(
pendingOwner
)
{
assert
.
isTrue
(
pendingOwner
===
newOwner
);
delayedClaimable
.
claimOwnership
({
from
:
newOwner
});
return
delayedClaimable
.
owner
();
})
.
then
(
function
(
owner
)
{
assert
.
isTrue
(
owner
===
newOwner
);
})
.
then
(
done
)
});
it
(
"changes pendingOwner after transfer fails"
,
function
(
done
)
{
var
newOwner
=
accounts
[
1
];
return
delayedClaimable
.
transfer
(
newOwner
)
.
then
(
function
(){
return
delayedClaimable
.
setDelay
(
1
)
})
.
then
(
function
(){
return
delayedClaimable
.
claimBefore
();
})
.
then
(
function
(
claimBefore
)
{
assert
.
isTrue
(
claimBefore
==
1
);
return
delayedClaimable
.
pendingOwner
();
})
.
then
(
function
(
pendingOwner
)
{
assert
.
isTrue
(
pendingOwner
===
newOwner
);
// delayedClaimable.claimOwnership({from: newOwner}); Uncomment to break the test.
return
delayedClaimable
.
owner
();
})
.
then
(
function
(
owner
)
{
assert
.
isTrue
(
owner
!=
newOwner
);
})
.
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