diff options
author | Alex Beregszaszi <alex@rtfs.hu> | 2017-02-08 00:20:05 +0800 |
---|---|---|
committer | Alex Beregszaszi <alex@rtfs.hu> | 2017-02-10 21:24:56 +0800 |
commit | 3128ec2ca5d30aaca78aae457642214f3f52e31f (patch) | |
tree | 74ef3c659d3a29db108f1f2e5cdc21b5ac25b33c /test | |
parent | af8e31b023723bfc6baa224931ef6570cd8d9a32 (diff) | |
download | dexon-solidity-3128ec2ca5d30aaca78aae457642214f3f52e31f.tar dexon-solidity-3128ec2ca5d30aaca78aae457642214f3f52e31f.tar.gz dexon-solidity-3128ec2ca5d30aaca78aae457642214f3f52e31f.tar.bz2 dexon-solidity-3128ec2ca5d30aaca78aae457642214f3f52e31f.tar.lz dexon-solidity-3128ec2ca5d30aaca78aae457642214f3f52e31f.tar.xz dexon-solidity-3128ec2ca5d30aaca78aae457642214f3f52e31f.tar.zst dexon-solidity-3128ec2ca5d30aaca78aae457642214f3f52e31f.zip |
Add blockNumber and blockTimestamp to ExecutionFramework
Diffstat (limited to 'test')
-rw-r--r-- | test/ExecutionFramework.cpp | 8 | ||||
-rw-r--r-- | test/ExecutionFramework.h | 2 | ||||
-rw-r--r-- | test/RPCSession.cpp | 1 | ||||
-rw-r--r-- | test/RPCSession.h | 1 |
4 files changed, 12 insertions, 0 deletions
diff --git a/test/ExecutionFramework.cpp b/test/ExecutionFramework.cpp index ddcd9cb6..70139642 100644 --- a/test/ExecutionFramework.cpp +++ b/test/ExecutionFramework.cpp @@ -82,6 +82,8 @@ void ExecutionFramework::sendMessage(bytes const& _data, bool _isCreation, u256 m_rpc.test_mineBlocks(1); RPCSession::TransactionReceipt receipt(m_rpc.eth_getTransactionReceipt(txHash)); + m_blockNumber = u256(receipt.blockNumber); + if (_isCreation) { m_contractAddress = Address(receipt.contractAddress); @@ -129,6 +131,12 @@ size_t ExecutionFramework::currentTimestamp() return size_t(u256(latestBlock.get("timestamp", "invalid").asString())); } +size_t ExecutionFramework::blockTimestamp(u256 _number) +{ + auto latestBlock = m_rpc.rpcCall("eth_getBlockByNumber", {toString(_number), "false"}); + return size_t(u256(latestBlock.get("timestamp", "invalid").asString())); +} + Address ExecutionFramework::account(size_t _i) { return Address(m_rpc.accountCreateIfNotExists(_i)); diff --git a/test/ExecutionFramework.h b/test/ExecutionFramework.h index 733fd56d..76d0fd8c 100644 --- a/test/ExecutionFramework.h +++ b/test/ExecutionFramework.h @@ -262,6 +262,7 @@ protected: void sendMessage(bytes const& _data, bool _isCreation, u256 const& _value = 0); void sendEther(Address const& _to, u256 const& _value); size_t currentTimestamp(); + size_t blockTimestamp(u256 number); /// @returns the (potentially newly created) _ith address. Address account(size_t _i); @@ -284,6 +285,7 @@ protected: bool m_showMessages = false; Address m_sender; Address m_contractAddress; + u256 m_blockNumber; u256 const m_gasPrice = 100 * szabo; u256 const m_gas = 100000000; bytes m_output; diff --git a/test/RPCSession.cpp b/test/RPCSession.cpp index b3451528..a58355d0 100644 --- a/test/RPCSession.cpp +++ b/test/RPCSession.cpp @@ -138,6 +138,7 @@ RPCSession::TransactionReceipt RPCSession::eth_getTransactionReceipt(string cons BOOST_REQUIRE(!result.isNull()); receipt.gasUsed = result["gasUsed"].asString(); receipt.contractAddress = result["contractAddress"].asString(); + receipt.blockNumber = result["blockNumber"].asString(); for (auto const& log: result["logs"]) { LogEntry entry; diff --git a/test/RPCSession.h b/test/RPCSession.h index f1aee6a8..b2e8a309 100644 --- a/test/RPCSession.h +++ b/test/RPCSession.h @@ -92,6 +92,7 @@ public: std::string gasUsed; std::string contractAddress; std::vector<LogEntry> logEntries; + std::string blockNumber; }; static RPCSession& instance(std::string const& _path); |