Skip to content

Commit b41b125

Browse files
Aniket-Enggnventuro
authored andcommitted
this is used in tests (#1380)
* signing prefix added * Minor improvement * Tests changed * Successfully tested * Minor improvements * Minor improvements * Revert "Dangling commas are now required. (#1359)" This reverts commit a688977. * updates * fixes #1200 * suggested change
1 parent fd4de77 commit b41b125

File tree

4 files changed

+21
-30
lines changed

4 files changed

+21
-30
lines changed

test/examples/SimpleToken.test.js

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,34 +8,32 @@ require('chai')
88
.should();
99

1010
contract('SimpleToken', function ([_, creator]) {
11-
let token;
12-
1311
const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';
1412

1513
beforeEach(async function () {
16-
token = await SimpleToken.new({ from: creator });
14+
this.token = await SimpleToken.new({ from: creator });
1715
});
1816

1917
it('has a name', async function () {
20-
(await token.name()).should.equal('SimpleToken');
18+
(await this.token.name()).should.equal('SimpleToken');
2119
});
2220

2321
it('has a symbol', async function () {
24-
(await token.symbol()).should.equal('SIM');
22+
(await this.token.symbol()).should.equal('SIM');
2523
});
2624

2725
it('has 18 decimals', async function () {
28-
(await token.decimals()).should.be.bignumber.equal(18);
26+
(await this.token.decimals()).should.be.bignumber.equal(18);
2927
});
3028

3129
it('assigns the initial total supply to the creator', async function () {
32-
const totalSupply = await token.totalSupply();
33-
const creatorBalance = await token.balanceOf(creator);
30+
const totalSupply = await this.token.totalSupply();
31+
const creatorBalance = await this.token.balanceOf(creator);
3432

3533
creatorBalance.should.be.bignumber.equal(totalSupply);
3634

37-
const receipt = await web3.eth.getTransactionReceipt(token.transactionHash);
38-
const logs = decodeLogs(receipt.logs, SimpleToken, token.address);
35+
const receipt = await web3.eth.getTransactionReceipt(this.token.transactionHash);
36+
const logs = decodeLogs(receipt.logs, SimpleToken, this.token.address);
3937
logs.length.should.equal(1);
4038
logs[0].event.should.equal('Transfer');
4139
logs[0].args.from.valueOf().should.equal(ZERO_ADDRESS);

test/library/MerkleProof.test.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,8 @@ require('chai')
77
.should();
88

99
contract('MerkleProof', function () {
10-
let merkleProof;
11-
1210
beforeEach(async function () {
13-
merkleProof = await MerkleProofWrapper.new();
11+
this.merkleProof = await MerkleProofWrapper.new();
1412
});
1513

1614
describe('verify', function () {
@@ -24,7 +22,7 @@ contract('MerkleProof', function () {
2422

2523
const leaf = bufferToHex(sha3(elements[0]));
2624

27-
(await merkleProof.verify(proof, root, leaf)).should.equal(true);
25+
(await this.merkleProof.verify(proof, root, leaf)).should.equal(true);
2826
});
2927

3028
it('should return false for an invalid Merkle proof', async function () {
@@ -40,7 +38,7 @@ contract('MerkleProof', function () {
4038

4139
const badProof = badMerkleTree.getHexProof(badElements[0]);
4240

43-
(await merkleProof.verify(badProof, correctRoot, correctLeaf)).should.equal(false);
41+
(await this.merkleProof.verify(badProof, correctRoot, correctLeaf)).should.equal(false);
4442
});
4543

4644
it('should return false for a Merkle proof of invalid length', async function () {
@@ -54,7 +52,7 @@ contract('MerkleProof', function () {
5452

5553
const leaf = bufferToHex(sha3(elements[0]));
5654

57-
(await merkleProof.verify(badProof, root, leaf)).should.equal(false);
55+
(await this.merkleProof.verify(badProof, root, leaf)).should.equal(false);
5856
});
5957
});
6058
});

test/token/ERC20/ERC20Detailed.test.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,23 @@ require('chai')
77
const ERC20DetailedMock = artifacts.require('ERC20DetailedMock');
88

99
contract('ERC20Detailed', function () {
10-
let detailedERC20 = null;
11-
1210
const _name = 'My Detailed ERC20';
1311
const _symbol = 'MDT';
1412
const _decimals = 18;
1513

1614
beforeEach(async function () {
17-
detailedERC20 = await ERC20DetailedMock.new(_name, _symbol, _decimals);
15+
this.detailedERC20 = await ERC20DetailedMock.new(_name, _symbol, _decimals);
1816
});
1917

2018
it('has a name', async function () {
21-
(await detailedERC20.name()).should.be.equal(_name);
19+
(await this.detailedERC20.name()).should.be.equal(_name);
2220
});
2321

2422
it('has a symbol', async function () {
25-
(await detailedERC20.symbol()).should.be.equal(_symbol);
23+
(await this.detailedERC20.symbol()).should.be.equal(_symbol);
2624
});
2725

2826
it('has an amount of decimals', async function () {
29-
(await detailedERC20.decimals()).should.be.bignumber.equal(_decimals);
27+
(await this.detailedERC20.decimals()).should.be.bignumber.equal(_decimals);
3028
});
3129
});

test/utils/ReentrancyGuard.test.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,25 @@ require('chai')
99
.should();
1010

1111
contract('ReentrancyGuard', function () {
12-
let reentrancyMock;
13-
1412
beforeEach(async function () {
15-
reentrancyMock = await ReentrancyMock.new();
16-
const initialCounter = await reentrancyMock.counter();
17-
initialCounter.should.be.bignumber.equal(0);
13+
this.reentrancyMock = await ReentrancyMock.new();
14+
(await this.reentrancyMock.counter()).should.be.bignumber.equal(0);
1815
});
1916

2017
it('should not allow remote callback', async function () {
2118
const attacker = await ReentrancyAttack.new();
22-
await expectThrow(reentrancyMock.countAndCall(attacker.address));
19+
await expectThrow(this.reentrancyMock.countAndCall(attacker.address));
2320
});
2421

2522
// The following are more side-effects than intended behavior:
2623
// I put them here as documentation, and to monitor any changes
2724
// in the side-effects.
2825

2926
it('should not allow local recursion', async function () {
30-
await expectThrow(reentrancyMock.countLocalRecursive(10));
27+
await expectThrow(this.reentrancyMock.countLocalRecursive(10));
3128
});
3229

3330
it('should not allow indirect local recursion', async function () {
34-
await expectThrow(reentrancyMock.countThisRecursive(10));
31+
await expectThrow(this.reentrancyMock.countThisRecursive(10));
3532
});
3633
});

0 commit comments

Comments
 (0)