forked from wagyuswapapp/wagyu-swap-core
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 36a59fb
Showing
6 changed files
with
7,217 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.sol linguist-language=Solidity |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules/ | ||
build/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
}); | ||
|
||
}); |
Oops, something went wrong.