From acb63a72ef2f07bbbcc92e6cc4f220e64d693fda Mon Sep 17 00:00:00 2001 From: Marcel Blijleven Date: Wed, 11 Apr 2018 18:23:43 +0200 Subject: [PATCH 01/15] Added Travis file for Travis implementation Added travis file Added newline to eof Cleaned up file --- .travis.yaml | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 .travis.yaml diff --git a/.travis.yaml b/.travis.yaml new file mode 100644 index 0000000..cbc10aa --- /dev/null +++ b/.travis.yaml @@ -0,0 +1,12 @@ +language: node_js +node_js: + - "stable" + +before_install: + - npm install -g truffle ethereumjs-testrpc + +script: + - testrpc > /dev/null & + - sleep 5 + - truffle migrate + - truffle test From 4f56144f275890db69d31af402fa6af8d2648fb2 Mon Sep 17 00:00:00 2001 From: Marcel Blijleven Date: Wed, 11 Apr 2018 18:33:13 +0200 Subject: [PATCH 02/15] Renamed travis.yaml to travis.yml --- .travis.yaml => .travis.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .travis.yaml => .travis.yml (100%) diff --git a/.travis.yaml b/.travis.yml similarity index 100% rename from .travis.yaml rename to .travis.yml From 9ed020667c81852f5fcc99404fc5ee73b7f13c82 Mon Sep 17 00:00:00 2001 From: Marcel Blijleven Date: Wed, 11 Apr 2018 18:57:20 +0200 Subject: [PATCH 03/15] Added node_modules caching for faster builds --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index cbc10aa..5f66a7d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,10 @@ language: node_js node_js: - "stable" +cache: + directories: + - node_modules + before_install: - npm install -g truffle ethereumjs-testrpc From 3c263177c2e9d5d36a244bdbd4c996ccb1ad8ed3 Mon Sep 17 00:00:00 2001 From: Marcel Blijleven Date: Wed, 11 Apr 2018 21:03:16 +0200 Subject: [PATCH 04/15] Added stages to travis.yml --- .travis.yml | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5f66a7d..aa69bc2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,8 +9,16 @@ cache: before_install: - npm install -g truffle ethereumjs-testrpc -script: - - testrpc > /dev/null & - - sleep 5 - - truffle migrate - - truffle test +jobs: + include: + - stage: start testrpc + install: skip + script: + - testrpc > /dev/null & + - sleep 5 + - stage: truffle migrate + install: skip + script: truffle migrate + - stage: test + install: skip + script: truffle test From 18c0216de53f7c8aa8ee80fae84affcc0d17ec1f Mon Sep 17 00:00:00 2001 From: Marcel Blijleven Date: Wed, 11 Apr 2018 21:07:15 +0200 Subject: [PATCH 05/15] Revert "Added stages to travis.yml" This reverts commit 3c263177c2e9d5d36a244bdbd4c996ccb1ad8ed3. --- .travis.yml | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/.travis.yml b/.travis.yml index aa69bc2..5f66a7d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,16 +9,8 @@ cache: before_install: - npm install -g truffle ethereumjs-testrpc -jobs: - include: - - stage: start testrpc - install: skip - script: - - testrpc > /dev/null & - - sleep 5 - - stage: truffle migrate - install: skip - script: truffle migrate - - stage: test - install: skip - script: truffle test +script: + - testrpc > /dev/null & + - sleep 5 + - truffle migrate + - truffle test From cd0955ed2ca2a04f2718f0e23c6482d098c5a4eb Mon Sep 17 00:00:00 2001 From: Marcel Blijleven Date: Wed, 11 Apr 2018 21:11:56 +0200 Subject: [PATCH 06/15] Added build status svg to README --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index fa1ae3b..074bda4 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ -# testcoders-blockchain-meetup +# testcoders-blockchain-meetup +![Build status master](https://api.travis-ci.org/TestCoders/testcoders-blockchain-meetup.svg?branch=master) ## Getting started Make sure you have `truffle` and `testrpc` installed From 9e0e366ad906b6ffd41099ceff1a0b9f3d95f5e3 Mon Sep 17 00:00:00 2001 From: Marcel Blijleven Date: Wed, 11 Apr 2018 22:41:12 +0200 Subject: [PATCH 07/15] Fixed warnings in solidity contract --- contracts/TestCodersToken.sol | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/contracts/TestCodersToken.sol b/contracts/TestCodersToken.sol index 7f0bcd9..54f37eb 100644 --- a/contracts/TestCodersToken.sol +++ b/contracts/TestCodersToken.sol @@ -3,24 +3,24 @@ pragma solidity ^0.4.18; contract ERC20Interface { // Get the total token supply - function totalSupply() constant returns (uint256); + function totalSupply() public constant returns (uint256); // Get the account balance of another account with address _owner - function balanceOf(address _owner) constant returns (uint256 balance); + function balanceOf(address _owner) public constant returns (uint256 balance); // Send _value amount of tokens to address _to - function transfer(address _to, uint256 _value) returns (bool success); + function transfer(address _to, uint256 _value) public returns (bool success); // Send _value amount of tokens from address _from to address _to - function transferFrom(address _from, address _to, uint256 _value) returns (bool success); + function transferFrom(address _from, address _to, uint256 _value) public returns (bool success); // Allow _spender to withdraw from your account, multiple times, up to the _value amount. // If this function is called again it overwrites the current allowance with _value. // this function is required for some DEX functionality - function approve(address _spender, uint256 _value) returns (bool success); + function approve(address _spender, uint256 _value) public returns (bool success); // Returns the amount which _spender is still allowed to withdraw from _owner - function allowance(address _owner, address _spender) constant returns (uint256 remaining); + function allowance(address _owner, address _spender) public constant returns (uint256 remaining); // Triggered when tokens are transferred. event Transfer(address indexed _from, address indexed _to, uint256 _value); @@ -53,26 +53,26 @@ contract TestCodersToken is ERC20Interface { } // Constructor - function TestCodersToken() { + function TestCodersToken() public { owner = msg.sender; balances[owner] = _totalSupply; } - function totalSupply() constant returns (uint256) { + function totalSupply() constant public returns (uint256) { return _totalSupply; } // What is the balance of a particular account? - function balanceOf(address _owner) constant returns (uint256 balance) { + function balanceOf(address _owner) constant public returns (uint256 balance) { return balances[_owner]; } // Transfer the balance from owner's account to another account - function transfer(address _to, uint256 _amount) returns (bool success) { + function transfer(address _to, uint256 _amount) public returns (bool success) { if (balances[msg.sender] >= _amount && _amount > 0 && balances[_to] + _amount > balances[_to]) { balances[msg.sender] -= _amount; balances[_to] += _amount; - Transfer(msg.sender, _to, _amount); + emit Transfer(msg.sender, _to, _amount); return true; } else { return false; @@ -89,12 +89,13 @@ contract TestCodersToken is ERC20Interface { address _from, address _to, uint256 _amount - ) returns (bool success) - { if (balances[_from] >= _amount && allowed[_from][msg.sender] >= _amount && _amount > 0 && balances[_to] + _amount > balances[_to]) { + ) public returns (bool success) + { + if (balances[_from] >= _amount && allowed[_from][msg.sender] >= _amount && _amount > 0 && balances[_to] + _amount > balances[_to]) { balances[_from] -= _amount; allowed[_from][msg.sender] -= _amount; balances[_to] += _amount; - Transfer(_from, _to, _amount); + emit Transfer(_from, _to, _amount); return true; } else { return false; @@ -103,13 +104,13 @@ contract TestCodersToken is ERC20Interface { // Allow _spender to withdraw from your account, multiple times, up to the _value amount. // If this function is called again it overwrites the current allowance with _value. - function approve(address _spender, uint256 _amount) returns (bool success) { + function approve(address _spender, uint256 _amount) public returns (bool success) { allowed[msg.sender][_spender] = _amount; - Approval(msg.sender, _spender, _amount); + emit Approval(msg.sender, _spender, _amount); return true; } - function allowance(address _owner, address _spender) constant returns (uint256 remaining) { + function allowance(address _owner, address _spender) public constant returns (uint256 remaining) { return allowed[_owner][_spender]; } } \ No newline at end of file From 710cd5ef18de049e56ca82fb2ef5c9ed7b20bb4b Mon Sep 17 00:00:00 2001 From: Marcel Blijleven Date: Wed, 11 Apr 2018 23:04:30 +0200 Subject: [PATCH 08/15] Removed references to the now deprecated testrpc --- .travis.yml | 6 +++++- README.md | 9 +++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5f66a7d..2f3e836 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,12 +2,16 @@ language: node_js node_js: - "stable" +services: + - docker + cache: directories: - node_modules before_install: - - npm install -g truffle ethereumjs-testrpc + - npm install -g truffle + - docker run -d -p 8545:8545 trufflesuite/ganache-cli:latest script: - testrpc > /dev/null & diff --git a/README.md b/README.md index 074bda4..e9ce3fb 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,14 @@ ![Build status master](https://api.travis-ci.org/TestCoders/testcoders-blockchain-meetup.svg?branch=master) ## Getting started -Make sure you have `truffle` and `testrpc` installed +Make sure you have `truffle` and `ganache-cli` installed ```bash -npm install -g truffle ethereumjs-testrpc +npm install -g truffle npm ganache-cli +``` + +Run ganache (formerly known as testrpc) +```bash +ganache-cli ``` `cd` into the repository directory and run the following command to create build artifacts for the smart contract: From 9b174ad7331344d138aaa8fdfe13355f56449316 Mon Sep 17 00:00:00 2001 From: Marcel Blijleven Date: Wed, 11 Apr 2018 23:08:16 +0200 Subject: [PATCH 09/15] Revert "Added build status svg to README" This reverts commit cd0955ed2ca2a04f2718f0e23c6482d098c5a4eb. --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index e9ce3fb..161b7cf 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,4 @@ -# testcoders-blockchain-meetup -![Build status master](https://api.travis-ci.org/TestCoders/testcoders-blockchain-meetup.svg?branch=master) +# testcoders-blockchain-meetup ## Getting started Make sure you have `truffle` and `ganache-cli` installed From 02136840fb82937c0beb9d1295ee03d88a1ed5e8 Mon Sep 17 00:00:00 2001 From: Marcel Blijleven Date: Wed, 11 Apr 2018 23:09:09 +0200 Subject: [PATCH 10/15] Removed testrpc in favour of ganache, moved ganache to docker on travis --- .travis.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2f3e836..b1dc8d2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,7 +14,5 @@ before_install: - docker run -d -p 8545:8545 trufflesuite/ganache-cli:latest script: - - testrpc > /dev/null & - - sleep 5 - truffle migrate - truffle test From 2a8a5911e4e585cb39b993e2995397a11f2482be Mon Sep 17 00:00:00 2001 From: Marcel Blijleven Date: Wed, 11 Apr 2018 23:04:30 +0200 Subject: [PATCH 11/15] Removed references to the now deprecated testrpc --- .travis.yml | 6 +++++- README.md | 9 +++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5f66a7d..2f3e836 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,12 +2,16 @@ language: node_js node_js: - "stable" +services: + - docker + cache: directories: - node_modules before_install: - - npm install -g truffle ethereumjs-testrpc + - npm install -g truffle + - docker run -d -p 8545:8545 trufflesuite/ganache-cli:latest script: - testrpc > /dev/null & diff --git a/README.md b/README.md index 074bda4..e9ce3fb 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,14 @@ ![Build status master](https://api.travis-ci.org/TestCoders/testcoders-blockchain-meetup.svg?branch=master) ## Getting started -Make sure you have `truffle` and `testrpc` installed +Make sure you have `truffle` and `ganache-cli` installed ```bash -npm install -g truffle ethereumjs-testrpc +npm install -g truffle npm ganache-cli +``` + +Run ganache (formerly known as testrpc) +```bash +ganache-cli ``` `cd` into the repository directory and run the following command to create build artifacts for the smart contract: From fa6df75fe6e8582fdfbcaeae91589f1756793102 Mon Sep 17 00:00:00 2001 From: Marcel Blijleven Date: Wed, 11 Apr 2018 23:08:16 +0200 Subject: [PATCH 12/15] Revert "Added build status svg to README" This reverts commit cd0955ed2ca2a04f2718f0e23c6482d098c5a4eb. --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index e9ce3fb..161b7cf 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,4 @@ -# testcoders-blockchain-meetup -![Build status master](https://api.travis-ci.org/TestCoders/testcoders-blockchain-meetup.svg?branch=master) +# testcoders-blockchain-meetup ## Getting started Make sure you have `truffle` and `ganache-cli` installed From 88882e99fc27709df32478748cd298fc37f9f529 Mon Sep 17 00:00:00 2001 From: Marcel Blijleven Date: Wed, 11 Apr 2018 23:09:09 +0200 Subject: [PATCH 13/15] Removed testrpc in favour of ganache, moved ganache to docker on travis --- .travis.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2f3e836..b1dc8d2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,7 +14,5 @@ before_install: - docker run -d -p 8545:8545 trufflesuite/ganache-cli:latest script: - - testrpc > /dev/null & - - sleep 5 - truffle migrate - truffle test From 29c10098586ff469ee3f6bddc44560d3936c5a84 Mon Sep 17 00:00:00 2001 From: Bart Bouman Date: Thu, 17 May 2018 17:39:17 +0200 Subject: [PATCH 14/15] Revert "Add smart contracts and tests for meetup" This reverts commit 0d2d05002202bc4a1000ac9220b43b4dc1cbac36. --- test/testcoders_token_test.js | 38 ----------------------------------- truffle-config.js | 4 ---- truffle.js | 10 --------- 3 files changed, 52 deletions(-) delete mode 100644 test/testcoders_token_test.js delete mode 100755 truffle-config.js delete mode 100755 truffle.js diff --git a/test/testcoders_token_test.js b/test/testcoders_token_test.js deleted file mode 100644 index 1c12108..0000000 --- a/test/testcoders_token_test.js +++ /dev/null @@ -1,38 +0,0 @@ -var TestCodersToken = artifacts.require("./TestCodersToken.sol"); - -// totalSupply tests - -contract("TestCodersToken:totalSupply", function () { - it("totalSupply of 999999 = FALSE", async function () { - let totalSupply = 999999; - let contract = await TestCodersToken.deployed(); - let result = await contract.totalSupply.call(); - assert.notEqual(result.valueOf(), totalSupply, "This is not the token's total supply!") - }); - }); - - contract("TestCodersToken:totalSupply", function () { - it("totalSupply of 1000000 = TRUE", async function () { - let totalSupply = 1000000; - let contract = await TestCodersToken.deployed(); - let result = await contract.totalSupply.call(); - assert.equal(result.valueOf(), totalSupply, "This is not the token's total supply!") - }); - }); - - contract("TestCodersToken:totalSupply", function () { - it("totalSupply of 1000001 = FALSE", async function () { - let totalSupply = 1000001; - let contract = await TestCodersToken.deployed(); - let result = await contract.totalSupply.call(); - assert.notEqual(result.valueOf(), totalSupply, "This is not the token's total supply!") - }); - }); - - //contract("TestCodersToken:balanceOf", function () { - // it("should return a correct number", async function () { - // let contract = await TestCodersToken.deployed(); - // let result = await contract.balanceOf.call(0x0000000000000000000000000000000000000000); - // assert.equal(result.valueOf(), 1000000, "This is not 4!") - // }); - //}); \ No newline at end of file diff --git a/truffle-config.js b/truffle-config.js deleted file mode 100755 index a6330d6..0000000 --- a/truffle-config.js +++ /dev/null @@ -1,4 +0,0 @@ -module.exports = { - // See - // to customize your Truffle configuration! -}; diff --git a/truffle.js b/truffle.js deleted file mode 100755 index ee423ce..0000000 --- a/truffle.js +++ /dev/null @@ -1,10 +0,0 @@ -module.exports = { - networks: { - development: { - host: "localhost", - port: 8545, - network_id: "*", // Match any network id - gas: 4700000 - } - } -}; From 7136586a6c2de33fa8fba5b79008cee3904e15da Mon Sep 17 00:00:00 2001 From: Bart Bouman Date: Thu, 17 May 2018 19:02:11 +0200 Subject: [PATCH 15/15] Revert "Revert "Add smart contracts and tests for meetup"" This reverts commit 29c10098586ff469ee3f6bddc44560d3936c5a84. --- test/testcoders_token_test.js | 38 +++++++++++++++++++++++++++++++++++ truffle-config.js | 4 ++++ truffle.js | 10 +++++++++ 3 files changed, 52 insertions(+) create mode 100644 test/testcoders_token_test.js create mode 100755 truffle-config.js create mode 100755 truffle.js diff --git a/test/testcoders_token_test.js b/test/testcoders_token_test.js new file mode 100644 index 0000000..1c12108 --- /dev/null +++ b/test/testcoders_token_test.js @@ -0,0 +1,38 @@ +var TestCodersToken = artifacts.require("./TestCodersToken.sol"); + +// totalSupply tests + +contract("TestCodersToken:totalSupply", function () { + it("totalSupply of 999999 = FALSE", async function () { + let totalSupply = 999999; + let contract = await TestCodersToken.deployed(); + let result = await contract.totalSupply.call(); + assert.notEqual(result.valueOf(), totalSupply, "This is not the token's total supply!") + }); + }); + + contract("TestCodersToken:totalSupply", function () { + it("totalSupply of 1000000 = TRUE", async function () { + let totalSupply = 1000000; + let contract = await TestCodersToken.deployed(); + let result = await contract.totalSupply.call(); + assert.equal(result.valueOf(), totalSupply, "This is not the token's total supply!") + }); + }); + + contract("TestCodersToken:totalSupply", function () { + it("totalSupply of 1000001 = FALSE", async function () { + let totalSupply = 1000001; + let contract = await TestCodersToken.deployed(); + let result = await contract.totalSupply.call(); + assert.notEqual(result.valueOf(), totalSupply, "This is not the token's total supply!") + }); + }); + + //contract("TestCodersToken:balanceOf", function () { + // it("should return a correct number", async function () { + // let contract = await TestCodersToken.deployed(); + // let result = await contract.balanceOf.call(0x0000000000000000000000000000000000000000); + // assert.equal(result.valueOf(), 1000000, "This is not 4!") + // }); + //}); \ No newline at end of file diff --git a/truffle-config.js b/truffle-config.js new file mode 100755 index 0000000..a6330d6 --- /dev/null +++ b/truffle-config.js @@ -0,0 +1,4 @@ +module.exports = { + // See + // to customize your Truffle configuration! +}; diff --git a/truffle.js b/truffle.js new file mode 100755 index 0000000..ee423ce --- /dev/null +++ b/truffle.js @@ -0,0 +1,10 @@ +module.exports = { + networks: { + development: { + host: "localhost", + port: 8545, + network_id: "*", // Match any network id + gas: 4700000 + } + } +};