Skip to content

Commit

Permalink
SKALED-1431 Tests for debug_getFutureTransactions
Browse files Browse the repository at this point in the history
  • Loading branch information
dimalit committed Jan 25, 2024
1 parent dcc9e4a commit 0ffa238
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
10 changes: 10 additions & 0 deletions test/unittests/libweb3jsonrpc/WebThreeStubClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1344,3 +1344,13 @@ Json::Value WebThreeStubClient::debug_doBlocksDbCompaction() {
throw jsonrpc::JsonRpcException(
jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString() );
}

Json::Value WebThreeStubClient::debug_getFutureTransactions() {
Json::Value p;
Json::Value result = this->CallMethod( "debug_getFutureTransactions", p );
if ( result.isArray() )
return result;
else
throw jsonrpc::JsonRpcException(
jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString() );
}
1 change: 1 addition & 0 deletions test/unittests/libweb3jsonrpc/WebThreeStubClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ class WebThreeStubClient : public jsonrpc::Client {
const Json::Value& param3 ) noexcept( false );
Json::Value debug_doStateDbCompaction() noexcept( false );
Json::Value debug_doBlocksDbCompaction() noexcept( false );
Json::Value debug_getFutureTransactions() noexcept( false );
};

#endif // JSONRPC_CPP_STUB_WEBTHREESTUBCLIENT_H_
17 changes: 17 additions & 0 deletions test/unittests/libweb3jsonrpc/jsonrpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2954,23 +2954,40 @@ BOOST_AUTO_TEST_CASE( mtm_import_future_txs ) {
BOOST_REQUIRE( h1 );
BOOST_REQUIRE_EQUAL( tq->futureSize(), 1);

Json::Value call = fixture.rpcClient->debug_getFutureTransactions();
BOOST_REQUIRE_EQUAL( call.size(), 1);

h256 h2 = fixture.client->importTransaction( tx3 );
BOOST_REQUIRE( h2 );
BOOST_REQUIRE_EQUAL( tq->futureSize(), 2);

call = fixture.rpcClient->debug_getFutureTransactions();
BOOST_REQUIRE_EQUAL( call.size(), 2);
BOOST_REQUIRE_EQUAL( call[0]["from"], string("0x")+txJson["from"].asString() );

h256 h3 = fixture.client->importTransaction( tx2 );
BOOST_REQUIRE( h3 );
BOOST_REQUIRE_EQUAL( tq->futureSize(), 3);

call = fixture.rpcClient->debug_getFutureTransactions();
BOOST_REQUIRE_EQUAL( call.size(), 3);

h256 h4 = fixture.client->importTransaction( tx1 );
BOOST_REQUIRE( h4 );
BOOST_REQUIRE_EQUAL( tq->futureSize(), 1);
BOOST_REQUIRE_EQUAL( tq->status().current, 3);

call = fixture.rpcClient->debug_getFutureTransactions();
BOOST_REQUIRE_EQUAL( call.size(), 1);

h256 h5 = fixture.client->importTransaction( tx4 );
BOOST_REQUIRE( h5 );
BOOST_REQUIRE_EQUAL( tq->futureSize(), 0);
BOOST_REQUIRE_EQUAL( tq->status().current, 5);

call = fixture.rpcClient->debug_getFutureTransactions();
BOOST_REQUIRE_EQUAL( call.size(), 0);

fixture.client->skaleHost()->pauseConsensus( false );
}

Expand Down

0 comments on commit 0ffa238

Please sign in to comment.