From 0ffa23854df91b45e2a7143f154b70aece82ef8d Mon Sep 17 00:00:00 2001 From: Dima Litvinov Date: Thu, 25 Jan 2024 15:24:46 +0000 Subject: [PATCH] SKALED-1431 Tests for debug_getFutureTransactions --- .../libweb3jsonrpc/WebThreeStubClient.cpp | 10 ++++++++++ .../libweb3jsonrpc/WebThreeStubClient.h | 1 + test/unittests/libweb3jsonrpc/jsonrpc.cpp | 17 +++++++++++++++++ 3 files changed, 28 insertions(+) diff --git a/test/unittests/libweb3jsonrpc/WebThreeStubClient.cpp b/test/unittests/libweb3jsonrpc/WebThreeStubClient.cpp index acdebbf42..680bdb57e 100644 --- a/test/unittests/libweb3jsonrpc/WebThreeStubClient.cpp +++ b/test/unittests/libweb3jsonrpc/WebThreeStubClient.cpp @@ -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() ); +} diff --git a/test/unittests/libweb3jsonrpc/WebThreeStubClient.h b/test/unittests/libweb3jsonrpc/WebThreeStubClient.h index 5f56db895..6385a340d 100644 --- a/test/unittests/libweb3jsonrpc/WebThreeStubClient.h +++ b/test/unittests/libweb3jsonrpc/WebThreeStubClient.h @@ -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_ diff --git a/test/unittests/libweb3jsonrpc/jsonrpc.cpp b/test/unittests/libweb3jsonrpc/jsonrpc.cpp index 714bb525e..041b8d6b0 100644 --- a/test/unittests/libweb3jsonrpc/jsonrpc.cpp +++ b/test/unittests/libweb3jsonrpc/jsonrpc.cpp @@ -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 ); }