aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts/src/current/test
diff options
context:
space:
mode:
authorAmir Bandeali <abandeali1@gmail.com>2018-02-02 07:48:06 +0800
committerAmir Bandeali <abandeali1@gmail.com>2018-02-03 01:39:08 +0800
commitd5d6079b673d0a6d311f349dba291da18c846d9e (patch)
treeb87cb20d4ce387cd35316d2785c3ab8968c51911 /packages/contracts/src/current/test
parentbb4c8bf8eb8c347900980d92534b19a3a80c690b (diff)
downloaddexon-sol-tools-d5d6079b673d0a6d311f349dba291da18c846d9e.tar.gz
dexon-sol-tools-d5d6079b673d0a6d311f349dba291da18c846d9e.tar.zst
dexon-sol-tools-d5d6079b673d0a6d311f349dba291da18c846d9e.zip
Rename directories
Diffstat (limited to 'packages/contracts/src/current/test')
-rw-r--r--packages/contracts/src/current/test/DummyToken/DummyToken.sol37
-rw-r--r--packages/contracts/src/current/test/MaliciousToken/MaliciousToken.sol31
-rw-r--r--packages/contracts/src/current/test/Mintable/Mintable.sol18
3 files changed, 86 insertions, 0 deletions
diff --git a/packages/contracts/src/current/test/DummyToken/DummyToken.sol b/packages/contracts/src/current/test/DummyToken/DummyToken.sol
new file mode 100644
index 000000000..ab04f4d16
--- /dev/null
+++ b/packages/contracts/src/current/test/DummyToken/DummyToken.sol
@@ -0,0 +1,37 @@
+pragma solidity ^0.4.18;
+
+import { Mintable } from "../Mintable/Mintable.sol";
+import { Ownable } from "../../utils/Ownable/Ownable.sol";
+
+contract DummyToken is Mintable, Ownable {
+ string public name;
+ string public symbol;
+ uint public decimals;
+
+ function DummyToken(
+ string _name,
+ string _symbol,
+ uint _decimals,
+ uint _totalSupply)
+ public
+ {
+ name = _name;
+ symbol = _symbol;
+ decimals = _decimals;
+ totalSupply = _totalSupply;
+ balances[msg.sender] = _totalSupply;
+ }
+
+ function setBalance(address _target, uint _value)
+ public
+ onlyOwner
+ {
+ uint currBalance = balanceOf(_target);
+ if (_value < currBalance) {
+ totalSupply = safeSub(totalSupply, safeSub(currBalance, _value));
+ } else {
+ totalSupply = safeAdd(totalSupply, safeSub(_value, currBalance));
+ }
+ balances[_target] = _value;
+ }
+}
diff --git a/packages/contracts/src/current/test/MaliciousToken/MaliciousToken.sol b/packages/contracts/src/current/test/MaliciousToken/MaliciousToken.sol
new file mode 100644
index 000000000..9e502616c
--- /dev/null
+++ b/packages/contracts/src/current/test/MaliciousToken/MaliciousToken.sol
@@ -0,0 +1,31 @@
+pragma solidity ^0.4.18;
+
+import { ERC20Token } from "../../tokens/ERC20Token/ERC20Token.sol";
+
+contract MaliciousToken is ERC20Token {
+ uint8 stateToUpdate = 1; // Not null so that change only requires 5000 gas
+
+ function updateState()
+ internal
+ {
+ stateToUpdate++;
+ }
+
+ function balanceOf(address _owner)
+ public
+ constant
+ returns (uint)
+ {
+ updateState();
+ return balances[_owner];
+ }
+
+ function allowance(address _owner, address _spender)
+ public
+ constant
+ returns (uint)
+ {
+ updateState();
+ return allowed[_owner][_spender];
+ }
+}
diff --git a/packages/contracts/src/current/test/Mintable/Mintable.sol b/packages/contracts/src/current/test/Mintable/Mintable.sol
new file mode 100644
index 000000000..cf7ee35a5
--- /dev/null
+++ b/packages/contracts/src/current/test/Mintable/Mintable.sol
@@ -0,0 +1,18 @@
+pragma solidity ^0.4.18;
+
+import { UnlimitedAllowanceToken } from "../../tokens/UnlimitedAllowanceToken/UnlimitedAllowanceToken.sol";
+import { SafeMath } from "../../utils/SafeMath/SafeMath.sol";
+
+/*
+ * Mintable
+ * Base contract that creates a mintable UnlimitedAllowanceToken
+ */
+contract Mintable is UnlimitedAllowanceToken, SafeMath {
+ function mint(uint _value)
+ public
+ {
+ require(_value <= 100000000000000000000);
+ balances[msg.sender] = safeAdd(_value, balances[msg.sender]);
+ totalSupply = safeAdd(totalSupply, _value);
+ }
+}