From 0a1cbb5fffc5e1d34fd03bd9faf27b1f046ee4e8 Mon Sep 17 00:00:00 2001 From: Ricardo Guilherme Schmidt <3esmit@gmail.com> Date: Sat, 12 May 2018 21:16:18 -0300 Subject: [PATCH] test script for testtoken and erc20token --- config/blockchain.json | 4 +- config/development/genesis.json | 4 +- contracts/token/StandardToken.sol | 2 +- embark.json | 13 ++++-- package.json | 12 ++---- test/erc20token.js | 66 +++++++++++++++++++++++++++++++ test/testtoken.js | 34 ++++++++++++++++ 7 files changed, 119 insertions(+), 16 deletions(-) create mode 100644 test/erc20token.js create mode 100644 test/testtoken.js diff --git a/config/blockchain.json b/config/blockchain.json index 9dccb92..638c816 100644 --- a/config/blockchain.json +++ b/config/blockchain.json @@ -9,12 +9,12 @@ "maxpeers": 0, "rpcHost": "localhost", "rpcPort": 8545, - "rpcCorsDomain": "http://localhost:8000", + "rpcCorsDomain": "auto", "account": { "password": "config/development/password" }, "targetGasLimit": 8000000, - "wsOrigins": "http://localhost:8000", + "wsOrigins": "auto", "wsRPC": true, "wsHost": "localhost", "wsPort": 8546, diff --git a/config/development/genesis.json b/config/development/genesis.json index 4b6ce0d..1a9501b 100644 --- a/config/development/genesis.json +++ b/config/development/genesis.json @@ -1,6 +1,8 @@ { "config": { - "homesteadBlock": 1 + "homesteadBlock": 1, + "byzantiumBlock": 1, + "daoForkSupport": true }, "nonce": "0x0000000000000042", "difficulty": "0x0", diff --git a/contracts/token/StandardToken.sol b/contracts/token/StandardToken.sol index d42852c..46b961e 100644 --- a/contracts/token/StandardToken.sol +++ b/contracts/token/StandardToken.sol @@ -66,7 +66,7 @@ contract StandardToken is ERC20Token { function totalSupply() external view - returns(uint256 supply) + returns(uint256 totalSupply) { return supply; } diff --git a/embark.json b/embark.json index ba742a4..7bd3d48 100644 --- a/embark.json +++ b/embark.json @@ -1,10 +1,17 @@ { "contracts": ["contracts/**"], + "app": { + "js/dapp.js": ["app/dapp.js"], + "index.html": "app/index.html", + "images/": ["app/images/**"] + }, "buildDir": "dist/", "config": "config/", - "plugins": { - }, "versions": { - "solc": "0.4.23" + "web3": "1.0.0-beta", + "solc": "0.4.23", + "ipfs-api": "17.2.4" + }, + "plugins": { } } diff --git a/package.json b/package.json index 7cf6084..e188c49 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,7 @@ { "name": "status-contracts", - "version": "1.0.0", + "version": "0.0.1", + "description": "", "scripts": { "solidity-coverage": "./node_modules/.bin/solidity-coverage", "test": "embark test" @@ -15,13 +16,6 @@ "url": "https://github.com/status-im/contracts/issues" }, "homepage": "https://github.com/status-im/contracts#readme", - "devDependencies": { - "solidity-coverage": "^0.5.0", - "elliptic": "^6.4.0" - }, - "dependencies": { - "embark": "^2.7.0", - "elliptic-curve": "^0.1.0", - "ethereumjs-util": "^5.1.5" + "dependencies": { } } diff --git a/test/erc20token.js b/test/erc20token.js new file mode 100644 index 0000000..075ddeb --- /dev/null +++ b/test/erc20token.js @@ -0,0 +1,66 @@ +describe("ERC20Token", async function() { + this.timeout(0); + var ERC20Token; + var accountsArr; + before(function(done) { + this.timeout(0); + var contractsConfig = { + "TestToken": { + } + }; + EmbarkSpec.deployAll(contractsConfig, async function(accounts) { + ERC20Token = TestToken; + accountsArr = accounts; + for(i=0;i { accountsArr = accounts; done() }); + }); + + + it("should start totalSupply 0", async function() { + let result = await TestToken.methods.totalSupply().call(); + assert.equal(result, 0); + }); + + it("should increase totalSupply in mint", async function() { + let initialSupply = await TestToken.methods.balanceOf(accountsArr[0]).call(); + await TestToken.methods.mint(100).send({from: accountsArr[0]}); + let result = await TestToken.methods.totalSupply().call(); + assert.equal(result, 100); + }); + + it("should increase accountBalance in mint", async function() { + let initialBalance = await TestToken.methods.balanceOf(accountsArr[0]).call(); + await TestToken.methods.mint(100).send({from: accountsArr[0]}); + let result = await TestToken.methods.totalSupply().call(); + assert.equal(result, +initialBalance+100); + }); + + +});