From 422f5762d3a4facecdcd78d7f0f2ca68b71bb9d4 Mon Sep 17 00:00:00 2001 From: theoreticalbts Date: Wed, 16 Sep 2015 09:44:35 -0400 Subject: [PATCH] Create unit test for genesis ID reservation #281 --- tests/tests/block_tests.cpp | 49 +++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/tests/tests/block_tests.cpp b/tests/tests/block_tests.cpp index f0830d48..dfa4cf0c 100644 --- a/tests/tests/block_tests.cpp +++ b/tests/tests/block_tests.cpp @@ -22,6 +22,7 @@ #include #include +#include #include #include #include @@ -1176,4 +1177,52 @@ BOOST_FIXTURE_TEST_CASE( transaction_invalidated_in_cache, database_fixture ) } } +BOOST_AUTO_TEST_CASE( genesis_reserve_ids ) +{ + try + { + fc::time_point_sec now( GRAPHENE_TESTING_GENESIS_TIMESTAMP ); + fc::temp_directory data_dir( graphene::utilities::temp_directory_path() ); + + uint32_t num_special_accounts = 100; + uint32_t num_special_assets = 30; + + database db; + db.open( data_dir.path(), [&]() -> genesis_state_type + { + genesis_state_type genesis_state = make_genesis(); + genesis_state_type::initial_asset_type usd; + + usd.symbol = "USD"; + usd.issuer_name = "init0"; + usd.description = "federally floated"; + usd.precision = 4; + usd.max_supply = GRAPHENE_MAX_SHARE_SUPPLY; + usd.accumulated_fees = 0; + usd.is_bitasset = true; + + genesis_state.immutable_parameters.num_special_accounts = num_special_accounts; + genesis_state.immutable_parameters.num_special_assets = num_special_assets; + genesis_state.initial_assets.push_back( usd ); + + return genesis_state; + } ); + + const auto& acct_idx = db.get_index_type().indices().get(); + auto acct_itr = acct_idx.find("init0"); + BOOST_REQUIRE( acct_itr != acct_idx.end() ); + BOOST_CHECK( acct_itr->id == account_id_type( num_special_accounts ) ); + + const auto& asset_idx = db.get_index_type().indices().get(); + auto asset_itr = asset_idx.find("USD"); + BOOST_REQUIRE( asset_itr != asset_idx.end() ); + BOOST_CHECK( asset_itr->id == asset_id_type( num_special_assets ) ); + } + catch (fc::exception& e) + { + edump((e.to_detail_string())); + throw; + } +} + BOOST_AUTO_TEST_SUITE_END()