aboutsummaryrefslogtreecommitdiffstats
path: root/test/compilationTests/zeppelin/lifecycle
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2017-07-12 21:03:29 +0800
committerGitHub <noreply@github.com>2017-07-12 21:03:29 +0800
commit106acd9cbb827a39cd9bfd67866dafe0eeeb31de (patch)
treed51cec3ba7cad7ccad440312ae2e19a7a62d2509 /test/compilationTests/zeppelin/lifecycle
parentfca8d781b4490026dce657fd344a1fe36c9179f2 (diff)
parentac84b36144f746662e5ddb984d283e053c7d06ba (diff)
downloaddexon-solidity-106acd9cbb827a39cd9bfd67866dafe0eeeb31de.tar.gz
dexon-solidity-106acd9cbb827a39cd9bfd67866dafe0eeeb31de.tar.zst
dexon-solidity-106acd9cbb827a39cd9bfd67866dafe0eeeb31de.zip
Merge pull request #2522 from ethereum/testCode
Added various contracts for testing.
Diffstat (limited to 'test/compilationTests/zeppelin/lifecycle')
-rw-r--r--test/compilationTests/zeppelin/lifecycle/Destructible.sol25
-rw-r--r--test/compilationTests/zeppelin/lifecycle/Migrations.sol21
-rw-r--r--test/compilationTests/zeppelin/lifecycle/Pausable.sol51
-rw-r--r--test/compilationTests/zeppelin/lifecycle/TokenDestructible.sol36
4 files changed, 133 insertions, 0 deletions
diff --git a/test/compilationTests/zeppelin/lifecycle/Destructible.sol b/test/compilationTests/zeppelin/lifecycle/Destructible.sol
new file mode 100644
index 00000000..3561e3b7
--- /dev/null
+++ b/test/compilationTests/zeppelin/lifecycle/Destructible.sol
@@ -0,0 +1,25 @@
+pragma solidity ^0.4.11;
+
+
+import "../ownership/Ownable.sol";
+
+
+/**
+ * @title Destructible
+ * @dev Base contract that can be destroyed by owner. All funds in contract will be sent to the owner.
+ */
+contract Destructible is Ownable {
+
+ function Destructible() payable { }
+
+ /**
+ * @dev Transfers the current balance to the owner and terminates the contract.
+ */
+ function destroy() onlyOwner {
+ selfdestruct(owner);
+ }
+
+ function destroyAndSend(address _recipient) onlyOwner {
+ selfdestruct(_recipient);
+ }
+}
diff --git a/test/compilationTests/zeppelin/lifecycle/Migrations.sol b/test/compilationTests/zeppelin/lifecycle/Migrations.sol
new file mode 100644
index 00000000..d5b05308
--- /dev/null
+++ b/test/compilationTests/zeppelin/lifecycle/Migrations.sol
@@ -0,0 +1,21 @@
+pragma solidity ^0.4.11;
+
+
+import '../ownership/Ownable.sol';
+
+/**
+ * @title Migrations
+ * @dev This is a truffle contract, needed for truffle integration, not meant for use by Zeppelin users.
+ */
+contract Migrations is Ownable {
+ uint256 public lastCompletedMigration;
+
+ function setCompleted(uint256 completed) onlyOwner {
+ lastCompletedMigration = completed;
+ }
+
+ function upgrade(address newAddress) onlyOwner {
+ Migrations upgraded = Migrations(newAddress);
+ upgraded.setCompleted(lastCompletedMigration);
+ }
+}
diff --git a/test/compilationTests/zeppelin/lifecycle/Pausable.sol b/test/compilationTests/zeppelin/lifecycle/Pausable.sol
new file mode 100644
index 00000000..b14f8767
--- /dev/null
+++ b/test/compilationTests/zeppelin/lifecycle/Pausable.sol
@@ -0,0 +1,51 @@
+pragma solidity ^0.4.11;
+
+
+import "../ownership/Ownable.sol";
+
+
+/**
+ * @title Pausable
+ * @dev Base contract which allows children to implement an emergency stop mechanism.
+ */
+contract Pausable is Ownable {
+ event Pause();
+ event Unpause();
+
+ bool public paused = false;
+
+
+ /**
+ * @dev modifier to allow actions only when the contract IS paused
+ */
+ modifier whenNotPaused() {
+ if (paused) throw;
+ _;
+ }
+
+ /**
+ * @dev modifier to allow actions only when the contract IS NOT paused
+ */
+ modifier whenPaused {
+ if (!paused) throw;
+ _;
+ }
+
+ /**
+ * @dev called by the owner to pause, triggers stopped state
+ */
+ function pause() onlyOwner whenNotPaused returns (bool) {
+ paused = true;
+ Pause();
+ return true;
+ }
+
+ /**
+ * @dev called by the owner to unpause, returns to normal state
+ */
+ function unpause() onlyOwner whenPaused returns (bool) {
+ paused = false;
+ Unpause();
+ return true;
+ }
+}
diff --git a/test/compilationTests/zeppelin/lifecycle/TokenDestructible.sol b/test/compilationTests/zeppelin/lifecycle/TokenDestructible.sol
new file mode 100644
index 00000000..fe0b46b6
--- /dev/null
+++ b/test/compilationTests/zeppelin/lifecycle/TokenDestructible.sol
@@ -0,0 +1,36 @@
+pragma solidity ^0.4.11;
+
+
+import "../ownership/Ownable.sol";
+import "../token/ERC20Basic.sol";
+
+/**
+ * @title TokenDestructible:
+ * @author Remco Bloemen <remco@2π.com>
+ * @dev Base contract that can be destroyed by owner. All funds in contract including
+ * listed tokens will be sent to the owner.
+ */
+contract TokenDestructible is Ownable {
+
+ function TokenDestructible() payable { }
+
+ /**
+ * @notice Terminate contract and refund to owner
+ * @param tokens List of addresses of ERC20 or ERC20Basic token contracts to
+ refund.
+ * @notice The called token contracts could try to re-enter this contract. Only
+ supply token contracts you trust.
+ */
+ function destroy(address[] tokens) onlyOwner {
+
+ // Transfer tokens to owner
+ for(uint256 i = 0; i < tokens.length; i++) {
+ ERC20Basic token = ERC20Basic(tokens[i]);
+ uint256 balance = token.balanceOf(this);
+ token.transfer(owner, balance);
+ }
+
+ // Transfer Eth to owner and terminate contract
+ selfdestruct(owner);
+ }
+}