Renamed files and replaced occurencies of 'Stoppable' to 'Pausable'
This commit is contained in:
@ -5,11 +5,11 @@ import "../ownership/Ownable.sol";
|
|||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Stoppable
|
* Pausable
|
||||||
* Abstract contract that allows children to implement an
|
* Abstract contract that allows children to implement an
|
||||||
* emergency stop mechanism.
|
* emergency stop mechanism.
|
||||||
*/
|
*/
|
||||||
contract Stoppable is Ownable {
|
contract Pausable is Ownable {
|
||||||
bool public stopped;
|
bool public stopped;
|
||||||
|
|
||||||
modifier stopInEmergency { if (!stopped) _; }
|
modifier stopInEmergency { if (!stopped) _; }
|
||||||
@ -1,15 +1,15 @@
|
|||||||
pragma solidity ^0.4.4;
|
pragma solidity ^0.4.4;
|
||||||
|
|
||||||
|
|
||||||
import '../lifecycle/Stoppable.sol';
|
import '../lifecycle/Pausable.sol';
|
||||||
|
|
||||||
|
|
||||||
// mock class using Stoppable
|
// mock class using Pausable
|
||||||
contract StoppableMock is Stoppable {
|
contract PausableMock is Pausable {
|
||||||
bool public drasticMeasureTaken;
|
bool public drasticMeasureTaken;
|
||||||
uint public count;
|
uint public count;
|
||||||
|
|
||||||
function StoppableMock() {
|
function PausableMock() {
|
||||||
drasticMeasureTaken = false;
|
drasticMeasureTaken = false;
|
||||||
count = 0;
|
count = 0;
|
||||||
}
|
}
|
||||||
@ -26,7 +26,7 @@ The code is open-source, and `available on github <https://github.com/OpenZeppel
|
|||||||
:caption: Smart Contracts
|
:caption: Smart Contracts
|
||||||
|
|
||||||
ownable
|
ownable
|
||||||
stoppable
|
Pausable
|
||||||
killable
|
killable
|
||||||
claimable
|
claimable
|
||||||
migrations
|
migrations
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
Stoppable
|
Pausable
|
||||||
=============================================
|
=============================================
|
||||||
|
|
||||||
Base contract that provides an emergency stop mechanism.
|
Base contract that provides an emergency stop mechanism.
|
||||||
52
test/Pausable.js
Normal file
52
test/Pausable.js
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
contract('Pausable', function(accounts) {
|
||||||
|
|
||||||
|
it("can perform normal process in non-emergency", async function() {
|
||||||
|
let Pausable = await PausableMock.new();
|
||||||
|
let count0 = await Pausable.count();
|
||||||
|
assert.equal(count0, 0);
|
||||||
|
|
||||||
|
let normalProcess = await Pausable.normalProcess();
|
||||||
|
let count1 = await Pausable.count();
|
||||||
|
assert.equal(count1, 1);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("can not perform normal process in emergency", async function() {
|
||||||
|
let Pausable = await PausableMock.new();
|
||||||
|
let emergencyStop = await Pausable.emergencyStop();
|
||||||
|
let count0 = await Pausable.count();
|
||||||
|
assert.equal(count0, 0);
|
||||||
|
|
||||||
|
let normalProcess = await Pausable.normalProcess();
|
||||||
|
let count1 = await Pausable.count();
|
||||||
|
assert.equal(count1, 0);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
it("can not take drastic measure in non-emergency", async function() {
|
||||||
|
let Pausable = await PausableMock.new();
|
||||||
|
let drasticMeasure = await Pausable.drasticMeasure();
|
||||||
|
let drasticMeasureTaken = await Pausable.drasticMeasureTaken();
|
||||||
|
|
||||||
|
assert.isFalse(drasticMeasureTaken);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("can take a drastic measure in an emergency", async function() {
|
||||||
|
let Pausable = await PausableMock.new();
|
||||||
|
let emergencyStop = await Pausable.emergencyStop();
|
||||||
|
let drasticMeasure = await Pausable.drasticMeasure();
|
||||||
|
let drasticMeasureTaken = await Pausable.drasticMeasureTaken();
|
||||||
|
|
||||||
|
assert.isTrue(drasticMeasureTaken);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should resume allowing normal process after emergency is over", async function() {
|
||||||
|
let Pausable = await PausableMock.new();
|
||||||
|
let emergencyStop = await Pausable.emergencyStop();
|
||||||
|
let release = await Pausable.release();
|
||||||
|
let normalProcess = await Pausable.normalProcess();
|
||||||
|
let count0 = await Pausable.count();
|
||||||
|
|
||||||
|
assert.equal(count0, 1);
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
@ -1,52 +0,0 @@
|
|||||||
contract('Stoppable', function(accounts) {
|
|
||||||
|
|
||||||
it("can perform normal process in non-emergency", async function() {
|
|
||||||
let stoppable = await StoppableMock.new();
|
|
||||||
let count0 = await stoppable.count();
|
|
||||||
assert.equal(count0, 0);
|
|
||||||
|
|
||||||
let normalProcess = await stoppable.normalProcess();
|
|
||||||
let count1 = await stoppable.count();
|
|
||||||
assert.equal(count1, 1);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("can not perform normal process in emergency", async function() {
|
|
||||||
let stoppable = await StoppableMock.new();
|
|
||||||
let emergencyStop = await stoppable.emergencyStop();
|
|
||||||
let count0 = await stoppable.count();
|
|
||||||
assert.equal(count0, 0);
|
|
||||||
|
|
||||||
let normalProcess = await stoppable.normalProcess();
|
|
||||||
let count1 = await stoppable.count();
|
|
||||||
assert.equal(count1, 0);
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
it("can not take drastic measure in non-emergency", async function() {
|
|
||||||
let stoppable = await StoppableMock.new();
|
|
||||||
let drasticMeasure = await stoppable.drasticMeasure();
|
|
||||||
let drasticMeasureTaken = await stoppable.drasticMeasureTaken();
|
|
||||||
|
|
||||||
assert.isFalse(drasticMeasureTaken);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("can take a drastic measure in an emergency", async function() {
|
|
||||||
let stoppable = await StoppableMock.new();
|
|
||||||
let emergencyStop = await stoppable.emergencyStop();
|
|
||||||
let drasticMeasure = await stoppable.drasticMeasure();
|
|
||||||
let drasticMeasureTaken = await stoppable.drasticMeasureTaken();
|
|
||||||
|
|
||||||
assert.isTrue(drasticMeasureTaken);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should resume allowing normal process after emergency is over", async function() {
|
|
||||||
let stoppable = await StoppableMock.new();
|
|
||||||
let emergencyStop = await stoppable.emergencyStop();
|
|
||||||
let release = await stoppable.release();
|
|
||||||
let normalProcess = await stoppable.normalProcess();
|
|
||||||
let count0 = await stoppable.count();
|
|
||||||
|
|
||||||
assert.equal(count0, 1);
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
|
||||||
Reference in New Issue
Block a user