aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity
diff options
context:
space:
mode:
authorCJentzsch <jentzsch.software@gmail.com>2015-08-06 06:14:45 +0800
committerCJentzsch <jentzsch.software@gmail.com>2015-08-06 06:14:45 +0800
commit4626890913b9639c886544cd38863b3ecd116ddc (patch)
treec234322e6dc1963c03a420d0da37617fb8d50633 /libsolidity
parente0863fbd27ae087e3afea94179274dbd29811f66 (diff)
downloaddexon-solidity-4626890913b9639c886544cd38863b3ecd116ddc.tar.gz
dexon-solidity-4626890913b9639c886544cd38863b3ecd116ddc.tar.zst
dexon-solidity-4626890913b9639c886544cd38863b3ecd116ddc.zip
update test to new Block/State refactoring - credit to winsvega and chriseth
Diffstat (limited to 'libsolidity')
-rw-r--r--libsolidity/SolidityEndToEndTest.cpp37
-rw-r--r--libsolidity/SolidityNameAndTypeResolution.cpp17
-rw-r--r--libsolidity/solidityExecutionFramework.h4
3 files changed, 10 insertions, 48 deletions
diff --git a/libsolidity/SolidityEndToEndTest.cpp b/libsolidity/SolidityEndToEndTest.cpp
index a10b4767..fdffed1e 100644
--- a/libsolidity/SolidityEndToEndTest.cpp
+++ b/libsolidity/SolidityEndToEndTest.cpp
@@ -1151,8 +1151,10 @@ BOOST_AUTO_TEST_CASE(blockchain)
" blockNumber = block.number;\n"
" }\n"
"}\n";
+ m_envInfo.setBeneficiary(Address(0x123));
+ m_envInfo.setNumber(7);
compileAndRun(sourceCode, 27);
- BOOST_CHECK(callContractFunctionWithValue("someInfo()", 28) == encodeArgs(28, 0, 1));
+ BOOST_CHECK(callContractFunctionWithValue("someInfo()", 28) == encodeArgs(28, 0x123, 7));
}
BOOST_AUTO_TEST_CASE(msg_sig)
@@ -1187,12 +1189,14 @@ BOOST_AUTO_TEST_CASE(msg_sig_after_internal_call_is_same)
BOOST_AUTO_TEST_CASE(now)
{
char const* sourceCode = "contract test {\n"
- " function someInfo() returns (bool success) {\n"
- " return block.timestamp == now && now > 0;\n"
+ " function someInfo() returns (bool equal, uint val) {\n"
+ " equal = block.timestamp == now;\n"
+ " val = now;\n"
" }\n"
"}\n";
+ m_envInfo.setTimestamp(9);
compileAndRun(sourceCode);
- BOOST_CHECK(callContractFunction("someInfo()") == encodeArgs(true));
+ BOOST_CHECK(callContractFunction("someInfo()") == encodeArgs(true, 9));
}
BOOST_AUTO_TEST_CASE(type_conversions_cleanup)
@@ -5099,31 +5103,6 @@ BOOST_AUTO_TEST_CASE(memory_structs_with_mappings)
BOOST_CHECK(callContractFunction("f()") == encodeArgs(u256(0)));
}
-BOOST_AUTO_TEST_CASE(string_bytes_conversion)
-{
- char const* sourceCode = R"(
- contract Test {
- string s;
- bytes b;
- function f(string _s, uint n) returns (byte) {
- b = bytes(_s);
- s = string(b);
- return bytes(s)[n];
- }
- function l() returns (uint) { return bytes(s).length; }
- }
- )";
- compileAndRun(sourceCode, 0, "Test");
- BOOST_CHECK(callContractFunction(
- "f(string,uint256)",
- u256(0x40),
- u256(2),
- u256(6),
- string("abcdef")
- ) == encodeArgs("c"));
- BOOST_CHECK(callContractFunction("l()") == encodeArgs(u256(6)));
-}
-
BOOST_AUTO_TEST_CASE(string_as_mapping_key)
{
char const* sourceCode = R"(
diff --git a/libsolidity/SolidityNameAndTypeResolution.cpp b/libsolidity/SolidityNameAndTypeResolution.cpp
index 6b116f25..cfc43df9 100644
--- a/libsolidity/SolidityNameAndTypeResolution.cpp
+++ b/libsolidity/SolidityNameAndTypeResolution.cpp
@@ -2149,23 +2149,6 @@ BOOST_AUTO_TEST_CASE(memory_structs_with_mappings)
BOOST_CHECK_THROW(parseTextAndResolveNames(text), TypeError);
}
-BOOST_AUTO_TEST_CASE(string_bytes_conversion)
-{
- char const* text = R"(
- contract Test {
- string s;
- bytes b;
- function h(string _s) external { bytes(_s).length; }
- function i(string _s) internal { bytes(_s).length; }
- function j() internal { bytes(s).length; }
- function k(bytes _b) external { string(_b); }
- function l(bytes _b) internal { string(_b); }
- function m() internal { string(b); }
- }
- )";
- BOOST_CHECK_NO_THROW(parseTextAndResolveNames(text));
-}
-
BOOST_AUTO_TEST_SUITE_END()
}
diff --git a/libsolidity/solidityExecutionFramework.h b/libsolidity/solidityExecutionFramework.h
index 58099235..c6686883 100644
--- a/libsolidity/solidityExecutionFramework.h
+++ b/libsolidity/solidityExecutionFramework.h
@@ -44,7 +44,6 @@ public:
ExecutionFramework()
{
g_logVerbosity = 0;
- m_state.resetCurrent();
}
bytes const& compileAndRunWithoutCheck(
@@ -185,7 +184,7 @@ protected:
void sendMessage(bytes const& _data, bool _isCreation, u256 const& _value = 0)
{
m_state.addBalance(m_sender, _value); // just in case
- eth::Executive executive(m_state, eth::EnvInfo(), 0);
+ eth::Executive executive(m_state, m_envInfo, 0);
eth::ExecutionResult res;
executive.setResultRecipient(res);
eth::Transaction t =
@@ -226,6 +225,7 @@ protected:
dev::solidity::CompilerStack m_compiler;
Address m_sender;
Address m_contractAddress;
+ eth::EnvInfo m_envInfo;
eth::State m_state;
u256 const m_gasPrice = 100 * eth::szabo;
u256 const m_gas = 100000000;