Skip to content

Commit

Permalink
basic setup
Browse files Browse the repository at this point in the history
  • Loading branch information
haydenadams committed Aug 28, 2019
0 parents commit 36a59fb
Show file tree
Hide file tree
Showing 6 changed files with 7,217 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.sol linguist-language=Solidity
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules/
build/
15 changes: 15 additions & 0 deletions contracts/test_contracts/Token.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
pragma solidity ^0.5.11;

import "openzeppelin-solidity/contracts/token/ERC20/ERC20.sol";
import "openzeppelin-solidity/contracts/token/ERC20/ERC20Detailed.sol";


// Example class - a mock class using delivering from ERC20
contract Token is ERC20, ERC20Detailed {
constructor(string memory _name, string memory _symbol, uint8 _decimals, uint256 initialBalance)
public
ERC20Detailed(_name, _symbol, _decimals)
{
super._mint(msg.sender, initialBalance);
}
}
14 changes: 14 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"dependencies": {
"solc": "^0.5.11"
},
"devDependencies": {
"chai": "^4.2.0",
"ethereum-waffle": "^2.1.0",
"mocha": "^6.2.0",
"openzeppelin-solidity": "^2.3.0"
},
"scripts": {
"test": "waffle && mocha"
}
}
47 changes: 47 additions & 0 deletions test/testToken.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
const chai = require('chai');
const {createMockProvider, deployContract, getWallets, solidity} = require('ethereum-waffle');
const BasicTokenMock = require('../build/Token');


chai.use(solidity);
const {expect} = chai;

describe('INTEGRATION: Example', () => {
let provider = createMockProvider();
let [wallet, walletTo] = getWallets(provider);
let token;

beforeEach(async () => {
token = await deployContract(wallet, BasicTokenMock, ['HayCoin', 'HAY', 18, 1000]);
});

it('Is named HayCoin', async () => {
expect(await token.name()).to.eq('HayCoin');
});

it('Assigns initial balance', async () => {
expect(await token.balanceOf(wallet.address)).to.eq(1000);
});

it('Transfer adds amount to destination account', async () => {
await token.transfer(walletTo.address, 7);
expect(await token.balanceOf(walletTo.address)).to.eq(7);
});

it('Transfer emits event', async () => {
await expect(token.transfer(walletTo.address, 7))
.to.emit(token, 'Transfer')
.withArgs(wallet.address, walletTo.address, 7);
});

it('Can not transfer above the amount', async () => {
await expect(token.transfer(walletTo.address, 1007)).to.be.reverted;
});

it('Can not transfer from empty account', async () => {
const tokenFromOtherWallet = token.connect(walletTo);
await expect(tokenFromOtherWallet.transfer(wallet.address, 1))
.to.be.reverted;
});

});
Loading

0 comments on commit 36a59fb

Please sign in to comment.