Skip to content

Commit

Permalink
upgrade to truffle 3
Browse files Browse the repository at this point in the history
  • Loading branch information
jellegerbrandy committed Mar 22, 2017
1 parent 190352a commit 9d7d621
Show file tree
Hide file tree
Showing 17 changed files with 75 additions and 16 deletions.
3 changes: 2 additions & 1 deletion .babelrc
@@ -1,3 +1,4 @@
{
"presets": ["es2015", "stage-2", "stage-3"]
"presets": ["es2015"],
"plugins": ["syntax-async-functions"]
}
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -13,8 +13,8 @@
},
"devDependencies": {
"truffle-contract": "^1.1.10",
"truffle-solidity-loader": "git+https://github.com/sogoiii/truffle-solidity-loader.git#1f1e213d52f033b6863218307b8968ae68220fe1",
"babel-preset-es2015": "^6.6.0",
"babel-plugin-syntax-async-functions": "^6.1.4",
"ethereumjs-testrpc": "^3.0.0",
"pm2": "^1.1.3",
"solc": "^0.3.5",
Expand Down
9 changes: 6 additions & 3 deletions test/distributereputation.js
@@ -1,19 +1,22 @@
const helpers = require('./helpers')

contract('Proposal to distribute Tokens', function(accounts) {
var SimpleVote = artifacts.require("./SimpleVote.sol");
var SimpleContribution = artifacts.require("./SimpleContribution.sol");

contract('Proposal to distribute Reputation', function(accounts) {
it("should respect basic sanity", async function() {
let submissionFee = 0;

await helpers.setupController(this)

// set up a distribution scheme for minting tokens

let contributionVotingScheme = await SimpleVote.new();
let contributionScheme = await SimpleContribution.new(
this.controllerAddress,
submissionFee,
contributionVotingScheme.address,
contributionVotingScheme.address
);

// vote and accept the schema (founders[1] has the majority)
await this.genesis.proposeScheme(contributionScheme.address);
await this.genesis.voteScheme(contributionScheme.address, true, {from: this.founders[1]});
Expand Down
6 changes: 4 additions & 2 deletions test/distributetokens.js
@@ -1,18 +1,20 @@
const helpers = require('./helpers')

var SimpleVote = artifacts.require("./SimpleVote.sol");
var SimpleContribution = artifacts.require("./SimpleContribution.sol");

contract('Proposal to distribute Tokens', function(accounts) {
it("should respect basic sanity", async function() {
let submissionFee = 0;

await helpers.setupController(this)

// set up a distribution scheme for minting tokens

let contributionVotingScheme = await SimpleVote.new();
let contributionScheme = await SimpleContribution.new(
this.controllerAddress,
submissionFee,
contributionVotingScheme.address,
contributionVotingScheme.address
);
// vote and accept the schema (founders[1] has the majority)
await this.genesis.proposeScheme(contributionScheme.address);
Expand Down
5 changes: 5 additions & 0 deletions test/genericaction.js
@@ -1,6 +1,11 @@
const helpers = require('./helpers')
const assertJump = require('./zeppelin-solidity/helpers/assertJump');

var StandardTokenMock = artifacts.require("./StandardTokenMock.sol");
var TokenSale = artifacts.require("./TokenSale.sol");
var WithdrawEtherFromOldController = artifacts.require("./WithdrawEtherFromOldController.sol");


contract('TokenSale', function(accounts) {

it("simple scenario - buy tokens", async function() {
Expand Down
2 changes: 2 additions & 0 deletions test/genesisscheme.js
@@ -1,6 +1,8 @@
const helpers = require('./helpers')
const assertJump = require('./zeppelin-solidity/helpers/assertJump');

var SimpleVote = artifacts.require("./SimpleVote.sol");

contract('GenesisScheme', function(accounts) {

it("founders should get their share", async function() {
Expand Down
24 changes: 22 additions & 2 deletions test/helpers.js
@@ -1,3 +1,12 @@

var Controller = artifacts.require("./Controller.sol");
var GenesisScheme = artifacts.require("./GenesisScheme.sol");
var MintableToken = artifacts.require("./MintableToken.sol");
// var Proposal = artifacts.require("./Proposal.sol");
var Reputation = artifacts.require("./Reputation.sol");
var SimpleVote = artifacts.require("./SimpleVote.sol");
var SimpleContribution = artifacts.require("./SimpleContribution.sol");

function getProposalAddress(tx) {

// helper function that returns a proposal object from the ProposalCreated event
Expand Down Expand Up @@ -50,11 +59,21 @@ async function setupDAO(ctx) {

module.exports.setupDAO = setupDAO

async function tokensforeveryone() {
let accounts = web3.eth.accounts;
for (let i=0; i < 10; i++) {
await web3.eth.sendTransaction({to: accounts[i], from: accounts[0], value: web3.toWei(0.1, "ether")})
}
}

module.exports.tokensforeveryone = tokensforeveryone

async function setupController(ctx, founders, tokenForFounders=[1, 2, 4], repForFounders=[7, 100, 12]) {
let accounts = web3.eth.accounts;
tokensforeveryone();

if (founders == undefined) {
founders = [accounts[0],accounts[1],accounts[2]];
founders = [accounts[0], accounts[1], accounts[2]];
}

let votingScheme = await SimpleVote.new();
Expand All @@ -67,7 +86,8 @@ async function setupController(ctx, founders, tokenForFounders=[1, 2, 4], repFor
votingScheme.address);

for (let i = 0 ; i < founders.length ; i++ ) {
await genesis.collectFoundersShare({'from': founders[i]});
// send some ether to the founder so she can collect her share
await genesis.collectFoundersShare({'from': founders[i]});
}

ctx.founders = founders
Expand Down
9 changes: 7 additions & 2 deletions test/mintabletoken.js
@@ -1,7 +1,11 @@
const helpers = require('./helpers')
var MintableToken = artifacts.require("./MintableToken.sol");

contract('Test MintableToken', function(accounts) {
it("should mint tokens to owner account", async function() {
helpers.tokensforeveryone()
let owner, totalSupply, userSupply
let token = MintableToken.deployed();
let token = await MintableToken.new();
totalSupply = await token.totalSupply();
owner = await token.owner()
userSupply = await token.balanceOf(owner)
Expand All @@ -23,7 +27,8 @@ contract('Test MintableToken', function(accounts) {
});

it("should allow minting tokens only by owner", async function() {
let token = MintableToken.deployed();
helpers.tokensforeveryone()
let token = await MintableToken.new();
let owner = await token.owner()
let totalSupply = await token.totalSupply();

Expand Down
2 changes: 2 additions & 0 deletions test/reputation.js
@@ -1,5 +1,7 @@
const assertJump = require('./zeppelin-solidity/helpers/assertJump');

var Reputation = artifacts.require("./Reputation.sol");


contract('Test Reputation', function(accounts) {
it("test setting and getting reputation by the owner", async function() {
Expand Down
3 changes: 3 additions & 0 deletions test/simplecontribution.js
@@ -1,6 +1,9 @@
const helpers = require('./helpers')
const assertJump = require('./zeppelin-solidity/helpers/assertJump');

var SimpleVote = artifacts.require("./SimpleVote.sol");
var SimpleContribution = artifacts.require("./SimpleContribution.sol");


contract('SimpleContribution', function(accounts) {

Expand Down
9 changes: 6 additions & 3 deletions test/token.js
@@ -1,20 +1,23 @@
const helpers = require('./helpers')
var MintableToken = artifacts.require("./MintableToken.sol");

contract('Test Token', function(accounts) {
it("should put 10000 Coins in the first account", async function() {
let token = MintableToken.deployed();
let token = await MintableToken.new();
let balance = await token.balanceOf.call(accounts[0])
assert.equal(balance.valueOf(), 0)
});

it("should be owned by the creator account", async function() {
let token = MintableToken.deployed();
let token = await MintableToken.new();
let owner = await token.owner();
assert.equal(owner, accounts[0]);
});

it("should be killable", async function() {
// we only test that the function actually exists
// "real" tests are in zeppelin-solidity/Killable.js
let token = MintableToken.deployed();
let token = await MintableToken.new();
let txnhash = await token.kill();
assert.isOk(txnhash);
});
Expand Down
3 changes: 3 additions & 0 deletions test/tokensale.js
@@ -1,5 +1,8 @@
const helpers = require('./helpers')

var TokenSale = artifacts.require("./TokenSale.sol");


contract('TokenSale', function(accounts) {

it("simple scenario - buy tokens", async function() {
Expand Down
3 changes: 3 additions & 0 deletions test/zeppelin-solidity/BasicToken.js
@@ -1,5 +1,8 @@
const assertJump = require('./helpers/assertJump');

var BasicTokenMock = artifacts.require("./BasicTokenMock.sol");


contract('BasicToken', function(accounts) {

it("should return the correct totalSupply after construction", async function() {
Expand Down
4 changes: 3 additions & 1 deletion test/zeppelin-solidity/Killable.js
@@ -1,4 +1,6 @@

var Killable = artifacts.require("./Killable.sol");

contract('Killable', function(accounts) {
//from https://gist.github.com/xavierlepretre/88682e871f4ad07be4534ae560692ee6
web3.eth.getTransactionReceiptMined = function (txnHash, interval) {
Expand Down Expand Up @@ -47,7 +49,7 @@ contract('Killable', function(accounts) {
initBalance = web3.eth.getBalance(owner);
kBalance = web3.eth.getBalance(killable.address);
txnHash = await killable.kill({from: owner});
receiptMined = await web3.eth.getTransactionReceiptMined(txnHash);
// receiptMined = await web3.eth.getTransactionReceiptMined(txnHash);
newBalance = web3.eth.getBalance(owner);

assert.isTrue(newBalance > initBalance);
Expand Down
2 changes: 1 addition & 1 deletion test/zeppelin-solidity/Ownable.js
@@ -1,5 +1,6 @@
/* https://github.com/OpenZeppelin/zeppelin-solidity/blob/eb41a81faac5fcf865608cd549d7e19579ec601a/test/Ownable.js */

var Ownable = artifacts.require("./Ownable.sol");

contract('Ownable', function(accounts) {
let ownable;
Expand Down Expand Up @@ -30,7 +31,6 @@ contract('Ownable', function(accounts) {
});

it("should guard ownership against stuck state", async function() {
let ownable = Ownable.deployed();
let originalOwner = await ownable.owner();
let transfer = await ownable.transferOwnership(null, {from: originalOwner});
let newOwner = await ownable.owner();
Expand Down
2 changes: 2 additions & 0 deletions test/zeppelin-solidity/StandardToken.js
@@ -1,5 +1,7 @@
const assertJump = require('./helpers/assertJump');

var StandardTokenMock = artifacts.require("./StandardTokenMock.sol");

contract('StandardToken', function(accounts) {

it("should return the correct totalSupply after construction", async function() {
Expand Down
3 changes: 3 additions & 0 deletions test/zeppelin-solidity/Stoppable.js
@@ -1,3 +1,6 @@

var StoppableMock = artifacts.require("./StoppableMock.sol");

contract('Stoppable', function(accounts) {

it("can perform normal process in non-emergency", async function() {
Expand Down

0 comments on commit 9d7d621

Please sign in to comment.