Update bootstrap to Embark 3.1 (#10)
* update configs to .js * update tests * better test abstraction * undo changes after test
This commit is contained in:
parent
5aa31324d8
commit
f5b76bc55a
|
@ -0,0 +1,62 @@
|
|||
module.exports = {
|
||||
development: {
|
||||
enabled: true,
|
||||
networkType: "custom", // Can be: testnet, rinkeby, livenet or custom, in which case, it will use the specified networkId
|
||||
networkId: "1337", // Network id used when networkType is custom
|
||||
isDev: true, // Uses and ephemeral proof-of-authority network with a pre-funded developer account, mining enabled
|
||||
genesisBlock: "config/development/genesis.json", // Genesis block to initiate on first creation of a development node
|
||||
datadir: ".embark/development/datadir", // Data directory for the databases and keystore
|
||||
mineWhenNeeded: true, // Uses our custom script (if isDev is false) to mine only when needed
|
||||
nodiscover: true, // Disables the peer discovery mechanism (manual peer addition)
|
||||
maxpeers: 0, // Maximum number of network peers (network disabled if set to 0) (default: 25)
|
||||
rpcHost: "localhost", // HTTP-RPC server listening interface (default: "localhost")
|
||||
rpcPort: 8545, // HTTP-RPC server listening port (default: 8545)
|
||||
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
|
||||
},
|
||||
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: {
|
||||
enabled: true,
|
||||
networkType: "testnet",
|
||||
light: true,
|
||||
rpcHost: "localhost",
|
||||
rpcPort: 8545,
|
||||
rpcCorsDomain: "http://localhost:8000",
|
||||
account: {
|
||||
password: "config/testnet/password"
|
||||
}
|
||||
},
|
||||
livenet: {
|
||||
enabled: true,
|
||||
networkType: "livenet",
|
||||
light: true,
|
||||
rpcHost: "localhost",
|
||||
rpcPort: 8545,
|
||||
rpcCorsDomain: "http://localhost:8000",
|
||||
account: {
|
||||
password: "config/livenet/password"
|
||||
}
|
||||
},
|
||||
privatenet: {
|
||||
enabled: true,
|
||||
networkType: "custom",
|
||||
rpcHost: "localhost",
|
||||
rpcPort: 8545,
|
||||
rpcCorsDomain: "http://localhost:8000",
|
||||
datadir: "yourdatadir",
|
||||
networkId: "123",
|
||||
bootnodes: ""
|
||||
}
|
||||
};
|
|
@ -1,56 +0,0 @@
|
|||
{
|
||||
"development": {
|
||||
"enabled": true,
|
||||
"networkType": "custom",
|
||||
"genesisBlock": "config/development/genesis.json",
|
||||
"datadir": ".embark/development/datadir",
|
||||
"mineWhenNeeded": true,
|
||||
"nodiscover": true,
|
||||
"maxpeers": 0,
|
||||
"rpcHost": "localhost",
|
||||
"rpcPort": 8545,
|
||||
"rpcCorsDomain": "auto",
|
||||
"account": {
|
||||
"password": "config/development/password"
|
||||
},
|
||||
"targetGasLimit": 8000000,
|
||||
"wsOrigins": "auto",
|
||||
"wsRPC": true,
|
||||
"wsHost": "localhost",
|
||||
"wsPort": 8546,
|
||||
"simulatorMnemonic": "example exile argue silk regular smile grass bomb merge arm assist farm",
|
||||
"simulatorBlocktime": 0
|
||||
},
|
||||
"testnet": {
|
||||
"enabled": true,
|
||||
"networkType": "testnet",
|
||||
"light": true,
|
||||
"rpcHost": "localhost",
|
||||
"rpcPort": 8545,
|
||||
"rpcCorsDomain": "http://localhost:8000",
|
||||
"account": {
|
||||
"password": "config/testnet/password"
|
||||
}
|
||||
},
|
||||
"livenet": {
|
||||
"enabled": true,
|
||||
"networkType": "livenet",
|
||||
"light": true,
|
||||
"rpcHost": "localhost",
|
||||
"rpcPort": 8545,
|
||||
"rpcCorsDomain": "http://localhost:8000",
|
||||
"account": {
|
||||
"password": "config/livenet/password"
|
||||
}
|
||||
},
|
||||
"privatenet": {
|
||||
"enabled": true,
|
||||
"networkType": "custom",
|
||||
"rpcHost": "localhost",
|
||||
"rpcPort": 8545,
|
||||
"rpcCorsDomain": "http://localhost:8000",
|
||||
"datadir": "yourdatadir",
|
||||
"networkId": "123",
|
||||
"bootnodes": ""
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
module.exports = {
|
||||
default: {
|
||||
enabled: true,
|
||||
provider: "whisper", // Communication provider. Currently, Embark only supports whisper
|
||||
available_providers: ["whisper"], // Array of available providers
|
||||
connection: {
|
||||
host: "localhost", // Host of the blockchain node
|
||||
port: 8546, // Port of the blockchain node
|
||||
type: "ws" // Type of connection (ws or rpc)
|
||||
}
|
||||
}
|
||||
};
|
|
@ -1,12 +0,0 @@
|
|||
{
|
||||
"default": {
|
||||
"enabled": true,
|
||||
"provider": "whisper",
|
||||
"available_providers": ["whisper", "orbit"],
|
||||
"connection": {
|
||||
"host": "localhost",
|
||||
"port": 8546,
|
||||
"type": "ws"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
module.exports = {
|
||||
// default applies to all environments
|
||||
default: {
|
||||
// Blockchain node to deploy the contracts
|
||||
deployment: {
|
||||
host: "localhost", // Host of the blockchain node
|
||||
port: 8545, // Port of the blockchain node
|
||||
type: "rpc" // Type of connection (ws or rpc),
|
||||
},
|
||||
// order of connections the dapp should connect to
|
||||
dappConnection: [
|
||||
"$WEB3", // uses pre existing web3 object if available (e.g in Mist)
|
||||
"ws://localhost:8546",
|
||||
"http://localhost:8545"
|
||||
],
|
||||
gas: "auto",
|
||||
contracts: {
|
||||
TestToken: {
|
||||
deploy: false
|
||||
},
|
||||
ERC20Receiver: {
|
||||
deploy: false
|
||||
}
|
||||
}
|
||||
},
|
||||
development: {
|
||||
contracts: {
|
||||
TestToken: {
|
||||
deploy: true
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
|
@ -1,29 +0,0 @@
|
|||
{
|
||||
"default": {
|
||||
"deployment": {
|
||||
"host": "localhost",
|
||||
"port": 8545,
|
||||
"type": "rpc"
|
||||
},
|
||||
"dappConnection": [
|
||||
"$WEB3",
|
||||
"http://localhost:8545"
|
||||
],
|
||||
"gas": "auto",
|
||||
"contracts": {
|
||||
"ERC20Receiver": {
|
||||
"deploy": false
|
||||
},
|
||||
"TestToken": {
|
||||
"deploy": false
|
||||
}
|
||||
}
|
||||
},
|
||||
"development": {
|
||||
"contracts": {
|
||||
"TestToken": {
|
||||
"deploy": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
module.exports = {
|
||||
default: {
|
||||
available_providers: ["ens"],
|
||||
provider: "ens"
|
||||
}
|
||||
};
|
|
@ -0,0 +1,35 @@
|
|||
module.exports = {
|
||||
default: {
|
||||
enabled: true,
|
||||
ipfs_bin: "ipfs",
|
||||
provider: "ipfs",
|
||||
available_providers: ["ipfs"],
|
||||
upload: {
|
||||
host: "localhost",
|
||||
port: 5001
|
||||
},
|
||||
dappConnection: [
|
||||
{
|
||||
provider:"ipfs",
|
||||
host: "localhost",
|
||||
port: 5001,
|
||||
getUrl: "http://localhost:8080/ipfs/"
|
||||
}
|
||||
]
|
||||
// Configuration to start Swarm in the same terminal as `embark run`
|
||||
/*,account: {
|
||||
address: "YOUR_ACCOUNT_ADDRESS", // Address of account accessing Swarm
|
||||
password: "PATH/TO/PASSWORD/FILE" // File containing the password of the account
|
||||
},
|
||||
swarmPath: "PATH/TO/SWARM/EXECUTABLE" // Path to swarm executable (default: swarm)*/
|
||||
},
|
||||
development: {
|
||||
enabled: true,
|
||||
provider: "ipfs",
|
||||
upload: {
|
||||
host: "localhost",
|
||||
port: 5001,
|
||||
getUrl: "http://localhost:8080/ipfs/"
|
||||
}
|
||||
}
|
||||
};
|
|
@ -1,20 +0,0 @@
|
|||
{
|
||||
"default": {
|
||||
"versions": {
|
||||
"ipfs-api": "17.2.4"
|
||||
},
|
||||
"enabled": true,
|
||||
"ipfs_bin": "ipfs",
|
||||
"provider": "ipfs",
|
||||
"available_providers": ["ipfs"],
|
||||
"host": "localhost",
|
||||
"port": 5001
|
||||
},
|
||||
"development": {
|
||||
"enabled": true,
|
||||
"provider": "ipfs",
|
||||
"host": "localhost",
|
||||
"port": 5001,
|
||||
"getUrl": "http://localhost:8080/ipfs/"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
module.exports = {
|
||||
enabled: true,
|
||||
host: "localhost",
|
||||
port: 8000
|
||||
};
|
|
@ -1,5 +0,0 @@
|
|||
{
|
||||
"enabled": true,
|
||||
"host": "localhost",
|
||||
"port": 8000
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
|
||||
exports.Test = (Controlled) => {
|
||||
describe("Controlled", async function() {
|
||||
this.timeout(0);
|
||||
var accounts;
|
||||
before(function(done) {
|
||||
web3.eth.getAccounts().then(function (res) {
|
||||
accounts = res;
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
it("should start with msg.sender as controller", async function() {
|
||||
var controller = await Controlled.methods.controller().call();
|
||||
assert(controller, accounts[0]);
|
||||
});
|
||||
|
||||
it("should allow controller to set new controller", async function() {
|
||||
await Controlled.methods.changeController(accounts[1]).send({from: accounts[0]});
|
||||
var controller = await Controlled.methods.controller().call();
|
||||
assert(controller, accounts[1]);
|
||||
});
|
||||
|
||||
it("should set back to original controller", async function() {
|
||||
await Controlled.methods.changeController(accounts[0]).send({from: accounts[1]});
|
||||
var controller = await Controlled.methods.controller().call();
|
||||
assert(controller, accounts[0]);
|
||||
});
|
||||
});
|
||||
}
|
|
@ -0,0 +1,85 @@
|
|||
|
||||
const ERC20Receiver = require('Embark/contracts/ERC20Receiver');
|
||||
|
||||
exports.config = {
|
||||
contracts : {
|
||||
"ERC20Receiver": {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
exports.Test = (ERC20Token) => {
|
||||
describe("ERC20Token", function() {
|
||||
|
||||
var accounts;
|
||||
before(function(done) {
|
||||
web3.eth.getAccounts().then(function (res) {
|
||||
accounts = res;
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it("should transfer 1 token", async function() {
|
||||
let initialBalance0 = await ERC20Token.methods.balanceOf(accounts[0]).call();
|
||||
let initialBalance1 = await ERC20Token.methods.balanceOf(accounts[1]).call();
|
||||
await ERC20Token.methods.transfer(accounts[1],1).send({from: accounts[0]});
|
||||
let result0 = await ERC20Token.methods.balanceOf(accounts[0]).call();
|
||||
let result1 = await ERC20Token.methods.balanceOf(accounts[1]).call();
|
||||
|
||||
assert.equal(result0, +initialBalance0-1, "account 0 balance unexpected");
|
||||
assert.equal(result1, +initialBalance1+1, "account 1 balance unexpected");
|
||||
});
|
||||
|
||||
it("should set approved amount", async function() {
|
||||
await ERC20Token.methods.approve(accounts[2],10000000).send({from: accounts[0]});
|
||||
let result = await ERC20Token.methods.allowance(accounts[0], accounts[2]).call();
|
||||
assert.equal(result, 10000000);
|
||||
});
|
||||
|
||||
it("should consume allowance amount", async function() {
|
||||
let initialAllowance = await ERC20Token.methods.allowance(accounts[0], accounts[2]).call();
|
||||
await ERC20Token.methods.transferFrom(accounts[0], accounts[0],1).send({from: accounts[2]});
|
||||
let result = await ERC20Token.methods.allowance(accounts[0], accounts[2]).call();
|
||||
|
||||
assert.equal(result, +initialAllowance-1);
|
||||
});
|
||||
|
||||
it("should transfer approved amount", async function() {
|
||||
let initialBalance0 = await ERC20Token.methods.balanceOf(accounts[0]).call();
|
||||
let initialBalance1 = await ERC20Token.methods.balanceOf(accounts[1]).call();
|
||||
await ERC20Token.methods.transferFrom(accounts[0], accounts[1],1).send({from: accounts[2]});
|
||||
let result0 = await ERC20Token.methods.balanceOf(accounts[0]).call();
|
||||
let result1 = await ERC20Token.methods.balanceOf(accounts[1]).call();
|
||||
|
||||
assert.equal(result0, +initialBalance0-1);
|
||||
assert.equal(result1, +initialBalance1+1);
|
||||
});
|
||||
|
||||
|
||||
it("should unset approved amount", async function() {
|
||||
await ERC20Token.methods.approve(accounts[2],0).send({from: accounts[0]});
|
||||
let result = await ERC20Token.methods.allowance(accounts[0], accounts[2]).call();
|
||||
assert.equal(result, 0);
|
||||
});
|
||||
|
||||
it("should deposit approved amount to contract ERC20Receiver", async function() {
|
||||
//ERC20Receiver = await ERC20Receiver.deploy().send();
|
||||
//console.log(ERC20Receiver.address);
|
||||
await ERC20Token.methods.approve(ERC20Receiver.address, 10).send({from: accounts[0]});
|
||||
await ERC20Receiver.methods.depositToken(ERC20Token.address, 10).send({from: accounts[0]});
|
||||
let result = await ERC20Receiver.methods.tokenBalanceOf(ERC20Token.address, accounts[0]).call();
|
||||
assert.equal(result, 10, "ERC20Receiver.tokenBalanceOf("+ERC20Token.address+","+accounts[0]+") wrong");
|
||||
});
|
||||
|
||||
it("should witdraw approved amount from contract ERC20Receiver", async function() {
|
||||
let tokenBalance = await ERC20Receiver.methods.tokenBalanceOf(ERC20Token.address, accounts[0]).call();
|
||||
await ERC20Receiver.methods.withdrawToken(ERC20Token.address, tokenBalance).send({from: accounts[0]});
|
||||
tokenBalance = await ERC20Receiver.methods.tokenBalanceOf(ERC20Token.address, accounts[0]).call();
|
||||
assert.equal(tokenBalance, 0, "ERC20Receiver.tokenBalanceOf("+ERC20Token.address+","+accounts[0]+") wrong");
|
||||
});
|
||||
|
||||
//TODO: include checks for expected events fired
|
||||
|
||||
|
||||
});
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
|
||||
exports.Test = (contractsConfig, afterDeploy) => {
|
||||
|
||||
describe("Controlled", async function() {
|
||||
this.timeout(0);
|
||||
var Controlled;
|
||||
var accountsArr;
|
||||
before(function(done) {
|
||||
EmbarkSpec.deployAll(contractsConfig, async function(accounts) {
|
||||
Controlled = Contract;
|
||||
accountsArr = accounts;
|
||||
await afterDeploy(accounts, Contract);
|
||||
done()
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
it("should start with msg.sender as controller", async function() {
|
||||
var controller = await Controlled.methods.controller().call();
|
||||
assert(controller, accountsArr[0]);
|
||||
});
|
||||
|
||||
it("should allow controller to set new controller", async function() {
|
||||
await Controlled.methods.changeController(accountsArr[1]).send({from: accountsArr[0]});
|
||||
var controller = await Controlled.methods.controller().call();
|
||||
assert(controller, accountsArr[1]);
|
||||
});
|
||||
});
|
||||
}
|
|
@ -1,78 +0,0 @@
|
|||
|
||||
exports.Test = (contractsConfig, afterDeploy) => {
|
||||
describe("ERC20Token", async function() {
|
||||
this.timeout(0);
|
||||
var ERC20Token;
|
||||
var accountsArr;
|
||||
before(function(done) {
|
||||
contractsConfig["ERC20Receiver"] = {};
|
||||
EmbarkSpec.deployAll(contractsConfig, async function(accounts) {
|
||||
ERC20Token = Contract;
|
||||
accountsArr = accounts;
|
||||
await afterDeploy(accounts, Contract);
|
||||
done()
|
||||
});
|
||||
});
|
||||
|
||||
it("should transfer 1 token", async function() {
|
||||
let initialBalance0 = await ERC20Token.methods.balanceOf(accountsArr[0]).call();
|
||||
let initialBalance1 = await ERC20Token.methods.balanceOf(accountsArr[1]).call();
|
||||
await ERC20Token.methods.transfer(accountsArr[1],1).send({from: accountsArr[0]});
|
||||
let result0 = await ERC20Token.methods.balanceOf(accountsArr[0]).call();
|
||||
let result1 = await ERC20Token.methods.balanceOf(accountsArr[1]).call();
|
||||
|
||||
assert.equal(result0, +initialBalance0-1, "account 0 balance unexpected");
|
||||
assert.equal(result1, +initialBalance1+1, "account 1 balance unexpected");
|
||||
});
|
||||
|
||||
it("should set approved amount", async function() {
|
||||
await ERC20Token.methods.approve(accountsArr[2],10000000).send({from: accountsArr[0]});
|
||||
let result = await ERC20Token.methods.allowance(accountsArr[0], accountsArr[2]).call();
|
||||
assert.equal(result, 10000000);
|
||||
});
|
||||
|
||||
it("should consume allowance amount", async function() {
|
||||
let initialAllowance = await ERC20Token.methods.allowance(accountsArr[0], accountsArr[2]).call();
|
||||
await ERC20Token.methods.transferFrom(accountsArr[0], accountsArr[0],1).send({from: accountsArr[2]});
|
||||
let result = await ERC20Token.methods.allowance(accountsArr[0], accountsArr[2]).call();
|
||||
|
||||
assert.equal(result, +initialAllowance-1);
|
||||
});
|
||||
|
||||
it("should transfer approved amount", async function() {
|
||||
let initialBalance0 = await ERC20Token.methods.balanceOf(accountsArr[0]).call();
|
||||
let initialBalance1 = await ERC20Token.methods.balanceOf(accountsArr[1]).call();
|
||||
await ERC20Token.methods.transferFrom(accountsArr[0], accountsArr[1],1).send({from: accountsArr[2]});
|
||||
let result0 = await ERC20Token.methods.balanceOf(accountsArr[0]).call();
|
||||
let result1 = await ERC20Token.methods.balanceOf(accountsArr[1]).call();
|
||||
|
||||
assert.equal(result0, +initialBalance0-1);
|
||||
assert.equal(result1, +initialBalance1+1);
|
||||
});
|
||||
|
||||
|
||||
it("should unset approved amount", async function() {
|
||||
await ERC20Token.methods.approve(accountsArr[2],0).send({from: accountsArr[0]});
|
||||
let result = await ERC20Token.methods.allowance(accountsArr[0], accountsArr[2]).call();
|
||||
assert.equal(result, 0);
|
||||
});
|
||||
|
||||
it("should deposit approved amount to contract ERC20Receiver", async function() {
|
||||
await ERC20Token.methods.approve(ERC20Receiver.address,10).send({from: accountsArr[0]});
|
||||
await ERC20Receiver.methods.depositToken(ERC20Token.address).send({from: accountsArr[0]});
|
||||
let result = await ERC20Receiver.methods.tokenBalanceOf(ERC20Token.address, accountsArr[0]).call();
|
||||
assert.equal(result, 10, "ERC20Receiver.tokenBalanceOf("+ERC20Token.address+","+accountsArr[0]+") wrong");
|
||||
});
|
||||
|
||||
it("should witdraw approved amount from contract ERC20Receiver", async function() {
|
||||
let tokenBalance = await ERC20Receiver.methods.tokenBalanceOf(ERC20Token.address, accountsArr[0]).call();
|
||||
await ERC20Receiver.methods.withdrawToken(ERC20Token.address, tokenBalance).send({from: accountsArr[0]});
|
||||
tokenBalance = await ERC20Receiver.methods.tokenBalanceOf(ERC20Token.address, accountsArr[0]).call();
|
||||
assert.equal(tokenBalance, 0, "ERC20Receiver.tokenBalanceOf("+ERC20Token.address+","+accountsArr[0]+") wrong");
|
||||
});
|
||||
|
||||
//TODO: include checks for expected events fired
|
||||
|
||||
|
||||
});
|
||||
}
|
|
@ -1,39 +1,55 @@
|
|||
const ERC20Token = require('./erc20token');
|
||||
const Utils = require('../utils/testUtils');
|
||||
const TestToken = require('Embark/contracts/TestToken');
|
||||
const ERC20TokenSpec = require('./abstract/erc20tokenspec');
|
||||
|
||||
describe("TestToken", async function() {
|
||||
config({
|
||||
contracts: {
|
||||
"TestToken": {
|
||||
},
|
||||
...ERC20TokenSpec.config.contracts
|
||||
}
|
||||
});
|
||||
|
||||
contract("TestToken", function() {
|
||||
this.timeout(0);
|
||||
var accountsArr;
|
||||
|
||||
var accounts;
|
||||
before(function(done) {
|
||||
var contractsConfig = {
|
||||
"TestToken": {
|
||||
}
|
||||
};
|
||||
EmbarkSpec.deployAll(contractsConfig, async function(accounts) {
|
||||
accountsArr = accounts
|
||||
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({from: accountsArr[0]});
|
||||
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(accountsArr[0]).call();
|
||||
await TestToken.methods.mint(100).send({from: accountsArr[0]});
|
||||
let result = await TestToken.methods.balanceOf(accountsArr[0]).call();
|
||||
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);
|
||||
});
|
||||
var erc20tokenConfig = {
|
||||
"Contract": { "instanceOf" : "TestToken" }
|
||||
}
|
||||
ERC20Token.Test(erc20tokenConfig, async function (accounts, TestToken) {
|
||||
|
||||
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(7 * 10 ^ 18).send({from: accounts[i]})
|
||||
}
|
||||
});
|
||||
await TestToken.methods.mint(initialBalance).send({from: accounts[i]})
|
||||
assert.equal(await TestToken.methods.balanceOf(accounts[i]).call(), initialBalance);
|
||||
}
|
||||
})
|
||||
|
||||
ERC20TokenSpec.Test(TestToken);
|
||||
|
||||
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue