diff options
author | chriseth <c@ethdev.com> | 2016-06-18 08:08:20 +0800 |
---|---|---|
committer | chriseth <c@ethdev.com> | 2016-06-29 05:18:55 +0800 |
commit | e5db096da9a2bfb3e6445b2d89cf730c7e22dc6d (patch) | |
tree | 3e950203ff1b0cb53f81447f1350feb3add0da27 /test/libsolidity/SolidityExecutionFramework.cpp | |
parent | 007132a78e5d97e0476e1153b14f0ae63f458b04 (diff) | |
download | dexon-solidity-e5db096da9a2bfb3e6445b2d89cf730c7e22dc6d.tar.gz dexon-solidity-e5db096da9a2bfb3e6445b2d89cf730c7e22dc6d.tar.zst dexon-solidity-e5db096da9a2bfb3e6445b2d89cf730c7e22dc6d.zip |
Fix some more tests.
Diffstat (limited to 'test/libsolidity/SolidityExecutionFramework.cpp')
-rw-r--r-- | test/libsolidity/SolidityExecutionFramework.cpp | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/test/libsolidity/SolidityExecutionFramework.cpp b/test/libsolidity/SolidityExecutionFramework.cpp index abb564db..efd3a8b8 100644 --- a/test/libsolidity/SolidityExecutionFramework.cpp +++ b/test/libsolidity/SolidityExecutionFramework.cpp @@ -45,7 +45,8 @@ string getIPCSocketPath() } } if (ipcPath.empty()) - ipcPath = getenv("ETH_TEST_IPC"); + if (auto path = getenv("ETH_TEST_IPC")) + ipcPath = path; if (ipcPath.empty()) BOOST_FAIL("ERROR: ipcPath not set! (use --ipc <path>)"); return ipcPath; @@ -86,7 +87,6 @@ void ExecutionFramework::sendMessage(bytes const& _data, bool _isCreation, u256 m_contractAddress = Address(receipt.contractAddress); BOOST_REQUIRE(m_contractAddress); string code = m_rpc.eth_getCode(receipt.contractAddress, "latest"); - BOOST_REQUIRE(code.size() > 2); m_output = fromHex(code, WhenError::Throw); } @@ -103,6 +103,31 @@ void ExecutionFramework::sendMessage(bytes const& _data, bool _isCreation, u256 } } +void ExecutionFramework::sendEther(Address const& _to, u256 const& _value) +{ + RPCSession::TransactionData d; + d.data = "0x"; + d.from = "0x" + toString(m_sender); + d.gas = toHex(m_gas, HexPrefix::Add); + d.gasPrice = toHex(m_gasPrice, HexPrefix::Add); + d.value = toHex(_value, HexPrefix::Add); + d.to = dev::toString(_to); + + string txHash = m_rpc.eth_sendTransaction(d); + m_rpc.test_mineBlocks(1); +} + +size_t ExecutionFramework::currentTimestamp() +{ + auto latestBlock = m_rpc.rpcCall("eth_getBlockByNumber", {"\"latest\"", "false"}); + return size_t(u256(latestBlock.get("timestamp", "invalid").asString())); +} + +Address ExecutionFramework::account(size_t _i) +{ + return Address(m_rpc.accountCreateIfNotExists(_i)); +} + bool ExecutionFramework::addressHasCode(Address const& _addr) { string code = m_rpc.eth_getCode(toString(_addr), "latest"); |