Merge pull request #1246 from debris/natspec_subtree

natspec.js subtree
This commit is contained in:
Gav Wood 2015-03-10 18:48:41 +00:00
commit bf01fe7804

View File

@ -34,7 +34,7 @@ BOOST_AUTO_TEST_CASE(natspec_eval_function_exists)
// given // given
NatspecExpressionEvaluator e; NatspecExpressionEvaluator e;
// when // when
string result = e.evalExpression("`typeof evaluateExpression`").toStdString(); string result = e.evalExpression("`typeof natspec.evaluateExpression`").toStdString();
// then // then
BOOST_CHECK_EQUAL(result, "function"); BOOST_CHECK_EQUAL(result, "function");
} }
@ -77,7 +77,7 @@ BOOST_AUTO_TEST_CASE(natspec_js_eval_input_params)
// given // given
char const* abi = R"([ char const* abi = R"([
{ {
"name": "f", "name": "multiply",
"constant": false, "constant": false,
"type": "function", "type": "function",
"inputs": [ "inputs": [
@ -94,7 +94,18 @@ BOOST_AUTO_TEST_CASE(natspec_js_eval_input_params)
] ]
} }
])"; ])";
NatspecExpressionEvaluator e(abi, "'f'", "[4]");
char const* transaction = R"({
"jsonrpc": "2.0",
"method": "eth_call",
"params": [{
"to": "0x8521742d3f456bd237e312d6e30724960f72517a",
"data": "0xc6888fa10000000000000000000000000000000000000000000000000000000000000004"
}],
"id": 6
})";
NatspecExpressionEvaluator e(abi, transaction , "multiply");
// when // when
string result = e.evalExpression("Will multiply `a` by 7 and return `a * 7`.").toStdString(); string result = e.evalExpression("Will multiply `a` by 7 and return `a * 7`.").toStdString();
// then // then
@ -108,7 +119,7 @@ BOOST_AUTO_TEST_CASE(natspec_js_eval_error)
// when // when
string result = e.evalExpression("`test(`").toStdString(); string result = e.evalExpression("`test(`").toStdString();
// then // then
BOOST_CHECK_EQUAL(result, "`test(`"); BOOST_CHECK_EQUAL(result, "Natspec evaluation failed, wrong input params");
} }
BOOST_AUTO_TEST_SUITE_END() BOOST_AUTO_TEST_SUITE_END()