mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Add blockNumber and blockTimestamp to ExecutionFramework
This commit is contained in:
parent
af8e31b023
commit
3128ec2ca5
@ -82,6 +82,8 @@ void ExecutionFramework::sendMessage(bytes const& _data, bool _isCreation, u256
|
|||||||
m_rpc.test_mineBlocks(1);
|
m_rpc.test_mineBlocks(1);
|
||||||
RPCSession::TransactionReceipt receipt(m_rpc.eth_getTransactionReceipt(txHash));
|
RPCSession::TransactionReceipt receipt(m_rpc.eth_getTransactionReceipt(txHash));
|
||||||
|
|
||||||
|
m_blockNumber = u256(receipt.blockNumber);
|
||||||
|
|
||||||
if (_isCreation)
|
if (_isCreation)
|
||||||
{
|
{
|
||||||
m_contractAddress = Address(receipt.contractAddress);
|
m_contractAddress = Address(receipt.contractAddress);
|
||||||
@ -129,6 +131,12 @@ size_t ExecutionFramework::currentTimestamp()
|
|||||||
return size_t(u256(latestBlock.get("timestamp", "invalid").asString()));
|
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)
|
Address ExecutionFramework::account(size_t _i)
|
||||||
{
|
{
|
||||||
return Address(m_rpc.accountCreateIfNotExists(_i));
|
return Address(m_rpc.accountCreateIfNotExists(_i));
|
||||||
|
@ -262,6 +262,7 @@ protected:
|
|||||||
void sendMessage(bytes const& _data, bool _isCreation, u256 const& _value = 0);
|
void sendMessage(bytes const& _data, bool _isCreation, u256 const& _value = 0);
|
||||||
void sendEther(Address const& _to, u256 const& _value);
|
void sendEther(Address const& _to, u256 const& _value);
|
||||||
size_t currentTimestamp();
|
size_t currentTimestamp();
|
||||||
|
size_t blockTimestamp(u256 number);
|
||||||
|
|
||||||
/// @returns the (potentially newly created) _ith address.
|
/// @returns the (potentially newly created) _ith address.
|
||||||
Address account(size_t _i);
|
Address account(size_t _i);
|
||||||
@ -284,6 +285,7 @@ protected:
|
|||||||
bool m_showMessages = false;
|
bool m_showMessages = false;
|
||||||
Address m_sender;
|
Address m_sender;
|
||||||
Address m_contractAddress;
|
Address m_contractAddress;
|
||||||
|
u256 m_blockNumber;
|
||||||
u256 const m_gasPrice = 100 * szabo;
|
u256 const m_gasPrice = 100 * szabo;
|
||||||
u256 const m_gas = 100000000;
|
u256 const m_gas = 100000000;
|
||||||
bytes m_output;
|
bytes m_output;
|
||||||
|
@ -138,6 +138,7 @@ RPCSession::TransactionReceipt RPCSession::eth_getTransactionReceipt(string cons
|
|||||||
BOOST_REQUIRE(!result.isNull());
|
BOOST_REQUIRE(!result.isNull());
|
||||||
receipt.gasUsed = result["gasUsed"].asString();
|
receipt.gasUsed = result["gasUsed"].asString();
|
||||||
receipt.contractAddress = result["contractAddress"].asString();
|
receipt.contractAddress = result["contractAddress"].asString();
|
||||||
|
receipt.blockNumber = result["blockNumber"].asString();
|
||||||
for (auto const& log: result["logs"])
|
for (auto const& log: result["logs"])
|
||||||
{
|
{
|
||||||
LogEntry entry;
|
LogEntry entry;
|
||||||
|
@ -92,6 +92,7 @@ public:
|
|||||||
std::string gasUsed;
|
std::string gasUsed;
|
||||||
std::string contractAddress;
|
std::string contractAddress;
|
||||||
std::vector<LogEntry> logEntries;
|
std::vector<LogEntry> logEntries;
|
||||||
|
std::string blockNumber;
|
||||||
};
|
};
|
||||||
|
|
||||||
static RPCSession& instance(std::string const& _path);
|
static RPCSession& instance(std::string const& _path);
|
||||||
|
Loading…
Reference in New Issue
Block a user