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
dfc133d9
Commit
dfc133d9
authored
Oct 25, 2016
by
Arseniy Klempner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create tests for Stoppable.
parent
f0ed649d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
115 additions
and
2 deletions
+115
-2
StoppableMock.sol
contracts/test-helpers/StoppableMock.sol
+7
-2
Stoppable.js
test/Stoppable.js
+108
-0
No files found.
contracts/test-helpers/StoppableMock.sol
View file @
dfc133d9
...
...
@@ -2,9 +2,14 @@ pragma solidity ^0.4.0;
import '../Stoppable.sol';
// mock class using Stoppable
contract StoppableMock is Stoppable {
contract StoppableMock is Stoppable
(msg.sender)
{
bool public drasticMeasureTaken;
uint public count = 0;
uint public count;
function StoppableMock() Stoppable(msg.sender){
drasticMeasureTaken = false;
count = 0;
}
function normalProcess() external stopInEmergency {
count++;
...
...
test/Stoppable.js
0 → 100644
View file @
dfc133d9
contract
(
'Stoppable'
,
function
(
accounts
)
{
it
(
"can perform normal process in non-emergency"
,
function
(
done
)
{
var
stoppable
;
return
StoppableMock
.
new
(
accounts
[
0
])
.
then
(
function
(
_stoppable
)
{
stoppable
=
_stoppable
;
return
stoppable
.
count
();
})
.
then
(
function
(
count
)
{
assert
.
equal
(
count
,
0
);
})
.
then
(
function
()
{
return
stoppable
.
normalProcess
();
})
.
then
(
function
()
{
return
stoppable
.
count
();
})
.
then
(
function
(
count
)
{
assert
.
equal
(
count
,
1
);
})
.
then
(
done
);
});
it
(
"can not perform normal process in emergency"
,
function
(
done
)
{
var
stoppable
;
return
StoppableMock
.
new
(
accounts
[
0
])
.
then
(
function
(
_stoppable
)
{
stoppable
=
_stoppable
;
return
stoppable
.
emergencyStop
();
})
.
then
(
function
()
{
return
stoppable
.
count
();
})
.
then
(
function
(
count
)
{
assert
.
equal
(
count
,
0
);
})
.
then
(
function
()
{
return
stoppable
.
normalProcess
();
})
.
then
(
function
()
{
return
stoppable
.
count
();
})
.
then
(
function
(
count
)
{
assert
.
equal
(
count
,
0
);
})
.
then
(
done
);
});
it
(
"can not take drastic measure in non-emergency"
,
function
(
done
)
{
var
stoppable
;
return
StoppableMock
.
new
(
accounts
[
0
])
.
then
(
function
(
_stoppable
)
{
stoppable
=
_stoppable
;
return
stoppable
.
drasticMeasure
();
})
.
then
(
function
()
{
return
stoppable
.
drasticMeasureTaken
();
})
.
then
(
function
(
taken
)
{
assert
.
isFalse
(
taken
);
})
.
then
(
done
);
});
it
(
"can take a drastic measure in an emergency"
,
function
(
done
)
{
var
stoppable
;
return
StoppableMock
.
new
(
accounts
[
0
])
.
then
(
function
(
_stoppable
)
{
stoppable
=
_stoppable
;
return
stoppable
.
emergencyStop
();
})
.
then
(
function
()
{
return
stoppable
.
drasticMeasure
();
})
.
then
(
function
()
{
return
stoppable
.
drasticMeasureTaken
();
})
.
then
(
function
(
taken
)
{
assert
.
isTrue
(
taken
);
})
.
then
(
done
);
});
it
(
"should resume allowing normal process after emergency is over"
,
function
(
done
)
{
var
stoppable
;
return
StoppableMock
.
new
(
accounts
[
0
])
.
then
(
function
(
_stoppable
)
{
stoppable
=
_stoppable
;
return
stoppable
.
emergencyStop
();
})
.
then
(
function
()
{
return
stoppable
.
release
();
})
.
then
(
function
()
{
return
stoppable
.
normalProcess
();
})
.
then
(
function
()
{
return
stoppable
.
count
();
})
.
then
(
function
(
count
)
{
assert
.
equal
(
count
,
1
);
})
.
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