By default there are only 10 test accounts being created, how do I create more when using Mocha to test smart contract?
I assume Mocha creates a testRPC instance somehow, there must be a way to modify that settings.
Ethereum Stack Exchange is a question and answer site for users of Ethereum, the decentralized application platform and smart contract enabled blockchain. It only takes a minute to sign up.Sign up to join this community
I assume Mocha creates a testRPC instance somehow...
No, it is you who needs to run Ganache (formerly known as TestRPC) before you run your Mocha test.
In this common setup, the Ganache process runs as a server, and your Mocha test runs as a client.
The protocol of communication between them is typically Web3 (over HTTP or WebSocket).
Here is an example of how you can start a Ganache process which initializes 15 accounts with 1 ether each:
ganache-cli --port=8545 --gasPrice=0x1 --gasLimit=0x1fffffffffffff --account=0x0000000000000000000000000000000000000000000000000000000000000001,1000000000000000000 --account=0x0000000000000000000000000000000000000000000000000000000000000002,1000000000000000000 --account=0x0000000000000000000000000000000000000000000000000000000000000003,1000000000000000000 --account=0x0000000000000000000000000000000000000000000000000000000000000004,1000000000000000000 --account=0x0000000000000000000000000000000000000000000000000000000000000005,1000000000000000000 --account=0x0000000000000000000000000000000000000000000000000000000000000006,1000000000000000000 --account=0x0000000000000000000000000000000000000000000000000000000000000007,1000000000000000000 --account=0x0000000000000000000000000000000000000000000000000000000000000008,1000000000000000000 --account=0x0000000000000000000000000000000000000000000000000000000000000009,1000000000000000000 --account=0x000000000000000000000000000000000000000000000000000000000000000A,1000000000000000000 --account=0x000000000000000000000000000000000000000000000000000000000000000B,1000000000000000000 --account=0x000000000000000000000000000000000000000000000000000000000000000C,1000000000000000000 --account=0x000000000000000000000000000000000000000000000000000000000000000D,1000000000000000000 --account=0x000000000000000000000000000000000000000000000000000000000000000E,1000000000000000000 --account=0x000000000000000000000000000000000000000000000000000000000000000F,1000000000000000000
What you see here are the private keys of these accounts, and Ganache will print their public addresses when it starts.
Note that in contrast with a real Ethereum Node (like Parity or Geth), Ganache keeps all of these accounts unlocked, so you can easily run your test without having to sign each transaction with the private key of the account that you send it with.
Therefore your test will not run when you try to execute it on a real Ethereum Node - you will have to either unlock the accounts first (highly not recommended), or at least before every transaction (also not recommended), or sign each transaction with the private key of the account that you send it with.