Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from 0xEther/master
Feat: Truffle tests to create DAI (MCD)
- Loading branch information
Showing
10 changed files
with
2,375 additions
and
2,223 deletions.
There are no files selected for viewing
File renamed without changes.
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,38 @@ | ||
const {BN, ether, balance} = require("openzeppelin-test-helpers"); | ||
const {expect} = require("chai"); | ||
const {asyncForEach} = require("./utils"); | ||
|
||
// ABI | ||
const daiABI = require("./abi/dai"); | ||
|
||
// userAddress must be unlocked using --unlock ADDRESS | ||
// https://etherscan.io/token/0x6b175474e89094c44da98b954eedeac495271d0f#balances) | ||
const userAddress = '0xdfbaf3e4c7496dad574a1b842bc85b402bdc298d'; | ||
// Dai | ||
const daiAddress = '0x6b175474e89094c44da98b954eedeac495271d0f'; | ||
const daiContract = new web3.eth.Contract(daiABI, daiAddress); | ||
|
||
contract("Truffle Mint Dai", async accounts => { | ||
it("should send ether to the Dai address", async () => { | ||
// Send 0.1 eth to userAddress to have gas to send an ERC20 tx. | ||
// Uses ForceSend contract, otherwise just sending | ||
// a normal tx will revert. | ||
const amount = ether("0.01"); | ||
await web3.eth.sendTransaction({from: accounts[0], to: userAddress, value: amount}) | ||
const ethBalance = await balance.current(userAddress); | ||
expect(new BN(ethBalance)).to.be.bignumber.least(new BN(ether("0.01"))); | ||
}); | ||
|
||
it("should mint Dai for our first 5 generated accounts", async () => { | ||
// Get 100 Dai for first 5 accounts | ||
await asyncForEach(accounts.slice(0, 5), async account => { | ||
// daiAddress is passed to ganache-cli with flag `--unlock` | ||
// so we can use the `transfer` method | ||
await daiContract.methods | ||
.transfer(account, '100000000000000000000') | ||
.send({from: userAddress, gasLimit: 800000}); | ||
const daiBalance = await daiContract.methods.balanceOf(account).call(); | ||
expect(new BN(daiBalance)).to.be.bignumber.least(ether("100")); | ||
}); | ||
}); | ||
}); |
File renamed without changes.
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
File renamed without changes.
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,325 @@ | ||
module.exports = [ | ||
{ | ||
constant: true, | ||
inputs: [], | ||
name: "name", | ||
outputs: [{ name: "", type: "bytes32" }], | ||
payable: false, | ||
stateMutability: "view", | ||
type: "function" | ||
}, | ||
{ | ||
constant: false, | ||
inputs: [], | ||
name: "stop", | ||
outputs: [], | ||
payable: false, | ||
stateMutability: "nonpayable", | ||
type: "function" | ||
}, | ||
{ | ||
constant: false, | ||
inputs: [ | ||
{ name: "guy", type: "address" }, | ||
{ name: "wad", type: "uint256" } | ||
], | ||
name: "approve", | ||
outputs: [{ name: "", type: "bool" }], | ||
payable: false, | ||
stateMutability: "nonpayable", | ||
type: "function" | ||
}, | ||
{ | ||
constant: false, | ||
inputs: [{ name: "owner_", type: "address" }], | ||
name: "setOwner", | ||
outputs: [], | ||
payable: false, | ||
stateMutability: "nonpayable", | ||
type: "function" | ||
}, | ||
{ | ||
constant: true, | ||
inputs: [], | ||
name: "totalSupply", | ||
outputs: [{ name: "", type: "uint256" }], | ||
payable: false, | ||
stateMutability: "view", | ||
type: "function" | ||
}, | ||
{ | ||
constant: false, | ||
inputs: [ | ||
{ name: "src", type: "address" }, | ||
{ name: "dst", type: "address" }, | ||
{ name: "wad", type: "uint256" } | ||
], | ||
name: "transferFrom", | ||
outputs: [{ name: "", type: "bool" }], | ||
payable: false, | ||
stateMutability: "nonpayable", | ||
type: "function" | ||
}, | ||
{ | ||
constant: true, | ||
inputs: [], | ||
name: "decimals", | ||
outputs: [{ name: "", type: "uint256" }], | ||
payable: false, | ||
stateMutability: "view", | ||
type: "function" | ||
}, | ||
{ | ||
constant: false, | ||
inputs: [ | ||
{ name: "guy", type: "address" }, | ||
{ name: "wad", type: "uint256" } | ||
], | ||
name: "mint", | ||
outputs: [], | ||
payable: false, | ||
stateMutability: "nonpayable", | ||
type: "function" | ||
}, | ||
{ | ||
constant: false, | ||
inputs: [{ name: "wad", type: "uint256" }], | ||
name: "burn", | ||
outputs: [], | ||
payable: false, | ||
stateMutability: "nonpayable", | ||
type: "function" | ||
}, | ||
{ | ||
constant: false, | ||
inputs: [{ name: "name_", type: "bytes32" }], | ||
name: "setName", | ||
outputs: [], | ||
payable: false, | ||
stateMutability: "nonpayable", | ||
type: "function" | ||
}, | ||
{ | ||
constant: true, | ||
inputs: [{ name: "src", type: "address" }], | ||
name: "balanceOf", | ||
outputs: [{ name: "", type: "uint256" }], | ||
payable: false, | ||
stateMutability: "view", | ||
type: "function" | ||
}, | ||
{ | ||
constant: true, | ||
inputs: [], | ||
name: "stopped", | ||
outputs: [{ name: "", type: "bool" }], | ||
payable: false, | ||
stateMutability: "view", | ||
type: "function" | ||
}, | ||
{ | ||
constant: false, | ||
inputs: [{ name: "authority_", type: "address" }], | ||
name: "setAuthority", | ||
outputs: [], | ||
payable: false, | ||
stateMutability: "nonpayable", | ||
type: "function" | ||
}, | ||
{ | ||
constant: true, | ||
inputs: [], | ||
name: "owner", | ||
outputs: [{ name: "", type: "address" }], | ||
payable: false, | ||
stateMutability: "view", | ||
type: "function" | ||
}, | ||
{ | ||
constant: true, | ||
inputs: [], | ||
name: "symbol", | ||
outputs: [{ name: "", type: "bytes32" }], | ||
payable: false, | ||
stateMutability: "view", | ||
type: "function" | ||
}, | ||
{ | ||
constant: false, | ||
inputs: [ | ||
{ name: "guy", type: "address" }, | ||
{ name: "wad", type: "uint256" } | ||
], | ||
name: "burn", | ||
outputs: [], | ||
payable: false, | ||
stateMutability: "nonpayable", | ||
type: "function" | ||
}, | ||
{ | ||
constant: false, | ||
inputs: [{ name: "wad", type: "uint256" }], | ||
name: "mint", | ||
outputs: [], | ||
payable: false, | ||
stateMutability: "nonpayable", | ||
type: "function" | ||
}, | ||
{ | ||
constant: false, | ||
inputs: [ | ||
{ name: "dst", type: "address" }, | ||
{ name: "wad", type: "uint256" } | ||
], | ||
name: "transfer", | ||
outputs: [{ name: "", type: "bool" }], | ||
payable: false, | ||
stateMutability: "nonpayable", | ||
type: "function" | ||
}, | ||
{ | ||
constant: false, | ||
inputs: [ | ||
{ name: "dst", type: "address" }, | ||
{ name: "wad", type: "uint256" } | ||
], | ||
name: "push", | ||
outputs: [], | ||
payable: false, | ||
stateMutability: "nonpayable", | ||
type: "function" | ||
}, | ||
{ | ||
constant: false, | ||
inputs: [ | ||
{ name: "src", type: "address" }, | ||
{ name: "dst", type: "address" }, | ||
{ name: "wad", type: "uint256" } | ||
], | ||
name: "move", | ||
outputs: [], | ||
payable: false, | ||
stateMutability: "nonpayable", | ||
type: "function" | ||
}, | ||
{ | ||
constant: false, | ||
inputs: [], | ||
name: "start", | ||
outputs: [], | ||
payable: false, | ||
stateMutability: "nonpayable", | ||
type: "function" | ||
}, | ||
{ | ||
constant: true, | ||
inputs: [], | ||
name: "authority", | ||
outputs: [{ name: "", type: "address" }], | ||
payable: false, | ||
stateMutability: "view", | ||
type: "function" | ||
}, | ||
{ | ||
constant: false, | ||
inputs: [{ name: "guy", type: "address" }], | ||
name: "approve", | ||
outputs: [{ name: "", type: "bool" }], | ||
payable: false, | ||
stateMutability: "nonpayable", | ||
type: "function" | ||
}, | ||
{ | ||
constant: true, | ||
inputs: [ | ||
{ name: "src", type: "address" }, | ||
{ name: "guy", type: "address" } | ||
], | ||
name: "allowance", | ||
outputs: [{ name: "", type: "uint256" }], | ||
payable: false, | ||
stateMutability: "view", | ||
type: "function" | ||
}, | ||
{ | ||
constant: false, | ||
inputs: [ | ||
{ name: "src", type: "address" }, | ||
{ name: "wad", type: "uint256" } | ||
], | ||
name: "pull", | ||
outputs: [], | ||
payable: false, | ||
stateMutability: "nonpayable", | ||
type: "function" | ||
}, | ||
{ | ||
inputs: [{ name: "symbol_", type: "bytes32" }], | ||
payable: false, | ||
stateMutability: "nonpayable", | ||
type: "constructor" | ||
}, | ||
{ | ||
anonymous: false, | ||
inputs: [ | ||
{ indexed: true, name: "guy", type: "address" }, | ||
{ indexed: false, name: "wad", type: "uint256" } | ||
], | ||
name: "Mint", | ||
type: "event" | ||
}, | ||
{ | ||
anonymous: false, | ||
inputs: [ | ||
{ indexed: true, name: "guy", type: "address" }, | ||
{ indexed: false, name: "wad", type: "uint256" } | ||
], | ||
name: "Burn", | ||
type: "event" | ||
}, | ||
{ | ||
anonymous: false, | ||
inputs: [{ indexed: true, name: "authority", type: "address" }], | ||
name: "LogSetAuthority", | ||
type: "event" | ||
}, | ||
{ | ||
anonymous: false, | ||
inputs: [{ indexed: true, name: "owner", type: "address" }], | ||
name: "LogSetOwner", | ||
type: "event" | ||
}, | ||
{ | ||
anonymous: true, | ||
inputs: [ | ||
{ indexed: true, name: "sig", type: "bytes4" }, | ||
{ indexed: true, name: "guy", type: "address" }, | ||
{ indexed: true, name: "foo", type: "bytes32" }, | ||
{ indexed: true, name: "bar", type: "bytes32" }, | ||
{ indexed: false, name: "wad", type: "uint256" }, | ||
{ indexed: false, name: "fax", type: "bytes" } | ||
], | ||
name: "LogNote", | ||
type: "event" | ||
}, | ||
{ | ||
anonymous: false, | ||
inputs: [ | ||
{ indexed: true, name: "src", type: "address" }, | ||
{ indexed: true, name: "guy", type: "address" }, | ||
{ indexed: false, name: "wad", type: "uint256" } | ||
], | ||
name: "Approval", | ||
type: "event" | ||
}, | ||
{ | ||
anonymous: false, | ||
inputs: [ | ||
{ indexed: true, name: "src", type: "address" }, | ||
{ indexed: true, name: "dst", type: "address" }, | ||
{ indexed: false, name: "wad", type: "uint256" } | ||
], | ||
name: "Transfer", | ||
type: "event" | ||
} | ||
]; |
Oops, something went wrong.