Skip to content

Commit

Permalink
Add Mock suffix to variable names #1172 (#1324)
Browse files Browse the repository at this point in the history
* Add Mock suffix to variable names #1172

* Add Impl suffix to variable names
  • Loading branch information
tinchoabbate authored and nventuro committed Sep 18, 2018
1 parent d062352 commit 4b21fcf
Show file tree
Hide file tree
Showing 18 changed files with 50 additions and 48 deletions.
4 changes: 2 additions & 2 deletions test/Counter.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

const Counter = artifacts.require('CounterImpl');
const CounterImpl = artifacts.require('CounterImpl');

require('chai')
.use(require('chai-bignumber')(web3.BigNumber))
Expand All @@ -11,7 +11,7 @@ const KEY2 = web3.sha3('key2');

contract('Counter', function ([_, owner]) {
beforeEach(async function () {
this.mock = await Counter.new({ from: owner });
this.mock = await CounterImpl.new({ from: owner });
});

context('custom key', async function () {
Expand Down
6 changes: 3 additions & 3 deletions test/crowdsale/AllowanceCrowdsale.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const should = require('chai')
.use(require('chai-bignumber')(BigNumber))
.should();

const AllowanceCrowdsale = artifacts.require('AllowanceCrowdsaleImpl');
const AllowanceCrowdsaleImpl = artifacts.require('AllowanceCrowdsaleImpl');
const SimpleToken = artifacts.require('SimpleToken');

contract('AllowanceCrowdsale', function ([_, investor, wallet, purchaser, tokenWallet]) {
Expand All @@ -20,7 +20,7 @@ contract('AllowanceCrowdsale', function ([_, investor, wallet, purchaser, tokenW

beforeEach(async function () {
this.token = await SimpleToken.new({ from: tokenWallet });
this.crowdsale = await AllowanceCrowdsale.new(rate, wallet, this.token.address, tokenWallet);
this.crowdsale = await AllowanceCrowdsaleImpl.new(rate, wallet, this.token.address, tokenWallet);
await this.token.approve(this.crowdsale.address, tokenAllowance, { from: tokenWallet });
});

Expand Down Expand Up @@ -73,7 +73,7 @@ contract('AllowanceCrowdsale', function ([_, investor, wallet, purchaser, tokenW
describe('when token wallet is different from token address', function () {
it('creation reverts', async function () {
this.token = await SimpleToken.new({ from: tokenWallet });
await assertRevert(AllowanceCrowdsale.new(rate, wallet, this.token.address, ZERO_ADDRESS));
await assertRevert(AllowanceCrowdsaleImpl.new(rate, wallet, this.token.address, ZERO_ADDRESS));
});
});
});
6 changes: 3 additions & 3 deletions test/crowdsale/CappedCrowdsale.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require('chai')
.use(require('chai-bignumber')(BigNumber))
.should();

const CappedCrowdsale = artifacts.require('CappedCrowdsaleImpl');
const CappedCrowdsaleImpl = artifacts.require('CappedCrowdsaleImpl');
const SimpleToken = artifacts.require('SimpleToken');

contract('CappedCrowdsale', function ([_, wallet]) {
Expand All @@ -23,14 +23,14 @@ contract('CappedCrowdsale', function ([_, wallet]) {

it('rejects a cap of zero', async function () {
await expectThrow(
CappedCrowdsale.new(rate, wallet, this.token.address, 0),
CappedCrowdsaleImpl.new(rate, wallet, this.token.address, 0),
EVMRevert,
);
});

context('with crowdsale', function () {
beforeEach(async function () {
this.crowdsale = await CappedCrowdsale.new(rate, wallet, this.token.address, cap);
this.crowdsale = await CappedCrowdsaleImpl.new(rate, wallet, this.token.address, cap);
await this.token.transfer(this.crowdsale.address, tokenSupply);
});

Expand Down
4 changes: 2 additions & 2 deletions test/crowdsale/FinalizableCrowdsale.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const should = require('chai')
.use(require('chai-bignumber')(BigNumber))
.should();

const FinalizableCrowdsale = artifacts.require('FinalizableCrowdsaleImpl');
const FinalizableCrowdsaleImpl = artifacts.require('FinalizableCrowdsaleImpl');
const ERC20 = artifacts.require('ERC20');

contract('FinalizableCrowdsale', function ([_, wallet, anyone]) {
Expand All @@ -27,7 +27,7 @@ contract('FinalizableCrowdsale', function ([_, wallet, anyone]) {
this.afterClosingTime = this.closingTime + duration.seconds(1);

this.token = await ERC20.new();
this.crowdsale = await FinalizableCrowdsale.new(
this.crowdsale = await FinalizableCrowdsaleImpl.new(
this.openingTime, this.closingTime, rate, wallet, this.token.address
);
});
Expand Down
8 changes: 4 additions & 4 deletions test/crowdsale/IncreasingPriceCrowdsale.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require('chai')
.use(require('chai-bignumber')(BigNumber))
.should();

const IncreasingPriceCrowdsale = artifacts.require('IncreasingPriceCrowdsaleImpl');
const IncreasingPriceCrowdsaleImpl = artifacts.require('IncreasingPriceCrowdsaleImpl');
const SimpleToken = artifacts.require('SimpleToken');

contract('IncreasingPriceCrowdsale', function ([_, investor, wallet, purchaser]) {
Expand All @@ -36,20 +36,20 @@ contract('IncreasingPriceCrowdsale', function ([_, investor, wallet, purchaser])
});

it('rejects a final rate larger than the initial rate', async function () {
await assertRevert(IncreasingPriceCrowdsale.new(
await assertRevert(IncreasingPriceCrowdsaleImpl.new(
this.startTime, this.closingTime, wallet, this.token.address, initialRate, initialRate.plus(1)
));
});

it('rejects a final rate of zero', async function () {
await assertRevert(IncreasingPriceCrowdsale.new(
await assertRevert(IncreasingPriceCrowdsaleImpl.new(
this.startTime, this.closingTime, wallet, this.token.address, initialRate, 0
));
});

context('with crowdsale', function () {
beforeEach(async function () {
this.crowdsale = await IncreasingPriceCrowdsale.new(
this.crowdsale = await IncreasingPriceCrowdsaleImpl.new(
this.startTime, this.closingTime, wallet, this.token.address, initialRate, finalRate
);
await this.token.transfer(this.crowdsale.address, tokenSupply);
Expand Down
6 changes: 3 additions & 3 deletions test/crowdsale/MintedCrowdsale.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const { assertRevert } = require('../helpers/assertRevert');

const BigNumber = web3.BigNumber;

const MintedCrowdsale = artifacts.require('MintedCrowdsaleImpl');
const MintedCrowdsaleImpl = artifacts.require('MintedCrowdsaleImpl');
const ERC20Mintable = artifacts.require('ERC20Mintable');
const ERC20 = artifacts.require('ERC20');

Expand All @@ -15,7 +15,7 @@ contract('MintedCrowdsale', function ([_, deployer, investor, wallet, purchaser]
describe('using ERC20Mintable', function () {
beforeEach(async function () {
this.token = await ERC20Mintable.new({ from: deployer });
this.crowdsale = await MintedCrowdsale.new(rate, wallet, this.token.address);
this.crowdsale = await MintedCrowdsaleImpl.new(rate, wallet, this.token.address);

await this.token.addMinter(this.crowdsale.address, { from: deployer });
await this.token.renounceMinter({ from: deployer });
Expand All @@ -31,7 +31,7 @@ contract('MintedCrowdsale', function ([_, deployer, investor, wallet, purchaser]
describe('using non-mintable token', function () {
beforeEach(async function () {
this.token = await ERC20.new();
this.crowdsale = await MintedCrowdsale.new(rate, wallet, this.token.address);
this.crowdsale = await MintedCrowdsaleImpl.new(rate, wallet, this.token.address);
});

it('rejects bare payments', async function () {
Expand Down
4 changes: 2 additions & 2 deletions test/crowdsale/PostDeliveryCrowdsale.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ require('chai')
.use(require('chai-bignumber')(BigNumber))
.should();

const PostDeliveryCrowdsale = artifacts.require('PostDeliveryCrowdsaleImpl');
const PostDeliveryCrowdsaleImpl = artifacts.require('PostDeliveryCrowdsaleImpl');
const SimpleToken = artifacts.require('SimpleToken');

contract('PostDeliveryCrowdsale', function ([_, investor, wallet, purchaser]) {
Expand All @@ -28,7 +28,7 @@ contract('PostDeliveryCrowdsale', function ([_, investor, wallet, purchaser]) {
this.closingTime = this.openingTime + duration.weeks(1);
this.afterClosingTime = this.closingTime + duration.seconds(1);
this.token = await SimpleToken.new();
this.crowdsale = await PostDeliveryCrowdsale.new(
this.crowdsale = await PostDeliveryCrowdsaleImpl.new(
this.openingTime, this.closingTime, rate, wallet, this.token.address
);
await this.token.transfer(this.crowdsale.address, tokenSupply);
Expand Down
6 changes: 3 additions & 3 deletions test/crowdsale/RefundableCrowdsale.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ require('chai')
.use(require('chai-bignumber')(BigNumber))
.should();

const RefundableCrowdsale = artifacts.require('RefundableCrowdsaleImpl');
const RefundableCrowdsaleImpl = artifacts.require('RefundableCrowdsaleImpl');
const SimpleToken = artifacts.require('SimpleToken');

contract('RefundableCrowdsale', function ([_, wallet, investor, purchaser, anyone]) {
Expand All @@ -37,7 +37,7 @@ contract('RefundableCrowdsale', function ([_, wallet, investor, purchaser, anyon

it('rejects a goal of zero', async function () {
await expectThrow(
RefundableCrowdsale.new(
RefundableCrowdsaleImpl.new(
this.openingTime, this.closingTime, rate, wallet, this.token.address, 0,
),
EVMRevert,
Expand All @@ -46,7 +46,7 @@ contract('RefundableCrowdsale', function ([_, wallet, investor, purchaser, anyon

context('with crowdsale', function () {
beforeEach(async function () {
this.crowdsale = await RefundableCrowdsale.new(
this.crowdsale = await RefundableCrowdsaleImpl.new(
this.openingTime, this.closingTime, rate, wallet, this.token.address, goal
);

Expand Down
10 changes: 6 additions & 4 deletions test/crowdsale/TimedCrowdsale.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ require('chai')
.use(require('chai-bignumber')(BigNumber))
.should();

const TimedCrowdsale = artifacts.require('TimedCrowdsaleImpl');
const TimedCrowdsaleImpl = artifacts.require('TimedCrowdsaleImpl');
const SimpleToken = artifacts.require('SimpleToken');

contract('TimedCrowdsale', function ([_, investor, wallet, purchaser]) {
Expand All @@ -32,20 +32,22 @@ contract('TimedCrowdsale', function ([_, investor, wallet, purchaser]) {
});

it('rejects an opening time in the past', async function () {
await expectThrow(TimedCrowdsale.new(
await expectThrow(TimedCrowdsaleImpl.new(
(await latestTime()) - duration.days(1), this.closingTime, rate, wallet, this.token.address
), EVMRevert);
});

it('rejects a closing time before the opening time', async function () {
await expectThrow(TimedCrowdsale.new(
await expectThrow(TimedCrowdsaleImpl.new(
this.openingTime, this.openingTime - duration.seconds(1), rate, wallet, this.token.address
), EVMRevert);
});

context('with crowdsale', function () {
beforeEach(async function () {
this.crowdsale = await TimedCrowdsale.new(this.openingTime, this.closingTime, rate, wallet, this.token.address);
this.crowdsale = await TimedCrowdsaleImpl.new(
this.openingTime, this.closingTime, rate, wallet, this.token.address
);
await this.token.transfer(this.crowdsale.address, tokenSupply);
});

Expand Down
4 changes: 2 additions & 2 deletions test/drafts/ERC1046/TokenMetadata.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const ERC20WithMetadata = artifacts.require('ERC20WithMetadataMock');
const ERC20WithMetadataMock = artifacts.require('ERC20WithMetadataMock');

require('chai')
.should();
Expand All @@ -7,7 +7,7 @@ const metadataURI = 'https://example.com';

describe('ERC20WithMetadata', function () {
beforeEach(async function () {
this.token = await ERC20WithMetadata.new(metadataURI);
this.token = await ERC20WithMetadataMock.new(metadataURI);
});

it('responds with the metadata', async function () {
Expand Down
4 changes: 2 additions & 2 deletions test/introspection/ERC165.test.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
const { shouldSupportInterfaces } = require('./SupportsInterface.behavior');
const { assertRevert } = require('../helpers/assertRevert');

const ERC165 = artifacts.require('ERC165Mock');
const ERC165Mock = artifacts.require('ERC165Mock');

require('chai')
.should();

contract('ERC165', function () {
beforeEach(async function () {
this.mock = await ERC165.new();
this.mock = await ERC165Mock.new();
});

it('does not allow 0xffffffff', async function () {
Expand Down
4 changes: 2 additions & 2 deletions test/token/ERC20/ERC20.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const { assertRevert } = require('../../helpers/assertRevert');
const expectEvent = require('../../helpers/expectEvent');

const ERC20 = artifacts.require('ERC20Mock');
const ERC20Mock = artifacts.require('ERC20Mock');

const BigNumber = web3.BigNumber;

Expand All @@ -13,7 +13,7 @@ contract('ERC20', function ([_, owner, recipient, anotherAccount]) {
const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';

beforeEach(async function () {
this.token = await ERC20.new(owner, 100);
this.token = await ERC20Mock.new(owner, 100);
});

describe('total supply', function () {
Expand Down
4 changes: 2 additions & 2 deletions test/token/ERC20/ERC20Pausable.test.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
const { assertRevert } = require('../../helpers/assertRevert');

const ERC20Pausable = artifacts.require('ERC20PausableMock');
const ERC20PausableMock = artifacts.require('ERC20PausableMock');
const { shouldBehaveLikePublicRole } = require('../../access/roles/PublicRole.behavior');

contract('ERC20Pausable', function ([_, pauser, otherPauser, recipient, anotherAccount, ...otherAccounts]) {
beforeEach(async function () {
this.token = await ERC20Pausable.new(pauser, 100, { from: pauser });
this.token = await ERC20PausableMock.new(pauser, 100, { from: pauser });
});

describe('pauser role', function () {
Expand Down
12 changes: 6 additions & 6 deletions test/token/ERC721/ERC721.behavior.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const { assertRevert } = require('../../helpers/assertRevert');
const { decodeLogs } = require('../../helpers/decodeLogs');
const { sendTransaction } = require('../../helpers/sendTransaction');

const ERC721Receiver = artifacts.require('ERC721ReceiverMock.sol');
const ERC721ReceiverMock = artifacts.require('ERC721ReceiverMock.sol');
const BigNumber = web3.BigNumber;

require('chai')
Expand Down Expand Up @@ -237,7 +237,7 @@ function shouldBehaveLikeERC721 (

describe('to a valid receiver contract', function () {
beforeEach(async function () {
this.receiver = await ERC721Receiver.new(RECEIVER_MAGIC_VALUE, false);
this.receiver = await ERC721ReceiverMock.new(RECEIVER_MAGIC_VALUE, false);
this.toWhom = this.receiver.address;
});

Expand All @@ -246,7 +246,7 @@ function shouldBehaveLikeERC721 (
it('should call onERC721Received', async function () {
const result = await transferFun.call(this, owner, this.receiver.address, tokenId, { from: owner });
result.receipt.logs.length.should.be.equal(2);
const [log] = decodeLogs([result.receipt.logs[1]], ERC721Receiver, this.receiver.address);
const [log] = decodeLogs([result.receipt.logs[1]], ERC721ReceiverMock, this.receiver.address);
log.event.should.be.equal('Received');
log.args.operator.should.be.equal(owner);
log.args.from.should.be.equal(owner);
Expand All @@ -261,7 +261,7 @@ function shouldBehaveLikeERC721 (
result.receipt.logs.length.should.be.equal(2);
const [log] = decodeLogs(
[result.receipt.logs[1]],
ERC721Receiver,
ERC721ReceiverMock,
this.receiver.address
);
log.event.should.be.equal('Received');
Expand Down Expand Up @@ -297,14 +297,14 @@ function shouldBehaveLikeERC721 (

describe('to a receiver contract returning unexpected value', function () {
it('reverts', async function () {
const invalidReceiver = await ERC721Receiver.new('0x42', false);
const invalidReceiver = await ERC721ReceiverMock.new('0x42', false);
await assertRevert(this.token.safeTransferFrom(owner, invalidReceiver.address, tokenId, { from: owner }));
});
});

describe('to a receiver contract that throws', function () {
it('reverts', async function () {
const invalidReceiver = await ERC721Receiver.new(RECEIVER_MAGIC_VALUE, true);
const invalidReceiver = await ERC721ReceiverMock.new(RECEIVER_MAGIC_VALUE, true);
await assertRevert(this.token.safeTransferFrom(owner, invalidReceiver.address, tokenId, { from: owner }));
});
});
Expand Down
4 changes: 2 additions & 2 deletions test/token/ERC721/ERC721.test.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
const { shouldBehaveLikeERC721 } = require('./ERC721.behavior');

const BigNumber = web3.BigNumber;
const ERC721 = artifacts.require('ERC721Mock.sol');
const ERC721Mock = artifacts.require('ERC721Mock.sol');

require('chai')
.use(require('chai-bignumber')(BigNumber))
.should();

contract('ERC721', function ([_, creator, ...accounts]) {
beforeEach(async function () {
this.token = await ERC721.new({ from: creator });
this.token = await ERC721Mock.new({ from: creator });
});

shouldBehaveLikeERC721(creator, creator, accounts);
Expand Down
4 changes: 2 additions & 2 deletions test/token/ERC721/ERC721Burnable.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const {
} = require('./ERC721MintBurn.behavior');

const BigNumber = web3.BigNumber;
const ERC721Burnable = artifacts.require('ERC721MintableBurnableImpl.sol');
const ERC721BurnableImpl = artifacts.require('ERC721MintableBurnableImpl.sol');

require('chai')
.use(require('chai-bignumber')(BigNumber))
Expand All @@ -14,7 +14,7 @@ contract('ERC721Burnable', function ([_, creator, ...accounts]) {
const minter = creator;

beforeEach(async function () {
this.token = await ERC721Burnable.new({ from: creator });
this.token = await ERC721BurnableImpl.new({ from: creator });
});

shouldBehaveLikeERC721(creator, minter, accounts);
Expand Down
4 changes: 2 additions & 2 deletions test/token/ERC721/ERC721Mintable.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const {
} = require('./ERC721MintBurn.behavior');

const BigNumber = web3.BigNumber;
const ERC721Mintable = artifacts.require('ERC721MintableBurnableImpl.sol');
const ERC721MintableImpl = artifacts.require('ERC721MintableBurnableImpl.sol');

require('chai')
.use(require('chai-bignumber')(BigNumber))
Expand All @@ -14,7 +14,7 @@ contract('ERC721Mintable', function ([_, creator, ...accounts]) {
const minter = creator;

beforeEach(async function () {
this.token = await ERC721Mintable.new({
this.token = await ERC721MintableImpl.new({
from: creator,
});
});
Expand Down
Loading

0 comments on commit 4b21fcf

Please sign in to comment.