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();
|
.should();
|
||||||
|
|
||||||
contract('SimpleToken', function ([_, creator]) {
|
contract('SimpleToken', function ([_, creator]) {
|
||||||
let token;
|
|
||||||
|
|
||||||
const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';
|
const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';
|
||||||
|
|
||||||
beforeEach(async function () {
|
beforeEach(async function () {
|
||||||
token = await SimpleToken.new({ from: creator });
|
this.token = await SimpleToken.new({ from: creator });
|
||||||
});
|
});
|
||||||
|
|
||||||
it('has a name', async function () {
|
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 () {
|
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 () {
|
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 () {
|
it('assigns the initial total supply to the creator', async function () {
|
||||||
const totalSupply = await token.totalSupply();
|
const totalSupply = await this.token.totalSupply();
|
||||||
const creatorBalance = await token.balanceOf(creator);
|
const creatorBalance = await this.token.balanceOf(creator);
|
||||||
|
|
||||||
creatorBalance.should.be.bignumber.equal(totalSupply);
|
creatorBalance.should.be.bignumber.equal(totalSupply);
|
||||||
|
|
||||||
const receipt = await web3.eth.getTransactionReceipt(token.transactionHash);
|
const receipt = await web3.eth.getTransactionReceipt(this.token.transactionHash);
|
||||||
const logs = decodeLogs(receipt.logs, SimpleToken, token.address);
|
const logs = decodeLogs(receipt.logs, SimpleToken, this.token.address);
|
||||||
logs.length.should.equal(1);
|
logs.length.should.equal(1);
|
||||||
logs[0].event.should.equal('Transfer');
|
logs[0].event.should.equal('Transfer');
|
||||||
logs[0].args.from.valueOf().should.equal(ZERO_ADDRESS);
|
logs[0].args.from.valueOf().should.equal(ZERO_ADDRESS);
|
||||||
|
|||||||
@ -7,10 +7,8 @@ require('chai')
|
|||||||
.should();
|
.should();
|
||||||
|
|
||||||
contract('MerkleProof', function () {
|
contract('MerkleProof', function () {
|
||||||
let merkleProof;
|
|
||||||
|
|
||||||
beforeEach(async function () {
|
beforeEach(async function () {
|
||||||
merkleProof = await MerkleProofWrapper.new();
|
this.merkleProof = await MerkleProofWrapper.new();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('verify', function () {
|
describe('verify', function () {
|
||||||
@ -24,7 +22,7 @@ contract('MerkleProof', function () {
|
|||||||
|
|
||||||
const leaf = bufferToHex(sha3(elements[0]));
|
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 () {
|
it('should return false for an invalid Merkle proof', async function () {
|
||||||
@ -40,7 +38,7 @@ contract('MerkleProof', function () {
|
|||||||
|
|
||||||
const badProof = badMerkleTree.getHexProof(badElements[0]);
|
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 () {
|
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]));
|
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');
|
const ERC20DetailedMock = artifacts.require('ERC20DetailedMock');
|
||||||
|
|
||||||
contract('ERC20Detailed', function () {
|
contract('ERC20Detailed', function () {
|
||||||
let detailedERC20 = null;
|
|
||||||
|
|
||||||
const _name = 'My Detailed ERC20';
|
const _name = 'My Detailed ERC20';
|
||||||
const _symbol = 'MDT';
|
const _symbol = 'MDT';
|
||||||
const _decimals = 18;
|
const _decimals = 18;
|
||||||
|
|
||||||
beforeEach(async function () {
|
beforeEach(async function () {
|
||||||
detailedERC20 = await ERC20DetailedMock.new(_name, _symbol, _decimals);
|
this.detailedERC20 = await ERC20DetailedMock.new(_name, _symbol, _decimals);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('has a name', async function () {
|
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 () {
|
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 () {
|
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();
|
.should();
|
||||||
|
|
||||||
contract('ReentrancyGuard', function () {
|
contract('ReentrancyGuard', function () {
|
||||||
let reentrancyMock;
|
|
||||||
|
|
||||||
beforeEach(async function () {
|
beforeEach(async function () {
|
||||||
reentrancyMock = await ReentrancyMock.new();
|
this.reentrancyMock = await ReentrancyMock.new();
|
||||||
const initialCounter = await reentrancyMock.counter();
|
(await this.reentrancyMock.counter()).should.be.bignumber.equal(0);
|
||||||
initialCounter.should.be.bignumber.equal(0);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not allow remote callback', async function () {
|
it('should not allow remote callback', async function () {
|
||||||
const attacker = await ReentrancyAttack.new();
|
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:
|
// The following are more side-effects than intended behavior:
|
||||||
@ -27,10 +24,10 @@ contract('ReentrancyGuard', function () {
|
|||||||
// in the side-effects.
|
// in the side-effects.
|
||||||
|
|
||||||
it('should not allow local recursion', async function () {
|
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 () {
|
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