Skip to content

Commit ebada53

Browse files
committed
Added account names to some missing contracts.
1 parent f7b431b commit ebada53

File tree

4 files changed

+20
-36
lines changed

4 files changed

+20
-36
lines changed

test/Heritable.test.js

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,11 @@ const NULL_ADDRESS = '0x0000000000000000000000000000000000000000';
66

77
const Heritable = artifacts.require('Heritable');
88

9-
contract('Heritable', function (accounts) {
9+
contract('Heritable', function ([_, owner, heir, anyone]) {
1010
let heritable;
11-
let owner;
1211

1312
beforeEach(async function () {
14-
heritable = await Heritable.new(4141);
15-
owner = await heritable.owner();
13+
heritable = await Heritable.new(4141, { from: owner });
1614
});
1715

1816
it('should start off with an owner, but without heir', async function () {
@@ -31,31 +29,23 @@ contract('Heritable', function (accounts) {
3129
});
3230

3331
it('only owner should set heir', async function () {
34-
const newHeir = accounts[1];
35-
const someRandomAddress = accounts[2];
36-
assert.isTrue(owner !== someRandomAddress);
37-
38-
await heritable.setHeir(newHeir, { from: owner });
39-
await expectThrow(heritable.setHeir(newHeir, { from: someRandomAddress }));
32+
await heritable.setHeir(heir, { from: owner });
33+
await expectThrow(heritable.setHeir(heir, { from: anyone }));
4034
});
4135

4236
it('owner can\'t be heir', async function () {
4337
await assertRevert(heritable.setHeir(owner, { from: owner }));
4438
});
4539

4640
it('owner can remove heir', async function () {
47-
const newHeir = accounts[1];
48-
await heritable.setHeir(newHeir, { from: owner });
49-
let heir = await heritable.heir();
50-
51-
assert.notStrictEqual(heir, NULL_ADDRESS);
52-
await heritable.removeHeir();
53-
heir = await heritable.heir();
54-
assert.isTrue(heir === NULL_ADDRESS);
41+
await heritable.setHeir(heir, { from: owner });
42+
assert.equal(await heritable.heir(), heir);
43+
44+
await heritable.removeHeir({ from: owner });
45+
assert.equal(await heritable.heir(), NULL_ADDRESS);
5546
});
5647

5748
it('heir can claim ownership only if owner is dead and timeout was reached', async function () {
58-
const heir = accounts[1];
5949
await heritable.setHeir(heir, { from: owner });
6050
await expectThrow(heritable.claimHeirOwnership({ from: heir }));
6151

@@ -69,20 +59,17 @@ contract('Heritable', function (accounts) {
6959
});
7060

7161
it('only heir can proclaim death', async function () {
72-
const someRandomAddress = accounts[2];
7362
await assertRevert(heritable.proclaimDeath({ from: owner }));
74-
await assertRevert(heritable.proclaimDeath({ from: someRandomAddress }));
63+
await assertRevert(heritable.proclaimDeath({ from: anyone }));
7564
});
7665

7766
it('heir can\'t proclaim death if owner is death', async function () {
78-
const heir = accounts[1];
7967
await heritable.setHeir(heir, { from: owner });
8068
await heritable.proclaimDeath({ from: heir });
8169
await assertRevert(heritable.proclaimDeath({ from: heir }));
8270
});
8371

8472
it('heir can\'t claim ownership if owner heartbeats', async function () {
85-
const heir = accounts[1];
8673
await heritable.setHeir(heir, { from: owner });
8774

8875
await heritable.proclaimDeath({ from: heir });
@@ -96,8 +83,6 @@ contract('Heritable', function (accounts) {
9683
});
9784

9885
it('should log events appropriately', async function () {
99-
const heir = accounts[1];
100-
10186
const setHeirLogs = (await heritable.setHeir(heir, { from: owner })).logs;
10287
const setHeirEvent = setHeirLogs.find(e => e.event === 'HeirChanged');
10388

test/LimitBalance.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const { ethGetBalance } = require('./helpers/web3');
33

44
const LimitBalanceMock = artifacts.require('LimitBalanceMock');
55

6-
contract('LimitBalance', function (accounts) {
6+
contract('LimitBalance', function () {
77
let limitBalance;
88

99
beforeEach(async function () {

test/ReentrancyGuard.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const { expectThrow } = require('./helpers/expectThrow');
22
const ReentrancyMock = artifacts.require('ReentrancyMock');
33
const ReentrancyAttack = artifacts.require('ReentrancyAttack');
44

5-
contract('ReentrancyGuard', function (accounts) {
5+
contract('ReentrancyGuard', function () {
66
let reentrancyMock;
77

88
beforeEach(async function () {

test/SimpleSavingsWallet.test.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,13 @@ const { ethGetBalance, ethSendTransaction } = require('./helpers/web3');
33

44
const SimpleSavingsWallet = artifacts.require('SimpleSavingsWallet');
55

6-
contract('SimpleSavingsWallet', function (accounts) {
6+
contract('SimpleSavingsWallet', function ([_, owner, anyone]) {
77
let savingsWallet;
8-
let owner;
98

109
const paymentAmount = 4242;
1110

1211
beforeEach(async function () {
13-
savingsWallet = await SimpleSavingsWallet.new(4141);
14-
owner = await savingsWallet.owner();
12+
savingsWallet = await SimpleSavingsWallet.new(4141, { from: owner });
1513
});
1614

1715
it('should receive funds', async function () {
@@ -22,14 +20,15 @@ contract('SimpleSavingsWallet', function (accounts) {
2220

2321
it('owner can send funds', async function () {
2422
// Receive payment so we have some money to spend.
25-
await ethSendTransaction({ from: accounts[9], to: savingsWallet.address, value: 1000000 });
23+
await ethSendTransaction({ from: anyone, to: savingsWallet.address, value: 1000000 });
24+
2625
await expectThrow(savingsWallet.sendTo(0, paymentAmount, { from: owner }));
2726
await expectThrow(savingsWallet.sendTo(savingsWallet.address, paymentAmount, { from: owner }));
28-
await expectThrow(savingsWallet.sendTo(accounts[1], 0, { from: owner }));
27+
await expectThrow(savingsWallet.sendTo(anyone, 0, { from: owner }));
2928

30-
const balance = await ethGetBalance(accounts[1]);
31-
await savingsWallet.sendTo(accounts[1], paymentAmount, { from: owner });
32-
const updatedBalance = await ethGetBalance(accounts[1]);
29+
const balance = await ethGetBalance(anyone);
30+
await savingsWallet.sendTo(anyone, paymentAmount, { from: owner });
31+
const updatedBalance = await ethGetBalance(anyone);
3332
assert.isTrue(balance.plus(paymentAmount).equals(updatedBalance));
3433
});
3534
});

0 commit comments

Comments
 (0)