aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts/src/current/test
diff options
context:
space:
mode:
authorBrandon Millman <brandon.millman@gmail.com>2018-02-06 05:16:46 +0800
committerBrandon Millman <brandon.millman@gmail.com>2018-02-06 05:16:46 +0800
commit99b1f81e89e3ac929c7829552ea7ae19998524e9 (patch)
tree534161a9fa8bcf8bb5572d7ef0aa311fe9b9d116 /packages/contracts/src/current/test
parent6577d607332e2fb1a442d663e260ecb969457c36 (diff)
parent46ad7b1b38df0f302821258629ffa749e7dd00b9 (diff)
downloaddexon-sol-tools-99b1f81e89e3ac929c7829552ea7ae19998524e9.tar
dexon-sol-tools-99b1f81e89e3ac929c7829552ea7ae19998524e9.tar.gz
dexon-sol-tools-99b1f81e89e3ac929c7829552ea7ae19998524e9.tar.bz2
dexon-sol-tools-99b1f81e89e3ac929c7829552ea7ae19998524e9.tar.lz
dexon-sol-tools-99b1f81e89e3ac929c7829552ea7ae19998524e9.tar.xz
dexon-sol-tools-99b1f81e89e3ac929c7829552ea7ae19998524e9.tar.zst
dexon-sol-tools-99b1f81e89e3ac929c7829552ea7ae19998524e9.zip
Merge branch 'development' into feature/testnet-faucets/order-dispenser
* development: (37 commits) Add dates to CHANGELOGs Change CHANGELOGs Add .editorconfig Fix a typo Temp Use forEach instead of map Add PR number Fix an exception when a signature collision happens Fix prettier Add regression tests Improve the comment and fix an exception Add missing comas Lerna-ignore tslint and tsconfig Update contract versions, fix tests Rename directories Rename previous contracts, fix imports, add nested file structure Move all contracts into a single directory Update import Fix import Get rid of suffixed contract versioning and replace it with a poor-mans package manager. Versions are stored locally, and are generated in a copy-on-write basis as required ...
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);
+ }
+}