truffle-personalities
v1.0.0
Published
Relatable names for your Truffle test accounts.
Downloads
10
Maintainers
Readme
Truffle Personalities
Alias the default Truffle or Ganache accounts with relatable names.
Behavior
Truffle Personalities will alias n accounts, where n is the lesser of the number of accounts provided and the number of names available. The default list of names, in order of assignment, is as follows:
ALICEBOBCAROLDAVIDEVEFRANKGRACEHEIDIIVANJUDYKATHERINELIAMMICHAELNIAJOLIVIAPEGGYQUENTINRICHARDSYBILTRENTULYSSESVICTORWENDYXIMENAYAAKOVZARA
Installation
npm install --save truffle-personalitiesUsage
Pass the accounts array provided to Truffle's contract function to Truffle Personalities.
const trufflePersonalities = require('truffle-personalities');
contract('TestContract', function (accounts) {
trufflePersonalities(accounts);
accounts.ALICE === accounts[0];
// => true
accounts.BOB === accounts[1];
// => true
});Options
An options object may be passed as the second argument.
| Option | Description | Default |
|-|-|-|
| context | the object to which aliases are assigned | accounts |
| names | array of names to assign before using the default names | [] |
| toLowerCase | boolean describing whether to convert names to lower case rather than to upper case | false |
Examples
Pass a list of custom names to override the defaults. This example proposes the use of NOLAN as "nobody", or an uninvolved third party, and OWEN as a contract's owner.
trufflePersonalities(accounts, { names: ['NOLAN', 'owen'], toLowerCase: true});
accounts.NOLAN === undefined;
// => true
accounts.nolan === accounts[0];
// => true
accounts.owen === accounts[1];
// => true
accounts.alice === accounts[2];
// => truePass the global object as the context option in order to access the aliased addresses as standalone variables.
trufflePersonalities(accounts, { context: global });
accounts.ALICE === undefined;
// => true
ALICE === accounts[0];
// => true