fix decode response + add tests

pull/1/head
yann300 7 years ago
parent 2b8c6983d8
commit 1cfa2b024f
  1. 6
      src/app/execution/txFormat.js
  2. 32
      test-browser/tests/compiling.js

@ -159,11 +159,7 @@ module.exports = {
var json = {} var json = {}
for (i = 0; i < outputTypes.length; i++) { for (i = 0; i < outputTypes.length; i++) {
var name = fnabi.outputs[i].name var name = fnabi.outputs[i].name
if (name.length > 0) { json[i] = outputTypes[i] + ': ' + (name ? name + ' ' + decodedObj[i] : decodedObj[i])
json[outputTypes[i] + ' ' + name] = decodedObj[i]
} else {
json[outputTypes[i]] = decodedObj[i]
}
} }
return json return json

@ -6,7 +6,13 @@ var sauce = require('./sauce')
var sources = { var sources = {
'sources': { 'sources': {
'browser/Untitled.sol': `pragma solidity ^0.4.0; 'browser/Untitled.sol': `pragma solidity ^0.4.0;
contract TestContract { function f() returns (uint) { return 8; } }` contract TestContract { function f() returns (uint) { return 8; }
function g() returns (uint, string, bool, uint) {
uint payment = 345;
bool payed = true;
string memory comment = "comment_comment_";
uint month = 4;
return (payment, comment, payed, month); } }`
} }
} }
@ -35,18 +41,18 @@ function runTests (browser) {
.waitForElementPresent('#editor-container div[class^="terminal"] span[id="tx0xa178c603400a184ce5fedbcfab392d9b77822f6ffa7facdec693aded214523bc"]') .waitForElementPresent('#editor-container div[class^="terminal"] span[id="tx0xa178c603400a184ce5fedbcfab392d9b77822f6ffa7facdec693aded214523bc"]')
.assert.containsText('#editor-container div[class^="terminal"] span[id="tx0xa178c603400a184ce5fedbcfab392d9b77822f6ffa7facdec693aded214523bc"]', '[vm] from:0xca3...a733c, to:browser/Untitled.sol:TestContract.f() 0x692...77b3a, value:0 wei, data:0x261...21ff0, 0 logs, hash:0xa17...523bc') .assert.containsText('#editor-container div[class^="terminal"] span[id="tx0xa178c603400a184ce5fedbcfab392d9b77822f6ffa7facdec693aded214523bc"]', '[vm] from:0xca3...a733c, to:browser/Untitled.sol:TestContract.f() 0x692...77b3a, value:0 wei, data:0x261...21ff0, 0 logs, hash:0xa17...523bc')
.click('#editor-container div[class^="terminal"] span[id="tx0xa178c603400a184ce5fedbcfab392d9b77822f6ffa7facdec693aded214523bc"] button[class^="details"]') .click('#editor-container div[class^="terminal"] span[id="tx0xa178c603400a184ce5fedbcfab392d9b77822f6ffa7facdec693aded214523bc"] button[class^="details"]')
.assert.containsText('#editor-container div[class^="terminal"] span[id="tx0xa178c603400a184ce5fedbcfab392d9b77822f6ffa7facdec693aded214523bc"] table[class^="txTable"] #decodedoutput', '"uint256": "8"') .assert.containsText('#editor-container div[class^="terminal"] span[id="tx0xa178c603400a184ce5fedbcfab392d9b77822f6ffa7facdec693aded214523bc"] table[class^="txTable"] #decodedoutput', `{
"0": "uint256: 8"
}`)
.click('.instance button[title="g - transact (not payable)"]')
.waitForElementPresent('#editor-container div[class^="terminal"] span[id="tx0xb1532162e2e31397dc1e07ed0a1cf08f728e9b4487c6f9ed79d2f39410c92781"]')
.click('#editor-container div[class^="terminal"] span[id="tx0xb1532162e2e31397dc1e07ed0a1cf08f728e9b4487c6f9ed79d2f39410c92781"] button[class^="details"]')
.assert.containsText('#editor-container div[class^="terminal"] span[id="tx0xb1532162e2e31397dc1e07ed0a1cf08f728e9b4487c6f9ed79d2f39410c92781"] table[class^="txTable"] #decodedoutput', `{
"0": "uint256: 345",
"1": "string: comment_comment_",
"2": "bool: true",
"3": "uint256: 4"
}`)
.end() .end()
/*
@TODO: need to check now the return value of the function
.waitForElementPresent('.output .returned')
.assert.containsText('.output .returned', '0x0000000000000000000000000000000000000000000000000000000000000008')
.execute(function () {
document.querySelector('.output .decoded li').scrollIntoView()
}, [], function () {
browser.assert.containsText('.output .decoded li', 'uint256: 8')
.end()
})
*/
}) })
} }

Loading…
Cancel
Save