Browse Source

Add release method to Stoppable. Create StoppableMock

Arseniy Klempner 9 years ago
parent
commit
f0ed649db3
2 changed files with 23 additions and 1 deletions
  1. 6 1
      contracts/Stoppable.sol
  2. 17 0
      contracts/test-helpers/StoppableMock.sol

+ 6 - 1
contracts/Stoppable.sol

@@ -2,7 +2,7 @@ pragma solidity ^0.4.0;
 /*
  * Stoppable
  * Abstract contract that allows children to implement an
- * emergency stop mechanism. 
+ * emergency stop mechanism.
  */
 contract Stoppable {
   address public curator;
@@ -21,4 +21,9 @@ contract Stoppable {
     stopped = true;
   }
 
+  function release() external onlyInEmergency {
+    if (msg.sender != curator) throw;
+    stopped = false;
+  }
+
 }

+ 17 - 0
contracts/test-helpers/StoppableMock.sol

@@ -0,0 +1,17 @@
+pragma solidity ^0.4.0;
+import '../Stoppable.sol';
+
+// mock class using Stoppable
+contract StoppableMock is Stoppable {
+  bool public drasticMeasureTaken;
+  uint public count = 0;
+
+  function normalProcess() external stopInEmergency {
+    count++;
+  }
+
+  function drasticMeasure() external onlyInEmergency {
+    drasticMeasureTaken = true;
+  }
+
+}