Openzeppelin-contracts: Rename 'anyone' account in tests to something else

Created on 26 Sep 2018  路  11Comments  路  Source: OpenZeppelin/openzeppelin-contracts

When testing access control related functionality, we usually have an anyone account that represents an account with no special permissions, e.g.:

it('reverts when anyone attempts to self-destruct', async function () {
  await assertRevert(this.contract.destroy({ from: anyone });
});

anyone is probably not the best name we can find, we should find something that better conveys the meaning of 'anyone else', 'any random account', etc.

good first issue tests

Most helpful comment

I think other is better than anyone because it conveys that it is a different account from all the other ones used in the same test.

All 11 comments

How about stranger?

what about guest?

I think other is better than anyone because it conveys that it is a different account from all the other ones used in the same test.

Hmm, I like other better than the other proposals, I think it could work.

My vote is on other as well.

I'd like to try and help work on this

I'll probably need a bit of guidance though - are we looking to change all references in anyone to "other" in the tests, or only in some specific instances, or only in the description?

I think just the account name: test descriptions to go 'tokens can be transferred to anyone' are actually correct (assuming anyone is no-none :stuck_out_tongue:).

:+1: got it. @nventuro, am I changing each instance of from: anyone to from: other? Or are some of the "anyone's" valid in the tests?

In other words, I'm only changing this:

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

to

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

Correct! I don't think we want to leave any instance of anyone: the core issue is that 'anyone' shouldn't be an account name (because it belongs to 'someone'). 'other' implies that that account isn't special (and represents 'anyone', which is why we leave it in the test descriptions :stuck_out_tongue:).

Got it. @nventuro - You can see my first attempt here: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/1718

I changed all the references of "anyone" in the code to "other" and I'm pretty confident I didn't miss any. Just not sure if I might have done a few that weren't meant to have changed. I think I noticed one instance where "other" was declared but never actually used. I could remove that if you'd like.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nventuro picture nventuro  路  4Comments

Flash-Git picture Flash-Git  路  3Comments

golivax picture golivax  路  4Comments

LogvinovLeon picture LogvinovLeon  路  4Comments

rstormsf picture rstormsf  路  4Comments