Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
186 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
<< Test DAO (since we need a token that we can send around in tests) >> | ||
*/ | ||
|
||
pragma solidity ^0.4.18; | ||
|
||
import "./dao/DelegatedShareholderAssociation.sol"; | ||
|
||
/** | ||
* @title TestDAO | ||
* @author Project Wyvern Developers | ||
* | ||
* | ||
*/ | ||
contract TestDAO is DelegatedShareholderAssociation { | ||
|
||
string public constant name = "Test DAO"; | ||
|
||
function TestDAO (ERC20 sharesAddress, uint minimumSharesToPassAVote, uint minutesForDebate) public { | ||
sharesTokenAddress = sharesAddress; | ||
minimumQuorum = minimumSharesToPassAVote; | ||
debatingPeriodInMinutes = minutesForDebate; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
<< Test Token (for use with the Test DAO) >> | ||
*/ | ||
|
||
pragma solidity ^0.4.18; | ||
|
||
import "zeppelin-solidity/contracts/token/StandardToken.sol"; | ||
|
||
/** | ||
* @title TestToken | ||
* @author Project Wyvern Developers | ||
* | ||
* | ||
*/ | ||
contract TestToken is StandardToken { | ||
|
||
uint constant public decimals = 18; | ||
string constant public name = "Test Token"; | ||
string constant public symbol = "TST"; | ||
|
||
uint constant public MINT_AMOUNT = 20000000 * (10 ** decimals); | ||
|
||
/** | ||
* @dev Initialize the test token | ||
*/ | ||
function TestToken () public { | ||
balances[msg.sender] = MINT_AMOUNT; | ||
totalSupply = MINT_AMOUNT; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* global artifacts: false */ | ||
|
||
const TestToken = artifacts.require('./TestToken.sol') | ||
const TestDAO = artifacts.require('./TestDAO.sol') | ||
|
||
module.exports = (deployer, network) => { | ||
if (network === 'development') { | ||
deployer.deploy(TestToken) | ||
.then(() => { | ||
return deployer.deploy(TestDAO, TestToken.address, Math.pow(10, 18) * 1000000, 60 * 24 * 7) | ||
}) | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* global artifacts:false, it:false, contract:false, assert:false */ | ||
|
||
const TestDAO = artifacts.require('TestDAO') | ||
const TestToken = artifacts.require('TestToken') | ||
|
||
const BigNumber = require('bignumber.js') | ||
|
||
contract('TestDAO', (accounts) => { | ||
it('should not allow delegation of more shares than owned', () => { | ||
return TestDAO | ||
.deployed() | ||
.then(daoInstance => { | ||
return daoInstance.setDelegateAndLockTokens.call((new BigNumber(Math.pow(10, 18 + 7)).mul(3)), accounts[1]) | ||
}) | ||
.then(ret => { | ||
assert.equal(true, false, 'Delegation was allowed without shares') | ||
}) | ||
.catch(err => { | ||
assert.equal(err.message, 'VM Exception while processing transaction: revert', 'Incorrect error') | ||
}) | ||
}) | ||
|
||
it('should allow share delegation after token allowance', () => { | ||
const amount = new BigNumber(Math.pow(10, 18 + 7)) | ||
return TestDAO | ||
.deployed() | ||
.then(daoInstance => { | ||
return TestToken | ||
.deployed() | ||
.then(tokenInstance => { | ||
return tokenInstance.approve.sendTransaction(daoInstance.address, amount) | ||
}) | ||
.then(() => { | ||
return daoInstance.setDelegateAndLockTokens.call(amount, accounts[1]) | ||
}) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* global artifacts:false, it:false, contract:false, assert:false */ | ||
|
||
const TestToken = artifacts.require('TestToken') | ||
|
||
const BigNumber = require('bignumber.js') | ||
|
||
contract('TestToken', (accounts) => { | ||
it('should set correct balance', () => { | ||
return TestToken | ||
.deployed() | ||
.then(tokenInstance => { | ||
return tokenInstance.balanceOf.call(accounts[0]) | ||
}) | ||
.then(amount => { | ||
assert.equal(amount.equals(new BigNumber(2 * Math.pow(10, 18 + 7))), true, 'Incorrect amount') | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters