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 a6889776f4.
* updates
* fixes #1200
* suggested change
This commit is contained in:
@ -8,34 +8,32 @@ require('chai')
|
||||
.should();
|
||||
|
||||
contract('SimpleToken', function ([_, creator]) {
|
||||
let token;
|
||||
|
||||
const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';
|
||||
|
||||
beforeEach(async function () {
|
||||
token = await SimpleToken.new({ from: creator });
|
||||
this.token = await SimpleToken.new({ from: creator });
|
||||
});
|
||||
|
||||
it('has a name', async function () {
|
||||
(await token.name()).should.equal('SimpleToken');
|
||||
(await this.token.name()).should.equal('SimpleToken');
|
||||
});
|
||||
|
||||
it('has a symbol', async function () {
|
||||
(await token.symbol()).should.equal('SIM');
|
||||
(await this.token.symbol()).should.equal('SIM');
|
||||
});
|
||||
|
||||
it('has 18 decimals', async function () {
|
||||
(await token.decimals()).should.be.bignumber.equal(18);
|
||||
(await this.token.decimals()).should.be.bignumber.equal(18);
|
||||
});
|
||||
|
||||
it('assigns the initial total supply to the creator', async function () {
|
||||
const totalSupply = await token.totalSupply();
|
||||
const creatorBalance = await token.balanceOf(creator);
|
||||
const totalSupply = await this.token.totalSupply();
|
||||
const creatorBalance = await this.token.balanceOf(creator);
|
||||
|
||||
creatorBalance.should.be.bignumber.equal(totalSupply);
|
||||
|
||||
const receipt = await web3.eth.getTransactionReceipt(token.transactionHash);
|
||||
const logs = decodeLogs(receipt.logs, SimpleToken, token.address);
|
||||
const receipt = await web3.eth.getTransactionReceipt(this.token.transactionHash);
|
||||
const logs = decodeLogs(receipt.logs, SimpleToken, this.token.address);
|
||||
logs.length.should.equal(1);
|
||||
logs[0].event.should.equal('Transfer');
|
||||
logs[0].args.from.valueOf().should.equal(ZERO_ADDRESS);
|
||||
|
||||
@ -7,10 +7,8 @@ require('chai')
|
||||
.should();
|
||||
|
||||
contract('MerkleProof', function () {
|
||||
let merkleProof;
|
||||
|
||||
beforeEach(async function () {
|
||||
merkleProof = await MerkleProofWrapper.new();
|
||||
this.merkleProof = await MerkleProofWrapper.new();
|
||||
});
|
||||
|
||||
describe('verify', function () {
|
||||
@ -24,7 +22,7 @@ contract('MerkleProof', function () {
|
||||
|
||||
const leaf = bufferToHex(sha3(elements[0]));
|
||||
|
||||
(await merkleProof.verify(proof, root, leaf)).should.equal(true);
|
||||
(await this.merkleProof.verify(proof, root, leaf)).should.equal(true);
|
||||
});
|
||||
|
||||
it('should return false for an invalid Merkle proof', async function () {
|
||||
@ -40,7 +38,7 @@ contract('MerkleProof', function () {
|
||||
|
||||
const badProof = badMerkleTree.getHexProof(badElements[0]);
|
||||
|
||||
(await merkleProof.verify(badProof, correctRoot, correctLeaf)).should.equal(false);
|
||||
(await this.merkleProof.verify(badProof, correctRoot, correctLeaf)).should.equal(false);
|
||||
});
|
||||
|
||||
it('should return false for a Merkle proof of invalid length', async function () {
|
||||
@ -54,7 +52,7 @@ contract('MerkleProof', function () {
|
||||
|
||||
const leaf = bufferToHex(sha3(elements[0]));
|
||||
|
||||
(await merkleProof.verify(badProof, root, leaf)).should.equal(false);
|
||||
(await this.merkleProof.verify(badProof, root, leaf)).should.equal(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@ -7,25 +7,23 @@ require('chai')
|
||||
const ERC20DetailedMock = artifacts.require('ERC20DetailedMock');
|
||||
|
||||
contract('ERC20Detailed', function () {
|
||||
let detailedERC20 = null;
|
||||
|
||||
const _name = 'My Detailed ERC20';
|
||||
const _symbol = 'MDT';
|
||||
const _decimals = 18;
|
||||
|
||||
beforeEach(async function () {
|
||||
detailedERC20 = await ERC20DetailedMock.new(_name, _symbol, _decimals);
|
||||
this.detailedERC20 = await ERC20DetailedMock.new(_name, _symbol, _decimals);
|
||||
});
|
||||
|
||||
it('has a name', async function () {
|
||||
(await detailedERC20.name()).should.be.equal(_name);
|
||||
(await this.detailedERC20.name()).should.be.equal(_name);
|
||||
});
|
||||
|
||||
it('has a symbol', async function () {
|
||||
(await detailedERC20.symbol()).should.be.equal(_symbol);
|
||||
(await this.detailedERC20.symbol()).should.be.equal(_symbol);
|
||||
});
|
||||
|
||||
it('has an amount of decimals', async function () {
|
||||
(await detailedERC20.decimals()).should.be.bignumber.equal(_decimals);
|
||||
(await this.detailedERC20.decimals()).should.be.bignumber.equal(_decimals);
|
||||
});
|
||||
});
|
||||
|
||||
@ -9,17 +9,14 @@ require('chai')
|
||||
.should();
|
||||
|
||||
contract('ReentrancyGuard', function () {
|
||||
let reentrancyMock;
|
||||
|
||||
beforeEach(async function () {
|
||||
reentrancyMock = await ReentrancyMock.new();
|
||||
const initialCounter = await reentrancyMock.counter();
|
||||
initialCounter.should.be.bignumber.equal(0);
|
||||
this.reentrancyMock = await ReentrancyMock.new();
|
||||
(await this.reentrancyMock.counter()).should.be.bignumber.equal(0);
|
||||
});
|
||||
|
||||
it('should not allow remote callback', async function () {
|
||||
const attacker = await ReentrancyAttack.new();
|
||||
await expectThrow(reentrancyMock.countAndCall(attacker.address));
|
||||
await expectThrow(this.reentrancyMock.countAndCall(attacker.address));
|
||||
});
|
||||
|
||||
// The following are more side-effects than intended behavior:
|
||||
@ -27,10 +24,10 @@ contract('ReentrancyGuard', function () {
|
||||
// in the side-effects.
|
||||
|
||||
it('should not allow local recursion', async function () {
|
||||
await expectThrow(reentrancyMock.countLocalRecursive(10));
|
||||
await expectThrow(this.reentrancyMock.countLocalRecursive(10));
|
||||
});
|
||||
|
||||
it('should not allow indirect local recursion', async function () {
|
||||
await expectThrow(reentrancyMock.countThisRecursive(10));
|
||||
await expectThrow(this.reentrancyMock.countThisRecursive(10));
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user