aboutsummaryrefslogtreecommitdiffstats
path: root/test/compilationTests/zeppelin/Bounty.sol
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2017-07-05 18:28:15 +0800
committerchriseth <chris@ethereum.org>2017-07-05 18:39:55 +0800
commitac84b36144f746662e5ddb984d283e053c7d06ba (patch)
treef50ee438a384e60574a4c28ea32d2b6ae2315795 /test/compilationTests/zeppelin/Bounty.sol
parent05a26fc98c1201057c618c536ca0537e456c9b15 (diff)
downloaddexon-solidity-ac84b36144f746662e5ddb984d283e053c7d06ba.tar.gz
dexon-solidity-ac84b36144f746662e5ddb984d283e053c7d06ba.tar.zst
dexon-solidity-ac84b36144f746662e5ddb984d283e053c7d06ba.zip
Added various contracts for testing.
Diffstat (limited to 'test/compilationTests/zeppelin/Bounty.sol')
-rw-r--r--test/compilationTests/zeppelin/Bounty.sol78
1 files changed, 78 insertions, 0 deletions
diff --git a/test/compilationTests/zeppelin/Bounty.sol b/test/compilationTests/zeppelin/Bounty.sol
new file mode 100644
index 00000000..4425b7a5
--- /dev/null
+++ b/test/compilationTests/zeppelin/Bounty.sol
@@ -0,0 +1,78 @@
+pragma solidity ^0.4.11;
+
+
+import './payment/PullPayment.sol';
+import './lifecycle/Destructible.sol';
+
+
+/**
+ * @title Bounty
+ * @dev This bounty will pay out to a researcher if they break invariant logic of the contract.
+ */
+contract Bounty is PullPayment, Destructible {
+ bool public claimed;
+ mapping(address => address) public researchers;
+
+ event TargetCreated(address createdAddress);
+
+ /**
+ * @dev Fallback function allowing the contract to recieve funds, if they haven't already been claimed.
+ */
+ function() payable {
+ if (claimed) {
+ throw;
+ }
+ }
+
+ /**
+ * @dev Create and deploy the target contract (extension of Target contract), and sets the
+ * msg.sender as a researcher
+ * @return A target contract
+ */
+ function createTarget() returns(Target) {
+ Target target = Target(deployContract());
+ researchers[target] = msg.sender;
+ TargetCreated(target);
+ return target;
+ }
+
+ /**
+ * @dev Internal function to deploy the target contract.
+ * @return A target contract address
+ */
+ function deployContract() internal returns(address);
+
+ /**
+ * @dev Sends the contract funds to the researcher that proved the contract is broken.
+ * @param target contract
+ */
+ function claim(Target target) {
+ address researcher = researchers[target];
+ if (researcher == 0) {
+ throw;
+ }
+ // Check Target contract invariants
+ if (target.checkInvariant()) {
+ throw;
+ }
+ asyncSend(researcher, this.balance);
+ claimed = true;
+ }
+
+}
+
+
+/**
+ * @title Target
+ * @dev Your main contract should inherit from this class and implement the checkInvariant method.
+ */
+contract Target {
+
+ /**
+ * @dev Checks all values a contract assumes to be true all the time. If this function returns
+ * false, the contract is broken in some way and is in an inconsistent state.
+ * In order to win the bounty, security researchers will try to cause this broken state.
+ * @return True if all invariant values are correct, false otherwise.
+ */
+ function checkInvariant() returns(bool);
+}