简体   繁体   中英

How to create/add an account to truffle test environment

I'm writing test for my solidity project. Using Truffle @5.3.5. So when running truffle test It generates 10 accounts with 100 ETH (I believe it runs with ganache in the background).

The problem lies with I need an account that starts with 0 ETH. I have looked through the docs and haven't seen a solution to this.

I have tried using the ethers library to generate a new wallet. but it the test node doesn't recognize address (rather it doesn't know the private key for that address).

Is there a way to do this within the truffle testing environment.

contract("TreasuryContract", ([ treasurer, managerRewardAddress, employeeRewardAddress ]) => 
    {...})

The test itself isn't really relative to the question but the above is the method I'm using to get the accounts. (this all works fine).

I was just hoping for an easy way to have an account that the test recognizes that start with 0 ETH

In Ganache configuration, accounts & keys, you can change de account default balance and put it in 0.

Bests

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM