diff --git a/nano/rpc_test/rpc.cpp b/nano/rpc_test/rpc.cpp index 1ac12323..51d4f13c 100644 --- a/nano/rpc_test/rpc.cpp +++ b/nano/rpc_test/rpc.cpp @@ -6252,3 +6252,42 @@ TEST (rpc, confirmation_info) ASSERT_EQ (0, response.get ("total_tally")); } } + +/** Test election scheduler container object stats + * The test set the AEC size to 0 and then creates a block which gets stuck + * in the election scheduler waiting for a slot in the AEC. Then it confirms that + * the stats RPC call shows the corresponding scheduler bucket incrementing + */ +TEST (node, election_scheduler_container_info) +{ + nano::system system; + nano::node_config node_config; + node_config.active_elections_size = 0; + nano::node_flags node_flags; + auto node = add_ipc_enabled_node (system, node_config); + auto const rpc_ctx = add_rpc (system, node); + + // create a send block + auto send1 = nano::state_block_builder () + .account (nano::dev::genesis_key.pub) + .previous (nano::dev::genesis->hash ()) + .representative (nano::dev::genesis_key.pub) + .balance (nano::dev::constants.genesis_amount - 1) + .link (nano::public_key ()) + .sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub) + .work (*node->work_generate_blocking (nano::dev::genesis->hash ())) + .build_shared (); + + // process the block and wait for it to show up in the election scheduler + node->process_active (send1); + ASSERT_TIMELY (10s, node->scheduler.size () == 1); + + // now check the RPC call + boost::property_tree::ptree request; + request.put ("action", "stats"); + request.put ("type", "objects"); + auto response = wait_response (system, rpc_ctx, request); + auto es = response.get_child ("node").get_child ("election_scheduler"); + ASSERT_EQ (es.get_child ("manual_queue").get ("count"), "0"); + ASSERT_EQ (es.get_child ("priority").get_child ("128").get ("count"), "1"); +}