【问题标题】:How do define the account addresses when running truffle test?运行松露测试时如何定义帐户地址?
【发布时间】:2017-12-26 10:41:18
【问题描述】:

默认情况下,truffle 使用 testrpc / truffle develop,其中包含预定义地址列表:

Truffle Develop started at http://localhost:9545/

Accounts:
(0) 0x627306090abab3a6e1400e9345bc60c78a8bef57
(1) 0xf17f52151ebef6c7334fad080c5704d77216b732
(2) 0xc5fdf4076b8f3a5357c5e395ab970b5b54098fef
(3) 0x821aea9a577a9b44299b9c15c88cf3087f3b5544
(4) 0x0d1d4e623d10f9fba5db95830f7d3839406c6af2
(5) 0x2932b7a2355d6fecc4b5c0b6bd44cc31df247a2e
(6) 0x2191ef87e392377ec08e7c08eb105ef5448eced5
(7) 0x0f4f2ac550a1b4e2280d04c21cea7ebd822934b5
(8) 0x6330a553fc93768f612722bb8c2ec78ac90b3bbc
(9) 0x5aeda56215b167893e80b4fe645ba6d5bab767de

如何覆盖或添加地址?

【问题讨论】:

    标签: unit-testing truffle


    【解决方案1】:

    您可以使用您选择的帐户运行 TestRPC。 为此,请使用

    testrpc --account "<private-key>, balance"

    例如,您想要一个具有私钥 = 64fa61f689c54ffdc73b048d7ebf7fb55953cb4c8deb2553e3615f7c2f459a6b 的帐户,在此私钥的开头附加一个0x,使其变为0x64fa61f689c54ffdc73b048d7ebf7fb55953cb4c8deb2553e3615f7c2f459a6b,现在运行,

    testrpc --account "0x64fa61f689c54ffdc73b048d7ebf7fb55953cb4c8deb2553e3615f7c2f459a6b, 100"

    这将使用私钥 = 64fa61f689c54ffdc73b048d7ebf7fb55953cb4c8deb2553e3615f7c2f459a6b 的一个帐户运行 testrpc

    如果您想创建多个帐户,

    testrpc --account "<private-key>, balance" --account "<private-key>, balance" 等等..

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-07-18
      • 2021-09-15
      • 1970-01-01
      • 1970-01-01
      • 2019-02-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多