simplify bootstrap

This commit is contained in:
Ricardo Guilherme Schmidt 2019-01-12 11:42:31 -02:00
parent 6559ff86ac
commit eebb8b352b
No known key found for this signature in database
GPG Key ID: BFB3F5C8ED618A94
19 changed files with 250 additions and 384 deletions

View File

@ -1,19 +0,0 @@
import ERC20Token from 'Embark/contracts/ERC20Token';
import { actions as accountActions } from '../reducers/accounts'
const { receiveAccounts } = accountActions
export const fetchAndDispatchAccountsWithBalances = (web3, dispatch) => {
web3.eth.getAccounts((err, addresses) => {
if (addresses) {
const defaultAccount = web3.eth.defaultAccount || addresses[0]
const accounts = addresses.map(async address => {
const balance = await web3.eth.getBalance(address, 'latest')
const ERC20TokenBalance = await ERC20Token.methods.balanceOf(address).call()
return { address, balance, ERC20TokenBalance }
})
Promise.all(accounts).then(accounts => {
dispatch(receiveAccounts(defaultAccount, accounts))
})
}
})
}

View File

@ -1,11 +1,9 @@
import EmbarkJS from 'Embark/EmbarkJS';
import StatusRoot from 'Embark/contracts/StatusRoot';
import TestStatusNetwork from 'Embark/contracts/TestStatusNetwork';
import MiniMeToken from 'Embark/contracts/MiniMeToken';
import React from 'react';
import { Form, FormGroup, FormControl, HelpBlock, Button } from 'react-bootstrap';
import ERC20TokenUI from './erc20token';
import { connect } from 'react-redux';
import { actions as accountActions } from '../reducers/accounts';
class TestTokenUI extends React.Component {
@ -20,20 +18,18 @@ class TestTokenUI extends React.Component {
this.setState({amountToMint: e.target.value});
}
mint(e){
const { addToBalance } = this.props;
async mint(e){
e.preventDefault();
await EmbarkJS.enableEthereum();
var value = parseInt(this.state.amountToMint, 10);
StatusRoot.methods.mint(value).send({from: web3.eth.defaultAccount})
.then(r => { addToBalance(value) });
TestStatusNetwork.methods.mint(value).send({ gas: 1000000 })
console.log(StatusRoot.options.address +".mint("+value+").send({from: " + web3.eth.defaultAccount + "})");
console.log(TestStatusNetwork.options.address +".mint("+value+").send({from: " + web3.eth.defaultAccount + "})");
}
render(){
return (<React.Fragment>
<h3> Mint Test Token</h3>
<h3> Test Status Network</h3>
<Form inline>
<FormGroup>
<FormControl
@ -51,10 +47,4 @@ class TestTokenUI extends React.Component {
}
}
const mapDispatchToProps = dispatch => ({
addToBalance(amount) {
dispatch(accountActions.addToErc20TokenBalance(amount));
},
});
export default connect(null, mapDispatchToProps)(TestTokenUI);
export default TestTokenUI;

View File

@ -1,66 +0,0 @@
import web3 from 'Embark/web3'
import React from 'react';
import { connect } from 'react-redux';
import { Nav, MenuItem, NavDropdown } from 'react-bootstrap';
import Blockies from 'react-blockies';
import { string, bool, func, arrayOf, shape } from 'prop-types';
import { getAccounts, getDefaultAccount, accountsIsLoading, actions as accountActions } from '../reducers/accounts';
import './accountlist.css';
const AccList = ({
accounts, defaultAccount, changeAccount, isLoading, classNameNavDropdown,
}) => (
<React.Fragment>
{!isLoading ?
<div className="accounts">
<div className="selectedIdenticon">
<Blockies seed={defaultAccount} />
</div>
<div className="accountList">
<Nav>
<NavDropdown key={1} title={defaultAccount} id="basic-nav-dropdown" className={classNameNavDropdown}>
{accounts.map(account => (
<MenuItem key={account.address} onClick={() => changeAccount(account.address)}>
<div className="account">
<div className="accountIdenticon">
<Blockies seed={account.address} />
</div>
<div className="accountHexString">
{account.address}
</div>
<div className="accountBalance">
Ξ {account.balance / (10 ** 18)}
</div>
</div>
</MenuItem>
))}
</NavDropdown>
</Nav>
</div>
</div>
: <div>Loading...</div>}
</React.Fragment>
);
AccList.propTypes = {
accounts: arrayOf(shape({ address: string, balance: string })).isRequired,
defaultAccount: string,
changeAccount: func.isRequired,
isLoading: bool.isRequired,
classNameNavDropdown: string
}
const mapStateToProps = state => ({
accounts: getAccounts(state),
defaultAccount: getDefaultAccount(state),
isLoading: accountsIsLoading(state),
});
const mapDispatchToProps = dispatch => ({
changeAccount(address) {
web3.eth.defaultAccount = address;
dispatch(accountActions.updateDefaultAccount(address));
},
});
export default connect(mapStateToProps, mapDispatchToProps)(AccList);

View File

@ -1,37 +0,0 @@
.identicon {
border-radius: 50%;
}
.selectedIdenticon {
border-radius: 50%;
overflow: hidden;
float: left;
margin: 7px 0;
}
.accountHexString {
margin-left: 7px;
width: 267px;
overflow: hidden;
text-overflow: ellipsis;
display:inline-block;
}
.accountBalance {
margin-left: 10px;
overflow: hidden;
display: inline-block;
width:77px;
text-align: center;
text-overflow: ellipsis;
}
.accountList {
float: left;
margin-left: 10px;
}
.account {
display: flex;
align-items: center;
}

View File

@ -1,9 +1,7 @@
import EmbarkJS from 'Embark/EmbarkJS';
import ERC20Token from 'Embark/contracts/ERC20Token';
import React from 'react';
import { connect } from 'react-redux';
import { Form, FormGroup, FormControl, HelpBlock, Button } from 'react-bootstrap';
import { getCurrentAccount, accountsIsLoading } from '../reducers/accounts';
class ERC20TokenUI extends React.Component {
@ -44,24 +42,14 @@ class ERC20TokenUI extends React.Component {
balanceOf(e){
e.preventDefault();
var who = e.target.value;
if (EmbarkJS.isNewWeb3()) {
ERC20Token.methods.balanceOf(who).call()
.then(_value => this.setState({balanceOf: _value}))
} else {
ERC20Token.balanceOf(who)
.then(_value => this.x({balanceOf: _value}));
}
ERC20Token.methods.balanceOf(who).call()
.then(_value => this.setState({balanceOf: _value}))
this._addToLog(ERC20Token.options.address+".balanceOf(" + who + ")");
}
getDefaultAccountBalance(){
if (EmbarkJS.isNewWeb3()) {
ERC20Token.methods.balanceOf(web3.eth.defaultAccount).call()
.then(_value => this.setState({accountBalance: _value}))
} else {
ERC20Token.balanceOf(web3.eth.defaultAccount)
.then(_value => this.x({valueGet: _value}))
}
ERC20Token.methods.balanceOf(web3.eth.defaultAccount).call()
.then(_value => this.setState({accountBalance: _value}))
this._addToLog(ERC20Token.options.address + ".balanceOf(" + web3.eth.defaultAccount + ")");
}
@ -70,16 +58,9 @@ class ERC20TokenUI extends React.Component {
}
render() {
const { account, isLoading } = this.props;
return (
<React.Fragment>
<h3> Read your account token balance </h3>
<Form inline>
<FormGroup>
{!isLoading && <HelpBlock>Your test token balance is <span className="accountBalance">{account.ERC20TokenBalance}</span></HelpBlock>}
</FormGroup>
</Form>
<h3> Read account token balance</h3>
<Form inline>
<FormGroup>
@ -124,9 +105,5 @@ class ERC20TokenUI extends React.Component {
}
}
const mapStateToProps = state => ({
account: getCurrentAccount(state),
isLoading: accountsIsLoading(state),
});
export default connect(mapStateToProps)(ERC20TokenUI);
export default ERC20TokenUI;

View File

@ -1,33 +0,0 @@
import EmbarkJS from 'Embark/EmbarkJS';
import React from 'react';
import { Navbar, NavItem, Nav, MenuItem , NavDropdown} from 'react-bootstrap';
import AccountList from './accountList';
class TopNavbar extends React.Component {
constructor(props) {
super(props);
this.state = {
}
}
render(){
return (
<React.Fragment>
<Navbar>
<Navbar.Header>
<Navbar.Brand>
<a href="#home">Status.im Demo</a>
</Navbar.Brand>
</Navbar.Header>
<AccountList classNameNavDropdown="pull-right" />
</Navbar>
</React.Fragment>
);
}
}
export default TopNavbar;

View File

@ -1,14 +1,11 @@
import React from 'react';
import ReactDOM from 'react-dom';
import { Tabs, Tab } from 'react-bootstrap';
import EmbarkJS from 'Embark/EmbarkJS';
import TopNavbar from './components/topnavbar';
import TestTokenUI from './components/testtoken';
import TestTokenUI from './components/TestStatusNetwork';
import './dapp.css';
class App extends React.Component {
class DApp extends React.Component {
constructor(props) {
super(props);
@ -32,7 +29,7 @@ class App extends React.Component {
render(){
return (
<div>
<TopNavbar />
<Tabs defaultActiveKey={1} id="uncontrolled-tab-example">
<Tab eventKey={1} title="TestToken">
<TestTokenUI />
@ -42,4 +39,4 @@ class App extends React.Component {
}
}
export default App;
export default DApp;

View File

@ -1,16 +1,9 @@
import React from 'react';
import { render } from 'react-dom';
import { Provider } from 'react-redux';
import store from './store/configureStore';
import App from './dapp';
import init from './store/init'
import DApp from './dapp';
import './dapp.css';
init();
render(
<Provider store={store}>
<App />
</Provider>,
<DApp />,
document.getElementById('app')
);

View File

@ -1,54 +0,0 @@
import { createTypes, actionCreator } from 'redux-action-creator'
import { createSelector } from 'reselect'
export const types = createTypes([
'RECEIVE_ACCOUNTS',
'UPDATE_DEFAULT_ACCOUNT',
'ADD_TO_ERC20_TOKEN_BALANCE'
], 'ACCOUNTS')
export const actions = {
receiveAccounts: actionCreator(types.RECEIVE_ACCOUNTS, 'defaultAccount','accounts'),
updateDefaultAccount: actionCreator(types.UPDATE_DEFAULT_ACCOUNT, 'defaultAccount'),
addToErc20TokenBalance: actionCreator(types.ADD_TO_ERC20_TOKEN_BALANCE, 'amount')
}
export default function(state = { loading: true, accounts: [] }, action) {
switch (action.type) {
case types.RECEIVE_ACCOUNTS: {
const { defaultAccount, accounts } = action.payload
return {
...state,
loading: false,
defaultAccount,
accounts
}
}
case types.UPDATE_DEFAULT_ACCOUNT: {
const { defaultAccount } = action.payload
return { ...state, defaultAccount }
}
case types.ADD_TO_ERC20_TOKEN_BALANCE: {
const currentAccount = { ...getCurrentAccount({accounts: state}) }
currentAccount.ERC20TokenBalance = Number(currentAccount.ERC20TokenBalance) + Number(action.payload.amount)
const accounts = [ ...state.accounts ]
const idx = accounts.findIndex(a => a.address === currentAccount.address)
accounts[idx] = currentAccount
return {
...state,
accounts
}
}
default:
return state;
}
}
export const getAccountState = state => state.acounts;
export const getAccounts = state => state.accounts.accounts;
export const getDefaultAccount = state => state.accounts.defaultAccount;
export const accountsIsLoading = state => state.accounts.loading;
export const getCurrentAccount = createSelector(
getDefaultAccount,
getAccounts,
(defaultAccount, accounts) => accounts.find(a => a.address === defaultAccount)
)

View File

@ -1,8 +0,0 @@
import { combineReducers } from 'redux';
import accounts from './accounts'
const rootReducer = combineReducers({
accounts
});
export default rootReducer;

View File

@ -1,11 +0,0 @@
import { createStore, applyMiddleware } from 'redux';
import rootReducer from '../reducers/rootReducer';
import thunk from 'redux-thunk';
const store = createStore(
rootReducer,
window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__(),
applyMiddleware(thunk)
);
export default store;

View File

@ -1,12 +0,0 @@
import web3 from "Embark/web3"
import EmbarkJS from 'Embark/EmbarkJS'
import store from './configureStore'
import { fetchAndDispatchAccountsWithBalances } from '../actions/accounts'
const dispatch = action => store.dispatch(action)
export default () => {
EmbarkJS.onReady((err) => {
fetchAndDispatchAccountsWithBalances(web3, dispatch)
})
}

View File

@ -14,17 +14,18 @@ module.exports = {
rpcCorsDomain: "auto", // Comma separated list of domains from which to accept cross origin requests (browser enforced)
// When set to "auto", Embark will automatically set the cors to the address of the webserver
proxy: true, // Proxy is used to present meaningful information about transactions
account: {
// "address": "", // When specified, uses that address instead of the default one for the network
password: "config/development/.password" // Password to unlock the account
},
accounts: [
{
nodeAccounts: true,
password: "config/development/.password"
}
],
targetGasLimit: 8000000, // Target gas limit sets the artificial target gas floor for the blocks to mine
wsRPC: true, // Enable the WS-RPC server
wsOrigins: "auto", // Origins from which to accept websockets requests
// When set to "auto", Embark will automatically set the cors to the address of the webserver
wsHost: "localhost", // WS-RPC server listening interface (default: "localhost")
wsPort: 8546, // WS-RPC server listening port (default: 8546)
simulatorMnemonic: "example exile argue silk regular smile grass bomb merge arm assist farm", // Mnemonic used by the simulator to generate a wallet
simulatorBlocktime: 0 // Specify blockTime in seconds for automatic mining. Default is 0 and no auto-mining.
},
testnet: {
@ -34,9 +35,12 @@ module.exports = {
rpcHost: "localhost",
rpcPort: 8545,
rpcCorsDomain: "http://localhost:8000",
account: {
password: "config/testnet/.password"
}
accounts: [
{
nodeAccounts: true,
password: "config/testnet/.password"
}
],
},
livenet: {
enabled: false,
@ -45,9 +49,12 @@ module.exports = {
rpcHost: "localhost",
rpcPort: 8545,
rpcCorsDomain: "http://localhost:8000",
account: {
password: "config/livenet/.password"
}
accounts: [
{
nodeAccounts: true,
password: "config/livenet/.password"
}
],
},
rinkeby: {
enabled: true,
@ -56,8 +63,11 @@ module.exports = {
rpcHost: "localhost",
rpcPort: 8545,
rpcCorsDomain: "http://localhost:8000",
account: {
password: "config/rinkeby/.password"
}
accounts: [
{
nodeAccounts: true,
password: "config/rinkeby/.password"
}
],
}
};

View File

@ -24,14 +24,12 @@ module.exports = {
},
"StatusNetwork": {"deploy": false},
"TestStatusNetwork": {"deploy": false},
"StatusRoot": {
"instanceOf": "TestStatusNetwork",
"TestStatusNetwork": {
"deploy": true,
"args": ["0x0", "$MiniMeToken"],
"onDeploy": [
"await MiniMeToken.methods.changeController(StatusRoot.address).send()",
"await StatusRoot.methods.setOpen(true).send()",
"await MiniMeToken.methods.changeController(TestStatusNetwork.address).send()",
"await TestStatusNetwork.methods.setOpen(true).send()",
]
}
}

View File

@ -1,16 +1,17 @@
module.exports = {
// default applies to all environments
default: {
enabled: true,
ipfs_bin: "ipfs",
provider: "ipfs",
available_providers: ["ipfs"],
upload: {
provider: "ipfs",
host: "localhost",
port: 5001
},
dappConnection: [
{
provider: "ipfs",
provider:"ipfs",
host: "localhost",
port: 5001,
getUrl: "http://localhost:8080/ipfs/"
@ -23,13 +24,36 @@ module.exports = {
},
swarmPath: "PATH/TO/SWARM/EXECUTABLE" // Path to swarm executable (default: swarm)*/
},
// default environment, merges with the settings in default
// assumed to be the intended environment by `embark run`
development: {
enabled: true,
provider: "ipfs",
upload: {
provider: "ipfs",
host: "localhost",
port: 5001,
getUrl: "http://localhost:8080/ipfs/"
}
}
},
// merges with the settings in default
// used with "embark run privatenet"
privatenet: {
},
// merges with the settings in default
// used with "embark run testnet"
testnet: {
},
// merges with the settings in default
// used with "embark run livenet"
livenet: {
},
// you can name an environment with specific settings and then specify with
// "embark run custom_name"
//custom_name: {
//}
};

View File

@ -28,10 +28,6 @@
"react-blockies": "^1.4.0",
"react-bootstrap": "0.32.1",
"react-dom": "^16.3.2",
"react-redux": "^6.0.0",
"redux": "^4.0.1",
"redux-action-creator": "^3.0.0",
"redux-thunk": "^2.3.0",
"web3": "^1.0.0-beta.34"
}
}

123
test/minimetoken.js Normal file
View File

@ -0,0 +1,123 @@
const utils = require('../utils/testUtils')
const MiniMeToken = require('Embark/contracts/MiniMeToken');
const ERC20TokenSpec = require('./abstract/erc20tokenspec');
const ControlledSpec = require('./abstract/controlled');
config({
contracts: {
"MiniMeTokenFactory": {
},
"MiniMeToken": {
"args": [
"$MiniMeTokenFactory",
utils.zeroAddress,
0,
"TestMiniMeToken",
18,
"TST",
true
]
},
...ERC20TokenSpec.config.contracts
}
});
contract("MiniMeToken", function() {
this.timeout(0);
var accounts;
before(function(done) {
web3.eth.getAccounts().then(function (res) {
accounts = res;
done();
});
});
var miniMeTokenClone;
const b = [];
it('should generate tokens for address 1', async () => {
await MiniMeToken.methods.generateTokens(accounts[1], 10).send();
assert.equal(await MiniMeToken.methods.totalSupply().call(), 10);
assert.equal(await MiniMeToken.methods.balanceOf(accounts[1]).call(), 10);
b[0] = await web3.eth.getBlockNumber();
});
it('should transfer tokens from address 1 to address 3', async () => {
await MiniMeToken.methods.transfer(accounts[3], 1).send({from: accounts[1]});
assert.equal(await MiniMeToken.methods.totalSupply().call(), 10);
assert.equal(await MiniMeToken.methods.balanceOf(accounts[1]).call(), 9);
assert.equal(await MiniMeToken.methods.balanceOf(accounts[3]).call(), 1);
b[1] = await web3.eth.getBlockNumber();
});
it('should destroy 3 tokens from 1 and 1 from 2', async () => {
await MiniMeToken.methods.destroyTokens(accounts[1], 3).send({ from: accounts[0] });
assert.equal(await MiniMeToken.methods.totalSupply().call(), 7);
assert.equal(await MiniMeToken.methods.balanceOf(accounts[1]).call(), 6);
b[2] = await web3.eth.getBlockNumber();
});
it('should create the clone token', async () => {
const miniMeTokenCloneTx = await MiniMeToken.methods.createCloneToken(
'Clone Token 1',
18,
'MMTc',
0,
true).send({ from: accounts[0]});
let addr = miniMeTokenCloneTx.events.NewCloneToken.returnValues[0];
miniMeTokenClone = new web3.eth.Contract(MiniMeToken._jsonInterface, addr);
b[3] = await web3.eth.getBlockNumber();
assert.equal(await miniMeTokenClone.methods.parentToken().call(), MiniMeToken.address);
assert.equal(await miniMeTokenClone.methods.parentSnapShotBlock().call(), b[3]);
assert.equal(await miniMeTokenClone.methods.totalSupply().call(), 7);
assert.equal(await MiniMeToken.methods.balanceOf(accounts[1]).call(), 6);
assert.equal(await miniMeTokenClone.methods.totalSupplyAt(b[2]).call(), 7);
assert.equal(await miniMeTokenClone.methods.balanceOfAt(accounts[3], b[2]).call(), 1);
});
it('should move tokens in the clone token from 2 to 3', async () => {
await miniMeTokenClone.methods.transfer(accounts[2], 4).send({ from: accounts[1], gas: 1000000 });
b[4] = await web3.eth.getBlockNumber();
assert.equal(await MiniMeToken.methods.balanceOfAt(accounts[1], b[3]).call(), 6);
assert.equal(await MiniMeToken.methods.balanceOfAt(accounts[2], b[3]).call(), 0);
assert.equal(await miniMeTokenClone.methods.totalSupply().call(), 7);
assert.equal(await miniMeTokenClone.methods.balanceOf(accounts[1]).call(), 2);
assert.equal(await miniMeTokenClone.methods.balanceOf(accounts[2]).call(), 4);
assert.equal(await miniMeTokenClone.methods.balanceOfAt(accounts[1], b[3]).call(), 6);
assert.equal(await miniMeTokenClone.methods.balanceOfAt(accounts[2], b[3]).call(), 0);
assert.equal(await miniMeTokenClone.methods.balanceOfAt(accounts[1], b[2]).call(), 6);
assert.equal(await miniMeTokenClone.methods.balanceOfAt(accounts[2], b[2]).call(), 0);
assert.equal(await miniMeTokenClone.methods.totalSupplyAt(b[3]).call(), 7);
assert.equal(await miniMeTokenClone.methods.totalSupplyAt(b[2]).call(), 7);
});
it('should create tokens in the child token', async () => {
await miniMeTokenClone.methods.generateTokens(accounts[1], 10).send({ from: accounts[0], gas: 1000000});
assert.equal(await miniMeTokenClone.methods.totalSupply().call(), 17);
assert.equal(await miniMeTokenClone.methods.balanceOf(accounts[1]).call(), 12);
assert.equal(await miniMeTokenClone.methods.balanceOf(accounts[2]).call(), 4);
});
it("should mint balances for ERC20TokenSpec", async function() {
let initialBalance = 7 * 10 ^ 18;
for(i=0;i<accounts.length;i++){
await MiniMeToken.methods.generateTokens(accounts[i], initialBalance).send({from: accounts[0]})
//assert.equal(await TestToken.methods.balanceOf(accounts[i]).call(), initialBalance);
}
})
ERC20TokenSpec.Test(MiniMeToken);
ControlledSpec.Test(MiniMeToken);
});

53
test/teststatusnetwork.js Normal file
View File

@ -0,0 +1,53 @@
const Utils = require('../utils/testUtils');
const MiniMeToken = require('Embark/contracts/MiniMeToken');
const TestStatusNetwork = require('Embark/contracts/TestStatusNetwork');
const ERC20TokenSpec = require('./abstract/erc20tokenspec');
config({
contracts: {
"MiniMeTokenFactory": {},
"MiniMeToken": {
"args":["$MiniMeTokenFactory", "0x0", "0x0", "Status Test Token", 18, "STT", true],
},
"TestStatusNetwork": {
"deploy": true,
"args": ["0x0", "$MiniMeToken"],
"onDeploy": [
"await MiniMeToken.methods.changeController(TestStatusNetwork.address).send()",
"await TestStatusNetwork.methods.setOpen(true).send()",
]
}
}
});
contract("TestStatusNetwork", function() {
this.timeout(0);
var accounts;
before(function(done) {
web3.eth.getAccounts().then(function (res) {
accounts = res;
done();
});
});
it("should increase totalSupply in mint", async function() {
let initialSupply = await MiniMeToken.methods.totalSupply().call();
await TestStatusNetwork.methods.mint(100).send();
let result = await MiniMeToken.methods.totalSupply().call();
assert.equal(result, +initialSupply+100);
});
it("should increase accountBalance in mint", async function() {
let initialBalance = await MiniMeToken.methods.balanceOf(accounts[0]).call();
await TestStatusNetwork.methods.mint(100).send({from: accounts[0]});
let result = await MiniMeToken.methods.balanceOf(accounts[0]).call();
assert.equal(result, +initialBalance+100);
});
it("should burn account supply", async function() {
let initialBalance = await MiniMeToken.methods.balanceOf(accounts[0]).call();
await TestStatusNetwork.methods.destroyTokens(accounts[0], initialBalance).send({from: accounts[0]});
assert.equal(await MiniMeToken.methods.totalSupply().call(), 0);
assert.equal(await MiniMeToken.methods.balanceOf(accounts[0]).call(), 0);
})
});

View File

@ -1,55 +0,0 @@
const Utils = require('../utils/testUtils');
const TestToken = require('Embark/contracts/TestToken');
const ERC20TokenSpec = require('./abstract/erc20tokenspec');
config({
contracts: {
"TestToken": {
},
...ERC20TokenSpec.config.contracts
}
});
contract("TestToken", function() {
this.timeout(0);
var accounts;
before(function(done) {
web3.eth.getAccounts().then(function (res) {
accounts = res;
done();
});
});
it("should increase totalSupply in mint", async function() {
let initialSupply = await TestToken.methods.totalSupply().call();
await TestToken.methods.mint(100).send();
let result = await TestToken.methods.totalSupply().call();
assert.equal(result, +initialSupply+100);
});
it("should increase accountBalance in mint", async function() {
let initialBalance = await TestToken.methods.balanceOf(accounts[0]).call();
await TestToken.methods.mint(100).send({from: accounts[0]});
let result = await TestToken.methods.balanceOf(accounts[0]).call();
assert.equal(result, +initialBalance+100);
});
it("should burn account supply", async function() {
let initialBalance = await TestToken.methods.balanceOf(accounts[0]).call();
await TestToken.methods.transfer(Utils.zeroAddress, initialBalance).send({from: accounts[0]});
assert.equal(await TestToken.methods.totalSupply().call(), 0);
assert.equal(await TestToken.methods.balanceOf(accounts[0]).call(), 0);
})
it("should mint balances for ERC20TokenSpec", async function() {
let initialBalance = 7 * 10 ^ 18;
for(i=0;i<accounts.length;i++){
await TestToken.methods.mint(initialBalance).send({from: accounts[i]})
assert.equal(await TestToken.methods.balanceOf(accounts[i]).call(), initialBalance);
}
})
ERC20TokenSpec.Test(TestToken);
});