TestFramework: Remove polling and use eth_flush instead

This commit is contained in:
Mathias Baumann 2019-05-07 14:45:59 +02:00
parent 2370eefa74
commit 473243ef31
2 changed files with 1 additions and 23 deletions

View File

@ -140,7 +140,7 @@ void ExecutionFramework::sendMessage(bytes const& _data, bool _isCreation, u256
}
string txHash = m_rpc.eth_sendTransaction(d);
waitForTransaction(txHash);
m_rpc.rpcCall("eth_flush");
m_rpc.test_mineBlocks(1);
RPCSession::TransactionReceipt receipt(m_rpc.eth_getTransactionReceipt(txHash));
@ -178,27 +178,6 @@ void ExecutionFramework::sendMessage(bytes const& _data, bool _isCreation, u256
m_transactionSuccessful = (m_gas != m_gasUsed);
}
void ExecutionFramework::waitForTransaction(std::string const& _txHash) const
{
for (int polls = 0; polls < 3000; polls++)
{
std::this_thread::sleep_for(std::chrono::milliseconds(1));
auto pendingBlock = m_rpc.eth_getBlockByNumber("pending", false);
if (!pendingBlock["transactions"].empty())
{
BOOST_REQUIRE_EQUAL(pendingBlock["transactions"][0].asString(), _txHash);
return;
}
if (polls == 200)
{
cerr << "Note: Already used 200 iterations while waiting for transaction confirmation. Issuing an eth_flush request." << endl;
m_rpc.rpcCall("eth_flush");
}
}
}
void ExecutionFramework::sendEther(Address const& _to, u256 const& _value)
{
RPCSession::TransactionData d;

View File

@ -247,7 +247,6 @@ private:
protected:
void sendMessage(bytes const& _data, bool _isCreation, u256 const& _value = 0);
void sendEther(Address const& _to, u256 const& _value);
void waitForTransaction(std::string const& _txHash) const;
size_t currentTimestamp();
size_t blockTimestamp(u256 _number);