[英]How to send wei/eth to contract address? (using truffle javascript test)
[英]In truffle test using js, how to set the parameters after the `contract `?
例如openzeppelin-solidity
WhitelistedCrowdsale.test.js
:
contract('WhitelistedCrowdsale', function ([_, wallet, authorized, unauthorized, anotherAuthorized]) { ... }
第12行。
為什么function(...)
的參數是_, wallet, authorized, unauthorized, anotherAuthorized
? 它們可以是其他東西嗎? 為什么?
謝謝!
松露注入您所連接的節點上可用的帳戶列表。 從松露文檔 :
contract()函數提供了以太坊客戶端可用的帳戶列表,您可以使用這些帳戶編寫測試。
要使用這些帳戶,您可以這樣編寫測試用例:
contract(‘MyContract’, function(accounts) {
it(‘test1’, function() {
const account = accounts[0];
// do something with account
}
});
accounts
只是一個數組。 您發布的OpenZeppelin中的代碼期望該節點中至少有5個帳戶可用(可通過web3.eth.getAccounts()
獲得相同的帳戶數組)。 他們只是將數組分解為特定的變量名。 _
是accounts[0]
, wallet
是accounts[1]
等,您可以根據需要命名。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.