Skip to content

Commit

Permalink
Fix/rename anyone account #1357 (#1718)
Browse files Browse the repository at this point in the history
* replacing all instances of from: anyone with from: other

* replacing all instances of from: anyone with from: other

* replacing all instances of from: anyone with from: other

* changing anyone to other

* changing anyone to other
  • Loading branch information
ckshei authored and nventuro committed Apr 11, 2019
1 parent d45f0c8 commit 19c705d
Show file tree
Hide file tree
Showing 20 changed files with 107 additions and 107 deletions.
8 changes: 4 additions & 4 deletions test/access/Roles.test.js
Expand Up @@ -3,7 +3,7 @@ const { ZERO_ADDRESS } = constants;

const RolesMock = artifacts.require('RolesMock');

contract('Roles', function ([_, authorized, otherAuthorized, anyone]) {
contract('Roles', function ([_, authorized, otherAuthorized, other]) {
beforeEach(async function () {
this.roles = await RolesMock.new();
});
Expand All @@ -16,14 +16,14 @@ contract('Roles', function ([_, authorized, otherAuthorized, anyone]) {
it('doesn\'t pre-assign roles', async function () {
(await this.roles.has(authorized)).should.equal(false);
(await this.roles.has(otherAuthorized)).should.equal(false);
(await this.roles.has(anyone)).should.equal(false);
(await this.roles.has(other)).should.equal(false);
});

describe('adding roles', function () {
it('adds roles to a single account', async function () {
await this.roles.add(authorized);
(await this.roles.has(authorized)).should.equal(true);
(await this.roles.has(anyone)).should.equal(false);
(await this.roles.has(other)).should.equal(false);
});

it('reverts when adding roles to an already assigned account', async function () {
Expand Down Expand Up @@ -51,7 +51,7 @@ contract('Roles', function ([_, authorized, otherAuthorized, anyone]) {
});

it('reverts when removing unassigned roles', async function () {
await shouldFail.reverting(this.roles.remove(anyone));
await shouldFail.reverting(this.roles.remove(other));
});

it('reverts when removing roles from the zero account', async function () {
Expand Down
22 changes: 11 additions & 11 deletions test/behaviors/access/roles/PublicRole.behavior.js
Expand Up @@ -16,18 +16,18 @@ function capitalize (str) {
//
// @param authorized an account that has the role
// @param otherAuthorized another account that also has the role
// @param anyone an account that doesn't have the role, passed inside an array for ergonomics
// @param other an account that doesn't have the role, passed inside an array for ergonomics
// @param rolename a string with the name of the role
// @param manager undefined for regular roles, or a manager account for managed roles. In these, only the manager
// account can create and remove new role bearers.
function shouldBehaveLikePublicRole (authorized, otherAuthorized, [anyone], rolename, manager) {
function shouldBehaveLikePublicRole (authorized, otherAuthorized, [other], rolename, manager) {
rolename = capitalize(rolename);

describe('should behave like public role', function () {
beforeEach('check preconditions', async function () {
(await this.contract[`is${rolename}`](authorized)).should.equal(true);
(await this.contract[`is${rolename}`](otherAuthorized)).should.equal(true);
(await this.contract[`is${rolename}`](anyone)).should.equal(false);
(await this.contract[`is${rolename}`](other)).should.equal(false);
});

if (manager === undefined) { // Managed roles are only assigned by the manager, and none are set at construction
Expand All @@ -52,7 +52,7 @@ function shouldBehaveLikePublicRole (authorized, otherAuthorized, [anyone], role
});

context('from unauthorized account', function () {
const from = anyone;
const from = other;

it('reverts', async function () {
await shouldFail.reverting(this.contract[`only${rolename}Mock`]({ from }));
Expand All @@ -65,13 +65,13 @@ function shouldBehaveLikePublicRole (authorized, otherAuthorized, [anyone], role

context(`from ${manager ? 'the manager' : 'a role-haver'} account`, function () {
it('adds role to a new account', async function () {
await this.contract[`add${rolename}`](anyone, { from });
(await this.contract[`is${rolename}`](anyone)).should.equal(true);
await this.contract[`add${rolename}`](other, { from });
(await this.contract[`is${rolename}`](other)).should.equal(true);
});

it(`emits a ${rolename}Added event`, async function () {
const { logs } = await this.contract[`add${rolename}`](anyone, { from });
expectEvent.inLogs(logs, `${rolename}Added`, { account: anyone });
const { logs } = await this.contract[`add${rolename}`](other, { from });
expectEvent.inLogs(logs, `${rolename}Added`, { account: other });
});

it('reverts when adding role to an already assigned account', async function () {
Expand All @@ -86,7 +86,7 @@ function shouldBehaveLikePublicRole (authorized, otherAuthorized, [anyone], role

describe('remove', function () {
// Non-managed roles have no restrictions on the mocked '_remove' function (exposed via 'remove').
const from = manager || anyone;
const from = manager || other;

context(`from ${manager ? 'the manager' : 'any'} account`, function () {
it('removes role from an already assigned account', async function () {
Expand All @@ -101,7 +101,7 @@ function shouldBehaveLikePublicRole (authorized, otherAuthorized, [anyone], role
});

it('reverts when removing from an unassigned account', async function () {
await shouldFail.reverting(this.contract[`remove${rolename}`](anyone, { from }));
await shouldFail.reverting(this.contract[`remove${rolename}`](other, { from }));
});

it('reverts when removing role from the null account', async function () {
Expand All @@ -122,7 +122,7 @@ function shouldBehaveLikePublicRole (authorized, otherAuthorized, [anyone], role
});

it('reverts when renouncing unassigned role', async function () {
await shouldFail.reverting(this.contract[`renounce${rolename}`]({ from: anyone }));
await shouldFail.reverting(this.contract[`renounce${rolename}`]({ from: other }));
});
});
});
Expand Down
12 changes: 6 additions & 6 deletions test/crowdsale/FinalizableCrowdsale.test.js
Expand Up @@ -3,7 +3,7 @@ const { BN, expectEvent, shouldFail, time } = require('openzeppelin-test-helpers
const FinalizableCrowdsaleImpl = artifacts.require('FinalizableCrowdsaleImpl');
const ERC20 = artifacts.require('ERC20');

contract('FinalizableCrowdsale', function ([_, wallet, anyone]) {
contract('FinalizableCrowdsale', function ([_, wallet, other]) {
const rate = new BN('1000');

before(async function () {
Expand All @@ -23,23 +23,23 @@ contract('FinalizableCrowdsale', function ([_, wallet, anyone]) {
});

it('cannot be finalized before ending', async function () {
await shouldFail.reverting(this.crowdsale.finalize({ from: anyone }));
await shouldFail.reverting(this.crowdsale.finalize({ from: other }));
});

it('can be finalized by anyone after ending', async function () {
await time.increaseTo(this.afterClosingTime);
await this.crowdsale.finalize({ from: anyone });
await this.crowdsale.finalize({ from: other });
});

it('cannot be finalized twice', async function () {
await time.increaseTo(this.afterClosingTime);
await this.crowdsale.finalize({ from: anyone });
await shouldFail.reverting(this.crowdsale.finalize({ from: anyone }));
await this.crowdsale.finalize({ from: other });
await shouldFail.reverting(this.crowdsale.finalize({ from: other }));
});

it('logs finalized', async function () {
await time.increaseTo(this.afterClosingTime);
const { logs } = await this.crowdsale.finalize({ from: anyone });
const { logs } = await this.crowdsale.finalize({ from: other });
expectEvent.inLogs(logs, 'CrowdsaleFinalized');
});
});
4 changes: 2 additions & 2 deletions test/crowdsale/IndividuallyCappedCrowdsale.test.js
Expand Up @@ -5,7 +5,7 @@ const SimpleToken = artifacts.require('SimpleToken');
const { shouldBehaveLikePublicRole } = require('../behaviors/access/roles/PublicRole.behavior');

contract('IndividuallyCappedCrowdsale', function (
[_, capper, otherCapper, wallet, alice, bob, charlie, anyone, ...otherAccounts]) {
[_, capper, otherCapper, wallet, alice, bob, charlie, other, ...otherAccounts]) {
const rate = new BN(1);
const capAlice = ether('10');
const capBob = ether('2');
Expand Down Expand Up @@ -34,7 +34,7 @@ contract('IndividuallyCappedCrowdsale', function (
});

it('reverts when a non-capper sets a cap', async function () {
await shouldFail.reverting(this.crowdsale.setCap(alice, capAlice, { from: anyone }));
await shouldFail.reverting(this.crowdsale.setCap(alice, capAlice, { from: other }));
});

context('with individual caps', function () {
Expand Down
14 changes: 7 additions & 7 deletions test/crowdsale/PausableCrowdsale.test.js
Expand Up @@ -3,7 +3,7 @@ const { BN, shouldFail } = require('openzeppelin-test-helpers');
const PausableCrowdsale = artifacts.require('PausableCrowdsaleImpl');
const SimpleToken = artifacts.require('SimpleToken');

contract('PausableCrowdsale', function ([_, pauser, wallet, anyone]) {
contract('PausableCrowdsale', function ([_, pauser, wallet, other]) {
const rate = new BN(1);
const value = new BN(1);

Expand All @@ -16,8 +16,8 @@ contract('PausableCrowdsale', function ([_, pauser, wallet, anyone]) {
});

it('purchases work', async function () {
await this.crowdsale.sendTransaction({ from: anyone, value });
await this.crowdsale.buyTokens(anyone, { from: anyone, value });
await this.crowdsale.sendTransaction({ from: other, value });
await this.crowdsale.buyTokens(other, { from: other, value });
});

context('after pause', function () {
Expand All @@ -26,8 +26,8 @@ contract('PausableCrowdsale', function ([_, pauser, wallet, anyone]) {
});

it('purchases do not work', async function () {
await shouldFail.reverting(this.crowdsale.sendTransaction({ from: anyone, value }));
await shouldFail.reverting(this.crowdsale.buyTokens(anyone, { from: anyone, value }));
await shouldFail.reverting(this.crowdsale.sendTransaction({ from: other, value }));
await shouldFail.reverting(this.crowdsale.buyTokens(other, { from: other, value }));
});

context('after unpause', function () {
Expand All @@ -36,8 +36,8 @@ contract('PausableCrowdsale', function ([_, pauser, wallet, anyone]) {
});

it('purchases work', async function () {
await this.crowdsale.sendTransaction({ from: anyone, value });
await this.crowdsale.buyTokens(anyone, { from: anyone, value });
await this.crowdsale.sendTransaction({ from: other, value });
await this.crowdsale.buyTokens(other, { from: other, value });
});
});
});
Expand Down
6 changes: 3 additions & 3 deletions test/crowdsale/RefundableCrowdsale.test.js
Expand Up @@ -3,7 +3,7 @@ const { balance, BN, ether, shouldFail, time } = require('openzeppelin-test-help
const RefundableCrowdsaleImpl = artifacts.require('RefundableCrowdsaleImpl');
const SimpleToken = artifacts.require('SimpleToken');

contract('RefundableCrowdsale', function ([_, wallet, investor, purchaser, anyone]) {
contract('RefundableCrowdsale', function ([_, wallet, investor, purchaser, other]) {
const rate = new BN(1);
const goal = ether('50');
const lessThanGoal = ether('45');
Expand Down Expand Up @@ -61,7 +61,7 @@ contract('RefundableCrowdsale', function ([_, wallet, investor, purchaser, anyon
context('after closing time and finalization', function () {
beforeEach(async function () {
await time.increaseTo(this.afterClosingTime);
await this.crowdsale.finalize({ from: anyone });
await this.crowdsale.finalize({ from: other });
});

it('refunds', async function () {
Expand All @@ -80,7 +80,7 @@ contract('RefundableCrowdsale', function ([_, wallet, investor, purchaser, anyon
context('after closing time and finalization', function () {
beforeEach(async function () {
await time.increaseTo(this.afterClosingTime);
await this.crowdsale.finalize({ from: anyone });
await this.crowdsale.finalize({ from: other });
});

it('denies refunds', async function () {
Expand Down
8 changes: 4 additions & 4 deletions test/crowdsale/WhitelistCrowdsale.test.js
Expand Up @@ -3,7 +3,7 @@ const { BN, ether, shouldFail } = require('openzeppelin-test-helpers');
const WhitelistCrowdsale = artifacts.require('WhitelistCrowdsaleImpl');
const SimpleToken = artifacts.require('SimpleToken');

contract('WhitelistCrowdsale', function ([_, wallet, whitelister, whitelisted, otherWhitelisted, anyone]) {
contract('WhitelistCrowdsale', function ([_, wallet, whitelister, whitelisted, otherWhitelisted, other]) {
const rate = new BN(1);
const value = ether('42');
const tokenSupply = new BN('10').pow(new BN('22'));
Expand All @@ -26,7 +26,7 @@ contract('WhitelistCrowdsale', function ([_, wallet, whitelister, whitelisted, o

context('with no whitelisted addresses', function () {
it('rejects all purchases', async function () {
await purchaseShouldFail(this.crowdsale, anyone, value);
await purchaseShouldFail(this.crowdsale, other, value);
await purchaseShouldFail(this.crowdsale, whitelisted, value);
});
});
Expand All @@ -43,11 +43,11 @@ contract('WhitelistCrowdsale', function ([_, wallet, whitelister, whitelisted, o
});

it('rejects purchases from whitelisted addresses with non-whitelisted beneficiaries', async function () {
await shouldFail(this.crowdsale.buyTokens(anyone, { from: whitelisted, value }));
await shouldFail(this.crowdsale.buyTokens(other, { from: whitelisted, value }));
});

it('rejects purchases with non-whitelisted beneficiaries', async function () {
await purchaseShouldFail(this.crowdsale, anyone, value);
await purchaseShouldFail(this.crowdsale, other, value);
});
});
});
12 changes: 6 additions & 6 deletions test/cryptography/ECDSA.test.js
Expand Up @@ -7,7 +7,7 @@ const ECDSAMock = artifacts.require('ECDSAMock');
const TEST_MESSAGE = web3.utils.sha3('OpenZeppelin');
const WRONG_MESSAGE = web3.utils.sha3('Nope');

contract('ECDSA', function ([_, anyone]) {
contract('ECDSA', function ([_, other]) {
beforeEach(async function () {
this.ecdsa = await ECDSAMock.new();
});
Expand Down Expand Up @@ -92,23 +92,23 @@ contract('ECDSA', function ([_, anyone]) {
context('with correct signature', function () {
it('returns signer address', async function () {
// Create the signature
const signature = fixSignature(await web3.eth.sign(TEST_MESSAGE, anyone));
const signature = fixSignature(await web3.eth.sign(TEST_MESSAGE, other));

// Recover the signer address from the generated message and signature.
(await this.ecdsa.recover(
toEthSignedMessageHash(TEST_MESSAGE),
signature
)).should.equal(anyone);
)).should.equal(other);
});
});

context('with wrong signature', function () {
it('does not return signer address', async function () {
// Create the signature
const signature = await web3.eth.sign(TEST_MESSAGE, anyone);
const signature = await web3.eth.sign(TEST_MESSAGE, other);

// Recover the signer address from the generated message and wrong signature.
(await this.ecdsa.recover(WRONG_MESSAGE, signature)).should.not.equal(anyone);
(await this.ecdsa.recover(WRONG_MESSAGE, signature)).should.not.equal(other);
});
});
});
Expand All @@ -117,7 +117,7 @@ contract('ECDSA', function ([_, anyone]) {
// @TODO - remove `skip` once we upgrade to solc^0.5
it.skip('reverts', async function () {
// Create the signature
const signature = await web3.eth.sign(TEST_MESSAGE, anyone);
const signature = await web3.eth.sign(TEST_MESSAGE, other);
await shouldFail.reverting(
this.ecdsa.recover(TEST_MESSAGE.substring(2), signature)
);
Expand Down
4 changes: 2 additions & 2 deletions test/drafts/ERC1820Implementer.test.js
Expand Up @@ -3,7 +3,7 @@ const { bufferToHex, keccak256 } = require('ethereumjs-util');

const ERC1820ImplementerMock = artifacts.require('ERC1820ImplementerMock');

contract('ERC1820Implementer', function ([_, registryFunder, implementee, anyone]) {
contract('ERC1820Implementer', function ([_, registryFunder, implementee, other]) {
const ERC1820_ACCEPT_MAGIC = bufferToHex(keccak256('ERC1820_ACCEPT_MAGIC'));

beforeEach(async function () {
Expand Down Expand Up @@ -45,7 +45,7 @@ contract('ERC1820Implementer', function ([_, registryFunder, implementee, anyone
});

it('returns false when interface implementation for non-supported addresses is queried', async function () {
(await this.implementer.canImplementInterfaceForAddress(this.interfaceA, anyone))
(await this.implementer.canImplementInterfaceForAddress(this.interfaceA, other))
.should.not.equal(ERC1820_ACCEPT_MAGIC);
});

Expand Down

0 comments on commit 19c705d

Please sign in to comment.