All tests now use account names, and dont use accounts[0] (except ERC… (#1137)
* All tests now use account names, and dont use accounts[0] (except ERC721) * Added account names to some missing contracts.
This commit is contained in:
@ -3,15 +3,13 @@ const { ethGetBalance, ethSendTransaction } = require('./helpers/web3');
|
||||
|
||||
const SimpleSavingsWallet = artifacts.require('SimpleSavingsWallet');
|
||||
|
||||
contract('SimpleSavingsWallet', function (accounts) {
|
||||
contract('SimpleSavingsWallet', function ([_, owner, anyone]) {
|
||||
let savingsWallet;
|
||||
let owner;
|
||||
|
||||
const paymentAmount = 4242;
|
||||
|
||||
beforeEach(async function () {
|
||||
savingsWallet = await SimpleSavingsWallet.new(4141);
|
||||
owner = await savingsWallet.owner();
|
||||
savingsWallet = await SimpleSavingsWallet.new(4141, { from: owner });
|
||||
});
|
||||
|
||||
it('should receive funds', async function () {
|
||||
@ -22,14 +20,15 @@ contract('SimpleSavingsWallet', function (accounts) {
|
||||
|
||||
it('owner can send funds', async function () {
|
||||
// Receive payment so we have some money to spend.
|
||||
await ethSendTransaction({ from: accounts[9], to: savingsWallet.address, value: 1000000 });
|
||||
await ethSendTransaction({ from: anyone, to: savingsWallet.address, value: 1000000 });
|
||||
|
||||
await expectThrow(savingsWallet.sendTo(0, paymentAmount, { from: owner }));
|
||||
await expectThrow(savingsWallet.sendTo(savingsWallet.address, paymentAmount, { from: owner }));
|
||||
await expectThrow(savingsWallet.sendTo(accounts[1], 0, { from: owner }));
|
||||
await expectThrow(savingsWallet.sendTo(anyone, 0, { from: owner }));
|
||||
|
||||
const balance = await ethGetBalance(accounts[1]);
|
||||
await savingsWallet.sendTo(accounts[1], paymentAmount, { from: owner });
|
||||
const updatedBalance = await ethGetBalance(accounts[1]);
|
||||
const balance = await ethGetBalance(anyone);
|
||||
await savingsWallet.sendTo(anyone, paymentAmount, { from: owner });
|
||||
const updatedBalance = await ethGetBalance(anyone);
|
||||
assert.isTrue(balance.plus(paymentAmount).equals(updatedBalance));
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user