2016-04-12 30 views
0
{ hash: '0xcc871efa64631ff57b6c4cdf9e9c52dce299956cc0bc2cdf6781dbd647a80926', 
    nonce: 34, 
    blockHash: '0xf4e21dabc0d6f99ae9a3fd128b9f25462110ed0e2811c0d5f91ffce9ac85594a', 
    blockNumber: 49, 
    transactionIndex: 0, 
    from: '0x9c3fe8bc6d259d44e80fb728e74727bfbe58e988', 
    to: '0xb22ab8533936d6d75c1ecf229c1ad68410ea8ee3', 
    value: { [String: '0'] s: 1, e: 0, c: [ 0 ] }, 
    gas: 3141592, 
    gasPrice: { [String: '1'] s: 1, e: 0, c: [ 1 ] }, 
    input: '0x1f5c1d9800000000000000000000000000000000000000000000000000000000000000400000000000000000000000007fa543843e2f5766ad623b2155d639d73635824400000000000000000000000000000000000000000000000000000000000000134f70656e20412042616e6b204163636f756e7400000000000000000000000000’ } 

我得到一個x.send(1)的事務,它的JSON看起來像上面那樣。我可以看到在輸入屬性的值中有一個「7fa543843e2f5766ad623b2155d639d736358244」與我爲x提供的帳戶的地址相匹配。 Solidity snippet是:TestRPC報告錯誤的交易?

function do(string _description, address x) { 
    if (msg.sender != owner) 
     throw; 
    description = _description; 

    x.send(1); 
} 

但是,JSON中的to:屬性是錯誤的。我的環境使用對TruRPC運行的測試。有人認爲這是我的一個已知問題或問題嗎?

我的測試代碼的相應部分是:

.then(
    function (_bool0) { 
     assert.isTrue(_bool0,"whoops"); 
     return contract.do("a test", accounts[4], {from: accounts[0]}); 
    }).then(
    function (tx_id) { 
     var transaction = web3.eth.getTransaction(tx_id); 
     /* debugging my test */ 
     console.log(transaction); 

     assert.strictEqual(transaction.to,accounts[4],"transaction \"to:\" was not provided address"); 

     done(); 
    } 
).catch(done); 
+0

我認爲這是一個與tx_id有關的合同問題,而不是我所做的x.send()。我需要send()的事務ID。 – Interition

+0

如果您覺得您的問題在stackoverflow上沒有得到足夠的重視,您也可以嘗試在新的[ethereum stack exchange beta site](http://ethereum.stackexchange.com/)上提問以太坊特定的問題。 – default

回答

0

的行爲不符合復仇是如何工作的實際是一致的。當測試呼叫時:

contract.do("a test", accounts[4], {from: accounts[0]}); 

它會導致記錄在區塊鏈中的事務。來自賬戶[0]賬戶和合同的交易:這也是一種賬戶類型。返回到我的測試的對象表示此事務:顯示爲上面的JSON。

我錯誤地認爲返回的對象代表合同到第二個帳戶之間的交易。

爲了達到我的測試目標,我需要檢查第二個帳戶是否存在交易。一旦我弄明白了,我會更新這個。