From 9d7d621c9d8d655f25652897be60bc14652867be Mon Sep 17 00:00:00 2001 From: Jelle Gerbrandy Date: Wed, 22 Mar 2017 09:11:22 +0100 Subject: [PATCH] upgrade to truffle 3 --- .babelrc | 3 ++- package.json | 2 +- test/distributereputation.js | 9 ++++++--- test/distributetokens.js | 6 ++++-- test/genericaction.js | 5 +++++ test/genesisscheme.js | 2 ++ test/helpers.js | 24 ++++++++++++++++++++++-- test/mintabletoken.js | 9 +++++++-- test/reputation.js | 2 ++ test/simplecontribution.js | 3 +++ test/token.js | 9 ++++++--- test/tokensale.js | 3 +++ test/zeppelin-solidity/BasicToken.js | 3 +++ test/zeppelin-solidity/Killable.js | 4 +++- test/zeppelin-solidity/Ownable.js | 2 +- test/zeppelin-solidity/StandardToken.js | 2 ++ test/zeppelin-solidity/Stoppable.js | 3 +++ 17 files changed, 75 insertions(+), 16 deletions(-) diff --git a/.babelrc b/.babelrc index ce6eb60b..2d1e9350 100644 --- a/.babelrc +++ b/.babelrc @@ -1,3 +1,4 @@ { - "presets": ["es2015", "stage-2", "stage-3"] + "presets": ["es2015"], + "plugins": ["syntax-async-functions"] } diff --git a/package.json b/package.json index ff15269b..9e249364 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/test/distributereputation.js b/test/distributereputation.js index cb5c0c73..77e94222 100644 --- a/test/distributereputation.js +++ b/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]}); diff --git a/test/distributetokens.js b/test/distributetokens.js index 771a23f1..e06491e2 100644 --- a/test/distributetokens.js +++ b/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); diff --git a/test/genericaction.js b/test/genericaction.js index 3c01cf84..0c25dd3f 100644 --- a/test/genericaction.js +++ b/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() { diff --git a/test/genesisscheme.js b/test/genesisscheme.js index b5c52f47..ffc62743 100644 --- a/test/genesisscheme.js +++ b/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() { diff --git a/test/helpers.js b/test/helpers.js index 787c7103..81d0bd2e 100644 --- a/test/helpers.js +++ b/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 @@ -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(); @@ -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 diff --git a/test/mintabletoken.js b/test/mintabletoken.js index bc52365d..d94181d9 100644 --- a/test/mintabletoken.js +++ b/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) @@ -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(); diff --git a/test/reputation.js b/test/reputation.js index ba9540ab..dc092a95 100644 --- a/test/reputation.js +++ b/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() { diff --git a/test/simplecontribution.js b/test/simplecontribution.js index 58a6470c..c1970b72 100644 --- a/test/simplecontribution.js +++ b/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) { diff --git a/test/token.js b/test/token.js index 59d84e44..5e076c02 100644 --- a/test/token.js +++ b/test/token.js @@ -1,12 +1,15 @@ +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]); }); @@ -14,7 +17,7 @@ contract('Test Token', function(accounts) { 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); }); diff --git a/test/tokensale.js b/test/tokensale.js index 2b7d41c5..68a1a009 100644 --- a/test/tokensale.js +++ b/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() { diff --git a/test/zeppelin-solidity/BasicToken.js b/test/zeppelin-solidity/BasicToken.js index b899fb02..16bbbd2c 100644 --- a/test/zeppelin-solidity/BasicToken.js +++ b/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() { diff --git a/test/zeppelin-solidity/Killable.js b/test/zeppelin-solidity/Killable.js index 73bc8067..ebea9eb5 100644 --- a/test/zeppelin-solidity/Killable.js +++ b/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) { @@ -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); diff --git a/test/zeppelin-solidity/Ownable.js b/test/zeppelin-solidity/Ownable.js index c49e7259..5556c2e7 100644 --- a/test/zeppelin-solidity/Ownable.js +++ b/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; @@ -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(); diff --git a/test/zeppelin-solidity/StandardToken.js b/test/zeppelin-solidity/StandardToken.js index 293810ee..feab810a 100644 --- a/test/zeppelin-solidity/StandardToken.js +++ b/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() { diff --git a/test/zeppelin-solidity/Stoppable.js b/test/zeppelin-solidity/Stoppable.js index e8e6e2e8..93798e8a 100644 --- a/test/zeppelin-solidity/Stoppable.js +++ b/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() {