diff --git a/Makefile.am b/Makefile.am index f3279ef4..fd5e7d6e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -65,6 +65,7 @@ test_libbitcoin_database_test_SOURCES = \ test/store.cpp \ test/test.cpp \ test/test.hpp \ + test/types.cpp \ test/file/rotator.cpp \ test/file/utilities.cpp \ test/locks/file_lock.cpp \ @@ -88,27 +89,48 @@ test_libbitcoin_database_test_SOURCES = \ test/primitives/linkage.cpp \ test/primitives/manager.cpp \ test/primitives/nomap.cpp \ - test/query/archive_read.cpp \ - test/query/archive_write.cpp \ - test/query/confirm.cpp \ - test/query/consensus.cpp \ - test/query/context.cpp \ + test/query/amounts.cpp \ + test/query/confirmed.cpp \ test/query/extent.cpp \ - test/query/fees.cpp \ + test/query/fee_rate.cpp \ + test/query/filters.cpp \ test/query/height.cpp \ test/query/initialize.cpp \ + test/query/locator.cpp \ test/query/merkle.cpp \ - test/query/network.cpp \ - test/query/objects.cpp \ - test/query/optional.cpp \ - test/query/translate.cpp \ - test/query/validate.cpp \ - test/query/wire.cpp \ + test/query/properties_block.cpp \ + test/query/properties_tx.cpp \ + test/query/sequences.cpp \ + test/query/sizes.cpp \ + test/query/address/address_balance.cpp \ + test/query/address/address_history.cpp \ + test/query/address/address_outpoints.cpp \ + test/query/address/address_unspent.cpp \ + test/query/archive/chain_reader.cpp \ + test/query/archive/chain_writer.cpp \ + test/query/archive/wire_reader.cpp \ + test/query/archive/wire_writer.cpp \ + test/query/consensus/consensus_block.cpp \ + test/query/consensus/consensus_chain_state.cpp \ + test/query/consensus/consensus_compact.cpp \ + test/query/consensus/consensus_forks.cpp \ + test/query/consensus/consensus_populate.cpp \ + test/query/consensus/consensus_prevouts.cpp \ + test/query/consensus/consensus_states.cpp \ + test/query/consensus/consensus_strong.cpp \ + test/query/consensus/consensus_transaction.cpp \ + test/query/consensus/consensus_work.cpp \ + test/query/navigate/navigate_arraymap.cpp \ + test/query/navigate/navigate_forward.cpp \ + test/query/navigate/navigate_hashmap.cpp \ + test/query/navigate/navigate_natural.cpp \ + test/query/navigate/navigate_reverse.cpp \ test/tables/archives/header.cpp \ test/tables/archives/input.cpp \ + test/tables/archives/ins.cpp \ test/tables/archives/output.cpp \ + test/tables/archives/outs.cpp \ test/tables/archives/point.cpp \ - test/tables/archives/puts.cpp \ test/tables/archives/transaction.cpp \ test/tables/archives/txs.cpp \ test/tables/caches/duplicate.cpp \ @@ -202,12 +224,12 @@ include_bitcoin_database_impl_query_address_HEADERS = \ include/bitcoin/database/impl/query/address/address_outpoints.ipp \ include/bitcoin/database/impl/query/address/address_unspent.ipp -include_bitcoin_database_impl_query_archivaldir = ${includedir}/bitcoin/database/impl/query/archival -include_bitcoin_database_impl_query_archival_HEADERS = \ - include/bitcoin/database/impl/query/archival/chain_reader.ipp \ - include/bitcoin/database/impl/query/archival/chain_writer.ipp \ - include/bitcoin/database/impl/query/archival/wire_reader.ipp \ - include/bitcoin/database/impl/query/archival/wire_writer.ipp +include_bitcoin_database_impl_query_archivedir = ${includedir}/bitcoin/database/impl/query/archive +include_bitcoin_database_impl_query_archive_HEADERS = \ + include/bitcoin/database/impl/query/archive/chain_reader.ipp \ + include/bitcoin/database/impl/query/archive/chain_writer.ipp \ + include/bitcoin/database/impl/query/archive/wire_reader.ipp \ + include/bitcoin/database/impl/query/archive/wire_writer.ipp include_bitcoin_database_impl_query_consensusdir = ${includedir}/bitcoin/database/impl/query/consensus include_bitcoin_database_impl_query_consensus_HEADERS = \ diff --git a/builds/msvc/vs2022/libbitcoin-database-test/libbitcoin-database-test.vcxproj b/builds/msvc/vs2022/libbitcoin-database-test/libbitcoin-database-test.vcxproj index f1f1c41a..3c94bc21 100644 --- a/builds/msvc/vs2022/libbitcoin-database-test/libbitcoin-database-test.vcxproj +++ b/builds/msvc/vs2022/libbitcoin-database-test/libbitcoin-database-test.vcxproj @@ -147,31 +147,52 @@ - - - - - + + + + + + + + + + + + + + + + + + + + - + + $(IntDir)test_query_height.obj + - - - - - - + + + + + + + + + + + - @@ -188,6 +209,7 @@ $(IntDir)test_test.obj + diff --git a/builds/msvc/vs2022/libbitcoin-database-test/libbitcoin-database-test.vcxproj.filters b/builds/msvc/vs2022/libbitcoin-database-test/libbitcoin-database-test.vcxproj.filters index 175e235e..510a16a5 100644 --- a/builds/msvc/vs2022/libbitcoin-database-test/libbitcoin-database-test.vcxproj.filters +++ b/builds/msvc/vs2022/libbitcoin-database-test/libbitcoin-database-test.vcxproj.filters @@ -28,20 +28,32 @@ {5C4DA53A-8C06-4DA6-0000-000000000006} + + {5C4DA53A-8C06-4DA6-0000-000000000008} + + + {5C4DA53A-8C06-4DA6-0000-000000000009} + + + {5C4DA53A-8C06-4DA6-0000-00000000000A} + + + {5C4DA53A-8C06-4DA6-0000-00000000000B} + {5C4DA53A-8C06-4DA6-0000-000000000007} - {5C4DA53A-8C06-4DA6-0000-000000000008} + {5C4DA53A-8C06-4DA6-0000-00000000000C} - {5C4DA53A-8C06-4DA6-0000-000000000009} + {5C4DA53A-8C06-4DA6-0000-00000000000D} - {5C4DA53A-8C06-4DA6-0000-00000000000A} + {5C4DA53A-8C06-4DA6-0000-00000000000E} - {5C4DA53A-8C06-4DA6-0000-00000000000B} + {5C4DA53A-8C06-4DA6-0000-00000000000F} @@ -108,25 +120,73 @@ src\primitives - - src\query + + src\query\address - - src\query + + src\query\address - - src\query + + src\query\address - + + src\query\address + + src\query - + + src\query\archive + + + src\query\archive + + + src\query\archive + + + src\query\archive + + src\query + + src\query\consensus + + + src\query\consensus + + + src\query\consensus + + + src\query\consensus + + + src\query\consensus + + + src\query\consensus + + + src\query\consensus + + + src\query\consensus + + + src\query\consensus + + + src\query\consensus + src\query - + + src\query + + src\query @@ -135,25 +195,37 @@ src\query - + src\query - + src\query - - src\query + + src\query\navigate + + + src\query\navigate + + + src\query\navigate - + + src\query\navigate + + + src\query\navigate + + src\query - + src\query - + src\query - + src\query @@ -168,13 +240,16 @@ src\tables\archives + + src\tables\archives + src\tables\archives - + src\tables\archives - + src\tables\archives @@ -213,6 +288,9 @@ src + + src + diff --git a/builds/msvc/vs2022/libbitcoin-database/libbitcoin-database.vcxproj b/builds/msvc/vs2022/libbitcoin-database/libbitcoin-database.vcxproj index e7472b71..fd204553 100644 --- a/builds/msvc/vs2022/libbitcoin-database/libbitcoin-database.vcxproj +++ b/builds/msvc/vs2022/libbitcoin-database/libbitcoin-database.vcxproj @@ -221,10 +221,10 @@ - - - - + + + + diff --git a/builds/msvc/vs2022/libbitcoin-database/libbitcoin-database.vcxproj.filters b/builds/msvc/vs2022/libbitcoin-database/libbitcoin-database.vcxproj.filters index 15623d74..7783cf66 100644 --- a/builds/msvc/vs2022/libbitcoin-database/libbitcoin-database.vcxproj.filters +++ b/builds/msvc/vs2022/libbitcoin-database/libbitcoin-database.vcxproj.filters @@ -34,7 +34,7 @@ {62D7FBEE-4D52-424A-0000-000000000002} - + {62D7FBEE-4D52-424A-0000-000000000003} @@ -364,17 +364,17 @@ include\bitcoin\database\impl\query - - include\bitcoin\database\impl\query\archival + + include\bitcoin\database\impl\query\archive - - include\bitcoin\database\impl\query\archival + + include\bitcoin\database\impl\query\archive - - include\bitcoin\database\impl\query\archival + + include\bitcoin\database\impl\query\archive - - include\bitcoin\database\impl\query\archival + + include\bitcoin\database\impl\query\archive include\bitcoin\database\impl\query diff --git a/include/bitcoin/database/impl/query/archival/chain_reader.ipp b/include/bitcoin/database/impl/query/archive/chain_reader.ipp similarity index 98% rename from include/bitcoin/database/impl/query/archival/chain_reader.ipp rename to include/bitcoin/database/impl/query/archive/chain_reader.ipp index e8be7b35..b2156208 100644 --- a/include/bitcoin/database/impl/query/archival/chain_reader.ipp +++ b/include/bitcoin/database/impl/query/archive/chain_reader.ipp @@ -16,8 +16,8 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -#ifndef LIBBITCOIN_DATABASE_QUERY_ARCHIVAL_CHAIN_READER_IPP -#define LIBBITCOIN_DATABASE_QUERY_ARCHIVAL_CHAIN_READER_IPP +#ifndef LIBBITCOIN_DATABASE_QUERY_ARCHIVE_CHAIN_READER_IPP +#define LIBBITCOIN_DATABASE_QUERY_ARCHIVE_CHAIN_READER_IPP #include #include diff --git a/include/bitcoin/database/impl/query/archival/chain_writer.ipp b/include/bitcoin/database/impl/query/archive/chain_writer.ipp similarity index 99% rename from include/bitcoin/database/impl/query/archival/chain_writer.ipp rename to include/bitcoin/database/impl/query/archive/chain_writer.ipp index 8da8afcd..95ce1da1 100644 --- a/include/bitcoin/database/impl/query/archival/chain_writer.ipp +++ b/include/bitcoin/database/impl/query/archive/chain_writer.ipp @@ -16,8 +16,8 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -#ifndef LIBBITCOIN_DATABASE_QUERY_ARCHIVAL_CHAIN_WRITER_IPP -#define LIBBITCOIN_DATABASE_QUERY_ARCHIVAL_CHAIN_WRITER_IPP +#ifndef LIBBITCOIN_DATABASE_QUERY_ARCHIVE_CHAIN_WRITER_IPP +#define LIBBITCOIN_DATABASE_QUERY_ARCHIVE_CHAIN_WRITER_IPP #include #include diff --git a/include/bitcoin/database/impl/query/archival/wire_reader.ipp b/include/bitcoin/database/impl/query/archive/wire_reader.ipp similarity index 97% rename from include/bitcoin/database/impl/query/archival/wire_reader.ipp rename to include/bitcoin/database/impl/query/archive/wire_reader.ipp index 90b60851..5f95ce49 100644 --- a/include/bitcoin/database/impl/query/archival/wire_reader.ipp +++ b/include/bitcoin/database/impl/query/archive/wire_reader.ipp @@ -16,8 +16,8 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -#ifndef LIBBITCOIN_DATABASE_QUERY_ARCHIVAL_WIRE_READER_IPP -#define LIBBITCOIN_DATABASE_QUERY_ARCHIVAL_WIRE_READER_IPP +#ifndef LIBBITCOIN_DATABASE_QUERY_ARCHIVE_WIRE_READER_IPP +#define LIBBITCOIN_DATABASE_QUERY_ARCHIVE_WIRE_READER_IPP #include #include diff --git a/include/bitcoin/database/impl/query/archival/wire_writer.ipp b/include/bitcoin/database/impl/query/archive/wire_writer.ipp similarity index 90% rename from include/bitcoin/database/impl/query/archival/wire_writer.ipp rename to include/bitcoin/database/impl/query/archive/wire_writer.ipp index eea0105a..98c5c1b1 100644 --- a/include/bitcoin/database/impl/query/archival/wire_writer.ipp +++ b/include/bitcoin/database/impl/query/archive/wire_writer.ipp @@ -16,8 +16,8 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -#ifndef LIBBITCOIN_DATABASE_QUERY_ARCHIVAL_WIRE_WRITER_IPP -#define LIBBITCOIN_DATABASE_QUERY_ARCHIVAL_WIRE_WRITER_IPP +#ifndef LIBBITCOIN_DATABASE_QUERY_ARCHIVE_WIRE_WRITER_IPP +#define LIBBITCOIN_DATABASE_QUERY_ARCHIVE_WIRE_WRITER_IPP #include diff --git a/include/bitcoin/database/query.hpp b/include/bitcoin/database/query.hpp index 42721972..107f663f 100644 --- a/include/bitcoin/database/query.hpp +++ b/include/bitcoin/database/query.hpp @@ -855,10 +855,10 @@ BC_PUSH_WARNING(NO_THROW_IN_NOEXCEPT) #include #include -#include -#include -#include -#include +#include +#include +#include +#include #include #include diff --git a/include/bitcoin/database/types.hpp b/include/bitcoin/database/types.hpp index 9aeac010..8bcc7c62 100644 --- a/include/bitcoin/database/types.hpp +++ b/include/bitcoin/database/types.hpp @@ -24,8 +24,6 @@ #include #include #include - -// Types pulls in tables etc, query and store both pull in types. #include namespace libbitcoin { @@ -72,17 +70,13 @@ using data_chunk = system::data_chunk; /// Common system::chain aliases. /// --------------------------------------------------------------------------- -using checkpoint = system::chain::checkpoint; -using outpoint = system::chain::outpoint; using inpoint = system::chain::point; +using outpoint = system::chain::outpoint; +using checkpoint = system::chain::checkpoint; /// Common carriers. /// --------------------------------------------------------------------------- -/// Sorted and deduped. -using outpoints = std::set; -using inpoints = std::set; - using counts = std::pair; using sizes = std::pair; using heights = std_vector; @@ -96,36 +90,40 @@ using fee_rate_sets = std::vector; struct span { - size_t size() const NOEXCEPT { return end - begin; } + inline size_t size() const NOEXCEPT { return end - begin; } size_t begin; size_t end; }; -struct BCD_API history +struct BCD_API unspent { struct less_than { - bool operator()(const history& a, const history& b) NOEXCEPT; + bool operator()(const unspent& a, const unspent& b) NOEXCEPT; }; - checkpoint tx{}; - uint64_t fee{}; + outpoint tx{}; + size_t height{}; size_t position{}; }; -using histories = std::set; -struct BCD_API unspent +struct BCD_API history { struct less_than { - bool operator()(const unspent& a, const unspent& b) NOEXCEPT; + bool operator()(const history& a, const history& b) NOEXCEPT; }; - outpoint tx{}; - size_t height{}; + checkpoint tx{}; + uint64_t fee{}; size_t position{}; }; + +/// Sorted and deduped. +using inpoints = std::set; +using outpoints = std::set; using unspents = std::set; +using histories = std::set; } // namespace database } // namespace libbitcoin diff --git a/test/mocks/blocks.cpp b/test/mocks/blocks.cpp index 7ba6ca7a..4659cd23 100644 --- a/test/mocks/blocks.cpp +++ b/test/mocks/blocks.cpp @@ -81,6 +81,13 @@ const block block7{ block7_data, true }; const block block8{ block8_data, true }; const block block9{ block9_data, true }; +system::hash_digest genesis_address() NOEXCEPT +{ + static const auto address = genesis.transactions_ptr()->front()-> + outputs_ptr()->front()->script().hash(); + return address; +} + bool setup_three_block_store(query_t& query) NOEXCEPT { return query.initialize(genesis) && diff --git a/test/mocks/blocks.hpp b/test/mocks/blocks.hpp index 82bc02ce..f802e78f 100644 --- a/test/mocks/blocks.hpp +++ b/test/mocks/blocks.hpp @@ -101,6 +101,7 @@ extern const system::chain::block block_spend_internal_2b; extern const system::chain::block block_missing_prevout_2b; extern const system::chain::block block_valid_spend_internal_2b; +system::hash_digest genesis_address() NOEXCEPT; bool setup_three_block_store(query_t& query) NOEXCEPT; bool setup_three_block_witness_store(query_t& query) NOEXCEPT; diff --git a/test/query/address/address_balance.cpp b/test/query/address/address_balance.cpp new file mode 100644 index 00000000..71325747 --- /dev/null +++ b/test/query/address/address_balance.cpp @@ -0,0 +1,59 @@ +/** + * Copyright (c) 2011-2026 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +#include "../../test.hpp" +#include "../../mocks/blocks.hpp" +#include "../../mocks/chunk_store.hpp" + +BOOST_FIXTURE_TEST_SUITE(query_address_tests, test::directory_setup_fixture) + +// TODO: get_unconfirmed_balance +// get_confirmed_balance +// TODO: get_balance + +BOOST_AUTO_TEST_CASE(query_address__get_confirmed_balance__turbo_genesis__expected) +{ + settings settings{}; + settings.path = TEST_DIRECTORY; + test::chunk_store store{ settings }; + test::query_accessor query{ store }; + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); + BOOST_REQUIRE(query.initialize(test::genesis)); + + uint64_t out{}; + std::atomic_bool cancel{}; + BOOST_REQUIRE(!query.get_confirmed_balance(cancel, out, test::genesis_address(), true)); + BOOST_REQUIRE_EQUAL(out, 5000000000u); +} + +BOOST_AUTO_TEST_CASE(query_address__get_confirmed_balance__genesis__expected) +{ + settings settings{}; + settings.path = TEST_DIRECTORY; + test::chunk_store store{ settings }; + test::query_accessor query{ store }; + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); + BOOST_REQUIRE(query.initialize(test::genesis)); + + uint64_t out{}; + std::atomic_bool cancel{}; + BOOST_REQUIRE(!query.get_confirmed_balance(cancel, out, test::genesis_address())); + BOOST_REQUIRE_EQUAL(out, 5000000000u); +} + +BOOST_AUTO_TEST_SUITE_END() diff --git a/test/query/address/address_history.cpp b/test/query/address/address_history.cpp new file mode 100644 index 00000000..66af766d --- /dev/null +++ b/test/query/address/address_history.cpp @@ -0,0 +1,29 @@ +/** + * Copyright (c) 2011-2026 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +#include "../../test.hpp" +#include "../../mocks/blocks.hpp" +#include "../../mocks/chunk_store.hpp" + +BOOST_FIXTURE_TEST_SUITE(query_address_tests, test::directory_setup_fixture) + +// get_unconfirmed_address +// get_confirmed_address +// get_address + +BOOST_AUTO_TEST_SUITE_END() diff --git a/test/query/optional.cpp b/test/query/address/address_outpoints.cpp similarity index 51% rename from test/query/optional.cpp rename to test/query/address/address_outpoints.cpp index b716a8a3..8dedabf5 100644 --- a/test/query/optional.cpp +++ b/test/query/address/address_outpoints.cpp @@ -16,41 +16,15 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -#include "../test.hpp" -#include "../mocks/blocks.hpp" -#include "../mocks/chunk_store.hpp" +#include "../../test.hpp" +#include "../../mocks/blocks.hpp" +#include "../../mocks/chunk_store.hpp" -BOOST_FIXTURE_TEST_SUITE(query_optional_tests, test::directory_setup_fixture) - -system::hash_digest genesis_address() -{ - static const auto address = test::genesis.transactions_ptr()->front()-> - outputs_ptr()->front()->script().hash(); - - return address; -} - -// to_address_outputs - -BOOST_AUTO_TEST_CASE(query_optional__to_address_outputs__genesis__expected) -{ - settings settings{}; - settings.path = TEST_DIRECTORY; - test::chunk_store store{ settings }; - test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); - BOOST_REQUIRE(query.initialize(test::genesis)); - - output_links out{}; - std::atomic_bool cancel{}; - BOOST_REQUIRE(!query.to_address_outputs(cancel, out, genesis_address())); - BOOST_REQUIRE_EQUAL(out.size(), 1u); - BOOST_REQUIRE_EQUAL(out.front(), query.to_output(0, 0)); -} +BOOST_FIXTURE_TEST_SUITE(query_address_tests, test::directory_setup_fixture) // get_address_outputs -BOOST_AUTO_TEST_CASE(query_optional__get_address_outputs__turbo_genesis__expected) +BOOST_AUTO_TEST_CASE(query_address__get_address_outputs__turbo_genesis__expected) { settings settings{}; settings.path = TEST_DIRECTORY; @@ -61,12 +35,12 @@ BOOST_AUTO_TEST_CASE(query_optional__get_address_outputs__turbo_genesis__expecte outpoints out{}; std::atomic_bool cancel{}; - BOOST_REQUIRE(!query.get_address_outputs(cancel, out, genesis_address(), true)); + BOOST_REQUIRE(!query.get_address_outputs(cancel, out, test::genesis_address(), true)); BOOST_REQUIRE_EQUAL(out.size(), 1u); ////BOOST_REQUIRE_EQUAL(out.front(), query.to_output(0, 0)); } -BOOST_AUTO_TEST_CASE(query_optional__get_address_outputs__genesis__expected) +BOOST_AUTO_TEST_CASE(query_address__get_address_outputs__genesis__expected) { settings settings{}; settings.path = TEST_DIRECTORY; @@ -77,12 +51,12 @@ BOOST_AUTO_TEST_CASE(query_optional__get_address_outputs__genesis__expected) outpoints out{}; std::atomic_bool cancel{}; - BOOST_REQUIRE(!query.get_address_outputs(cancel, out, genesis_address())); + BOOST_REQUIRE(!query.get_address_outputs(cancel, out, test::genesis_address())); BOOST_REQUIRE_EQUAL(out.size(), 1u); ////BOOST_REQUIRE_EQUAL(out.front(), query.to_output(0, 0)); } -BOOST_AUTO_TEST_CASE(query_optional__get_address_outputs__cancel__canceled_false) +BOOST_AUTO_TEST_CASE(query_address__get_address_outputs__cancel__canceled_false) { settings settings{}; settings.path = TEST_DIRECTORY; @@ -93,13 +67,13 @@ BOOST_AUTO_TEST_CASE(query_optional__get_address_outputs__cancel__canceled_false outpoints out{}; std::atomic_bool cancel{ true }; - BOOST_REQUIRE_EQUAL(query.get_address_outputs(cancel, out, genesis_address()), error::canceled); + BOOST_REQUIRE_EQUAL(query.get_address_outputs(cancel, out, test::genesis_address()), error::canceled); BOOST_REQUIRE(out.empty()); } // get_confirmed_unspent_outputs -BOOST_AUTO_TEST_CASE(query_optional__get_confirmed_unspent_outputs__turbo_genesis__expected) +BOOST_AUTO_TEST_CASE(query_address__get_confirmed_unspent_outputs__turbo_genesis__expected) { settings settings{}; settings.path = TEST_DIRECTORY; @@ -110,12 +84,12 @@ BOOST_AUTO_TEST_CASE(query_optional__get_confirmed_unspent_outputs__turbo_genesi outpoints out{}; std::atomic_bool cancel{}; - BOOST_REQUIRE(!query.get_confirmed_unspent_outputs(cancel, out, genesis_address(), true)); + BOOST_REQUIRE(!query.get_confirmed_unspent_outputs(cancel, out, test::genesis_address(), true)); BOOST_REQUIRE_EQUAL(out.size(), 1u); ////BOOST_REQUIRE_EQUAL(out.front(), 0); } -BOOST_AUTO_TEST_CASE(query_optional__get_confirmed_unspent_outputs__genesis__expected) +BOOST_AUTO_TEST_CASE(query_address__get_confirmed_unspent_outputs__genesis__expected) { settings settings{}; settings.path = TEST_DIRECTORY; @@ -126,14 +100,14 @@ BOOST_AUTO_TEST_CASE(query_optional__get_confirmed_unspent_outputs__genesis__exp outpoints out{}; std::atomic_bool cancel{}; - BOOST_REQUIRE(!query.get_confirmed_unspent_outputs(cancel, out, genesis_address())); + BOOST_REQUIRE(!query.get_confirmed_unspent_outputs(cancel, out, test::genesis_address())); BOOST_REQUIRE_EQUAL(out.size(), 1u); ////BOOST_REQUIRE_EQUAL(out.front(), 0); } // get_minimum_unspent_outputs -BOOST_AUTO_TEST_CASE(query_optional__get_minimum_unspent_outputs__turbo_above__excluded) +BOOST_AUTO_TEST_CASE(query_address__get_minimum_unspent_outputs__turbo_above__excluded) { settings settings{}; settings.path = TEST_DIRECTORY; @@ -144,11 +118,11 @@ BOOST_AUTO_TEST_CASE(query_optional__get_minimum_unspent_outputs__turbo_above__e outpoints out{}; std::atomic_bool cancel{}; - BOOST_REQUIRE(!query.get_minimum_unspent_outputs(cancel, out, genesis_address(), 5000000001, true)); + BOOST_REQUIRE(!query.get_minimum_unspent_outputs(cancel, out, test::genesis_address(), 5000000001, true)); BOOST_REQUIRE(out.empty()); } -BOOST_AUTO_TEST_CASE(query_optional__get_minimum_unspent_outputs__above__excluded) +BOOST_AUTO_TEST_CASE(query_address__get_minimum_unspent_outputs__above__excluded) { settings settings{}; settings.path = TEST_DIRECTORY; @@ -159,11 +133,11 @@ BOOST_AUTO_TEST_CASE(query_optional__get_minimum_unspent_outputs__above__exclude outpoints out{}; std::atomic_bool cancel{}; - BOOST_REQUIRE(!query.get_minimum_unspent_outputs(cancel, out, genesis_address(), 5000000001)); + BOOST_REQUIRE(!query.get_minimum_unspent_outputs(cancel, out, test::genesis_address(), 5000000001)); BOOST_REQUIRE(out.empty()); } -BOOST_AUTO_TEST_CASE(query_optional__get_minimum_unspent_outputs__at__included) +BOOST_AUTO_TEST_CASE(query_address__get_minimum_unspent_outputs__at__included) { settings settings{}; settings.path = TEST_DIRECTORY; @@ -174,12 +148,12 @@ BOOST_AUTO_TEST_CASE(query_optional__get_minimum_unspent_outputs__at__included) outpoints out{}; std::atomic_bool cancel{}; - BOOST_REQUIRE(!query.get_minimum_unspent_outputs(cancel, out, genesis_address(), 5000000000)); + BOOST_REQUIRE(!query.get_minimum_unspent_outputs(cancel, out, test::genesis_address(), 5000000000)); BOOST_REQUIRE_EQUAL(out.size(), 1u); ////BOOST_REQUIRE_EQUAL(out.front(), 0); } -BOOST_AUTO_TEST_CASE(query_optional__get_minimum_unspent_outputs__below__included) +BOOST_AUTO_TEST_CASE(query_address__get_minimum_unspent_outputs__below__included) { settings settings{}; settings.path = TEST_DIRECTORY; @@ -190,74 +164,12 @@ BOOST_AUTO_TEST_CASE(query_optional__get_minimum_unspent_outputs__below__include outpoints out{}; std::atomic_bool cancel{}; - BOOST_REQUIRE(!query.get_minimum_unspent_outputs(cancel, out, genesis_address(), 0)); + BOOST_REQUIRE(!query.get_minimum_unspent_outputs(cancel, out, test::genesis_address(), 0)); BOOST_REQUIRE_EQUAL(out.size(), 1u); ////BOOST_REQUIRE_EQUAL(out.front(), 0); - BOOST_REQUIRE(!query.get_minimum_unspent_outputs(cancel, out, genesis_address(), 4999999999)); + BOOST_REQUIRE(!query.get_minimum_unspent_outputs(cancel, out, test::genesis_address(), 4999999999)); BOOST_REQUIRE_EQUAL(out.size(), 1u); ////BOOST_REQUIRE_EQUAL(out.front(), 0); } -// get_confirmed_balance - -BOOST_AUTO_TEST_CASE(query_optional__get_confirmed_balance__turbo_genesis__expected) -{ - settings settings{}; - settings.path = TEST_DIRECTORY; - test::chunk_store store{ settings }; - test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); - BOOST_REQUIRE(query.initialize(test::genesis)); - - uint64_t out{}; - std::atomic_bool cancel{}; - BOOST_REQUIRE(!query.get_confirmed_balance(cancel, out, genesis_address(), true)); - BOOST_REQUIRE_EQUAL(out, 5000000000u); -} - -BOOST_AUTO_TEST_CASE(query_optional__get_confirmed_balance__genesis__expected) -{ - settings settings{}; - settings.path = TEST_DIRECTORY; - test::chunk_store store{ settings }; - test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); - BOOST_REQUIRE(query.initialize(test::genesis)); - - uint64_t out{}; - std::atomic_bool cancel{}; - BOOST_REQUIRE(!query.get_confirmed_balance(cancel, out, genesis_address())); - BOOST_REQUIRE_EQUAL(out, 5000000000u); -} - -////BOOST_AUTO_TEST_CASE(query_optional__set_filter__get_filter_and_head__expected) -////{ -//// const auto& filter_head0 = system::null_hash; -//// const auto filter0 = system::base16_chunk("0102030405060708090a0b0c0d0e0f"); -//// const auto& filter_head1 = system::one_hash; -//// const auto filter1 = system::base16_chunk("102030405060708090a0b0c0d0e0f0102030405060708090a0b0c0d0e0f0"); -//// -//// settings settings{}; -//// settings.path = TEST_DIRECTORY; -//// test::chunk_store store{ settings }; -//// test::query_accessor query{ store }; -//// BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); -//// BOOST_REQUIRE(query.initialize(test::genesis)); -//// BOOST_REQUIRE(query.set(test::block1a, context{}, false, false)); -//// BOOST_REQUIRE(query.set_filter(0, filter_head0, filter0)); -//// BOOST_REQUIRE(query.set_filter(1, filter_head1, filter1)); -//// -//// hash_digest head{}; -//// BOOST_REQUIRE(query.get_filter_head(head, 0)); -//// BOOST_REQUIRE_EQUAL(head, filter_head0); -//// BOOST_REQUIRE(query.get_filter_head(head, 1)); -//// BOOST_REQUIRE_EQUAL(head, filter_head1); -//// -//// system::data_chunk out{}; -//// BOOST_REQUIRE(query.get_filter(out, 0)); -//// BOOST_REQUIRE_EQUAL(out, filter0); -//// BOOST_REQUIRE(query.get_filter(out, 1)); -//// BOOST_REQUIRE_EQUAL(out, filter1); -////} - BOOST_AUTO_TEST_SUITE_END() diff --git a/test/query/address/address_unspent.cpp b/test/query/address/address_unspent.cpp new file mode 100644 index 00000000..0482c55d --- /dev/null +++ b/test/query/address/address_unspent.cpp @@ -0,0 +1,29 @@ +/** + * Copyright (c) 2011-2026 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +#include "../../test.hpp" +#include "../../mocks/blocks.hpp" +#include "../../mocks/chunk_store.hpp" + +BOOST_FIXTURE_TEST_SUITE(query_address_tests, test::directory_setup_fixture) + +// get_unconfirmed_unspent +// get_confirmed_unspent +// get_unspent + +BOOST_AUTO_TEST_SUITE_END() diff --git a/test/query/objects.cpp b/test/query/amounts.cpp similarity index 83% rename from test/query/objects.cpp rename to test/query/amounts.cpp index 086ed58f..68b3c51f 100644 --- a/test/query/objects.cpp +++ b/test/query/amounts.cpp @@ -20,13 +20,6 @@ #include "../mocks/blocks.hpp" #include "../mocks/chunk_store.hpp" -BOOST_FIXTURE_TEST_SUITE(query_objects_tests, test::directory_setup_fixture) - -////const auto events_handler = [](auto, auto) {}; - -BOOST_AUTO_TEST_CASE(query_objects_test) -{ - BOOST_REQUIRE(true); -} +BOOST_FIXTURE_TEST_SUITE(query_amounts_tests, test::directory_setup_fixture) BOOST_AUTO_TEST_SUITE_END() diff --git a/test/query/archive_read.cpp b/test/query/archive/chain_reader.cpp similarity index 86% rename from test/query/archive_read.cpp rename to test/query/archive/chain_reader.cpp index c296cba8..10b69b70 100644 --- a/test/query/archive_read.cpp +++ b/test/query/archive/chain_reader.cpp @@ -16,27 +16,24 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -#include "../test.hpp" -#include "../mocks/blocks.hpp" -#include "../mocks/chunk_store.hpp" - -BOOST_FIXTURE_TEST_SUITE(query_archive_read_tests, test::directory_setup_fixture) +#include "../../test.hpp" +#include "../../mocks/blocks.hpp" +#include "../../mocks/chunk_store.hpp" // ensure context::flags is same size as chain_context::flags. -static_assert(is_same_type); +static_assert(is_same_type < database::context::flag_t::integer, decltype(system::chain::context{}.flags) > ); -// nop event handler. -const auto events_handler = [](auto, auto) {}; +BOOST_FIXTURE_TEST_SUITE(query_chain_reader_tests, test::directory_setup_fixture) // is_coinbase -BOOST_AUTO_TEST_CASE(query_archive_read__is_coinbase__coinbase__true) +BOOST_AUTO_TEST_CASE(query_chain_reader__is_coinbase__coinbase__true) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK(!store.create(events_handler)); + BOOST_CHECK(!store.create(test::events_handler)); BOOST_CHECK(query.initialize(test::genesis)); BOOST_CHECK(query.set(test::block1, context{}, false, false)); BOOST_CHECK(query.set(test::block2, context{}, false, false)); @@ -47,13 +44,13 @@ BOOST_AUTO_TEST_CASE(query_archive_read__is_coinbase__coinbase__true) BOOST_CHECK(query.is_coinbase(3)); } -BOOST_AUTO_TEST_CASE(query_archive_read__is_coinbase__non_coinbase__false) +BOOST_AUTO_TEST_CASE(query_chain_reader__is_coinbase__non_coinbase__false) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK(!store.create(events_handler)); + BOOST_CHECK(!store.create(test::events_handler)); BOOST_CHECK(query.initialize(test::genesis)); BOOST_CHECK(query.set(test::block1a, context{}, false, false)); BOOST_CHECK(query.set(test::block2a, context{}, false, false)); @@ -67,13 +64,13 @@ BOOST_AUTO_TEST_CASE(query_archive_read__is_coinbase__non_coinbase__false) // is_tx_segregated -BOOST_AUTO_TEST_CASE(query_archive_read__is_tx_segregated__always__expected) +BOOST_AUTO_TEST_CASE(query_chain_reader__is_tx_segregated__always__expected) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK_EQUAL(store.create(events_handler), error::success); + BOOST_CHECK_EQUAL(store.create(test::events_handler), error::success); BOOST_CHECK(query.initialize(test::genesis)); BOOST_CHECK(query.set(test::block1a, context{}, false, false)); BOOST_CHECK(!query.is_tx_segregated(0)); @@ -83,13 +80,13 @@ BOOST_AUTO_TEST_CASE(query_archive_read__is_tx_segregated__always__expected) // is_block_segregated -BOOST_AUTO_TEST_CASE(query_archive_read__is_block_segregated__always__expected) +BOOST_AUTO_TEST_CASE(query_chain_reader__is_block_segregated__always__expected) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK_EQUAL(store.create(events_handler), error::success); + BOOST_CHECK_EQUAL(store.create(test::events_handler), error::success); BOOST_CHECK(query.initialize(test::genesis)); BOOST_CHECK(query.set(test::block1a, context{}, false, false)); BOOST_CHECK(!query.is_block_segregated(0)); @@ -99,25 +96,25 @@ BOOST_AUTO_TEST_CASE(query_archive_read__is_block_segregated__always__expected) // is_milestone -BOOST_AUTO_TEST_CASE(query_archive_read__is_milestone__genesis__false) +BOOST_AUTO_TEST_CASE(query_chain_reader__is_milestone__genesis__false) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK_EQUAL(store.create(events_handler), error::success); + BOOST_CHECK_EQUAL(store.create(test::events_handler), error::success); BOOST_CHECK(query.initialize(test::genesis)); BOOST_CHECK(!query.is_milestone(0)); BOOST_CHECK(!query.is_milestone(1)); } -BOOST_AUTO_TEST_CASE(query_archive_read__is_milestone__set__expected) +BOOST_AUTO_TEST_CASE(query_chain_reader__is_milestone__set__expected) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK_EQUAL(store.create(events_handler), error::success); + BOOST_CHECK_EQUAL(store.create(test::events_handler), error::success); BOOST_CHECK(query.initialize(test::genesis)); BOOST_CHECK(query.set(test::block1, context{}, true, false)); BOOST_CHECK(query.set(test::block2, context{}, false, false));; @@ -126,7 +123,7 @@ BOOST_AUTO_TEST_CASE(query_archive_read__is_milestone__set__expected) BOOST_CHECK(!query.is_milestone(2)); } -BOOST_AUTO_TEST_CASE(query_archive_read__get_header__invalid_parent__expected) +BOOST_AUTO_TEST_CASE(query_chain_reader__get_header__invalid_parent__expected) { constexpr auto root = system::base16_array("119192939495969798999a9b9c9d9e9f229192939495969798999a9b9c9d9e9f"); constexpr auto block_hash = system::base16_array("85d0b02a16f6d645aa865fad4a8666f5e7bb2b0c4392a5d675496d6c3defa1f2"); @@ -169,7 +166,7 @@ BOOST_AUTO_TEST_CASE(query_archive_read__get_header__invalid_parent__expected) settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK(!store.create(events_handler)); + BOOST_CHECK(!store.create(test::events_handler)); store.header_head() = expected_header_head; store.header_body() = expected_header_body; @@ -177,7 +174,7 @@ BOOST_AUTO_TEST_CASE(query_archive_read__get_header__invalid_parent__expected) BOOST_CHECK(!query.get_header(header_link::terminal)); } -BOOST_AUTO_TEST_CASE(query_archive_read__get_header__default__expected) +BOOST_AUTO_TEST_CASE(query_chain_reader__get_header__default__expected) { constexpr auto root = system::base16_array("119192939495969798999a9b9c9d9e9f229192939495969798999a9b9c9d9e9f"); constexpr auto block_hash = system::base16_array("85d0b02a16f6d645aa865fad4a8666f5e7bb2b0c4392a5d675496d6c3defa1f2"); @@ -231,7 +228,7 @@ BOOST_AUTO_TEST_CASE(query_archive_read__get_header__default__expected) settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK(!store.create(events_handler)); + BOOST_CHECK(!store.create(test::events_handler)); ////store.header_head() = expected_header_head; ////store.header_body() = expected_header_body; @@ -248,36 +245,36 @@ BOOST_AUTO_TEST_CASE(query_archive_read__get_header__default__expected) BOOST_CHECK_EQUAL(pointer1->hash(), block_hash); } -BOOST_AUTO_TEST_CASE(query_archive_read__get_tx_keys__not_found__empty) +BOOST_AUTO_TEST_CASE(query_chain_reader__get_tx_keys__not_found__empty) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK(!store.create(events_handler)); + BOOST_CHECK(!store.create(test::events_handler)); BOOST_CHECK(query.get_tx_keys(query.to_header(system::null_hash)).empty()); - BOOST_CHECK(!store.close(events_handler)); + BOOST_CHECK(!store.close(test::events_handler)); } -BOOST_AUTO_TEST_CASE(query_archive_read__get_header_key__always__expected) +BOOST_AUTO_TEST_CASE(query_chain_reader__get_header_key__always__expected) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK(!store.create(events_handler)); + BOOST_CHECK(!store.create(test::events_handler)); BOOST_CHECK(query.initialize(test::genesis)); BOOST_CHECK_EQUAL(query.get_header_key(0), test::genesis.hash()); BOOST_CHECK_EQUAL(query.get_header_key(1), system::null_hash); } -BOOST_AUTO_TEST_CASE(query_archive_read__get_point_key__always__expected) +BOOST_AUTO_TEST_CASE(query_chain_reader__get_point_key__always__expected) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK(!store.create(events_handler)); + BOOST_CHECK(!store.create(test::events_handler)); BOOST_CHECK(query.initialize(test::genesis)); BOOST_CHECK_EQUAL(query.get_point_hash(0), system::null_hash); @@ -297,13 +294,13 @@ BOOST_AUTO_TEST_CASE(query_archive_read__get_point_key__always__expected) ////BOOST_CHECK_EQUAL(query.get_point_hash(6), system::null_hash); } -BOOST_AUTO_TEST_CASE(query_archive_read__get_tx_key__always__expected) +BOOST_AUTO_TEST_CASE(query_chain_reader__get_tx_key__always__expected) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK(!store.create(events_handler)); + BOOST_CHECK(!store.create(test::events_handler)); BOOST_CHECK(query.initialize(test::genesis)); BOOST_CHECK_EQUAL(query.get_tx_key(0), test::genesis.transactions_ptr()->front()->hash(false)); BOOST_CHECK_EQUAL(query.get_tx_key(1), system::null_hash); @@ -314,13 +311,13 @@ BOOST_AUTO_TEST_CASE(query_archive_read__get_tx_key__always__expected) BOOST_CHECK_EQUAL(query.get_tx_key(3), system::null_hash); } -BOOST_AUTO_TEST_CASE(query_archive_read__get_height1__always__expected) +BOOST_AUTO_TEST_CASE(query_chain_reader__get_height1__always__expected) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK(!store.create(events_handler)); + BOOST_CHECK(!store.create(test::events_handler)); BOOST_CHECK(query.initialize(test::genesis)); BOOST_CHECK(query.set(test::block1, context{ 0, 1, 0 }, false, false)); BOOST_CHECK(query.set(test::block2, context{ 0, 2, 0 }, false, false)); @@ -344,13 +341,13 @@ BOOST_AUTO_TEST_CASE(query_archive_read__get_height1__always__expected) BOOST_CHECK(!query.get_height(out, 6)); } -BOOST_AUTO_TEST_CASE(query_archive_read__get_height2__always__expected) +BOOST_AUTO_TEST_CASE(query_chain_reader__get_height2__always__expected) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK(!store.create(events_handler)); + BOOST_CHECK(!store.create(test::events_handler)); BOOST_CHECK(query.initialize(test::genesis)); BOOST_CHECK(query.set(test::block1, context{ 0, 1, 0 }, false, false)); BOOST_CHECK(query.set(test::block2, context{ 0, 2, 0 }, false, false)); @@ -374,13 +371,13 @@ BOOST_AUTO_TEST_CASE(query_archive_read__get_height2__always__expected) BOOST_CHECK(!query.get_height(out, system::one_hash)); } -BOOST_AUTO_TEST_CASE(query_archive_read__get_tx_height__not_strong__false) +BOOST_AUTO_TEST_CASE(query_chain_reader__get_tx_height__not_strong__false) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK(!store.create(events_handler)); + BOOST_CHECK(!store.create(test::events_handler)); BOOST_CHECK(query.initialize(test::genesis)); BOOST_CHECK(query.set(test::tx4)); @@ -388,13 +385,13 @@ BOOST_AUTO_TEST_CASE(query_archive_read__get_tx_height__not_strong__false) BOOST_CHECK(!query.get_tx_height(out, 1)); } -BOOST_AUTO_TEST_CASE(query_archive_read__get_tx_position__strong__expected) +BOOST_AUTO_TEST_CASE(query_chain_reader__get_tx_position__strong__expected) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK(!store.create(events_handler)); + BOOST_CHECK(!store.create(test::events_handler)); BOOST_CHECK(query.initialize(test::genesis)); BOOST_CHECK(query.set(test::block1a, context{ 0, 1, 0 }, false, false)); BOOST_CHECK(query.set(test::block2a, context{ 0, 2, 0 }, false, false)); @@ -433,13 +430,13 @@ BOOST_AUTO_TEST_CASE(query_archive_read__get_tx_position__strong__expected) BOOST_CHECK_EQUAL(query.get_position_tx(3, 0), 4u); } -BOOST_AUTO_TEST_CASE(query_archive_read__get_tx_position__always__expected) +BOOST_AUTO_TEST_CASE(query_chain_reader__get_tx_position__always__expected) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK(!store.create(events_handler)); + BOOST_CHECK(!store.create(test::events_handler)); BOOST_CHECK(query.initialize(test::genesis)); BOOST_CHECK(query.set(test::block1a, context{ 0, 1, 0 }, false, false)); BOOST_CHECK(query.set(test::block2a, context{ 0, 2, 0 }, false, false)); @@ -475,13 +472,13 @@ BOOST_AUTO_TEST_CASE(query_archive_read__get_tx_position__always__expected) } -BOOST_AUTO_TEST_CASE(query_archive_read__get_position_tx__always__expected) +BOOST_AUTO_TEST_CASE(query_chain_reader__get_position_tx__always__expected) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK(!store.create(events_handler)); + BOOST_CHECK(!store.create(test::events_handler)); BOOST_CHECK(query.initialize(test::genesis)); BOOST_CHECK(query.set(test::block1a, context{ 0, 1, 0 }, false, false)); BOOST_CHECK(query.set(test::block2a, context{ 0, 2, 0 }, false, false)); @@ -496,13 +493,13 @@ BOOST_AUTO_TEST_CASE(query_archive_read__get_position_tx__always__expected) BOOST_CHECK(query.get_position_tx({}, 0).is_terminal()); } -BOOST_AUTO_TEST_CASE(query_archive_read__get_tx_sizes__coinbase__204) +BOOST_AUTO_TEST_CASE(query_chain_reader__get_tx_sizes__coinbase__204) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK(!store.create(events_handler)); + BOOST_CHECK(!store.create(test::events_handler)); BOOST_CHECK(query.initialize(test::genesis)); size_t light{}; @@ -512,52 +509,52 @@ BOOST_AUTO_TEST_CASE(query_archive_read__get_tx_sizes__coinbase__204) BOOST_CHECK_EQUAL(heavy, 204u); } -BOOST_AUTO_TEST_CASE(query_archive_read__get_tx_count__coinbase__1) +BOOST_AUTO_TEST_CASE(query_chain_reader__get_tx_count__coinbase__1) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK(!store.create(events_handler)); + BOOST_CHECK(!store.create(test::events_handler)); BOOST_CHECK(query.initialize(test::genesis)); BOOST_CHECK_EQUAL(query.get_tx_count(0), 1u); } -BOOST_AUTO_TEST_CASE(query_archive_read__get_witness__not_found__nullptr) +BOOST_AUTO_TEST_CASE(query_chain_reader__get_witness__not_found__nullptr) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK(!store.create(events_handler)); + BOOST_CHECK(!store.create(test::events_handler)); BOOST_CHECK(!query.get_witness(query.to_point({}, {}))); - BOOST_CHECK(!store.close(events_handler)); + BOOST_CHECK(!store.close(test::events_handler)); } -BOOST_AUTO_TEST_CASE(query_archive_read__get_input_script__not_found__nullptr) +BOOST_AUTO_TEST_CASE(query_chain_reader__get_input_script__not_found__nullptr) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK(!store.create(events_handler)); + BOOST_CHECK(!store.create(test::events_handler)); BOOST_CHECK(!query.get_input_script(query.to_point(tx_link{}, {}))); - BOOST_CHECK(!store.close(events_handler)); + BOOST_CHECK(!store.close(test::events_handler)); } -BOOST_AUTO_TEST_CASE(query_archive_read__get_input__not_found__nullptr) +BOOST_AUTO_TEST_CASE(query_chain_reader__get_input__not_found__nullptr) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK(!store.create(events_handler)); + BOOST_CHECK(!store.create(test::events_handler)); BOOST_CHECK(!query.get_input(query.to_point(tx_link{}, {}), false)); BOOST_CHECK(!query.get_input(query.to_tx(system::null_hash), {}, false)); - BOOST_CHECK(!store.close(events_handler)); + BOOST_CHECK(!store.close(test::events_handler)); } -BOOST_AUTO_TEST_CASE(query_archive_read__get_input__genesis__expected) +BOOST_AUTO_TEST_CASE(query_chain_reader__get_input__genesis__expected) { settings settings{}; settings.header_buckets = 8; @@ -566,7 +563,7 @@ BOOST_AUTO_TEST_CASE(query_archive_read__get_input__genesis__expected) settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK(!store.create(events_handler)); + BOOST_CHECK(!store.create(test::events_handler)); BOOST_CHECK(query.set(test::genesis, test::context, false, false)); const auto tx = test::genesis.transactions_ptr()->front(); @@ -577,55 +574,55 @@ BOOST_AUTO_TEST_CASE(query_archive_read__get_input__genesis__expected) BOOST_CHECK(input->script() == *query.get_input_script(point)); } -BOOST_AUTO_TEST_CASE(query_archive_read__get_inputs__tx_not_found__nullptr) +BOOST_AUTO_TEST_CASE(query_chain_reader__get_inputs__tx_not_found__nullptr) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK(!store.create(events_handler)); + BOOST_CHECK(!store.create(test::events_handler)); BOOST_CHECK(query.initialize(test::genesis)); BOOST_CHECK(!query.get_inputs(1, false)); } -BOOST_AUTO_TEST_CASE(query_archive_read__get_inputs__found__expected) +BOOST_AUTO_TEST_CASE(query_chain_reader__get_inputs__found__expected) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK(!store.create(events_handler)); + BOOST_CHECK(!store.create(test::events_handler)); BOOST_CHECK(query.initialize(test::genesis)); BOOST_CHECK(query.set(test::tx4)); BOOST_CHECK_EQUAL(query.get_inputs(1, false)->size(), 2u); } -BOOST_AUTO_TEST_CASE(query_archive_read__get_output_script__not_found__nullptr) +BOOST_AUTO_TEST_CASE(query_chain_reader__get_output_script__not_found__nullptr) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK(!store.create(events_handler)); + BOOST_CHECK(!store.create(test::events_handler)); BOOST_CHECK(!query.get_output_script(query.to_output(system::null_hash, 0u))); BOOST_CHECK(!query.get_output(0)); - BOOST_CHECK(!store.close(events_handler)); + BOOST_CHECK(!store.close(test::events_handler)); } -BOOST_AUTO_TEST_CASE(query_archive_read__get_output__not_found__nullptr) +BOOST_AUTO_TEST_CASE(query_chain_reader__get_output__not_found__nullptr) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK(!store.create(events_handler)); + BOOST_CHECK(!store.create(test::events_handler)); BOOST_CHECK(!query.get_output(query.to_tx(system::null_hash), 0u)); BOOST_CHECK(!query.get_output(query.to_output(system::null_hash, 0u))); BOOST_CHECK(!query.get_output(0)); - BOOST_CHECK(!store.close(events_handler)); + BOOST_CHECK(!store.close(test::events_handler)); } -BOOST_AUTO_TEST_CASE(query_archive_read__get_output__genesis__expected) +BOOST_AUTO_TEST_CASE(query_chain_reader__get_output__genesis__expected) { settings settings{}; settings.header_buckets = 8; @@ -634,7 +631,7 @@ BOOST_AUTO_TEST_CASE(query_archive_read__get_output__genesis__expected) settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK(!store.create(events_handler)); + BOOST_CHECK(!store.create(test::events_handler)); BOOST_CHECK(query.set(test::genesis, test::context, false, false)); const auto tx = test::genesis.transactions_ptr()->front(); @@ -645,48 +642,48 @@ BOOST_AUTO_TEST_CASE(query_archive_read__get_output__genesis__expected) BOOST_CHECK(output->script() == *query.get_output_script(query.to_output(tx->hash(false), 0u))); } -BOOST_AUTO_TEST_CASE(query_archive_read__get_outputs__tx_not_found__nullptr) +BOOST_AUTO_TEST_CASE(query_chain_reader__get_outputs__tx_not_found__nullptr) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK(!store.create(events_handler)); + BOOST_CHECK(!store.create(test::events_handler)); BOOST_CHECK(query.initialize(test::genesis)); BOOST_CHECK(!query.get_outputs(1)); } -BOOST_AUTO_TEST_CASE(query_archive_read__get_outputs__found__expected) +BOOST_AUTO_TEST_CASE(query_chain_reader__get_outputs__found__expected) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK(!store.create(events_handler)); + BOOST_CHECK(!store.create(test::events_handler)); BOOST_CHECK(query.initialize(test::genesis)); BOOST_CHECK(query.set(test::tx4)); BOOST_CHECK_EQUAL(query.get_outputs(1)->size(), 1u); } -BOOST_AUTO_TEST_CASE(query_archive_read__get_transactions__tx_not_found__nullptr) +BOOST_AUTO_TEST_CASE(query_chain_reader__get_transactions__tx_not_found__nullptr) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK(!store.create(events_handler)); + BOOST_CHECK(!store.create(test::events_handler)); BOOST_CHECK(query.initialize(test::genesis)); BOOST_CHECK(query.set(test::tx4)); BOOST_CHECK(!query.get_transactions(3, false)); } -BOOST_AUTO_TEST_CASE(query_archive_read__get_transactions__found__expected) +BOOST_AUTO_TEST_CASE(query_chain_reader__get_transactions__found__expected) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK(!store.create(events_handler)); + BOOST_CHECK(!store.create(test::events_handler)); BOOST_CHECK(query.initialize(test::genesis)); BOOST_CHECK(query.set(test::block1a, test::context, false, false)); BOOST_CHECK(query.set(test::block2a, test::context, false, false)); @@ -696,13 +693,13 @@ BOOST_AUTO_TEST_CASE(query_archive_read__get_transactions__found__expected) BOOST_CHECK_EQUAL(query.get_transactions(2, false)->size(), 2u); } -BOOST_AUTO_TEST_CASE(query_archive_read__get_spenders__unspent_or_not_found__expected) +BOOST_AUTO_TEST_CASE(query_chain_reader__get_spenders__unspent_or_not_found__expected) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK(!store.create(events_handler)); + BOOST_CHECK(!store.create(test::events_handler)); BOOST_CHECK(query.initialize(test::genesis)); BOOST_CHECK(query.set(test::block1, test::context, false, false)); BOOST_CHECK(query.set(test::block2, test::context, false, false)); @@ -734,13 +731,13 @@ BOOST_AUTO_TEST_CASE(query_archive_read__get_spenders__unspent_or_not_found__exp ////BOOST_CHECK(query.get_spenders_index(3, 1, true)->empty()); } -////BOOST_AUTO_TEST_CASE(query_archive_read__get_spenders__found_and_spent__expected) +////BOOST_AUTO_TEST_CASE(query_chain_reader__get_spenders__found_and_spent__expected) ////{ //// settings settings{}; //// settings.path = TEST_DIRECTORY; //// test::chunk_store store{ settings }; //// test::query_accessor query{ store }; -//// BOOST_CHECK(!store.create(events_handler)); +//// BOOST_CHECK(!store.create(test::events_handler)); //// BOOST_CHECK(query.initialize(test::genesis)); //// //// // Neither of the two block1a outputs spent yet. @@ -790,13 +787,13 @@ BOOST_AUTO_TEST_CASE(query_archive_read__get_spenders__unspent_or_not_found__exp //// BOOST_CHECK(*query.get_spenders_index(1, 1, true)->back() == *(*block_inputs).back()); ////} -BOOST_AUTO_TEST_CASE(query_archive_read__get_value__genesis__expected) +BOOST_AUTO_TEST_CASE(query_chain_reader__get_value__genesis__expected) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK(!store.create(events_handler)); + BOOST_CHECK(!store.create(test::events_handler)); BOOST_CHECK(query.initialize(test::genesis)); uint64_t value{}; @@ -823,13 +820,13 @@ const auto& clean_(const auto& block_or_tx) NOEXCEPT } // First four blocks have only coinbase txs. -BOOST_AUTO_TEST_CASE(query_archive_read__populate_with_metadata__null_prevouts__true) +BOOST_AUTO_TEST_CASE(query_chain_reader__populate_with_metadata__null_prevouts__true) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK(!store.create(events_handler)); + BOOST_CHECK(!store.create(test::events_handler)); BOOST_CHECK(query.initialize(test::genesis)); BOOST_CHECK(query.set(test::block1, test::context, false, false)); BOOST_CHECK(query.set(test::block2, test::context, false, false)); @@ -846,13 +843,13 @@ BOOST_AUTO_TEST_CASE(query_archive_read__populate_with_metadata__null_prevouts__ BOOST_CHECK(query.populate_with_metadata(copy3)); } -BOOST_AUTO_TEST_CASE(query_archive_read__populate_with_metadata__partial_prevouts__false) +BOOST_AUTO_TEST_CASE(query_chain_reader__populate_with_metadata__partial_prevouts__false) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK(!store.create(events_handler)); + BOOST_CHECK(!store.create(test::events_handler)); BOOST_CHECK(query.initialize(test::genesis)); BOOST_CHECK(query.set(test::block1a, test::context, false, false)); BOOST_CHECK(query.set(test::block2a, test::context, false, false)); @@ -880,13 +877,13 @@ BOOST_AUTO_TEST_CASE(query_archive_read__populate_with_metadata__partial_prevout BOOST_CHECK(query.populate_with_metadata(*tx4.inputs_ptr()->at(1))); } -BOOST_AUTO_TEST_CASE(query_archive_read__populate_with_metadata__metadata__expected) +BOOST_AUTO_TEST_CASE(query_chain_reader__populate_with_metadata__metadata__expected) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK(!store.create(events_handler)); + BOOST_CHECK(!store.create(test::events_handler)); BOOST_CHECK(query.initialize(test::genesis)); BOOST_CHECK(query.set(test::block1a, test::context, false, false)); BOOST_CHECK(query.set(test::block2a, test::context, false, false)); @@ -932,13 +929,13 @@ BOOST_AUTO_TEST_CASE(query_archive_read__populate_with_metadata__metadata__expec // ---------------------------------------------------------------------------- // First four blocks have only coinbase txs. -BOOST_AUTO_TEST_CASE(query_archive_read__populate_without_metadata__null_prevouts__true) +BOOST_AUTO_TEST_CASE(query_chain_reader__populate_without_metadata__null_prevouts__true) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK(!store.create(events_handler)); + BOOST_CHECK(!store.create(test::events_handler)); BOOST_CHECK(query.initialize(test::genesis)); BOOST_CHECK(query.set(test::block1, test::context, false, false)); BOOST_CHECK(query.set(test::block2, test::context, false, false)); @@ -949,13 +946,13 @@ BOOST_AUTO_TEST_CASE(query_archive_read__populate_without_metadata__null_prevout BOOST_CHECK(query.populate_without_metadata(test::block3)); } -BOOST_AUTO_TEST_CASE(query_archive_read__populate_without_metadata__partial_prevouts__false) +BOOST_AUTO_TEST_CASE(query_chain_reader__populate_without_metadata__partial_prevouts__false) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK(!store.create(events_handler)); + BOOST_CHECK(!store.create(test::events_handler)); BOOST_CHECK(query.initialize(test::genesis)); BOOST_CHECK(query.set(test::block1a, test::context, false, false)); BOOST_CHECK(query.set(test::block2a, test::context, false, false)); diff --git a/test/query/archive_write.cpp b/test/query/archive/chain_writer.cpp similarity index 90% rename from test/query/archive_write.cpp rename to test/query/archive/chain_writer.cpp index 8c71c95f..11273b5b 100644 --- a/test/query/archive_write.cpp +++ b/test/query/archive/chain_writer.cpp @@ -16,20 +16,17 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -#include "../test.hpp" -#include "../mocks/blocks.hpp" -#include "../mocks/chunk_store.hpp" - -BOOST_FIXTURE_TEST_SUITE(query_archive_write_tests, test::directory_setup_fixture) +#include "../../test.hpp" +#include "../../mocks/blocks.hpp" +#include "../../mocks/chunk_store.hpp" // ensure context::flags is same size as chain_context::flags. -static_assert(is_same_type); +static_assert(is_same_type < database::context::flag_t::integer, decltype(system::chain::context{}.flags) > ); -// nop event handler. -const auto events_handler = [](auto, auto) {}; +BOOST_FIXTURE_TEST_SUITE(query_chain_writer_tests, test::directory_setup_fixture) // slow test (mmap) -BOOST_AUTO_TEST_CASE(query_archive_write__set_header__mmap_get_header__expected) +BOOST_AUTO_TEST_CASE(query_chain_writer__set_header__mmap_get_header__expected) { constexpr auto milestone = false; constexpr auto parent = system::null_hash; @@ -50,7 +47,7 @@ BOOST_AUTO_TEST_CASE(query_archive_write__set_header__mmap_get_header__expected) settings.path = TEST_DIRECTORY; store store{ settings }; query> query{ store }; - BOOST_CHECK(!store.create(events_handler)); + BOOST_CHECK(!store.create(test::events_handler)); BOOST_CHECK(query.set(header, test::context, milestone)); table::header::record element1{}; @@ -61,7 +58,7 @@ BOOST_AUTO_TEST_CASE(query_archive_write__set_header__mmap_get_header__expected) BOOST_CHECK(*pointer == header); // must open/close mmap - BOOST_CHECK(!store.close(events_handler)); + BOOST_CHECK(!store.close(test::events_handler)); BOOST_CHECK_EQUAL(element1.ctx.height, system::mask_left(test::context.height, byte_bits)); BOOST_CHECK_EQUAL(element1.ctx.flags, test::context.flags); BOOST_CHECK_EQUAL(element1.ctx.mtp, test::context.mtp); @@ -74,7 +71,7 @@ BOOST_AUTO_TEST_CASE(query_archive_write__set_header__mmap_get_header__expected) BOOST_CHECK_EQUAL(element1.nonce, header.nonce()); } -BOOST_AUTO_TEST_CASE(query_archive_write__set_link_header__is_header__expected) +BOOST_AUTO_TEST_CASE(query_chain_writer__set_link_header__is_header__expected) { constexpr auto milestone = true; constexpr auto merkle_root = system::base16_array("119192939495969798999a9b9c9d9e9f229192939495969798999a9b9c9d9e9f"); @@ -129,7 +126,7 @@ BOOST_AUTO_TEST_CASE(query_archive_write__set_link_header__is_header__expected) settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK(!store.create(events_handler)); + BOOST_CHECK(!store.create(test::events_handler)); // store open/close flushes record count to head. BOOST_CHECK(!query.is_header(header.hash())); @@ -140,7 +137,7 @@ BOOST_AUTO_TEST_CASE(query_archive_write__set_link_header__is_header__expected) BOOST_CHECK(!query.is_associated(0)); table::header::record element1{}; BOOST_CHECK(store.header.get(query.to_header(block_hash), element1)); - BOOST_CHECK(!store.close(events_handler)); + BOOST_CHECK(!store.close(test::events_handler)); BOOST_CHECK_EQUAL(store.header_head(), expected_header_head); BOOST_CHECK_EQUAL(store.header_body(), expected_header_body); @@ -156,7 +153,7 @@ BOOST_AUTO_TEST_CASE(query_archive_write__set_link_header__is_header__expected) BOOST_CHECK_EQUAL(element1.nonce, header.nonce()); } -BOOST_AUTO_TEST_CASE(query_archive_write__set_tx__empty__expected) +BOOST_AUTO_TEST_CASE(query_chain_writer__set_tx__empty__expected) { const system::chain::transaction tx{}; const auto expected_head5_array = system::base16_chunk("0000000000"); @@ -185,11 +182,11 @@ BOOST_AUTO_TEST_CASE(query_archive_write__set_tx__empty__expected) settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK(!store.create(events_handler)); + BOOST_CHECK(!store.create(test::events_handler)); // store open/close flushes record count to heads. BOOST_CHECK(!query.set(tx)); - BOOST_CHECK(!store.close(events_handler)); + BOOST_CHECK(!store.close(test::events_handler)); BOOST_CHECK_EQUAL(store.tx_head(), expected_head4_hash); BOOST_CHECK_EQUAL(store.input_head(), expected_head5_array); BOOST_CHECK_EQUAL(store.output_head(), expected_head5_array); @@ -201,7 +198,7 @@ BOOST_AUTO_TEST_CASE(query_archive_write__set_tx__empty__expected) BOOST_CHECK(store.outs_body().empty()); } -BOOST_AUTO_TEST_CASE(query_archive_write__set_link_tx__null_input__expected) +BOOST_AUTO_TEST_CASE(query_chain_writer__set_link_tx__null_input__expected) { using namespace system::chain; const transaction tx @@ -279,9 +276,9 @@ BOOST_AUTO_TEST_CASE(query_archive_write__set_link_tx__null_input__expected) settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK(!store.create(events_handler)); + BOOST_CHECK(!store.create(test::events_handler)); BOOST_CHECK(!query.set_code(tx)); - BOOST_CHECK(!store.close(events_handler)); + BOOST_CHECK(!store.close(test::events_handler)); BOOST_CHECK_EQUAL(store.tx_head(), expected_tx_head); BOOST_CHECK_EQUAL(store.input_head(), expected_input_head); @@ -297,7 +294,7 @@ BOOST_AUTO_TEST_CASE(query_archive_write__set_link_tx__null_input__expected) ////BOOST_CHECK_EQUAL(store.spend_body(), expected_spend_body); } -BOOST_AUTO_TEST_CASE(query_archive_write__set_tx__get_tx__expected) +BOOST_AUTO_TEST_CASE(query_chain_writer__set_tx__get_tx__expected) { using namespace system::chain; const transaction tx @@ -415,7 +412,7 @@ BOOST_AUTO_TEST_CASE(query_archive_write__set_tx__get_tx__expected) settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK(!store.create(events_handler)); + BOOST_CHECK(!store.create(test::events_handler)); BOOST_CHECK(!query.is_tx(tx.hash(false))); BOOST_CHECK(query.set(tx)); BOOST_CHECK(query.is_tx(tx.hash(false))); @@ -424,7 +421,7 @@ BOOST_AUTO_TEST_CASE(query_archive_write__set_tx__get_tx__expected) BOOST_CHECK(pointer); BOOST_CHECK(*pointer == tx); BOOST_CHECK_EQUAL(pointer->hash(false), tx_hash); - BOOST_CHECK(!store.close(events_handler)); + BOOST_CHECK(!store.close(test::events_handler)); BOOST_CHECK_EQUAL(store.tx_head(), expected_tx_head); BOOST_CHECK_EQUAL(store.input_head(), expected_input_head); @@ -440,7 +437,7 @@ BOOST_AUTO_TEST_CASE(query_archive_write__set_tx__get_tx__expected) ////BOOST_CHECK_EQUAL(store.spend_body(), expected_spend_body); } -BOOST_AUTO_TEST_CASE(query_archive_write__set_block__get_block__expected) +BOOST_AUTO_TEST_CASE(query_chain_writer__set_block__get_block__expected) { constexpr auto milestone = true; const auto genesis_header_head = system::base16_chunk( @@ -551,7 +548,7 @@ BOOST_AUTO_TEST_CASE(query_archive_write__set_block__get_block__expected) settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK(!store.create(events_handler)); + BOOST_CHECK(!store.create(test::events_handler)); // Set block (header/txs). BOOST_CHECK(!query.is_block(test::genesis.hash())); @@ -560,7 +557,7 @@ BOOST_AUTO_TEST_CASE(query_archive_write__set_block__get_block__expected) table::header::record element1{}; BOOST_CHECK(store.header.get(query.to_header(test::genesis.hash()), element1)); - BOOST_CHECK(!store.close(events_handler)); + BOOST_CHECK(!store.close(test::events_handler)); BOOST_CHECK_EQUAL(store.header_head(), genesis_header_head); BOOST_CHECK_EQUAL(store.tx_head(), genesis_tx_head); @@ -587,7 +584,7 @@ BOOST_AUTO_TEST_CASE(query_archive_write__set_block__get_block__expected) BOOST_CHECK_EQUAL(hashes, test::genesis.transaction_hashes(false)); } -BOOST_AUTO_TEST_CASE(query_archive_write__set_block_txs__get_block__expected) +BOOST_AUTO_TEST_CASE(query_chain_writer__set_block_txs__get_block__expected) { constexpr auto milestone = true; const auto genesis_header_head = system::base16_chunk( @@ -699,7 +696,7 @@ BOOST_AUTO_TEST_CASE(query_archive_write__set_block_txs__get_block__expected) settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK(!store.create(events_handler)); + BOOST_CHECK(!store.create(test::events_handler)); // Set header and then txs. BOOST_CHECK(!query.is_block(test::genesis.hash())); @@ -711,7 +708,7 @@ BOOST_AUTO_TEST_CASE(query_archive_write__set_block_txs__get_block__expected) table::header::record element1{}; BOOST_CHECK(store.header.get(query.to_header(test::genesis.hash()), element1)); - BOOST_CHECK(!store.close(events_handler)); + BOOST_CHECK(!store.close(test::events_handler)); BOOST_CHECK_EQUAL(store.header_head(), genesis_header_head); BOOST_CHECK_EQUAL(store.tx_head(), genesis_tx_head); @@ -757,13 +754,13 @@ const auto& clean_(const auto& block_or_tx) NOEXCEPT } // First four blocks have only coinbase txs. -BOOST_AUTO_TEST_CASE(query_archive_write__populate_with_metadata__null_prevouts__true) +BOOST_AUTO_TEST_CASE(query_chain_writer__populate_with_metadata__null_prevouts__true) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK(!store.create(events_handler)); + BOOST_CHECK(!store.create(test::events_handler)); BOOST_CHECK(query.initialize(test::genesis)); BOOST_CHECK(query.set(test::block1, test::context, false, false)); BOOST_CHECK(query.set(test::block2, test::context, false, false)); @@ -780,13 +777,13 @@ BOOST_AUTO_TEST_CASE(query_archive_write__populate_with_metadata__null_prevouts_ BOOST_CHECK(query.populate_with_metadata(copy3)); } -BOOST_AUTO_TEST_CASE(query_archive_write__populate_with_metadata__partial_prevouts__false) +BOOST_AUTO_TEST_CASE(query_chain_writer__populate_with_metadata__partial_prevouts__false) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK(!store.create(events_handler)); + BOOST_CHECK(!store.create(test::events_handler)); BOOST_CHECK(query.initialize(test::genesis)); BOOST_CHECK(query.set(test::block1a, test::context, false, false)); BOOST_CHECK(query.set(test::block2a, test::context, false, false)); @@ -814,13 +811,13 @@ BOOST_AUTO_TEST_CASE(query_archive_write__populate_with_metadata__partial_prevou BOOST_CHECK(query.populate_with_metadata(*tx4.inputs_ptr()->at(1))); } -BOOST_AUTO_TEST_CASE(query_archive_write__populate_with_metadata__metadata__expected) +BOOST_AUTO_TEST_CASE(query_chain_writer__populate_with_metadata__metadata__expected) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK(!store.create(events_handler)); + BOOST_CHECK(!store.create(test::events_handler)); BOOST_CHECK(query.initialize(test::genesis)); BOOST_CHECK(query.set(test::block1a, test::context, false, false)); BOOST_CHECK(query.set(test::block2a, test::context, false, false)); @@ -866,13 +863,13 @@ BOOST_AUTO_TEST_CASE(query_archive_write__populate_with_metadata__metadata__expe // ---------------------------------------------------------------------------- // First four blocks have only coinbase txs. -BOOST_AUTO_TEST_CASE(query_archive_write__populate_without_metadata__null_prevouts__true) +BOOST_AUTO_TEST_CASE(query_chain_writer__populate_without_metadata__null_prevouts__true) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK(!store.create(events_handler)); + BOOST_CHECK(!store.create(test::events_handler)); BOOST_CHECK(query.initialize(test::genesis)); BOOST_CHECK(query.set(test::block1, test::context, false, false)); BOOST_CHECK(query.set(test::block2, test::context, false, false)); @@ -883,13 +880,13 @@ BOOST_AUTO_TEST_CASE(query_archive_write__populate_without_metadata__null_prevou BOOST_CHECK(query.populate_without_metadata(test::block3)); } -BOOST_AUTO_TEST_CASE(query_archive_write__populate_without_metadata__partial_prevouts__false) +BOOST_AUTO_TEST_CASE(query_chain_writer__populate_without_metadata__partial_prevouts__false) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK(!store.create(events_handler)); + BOOST_CHECK(!store.create(test::events_handler)); BOOST_CHECK(query.initialize(test::genesis)); BOOST_CHECK(query.set(test::block1a, test::context, false, false)); BOOST_CHECK(query.set(test::block2a, test::context, false, false)); @@ -917,13 +914,13 @@ BOOST_AUTO_TEST_CASE(query_archive_write__populate_without_metadata__partial_pre // archive_write (foreign-keyed) -BOOST_AUTO_TEST_CASE(query_archive_write__is_coinbase__coinbase__true) +BOOST_AUTO_TEST_CASE(query_chain_writer__is_coinbase__coinbase__true) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK(!store.create(events_handler)); + BOOST_CHECK(!store.create(test::events_handler)); BOOST_CHECK(query.initialize(test::genesis)); BOOST_CHECK(query.set(test::block1, context{}, false, false)); BOOST_CHECK(query.set(test::block2, context{}, false, false)); @@ -934,13 +931,13 @@ BOOST_AUTO_TEST_CASE(query_archive_write__is_coinbase__coinbase__true) BOOST_CHECK(query.is_coinbase(3)); } -BOOST_AUTO_TEST_CASE(query_archive_write__is_coinbase__non_coinbase__false) +BOOST_AUTO_TEST_CASE(query_chain_writer__is_coinbase__non_coinbase__false) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK(!store.create(events_handler)); + BOOST_CHECK(!store.create(test::events_handler)); BOOST_CHECK(query.initialize(test::genesis)); BOOST_CHECK(query.set(test::block1a, context{}, false, false)); BOOST_CHECK(query.set(test::block2a, context{}, false, false)); @@ -952,25 +949,25 @@ BOOST_AUTO_TEST_CASE(query_archive_write__is_coinbase__non_coinbase__false) BOOST_CHECK(!query.is_coinbase(42)); } -BOOST_AUTO_TEST_CASE(query_archive_write__is_milestone__genesis__false) +BOOST_AUTO_TEST_CASE(query_chain_writer__is_milestone__genesis__false) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK_EQUAL(store.create(events_handler), error::success); + BOOST_CHECK_EQUAL(store.create(test::events_handler), error::success); BOOST_CHECK(query.initialize(test::genesis)); BOOST_CHECK(!query.is_milestone(0)); BOOST_CHECK(!query.is_milestone(1)); } -BOOST_AUTO_TEST_CASE(query_archive_write__is_milestone__set__expected) +BOOST_AUTO_TEST_CASE(query_chain_writer__is_milestone__set__expected) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK_EQUAL(store.create(events_handler), error::success); + BOOST_CHECK_EQUAL(store.create(test::events_handler), error::success); BOOST_CHECK(query.initialize(test::genesis)); BOOST_CHECK(query.set(test::block1, context{}, true, false)); BOOST_CHECK(query.set(test::block2, context{}, false, false));; @@ -979,7 +976,7 @@ BOOST_AUTO_TEST_CASE(query_archive_write__is_milestone__set__expected) BOOST_CHECK(!query.is_milestone(2)); } -BOOST_AUTO_TEST_CASE(query_archive_write__get_header__invalid_parent__expected) +BOOST_AUTO_TEST_CASE(query_chain_writer__get_header__invalid_parent__expected) { constexpr auto root = system::base16_array("119192939495969798999a9b9c9d9e9f229192939495969798999a9b9c9d9e9f"); constexpr auto block_hash = system::base16_array("85d0b02a16f6d645aa865fad4a8666f5e7bb2b0c4392a5d675496d6c3defa1f2"); @@ -1022,7 +1019,7 @@ BOOST_AUTO_TEST_CASE(query_archive_write__get_header__invalid_parent__expected) settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK(!store.create(events_handler)); + BOOST_CHECK(!store.create(test::events_handler)); store.header_head() = expected_header_head; store.header_body() = expected_header_body; @@ -1030,7 +1027,7 @@ BOOST_AUTO_TEST_CASE(query_archive_write__get_header__invalid_parent__expected) BOOST_CHECK(!query.get_header(header_link::terminal)); } -BOOST_AUTO_TEST_CASE(query_archive_write__get_header__default__expected) +BOOST_AUTO_TEST_CASE(query_chain_writer__get_header__default__expected) { constexpr auto root = system::base16_array("119192939495969798999a9b9c9d9e9f229192939495969798999a9b9c9d9e9f"); constexpr auto block_hash = system::base16_array("85d0b02a16f6d645aa865fad4a8666f5e7bb2b0c4392a5d675496d6c3defa1f2"); @@ -1084,7 +1081,7 @@ BOOST_AUTO_TEST_CASE(query_archive_write__get_header__default__expected) settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK(!store.create(events_handler)); + BOOST_CHECK(!store.create(test::events_handler)); ////store.header_head() = expected_header_head; ////store.header_body() = expected_header_body; @@ -1101,36 +1098,36 @@ BOOST_AUTO_TEST_CASE(query_archive_write__get_header__default__expected) BOOST_CHECK_EQUAL(pointer1->hash(), block_hash); } -BOOST_AUTO_TEST_CASE(query_archive_write__get_tx_keys__not_found__empty) +BOOST_AUTO_TEST_CASE(query_chain_writer__get_tx_keys__not_found__empty) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK(!store.create(events_handler)); + BOOST_CHECK(!store.create(test::events_handler)); BOOST_CHECK(query.get_tx_keys(query.to_header(system::null_hash)).empty()); - BOOST_CHECK(!store.close(events_handler)); + BOOST_CHECK(!store.close(test::events_handler)); } -BOOST_AUTO_TEST_CASE(query_archive_write__get_header_key__always__expected) +BOOST_AUTO_TEST_CASE(query_chain_writer__get_header_key__always__expected) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK(!store.create(events_handler)); + BOOST_CHECK(!store.create(test::events_handler)); BOOST_CHECK(query.initialize(test::genesis)); BOOST_CHECK_EQUAL(query.get_header_key(0), test::genesis.hash()); BOOST_CHECK_EQUAL(query.get_header_key(1), system::null_hash); } -BOOST_AUTO_TEST_CASE(query_archive_write__get_point_key__always__expected) +BOOST_AUTO_TEST_CASE(query_chain_writer__get_point_key__always__expected) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK(!store.create(events_handler)); + BOOST_CHECK(!store.create(test::events_handler)); BOOST_CHECK(query.initialize(test::genesis)); BOOST_CHECK_EQUAL(query.get_point_hash(0), system::null_hash); @@ -1150,13 +1147,13 @@ BOOST_AUTO_TEST_CASE(query_archive_write__get_point_key__always__expected) ////BOOST_CHECK_EQUAL(query.get_point_hash(6), system::null_hash); } -BOOST_AUTO_TEST_CASE(query_archive_write__get_tx_key__always__expected) +BOOST_AUTO_TEST_CASE(query_chain_writer__get_tx_key__always__expected) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK(!store.create(events_handler)); + BOOST_CHECK(!store.create(test::events_handler)); BOOST_CHECK(query.initialize(test::genesis)); BOOST_CHECK_EQUAL(query.get_tx_key(0), test::genesis.transactions_ptr()->front()->hash(false)); BOOST_CHECK_EQUAL(query.get_tx_key(1), system::null_hash); @@ -1167,13 +1164,13 @@ BOOST_AUTO_TEST_CASE(query_archive_write__get_tx_key__always__expected) BOOST_CHECK_EQUAL(query.get_tx_key(3), system::null_hash); } -BOOST_AUTO_TEST_CASE(query_archive_write__get_height1__always__expected) +BOOST_AUTO_TEST_CASE(query_chain_writer__get_height1__always__expected) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK(!store.create(events_handler)); + BOOST_CHECK(!store.create(test::events_handler)); BOOST_CHECK(query.initialize(test::genesis)); BOOST_CHECK(query.set(test::block1, context{ 0, 1, 0 }, false, false)); BOOST_CHECK(query.set(test::block2, context{ 0, 2, 0 }, false, false)); @@ -1197,13 +1194,13 @@ BOOST_AUTO_TEST_CASE(query_archive_write__get_height1__always__expected) BOOST_CHECK(!query.get_height(out, 6)); } -BOOST_AUTO_TEST_CASE(query_archive_write__get_height2__always__expected) +BOOST_AUTO_TEST_CASE(query_chain_writer__get_height2__always__expected) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK(!store.create(events_handler)); + BOOST_CHECK(!store.create(test::events_handler)); BOOST_CHECK(query.initialize(test::genesis)); BOOST_CHECK(query.set(test::block1, context{ 0, 1, 0 }, false, false)); BOOST_CHECK(query.set(test::block2, context{ 0, 2, 0 }, false, false)); @@ -1227,13 +1224,13 @@ BOOST_AUTO_TEST_CASE(query_archive_write__get_height2__always__expected) BOOST_CHECK(!query.get_height(out, system::one_hash)); } -BOOST_AUTO_TEST_CASE(query_archive_write__get_tx_height__not_strong__false) +BOOST_AUTO_TEST_CASE(query_chain_writer__get_tx_height__not_strong__false) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK(!store.create(events_handler)); + BOOST_CHECK(!store.create(test::events_handler)); BOOST_CHECK(query.initialize(test::genesis)); BOOST_CHECK(query.set(test::tx4)); @@ -1241,13 +1238,13 @@ BOOST_AUTO_TEST_CASE(query_archive_write__get_tx_height__not_strong__false) BOOST_CHECK(!query.get_tx_height(out, 1)); } -BOOST_AUTO_TEST_CASE(query_archive_write__get_tx_position__confirmed__expected) +BOOST_AUTO_TEST_CASE(query_chain_writer__get_tx_position__confirmed__expected) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK(!store.create(events_handler)); + BOOST_CHECK(!store.create(test::events_handler)); BOOST_CHECK(query.initialize(test::genesis)); BOOST_CHECK(query.set(test::block1a, context{ 0, 1, 0 }, false, false)); BOOST_CHECK(query.set(test::block2a, context{ 0, 2, 0 }, false, false)); @@ -1280,13 +1277,13 @@ BOOST_AUTO_TEST_CASE(query_archive_write__get_tx_position__confirmed__expected) BOOST_CHECK(!query.get_tx_position(out, 5)); } -BOOST_AUTO_TEST_CASE(query_archive_write__get_tx_position__always__expected) +BOOST_AUTO_TEST_CASE(query_chain_writer__get_tx_position__always__expected) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK(!store.create(events_handler)); + BOOST_CHECK(!store.create(test::events_handler)); BOOST_CHECK(query.initialize(test::genesis)); BOOST_CHECK(query.set(test::block1a, context{ 0, 1, 0 }, false, false)); BOOST_CHECK(query.set(test::block2a, context{ 0, 2, 0 }, false, false)); @@ -1321,13 +1318,13 @@ BOOST_AUTO_TEST_CASE(query_archive_write__get_tx_position__always__expected) BOOST_CHECK(!query.get_tx_position(out, 5)); } -BOOST_AUTO_TEST_CASE(query_archive_write__get_tx_sizes__coinbase__204) +BOOST_AUTO_TEST_CASE(query_chain_writer__get_tx_sizes__coinbase__204) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK(!store.create(events_handler)); + BOOST_CHECK(!store.create(test::events_handler)); BOOST_CHECK(query.initialize(test::genesis)); size_t light{}; @@ -1337,29 +1334,29 @@ BOOST_AUTO_TEST_CASE(query_archive_write__get_tx_sizes__coinbase__204) BOOST_CHECK_EQUAL(heavy, 204u); } -BOOST_AUTO_TEST_CASE(query_archive_write__get_tx_count__coinbase__1) +BOOST_AUTO_TEST_CASE(query_chain_writer__get_tx_count__coinbase__1) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK(!store.create(events_handler)); + BOOST_CHECK(!store.create(test::events_handler)); BOOST_CHECK(query.initialize(test::genesis)); BOOST_CHECK_EQUAL(query.get_tx_count(0), 1u); } -BOOST_AUTO_TEST_CASE(query_archive_write__get_input__not_found__nullptr) +BOOST_AUTO_TEST_CASE(query_chain_writer__get_input__not_found__nullptr) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK(!store.create(events_handler)); + BOOST_CHECK(!store.create(test::events_handler)); BOOST_CHECK(!query.get_input(query.to_tx(system::null_hash), 0u, false)); - BOOST_CHECK(!store.close(events_handler)); + BOOST_CHECK(!store.close(test::events_handler)); } -BOOST_AUTO_TEST_CASE(query_archive_write__get_input__genesis__expected) +BOOST_AUTO_TEST_CASE(query_chain_writer__get_input__genesis__expected) { settings settings{}; settings.header_buckets = 8; @@ -1368,7 +1365,7 @@ BOOST_AUTO_TEST_CASE(query_archive_write__get_input__genesis__expected) settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK(!store.create(events_handler)); + BOOST_CHECK(!store.create(test::events_handler)); BOOST_CHECK(query.set(test::genesis, test::context, false, false)); const auto tx = test::genesis.transactions_ptr()->front(); @@ -1377,43 +1374,43 @@ BOOST_AUTO_TEST_CASE(query_archive_write__get_input__genesis__expected) ////BOOST_CHECK(*input == *query.get_input(0)); } -BOOST_AUTO_TEST_CASE(query_archive_write__get_inputs__tx_not_found__nullptr) +BOOST_AUTO_TEST_CASE(query_chain_writer__get_inputs__tx_not_found__nullptr) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK(!store.create(events_handler)); + BOOST_CHECK(!store.create(test::events_handler)); BOOST_CHECK(query.initialize(test::genesis)); BOOST_CHECK(!query.get_inputs(1, false)); } -BOOST_AUTO_TEST_CASE(query_archive_write__get_inputs__found__expected) +BOOST_AUTO_TEST_CASE(query_chain_writer__get_inputs__found__expected) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK(!store.create(events_handler)); + BOOST_CHECK(!store.create(test::events_handler)); BOOST_CHECK(query.initialize(test::genesis)); BOOST_CHECK(query.set(test::tx4)); BOOST_CHECK_EQUAL(query.get_inputs(1, false)->size(), 2u); } -BOOST_AUTO_TEST_CASE(query_archive_write__get_output__not_found__nullptr) +BOOST_AUTO_TEST_CASE(query_chain_writer__get_output__not_found__nullptr) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK(!store.create(events_handler)); + BOOST_CHECK(!store.create(test::events_handler)); BOOST_CHECK(!query.get_output(query.to_tx(system::null_hash), 0u)); BOOST_CHECK(!query.get_output(query.to_output(system::chain::point{ system::null_hash, 0u }))); BOOST_CHECK(!query.get_output(0)); - BOOST_CHECK(!store.close(events_handler)); + BOOST_CHECK(!store.close(test::events_handler)); } -BOOST_AUTO_TEST_CASE(query_archive_write__get_output__genesis__expected) +BOOST_AUTO_TEST_CASE(query_chain_writer__get_output__genesis__expected) { settings settings{}; settings.header_buckets = 8; @@ -1422,7 +1419,7 @@ BOOST_AUTO_TEST_CASE(query_archive_write__get_output__genesis__expected) settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK(!store.create(events_handler)); + BOOST_CHECK(!store.create(test::events_handler)); BOOST_CHECK(query.set(test::genesis, test::context, false, false)); const auto tx = test::genesis.transactions_ptr()->front(); @@ -1432,48 +1429,48 @@ BOOST_AUTO_TEST_CASE(query_archive_write__get_output__genesis__expected) BOOST_CHECK(*output1 == *query.get_output(0)); } -BOOST_AUTO_TEST_CASE(query_archive_write__get_outputs__tx_not_found__nullptr) +BOOST_AUTO_TEST_CASE(query_chain_writer__get_outputs__tx_not_found__nullptr) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK(!store.create(events_handler)); + BOOST_CHECK(!store.create(test::events_handler)); BOOST_CHECK(query.initialize(test::genesis)); BOOST_CHECK(!query.get_outputs(1)); } -BOOST_AUTO_TEST_CASE(query_archive_write__get_outputs__found__expected) +BOOST_AUTO_TEST_CASE(query_chain_writer__get_outputs__found__expected) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK(!store.create(events_handler)); + BOOST_CHECK(!store.create(test::events_handler)); BOOST_CHECK(query.initialize(test::genesis)); BOOST_CHECK(query.set(test::tx4)); BOOST_CHECK_EQUAL(query.get_outputs(1)->size(), 1u); } -BOOST_AUTO_TEST_CASE(query_archive_write__get_transactions__tx_not_found__nullptr) +BOOST_AUTO_TEST_CASE(query_chain_writer__get_transactions__tx_not_found__nullptr) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK(!store.create(events_handler)); + BOOST_CHECK(!store.create(test::events_handler)); BOOST_CHECK(query.initialize(test::genesis)); BOOST_CHECK(query.set(test::tx4)); BOOST_CHECK(!query.get_transactions(3, false)); } -BOOST_AUTO_TEST_CASE(query_archive_write__get_transactions__found__expected) +BOOST_AUTO_TEST_CASE(query_chain_writer__get_transactions__found__expected) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK(!store.create(events_handler)); + BOOST_CHECK(!store.create(test::events_handler)); BOOST_CHECK(query.initialize(test::genesis)); BOOST_CHECK(query.set(test::block1a, test::context, false, false)); BOOST_CHECK(query.set(test::block2a, test::context, false, false)); @@ -1483,13 +1480,13 @@ BOOST_AUTO_TEST_CASE(query_archive_write__get_transactions__found__expected) BOOST_CHECK_EQUAL(query.get_transactions(2, false)->size(), 2u); } -BOOST_AUTO_TEST_CASE(query_archive_write__get_spenders__unspent_or_not_found__expected) +BOOST_AUTO_TEST_CASE(query_chain_writer__get_spenders__unspent_or_not_found__expected) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK(!store.create(events_handler)); + BOOST_CHECK(!store.create(test::events_handler)); BOOST_CHECK(query.initialize(test::genesis)); BOOST_CHECK(query.set(test::block1, test::context, false, false)); BOOST_CHECK(query.set(test::block2, test::context, false, false)); @@ -1521,13 +1518,13 @@ BOOST_AUTO_TEST_CASE(query_archive_write__get_spenders__unspent_or_not_found__ex ////BOOST_CHECK(query.get_spenders_index(3, 1, true)->empty()); } -////BOOST_AUTO_TEST_CASE(query_archive_write__get_spenders__found_and_spent__expected) +////BOOST_AUTO_TEST_CASE(query_chain_writer__get_spenders__found_and_spent__expected) ////{ //// settings settings{}; //// settings.path = TEST_DIRECTORY; //// test::chunk_store store{ settings }; //// test::query_accessor query{ store }; -//// BOOST_CHECK(!store.create(events_handler)); +//// BOOST_CHECK(!store.create(test::events_handler)); //// BOOST_CHECK(query.initialize(test::genesis)); //// //// // Neither of the two block1a outputs spent yet. @@ -1577,13 +1574,13 @@ BOOST_AUTO_TEST_CASE(query_archive_write__get_spenders__unspent_or_not_found__ex //// BOOST_CHECK(*query.get_spenders_index(1, 1, true)->back() == *(*block_inputs).back()); ////} -BOOST_AUTO_TEST_CASE(query_archive_write__get_value__genesis__expected) +BOOST_AUTO_TEST_CASE(query_chain_writer__get_value__genesis__expected) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK(!store.create(events_handler)); + BOOST_CHECK(!store.create(test::events_handler)); BOOST_CHECK(query.initialize(test::genesis)); uint64_t value{}; diff --git a/test/query/wire.cpp b/test/query/archive/wire_reader.cpp similarity index 87% rename from test/query/wire.cpp rename to test/query/archive/wire_reader.cpp index c105454d..d5408fbe 100644 --- a/test/query/wire.cpp +++ b/test/query/archive/wire_reader.cpp @@ -16,15 +16,15 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -#include "../test.hpp" -#include "../mocks/blocks.hpp" -#include "../mocks/chunk_store.hpp" +#include "../../test.hpp" +#include "../../mocks/blocks.hpp" +#include "../../mocks/chunk_store.hpp" -BOOST_FIXTURE_TEST_SUITE(query_wire_tests, test::directory_setup_fixture) +BOOST_FIXTURE_TEST_SUITE(query_wire_reader_reader_tests, test::directory_setup_fixture) // get_wire_header -BOOST_AUTO_TEST_CASE(query_wire__get_wire_header__genesis_and_not__expected) +BOOST_AUTO_TEST_CASE(query_wire_reader__get_wire_header__genesis_and_not__expected) { using namespace system; database::settings settings{}; @@ -41,7 +41,7 @@ BOOST_AUTO_TEST_CASE(query_wire__get_wire_header__genesis_and_not__expected) // get_wire_tx -BOOST_AUTO_TEST_CASE(query_wire__get_wire_tx__genesis_and_not__expected) +BOOST_AUTO_TEST_CASE(query_wire_reader__get_wire_tx__genesis_and_not__expected) { using namespace system; database::settings settings{}; @@ -56,7 +56,7 @@ BOOST_AUTO_TEST_CASE(query_wire__get_wire_tx__genesis_and_not__expected) BOOST_CHECK(!store.close(test::events_handler)); } -BOOST_AUTO_TEST_CASE(query_wire__get_wire_tx__witness_true__expected) +BOOST_AUTO_TEST_CASE(query_wire_reader__get_wire_tx__witness_true__expected) { using namespace system; database::settings settings{}; @@ -72,7 +72,7 @@ BOOST_AUTO_TEST_CASE(query_wire__get_wire_tx__witness_true__expected) BOOST_CHECK(!store.close(test::events_handler)); } -BOOST_AUTO_TEST_CASE(query_wire__get_wire_tx__witness_false__expected) +BOOST_AUTO_TEST_CASE(query_wire_reader__get_wire_tx__witness_false__expected) { using namespace system; database::settings settings{}; @@ -90,7 +90,7 @@ BOOST_AUTO_TEST_CASE(query_wire__get_wire_tx__witness_false__expected) // get_wire_block -BOOST_AUTO_TEST_CASE(query_wire__get_wire_block__genesis_and_not__expected) +BOOST_AUTO_TEST_CASE(query_wire_reader__get_wire_block__genesis_and_not__expected) { using namespace system; database::settings settings{}; @@ -104,7 +104,7 @@ BOOST_AUTO_TEST_CASE(query_wire__get_wire_block__genesis_and_not__expected) BOOST_CHECK(!store.close(test::events_handler)); } -BOOST_AUTO_TEST_CASE(query_wire__get_wire_block__witness_true__expected) +BOOST_AUTO_TEST_CASE(query_wire_reader__get_wire_block__witness_true__expected) { using namespace system; database::settings settings{}; @@ -118,7 +118,7 @@ BOOST_AUTO_TEST_CASE(query_wire__get_wire_block__witness_true__expected) BOOST_CHECK(!store.close(test::events_handler)); } -BOOST_AUTO_TEST_CASE(query_wire__get_wire_block__witness_false__expected) +BOOST_AUTO_TEST_CASE(query_wire_reader__get_wire_block__witness_false__expected) { using namespace system; database::settings settings{}; diff --git a/test/query/archive/wire_writer.cpp b/test/query/archive/wire_writer.cpp new file mode 100644 index 00000000..6491f83a --- /dev/null +++ b/test/query/archive/wire_writer.cpp @@ -0,0 +1,25 @@ +/** + * Copyright (c) 2011-2026 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +#include "../../test.hpp" +#include "../../mocks/blocks.hpp" +#include "../../mocks/chunk_store.hpp" + +BOOST_FIXTURE_TEST_SUITE(query_wire_writer_writer_tests, test::directory_setup_fixture) + +BOOST_AUTO_TEST_SUITE_END() diff --git a/test/query/confirm.cpp b/test/query/confirmed.cpp similarity index 83% rename from test/query/confirm.cpp rename to test/query/confirmed.cpp index a69a3e5a..35d59376 100644 --- a/test/query/confirm.cpp +++ b/test/query/confirmed.cpp @@ -20,18 +20,15 @@ #include "../mocks/blocks.hpp" #include "../mocks/chunk_store.hpp" -BOOST_FIXTURE_TEST_SUITE(query_confirm_tests, test::directory_setup_fixture) +BOOST_FIXTURE_TEST_SUITE(query_confirmed_tests, test::directory_setup_fixture) -// nop event handler. -const auto events_handler = [](auto, auto) {}; - -BOOST_AUTO_TEST_CASE(query_confirm__is_candidate_block__push_pop_candidate__expected) +BOOST_AUTO_TEST_CASE(query_confirmed__is_candidate_block__push_pop_candidate__expected) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE(query.set(test::block1, context{ 0, 1, 0 }, false, false)); BOOST_REQUIRE(query.set(test::block2, context{ 0, 2, 0 }, false, false)); @@ -59,13 +56,13 @@ BOOST_AUTO_TEST_CASE(query_confirm__is_candidate_block__push_pop_candidate__expe BOOST_REQUIRE(!query.is_candidate_header(database::header_link::terminal)); } -BOOST_AUTO_TEST_CASE(query_confirm__is_confirmed_block__push_pop_confirmed__expected) +BOOST_AUTO_TEST_CASE(query_confirmed__is_confirmed_block__push_pop_confirmed__expected) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE(query.set(test::block1, context{ 0, 1, 0 }, false, false)); BOOST_REQUIRE(query.set(test::block2, context{ 0, 2, 0 }, false, false)); @@ -90,13 +87,13 @@ BOOST_AUTO_TEST_CASE(query_confirm__is_confirmed_block__push_pop_confirmed__expe BOOST_REQUIRE(!query.is_confirmed_block(2)); } -BOOST_AUTO_TEST_CASE(query_confirm__is_confirmed_tx__confirm__expected) +BOOST_AUTO_TEST_CASE(query_confirmed__is_confirmed_tx__confirm__expected) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE(query.set(test::block1, context{ 0, 1, 0 }, false, false)); BOOST_REQUIRE(query.set(test::block2, context{ 0, 2, 0 }, false, false)); @@ -116,24 +113,24 @@ BOOST_AUTO_TEST_CASE(query_confirm__is_confirmed_tx__confirm__expected) BOOST_REQUIRE(query.is_confirmed_tx(2)); } -BOOST_AUTO_TEST_CASE(query_confirm__is_confirmed_input__genesis__true) +BOOST_AUTO_TEST_CASE(query_confirmed__is_confirmed_input__genesis__true) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE(query.is_confirmed_input(query.to_point(0, 0))); } -BOOST_AUTO_TEST_CASE(query_confirm__is_confirmed_input__unconfirmed__false) +BOOST_AUTO_TEST_CASE(query_confirmed__is_confirmed_input__unconfirmed__false) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE(query.set(test::block1, context{ 0, 1, 0 }, false, false)); @@ -144,13 +141,13 @@ BOOST_AUTO_TEST_CASE(query_confirm__is_confirmed_input__unconfirmed__false) BOOST_REQUIRE(query.is_confirmed_input(query.to_point(1, 0))); } -BOOST_AUTO_TEST_CASE(query_confirm__is_confirmed_input__confirmed_weak__expected) +BOOST_AUTO_TEST_CASE(query_confirmed__is_confirmed_input__confirmed_weak__expected) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE(query.set(test::block1a, context{ 0, 1, 0 }, false, false)); BOOST_REQUIRE(query.set(test::block2a, context{ 0, 2, 0 }, false, false)); @@ -182,13 +179,13 @@ BOOST_AUTO_TEST_CASE(query_confirm__is_confirmed_input__confirmed_weak__expected BOOST_REQUIRE(query.is_confirmed_input(query.to_point(2, 1))); } -BOOST_AUTO_TEST_CASE(query_confirm__is_confirmed_input__confirmed_strong__expected) +BOOST_AUTO_TEST_CASE(query_confirmed__is_confirmed_input__confirmed_strong__expected) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE(query.set(test::block1, context{ 0, 1, 0 }, false, false)); BOOST_REQUIRE(query.set(test::block2, context{ 0, 2, 0 }, false, false)); @@ -207,13 +204,13 @@ BOOST_AUTO_TEST_CASE(query_confirm__is_confirmed_input__confirmed_strong__expect BOOST_REQUIRE(query.is_confirmed_input(query.to_point(2, 0))); } -BOOST_AUTO_TEST_CASE(query_confirm__is_confirmed_output__confirm__expected) +BOOST_AUTO_TEST_CASE(query_confirmed__is_confirmed_output__confirm__expected) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE(query.set(test::block1, context{ 0, 1, 0 }, false, false)); BOOST_REQUIRE(query.set(test::block2, context{ 0, 2, 0 }, false, false)); @@ -235,25 +232,25 @@ BOOST_AUTO_TEST_CASE(query_confirm__is_confirmed_output__confirm__expected) BOOST_REQUIRE(query.is_confirmed_output(query.to_output(2, 0))); } -BOOST_AUTO_TEST_CASE(query_confirm__is_spent_output__genesis__false) +BOOST_AUTO_TEST_CASE(query_confirmed__is_spent_output__genesis__false) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE(!query.is_spent_output(query.to_output(0, 0))); BOOST_REQUIRE(!query.is_spent_output(query.to_output(1, 1))); } -BOOST_AUTO_TEST_CASE(query_confirm__is_spent_output__strong_confirmed__true) +BOOST_AUTO_TEST_CASE(query_confirmed__is_spent_output__strong_confirmed__true) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE(query.set(test::block1a, context{ 0, 1, 0 }, false, false)); BOOST_REQUIRE(query.set(test::block2a, context{ 0, 2, 0 }, false, false)); @@ -276,25 +273,25 @@ BOOST_AUTO_TEST_CASE(query_confirm__is_spent_output__strong_confirmed__true) } // The coinbase tx is strong. -BOOST_AUTO_TEST_CASE(query_confirm__is_strong__strong__true) +BOOST_AUTO_TEST_CASE(query_confirmed__is_strong__strong__true) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE(query.is_strong_tx(0)); BOOST_REQUIRE(query.is_strong_block(0)); } -BOOST_AUTO_TEST_CASE(query_confirm__is_strong__weak__false) +BOOST_AUTO_TEST_CASE(query_confirmed__is_strong__weak__false) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE(query.set(test::block1, context{}, false, false)); BOOST_REQUIRE(!query.is_strong_tx(1)); @@ -304,26 +301,26 @@ BOOST_AUTO_TEST_CASE(query_confirm__is_strong__weak__false) BOOST_REQUIRE(query.is_strong_block(1)); } -BOOST_AUTO_TEST_CASE(query_confirm__set_strong__unassociated__false) +BOOST_AUTO_TEST_CASE(query_confirmed__set_strong__unassociated__false) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE(query.set(test::block1.header(), context{}, false)); BOOST_REQUIRE(!query.set_strong(1)); BOOST_REQUIRE(!query.set_unstrong(1)); } -BOOST_AUTO_TEST_CASE(query_confirm__set_strong__set_unstrong__expected) +BOOST_AUTO_TEST_CASE(query_confirmed__set_strong__set_unstrong__expected) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE(query.set(test::block1, context{ 0, 1, 0 }, false, false)); BOOST_REQUIRE(query.set(test::block2, context{ 0, 2, 0 }, false, false)); @@ -373,49 +370,49 @@ BOOST_AUTO_TEST_CASE(query_confirm__set_strong__set_unstrong__expected) BOOST_REQUIRE(!query.is_confirmed_output(query.to_output(2, 0))); } -////BOOST_AUTO_TEST_CASE(query_confirm__is_mature__spend_genesis__false) +////BOOST_AUTO_TEST_CASE(query_confirmed__is_mature__spend_genesis__false) ////{ //// settings settings{}; //// settings.path = TEST_DIRECTORY; //// test::chunk_store store{ settings }; //// test::query_accessor query{ store }; -//// BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); +//// BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); //// BOOST_REQUIRE(query.initialize(test::genesis)); //// BOOST_REQUIRE(query.set(test::tx_spend_genesis)); //// BOOST_REQUIRE(!query.is_mature(query.to_point(1, 0), 0)); //// BOOST_REQUIRE(!query.is_mature(query.to_point(1, 0), 100)); ////} //// -////BOOST_AUTO_TEST_CASE(query_confirm__is_mature__not_found__false) +////BOOST_AUTO_TEST_CASE(query_confirmed__is_mature__not_found__false) ////{ //// settings settings{}; //// settings.path = TEST_DIRECTORY; //// test::chunk_store store{ settings }; //// test::query_accessor query{ store }; -//// BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); +//// BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); //// BOOST_REQUIRE(query.initialize(test::genesis)); //// BOOST_REQUIRE(!query.is_mature(query.to_point(0, 1), 0)); //// BOOST_REQUIRE(!query.is_mature(query.to_point(42, 24), 1000)); ////} //// -////BOOST_AUTO_TEST_CASE(query_confirm__is_mature__null_input__true) +////BOOST_AUTO_TEST_CASE(query_confirmed__is_mature__null_input__true) ////{ //// settings settings{}; //// settings.path = TEST_DIRECTORY; //// test::chunk_store store{ settings }; //// test::query_accessor query{ store }; -//// BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); +//// BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); //// BOOST_REQUIRE(query.initialize(test::genesis)); //// BOOST_REQUIRE(query.is_mature(query.to_point(0, 0), 0)); ////} //// -////BOOST_AUTO_TEST_CASE(query_confirm__is_mature__non_coinbase_strong_above__true) +////BOOST_AUTO_TEST_CASE(query_confirmed__is_mature__non_coinbase_strong_above__true) ////{ //// settings settings{}; //// settings.path = TEST_DIRECTORY; //// test::chunk_store store{ settings }; //// test::query_accessor query{ store }; -//// BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); +//// BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); //// BOOST_REQUIRE(query.initialize(test::genesis)); //// BOOST_REQUIRE(query.set(test::block1a, context{ 0, 1, 0 }, false, false)); //// BOOST_REQUIRE(query.set(test::tx4)); @@ -426,13 +423,13 @@ BOOST_AUTO_TEST_CASE(query_confirm__set_strong__set_unstrong__expected) //// BOOST_REQUIRE(query.is_mature(query.to_point(2, 0), 0)); ////} //// -////BOOST_AUTO_TEST_CASE(query_confirm__is_mature__non_coinbase__true) +////BOOST_AUTO_TEST_CASE(query_confirmed__is_mature__non_coinbase__true) ////{ //// settings settings{}; //// settings.path = TEST_DIRECTORY; //// test::chunk_store store{ settings }; //// test::query_accessor query{ store }; -//// BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); +//// BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); //// BOOST_REQUIRE(query.initialize(test::genesis)); //// BOOST_REQUIRE(query.set(test::block1a, context{ 0, 1, 0 }, false, false)); //// BOOST_REQUIRE(query.set(test::tx4)); @@ -440,13 +437,13 @@ BOOST_AUTO_TEST_CASE(query_confirm__set_strong__set_unstrong__expected) //// BOOST_REQUIRE(query.is_mature(query.to_point(2, 0), 1)); ////} //// -////BOOST_AUTO_TEST_CASE(query_confirm__is_mature__coinbase__expected) +////BOOST_AUTO_TEST_CASE(query_confirmed__is_mature__coinbase__expected) ////{ //// settings settings{}; //// settings.path = TEST_DIRECTORY; //// test::chunk_store store{ settings }; //// test::query_accessor query{ store }; -//// BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); +//// BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); //// BOOST_REQUIRE(query.initialize(test::genesis)); //// BOOST_REQUIRE(query.set(test::block1b, context{ 0, 1, 0 }, false, false)); //// BOOST_REQUIRE(query.set_strong(1)); @@ -457,13 +454,13 @@ BOOST_AUTO_TEST_CASE(query_confirm__set_strong__set_unstrong__expected) constexpr auto bip68 = system::chain::flags::bip68_rule; -BOOST_AUTO_TEST_CASE(query_confirm__block_confirmable__bad_link__integrity_block_confirmable1) +BOOST_AUTO_TEST_CASE(query_confirmed__block_confirmable__bad_link__integrity_block_confirmable1) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE(query.set(test::block1, context{ bip68, 1, 0 }, false, false)); BOOST_REQUIRE_EQUAL(query.block_confirmable(2), error::integrity_block_confirmable1); @@ -472,13 +469,13 @@ BOOST_AUTO_TEST_CASE(query_confirm__block_confirmable__bad_link__integrity_block // These pass but are limited by vectors with mostly coinbases. // ---------------------------------------------------------------------------- -BOOST_AUTO_TEST_CASE(query_confirm__block_confirmable__null_points__success) +BOOST_AUTO_TEST_CASE(query_confirmed__block_confirmable__null_points__success) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE(query.set(test::block1, context{ bip68 }, false, false)); BOOST_REQUIRE(query.set(test::block2, context{ bip68 }, false, false)); @@ -493,13 +490,13 @@ BOOST_AUTO_TEST_CASE(query_confirm__block_confirmable__null_points__success) BOOST_REQUIRE_EQUAL(query.block_confirmable(3), error::success); } -BOOST_AUTO_TEST_CASE(query_confirm__block_confirmable__missing_prevouts__integrity) +BOOST_AUTO_TEST_CASE(query_confirmed__block_confirmable__missing_prevouts__integrity) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE(query.set(test::block1a, context{ bip68, 1, 0 }, false, false)); @@ -509,13 +506,13 @@ BOOST_AUTO_TEST_CASE(query_confirm__block_confirmable__missing_prevouts__integri BOOST_REQUIRE_EQUAL(query.block_confirmable(1), error::success); } -BOOST_AUTO_TEST_CASE(query_confirm__block_confirmable__spend_gensis__coinbase_maturity) +BOOST_AUTO_TEST_CASE(query_confirmed__block_confirmable__spend_gensis__coinbase_maturity) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); BOOST_REQUIRE(query.initialize(test::genesis)); // block_spend_genesis spends the genesis output. @@ -527,13 +524,13 @@ BOOST_AUTO_TEST_CASE(query_confirm__block_confirmable__spend_gensis__coinbase_ma BOOST_REQUIRE_EQUAL(query.block_confirmable(1), error::success); } -BOOST_AUTO_TEST_CASE(query_confirm__block_confirmable__immature_prevouts__coinbase_maturity) +BOOST_AUTO_TEST_CASE(query_confirmed__block_confirmable__immature_prevouts__coinbase_maturity) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); BOOST_REQUIRE(query.initialize(test::genesis)); // block1b has only a coinbase tx. @@ -548,13 +545,13 @@ BOOST_AUTO_TEST_CASE(query_confirm__block_confirmable__immature_prevouts__coinba BOOST_REQUIRE_EQUAL(query.block_confirmable(2), error::success); } -BOOST_AUTO_TEST_CASE(query_confirm__block_confirmable__mature_prevouts__success) +BOOST_AUTO_TEST_CASE(query_confirmed__block_confirmable__mature_prevouts__success) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); BOOST_REQUIRE(query.initialize(test::genesis)); // block1b has only a coinbase tx. @@ -569,13 +566,13 @@ BOOST_AUTO_TEST_CASE(query_confirm__block_confirmable__mature_prevouts__success) BOOST_REQUIRE_EQUAL(query.block_confirmable(2), error::success); } -BOOST_AUTO_TEST_CASE(query_confirm__block_confirmable__spend_non_coinbase__success) +BOOST_AUTO_TEST_CASE(query_confirmed__block_confirmable__spend_non_coinbase__success) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); BOOST_REQUIRE(query.initialize(test::genesis)); // block1a has non-coinbase tx/outputs. @@ -594,13 +591,13 @@ BOOST_AUTO_TEST_CASE(query_confirm__block_confirmable__spend_non_coinbase__succe // These pass but vectors need to be updated to create clear test conditions. // ---------------------------------------------------------------------------- -BOOST_AUTO_TEST_CASE(query_confirm__block_confirmable__spend_coinbase_and_internal_immature__coinbase_maturity) +BOOST_AUTO_TEST_CASE(query_confirmed__block_confirmable__spend_coinbase_and_internal_immature__coinbase_maturity) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); BOOST_REQUIRE(query.initialize(test::genesis)); // block1b has coinbase tx/outputs. @@ -619,13 +616,13 @@ BOOST_AUTO_TEST_CASE(query_confirm__block_confirmable__spend_coinbase_and_intern BOOST_REQUIRE_EQUAL(query.block_confirmable(2), error::integrity_get_prevouts); } -BOOST_AUTO_TEST_CASE(query_confirm__block_confirmable__spend_coinbase_and_internal_mature__success) +BOOST_AUTO_TEST_CASE(query_confirmed__block_confirmable__spend_coinbase_and_internal_mature__success) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); BOOST_REQUIRE(query.initialize(test::genesis)); // block1b has coinbase tx/outputs. @@ -646,13 +643,13 @@ BOOST_AUTO_TEST_CASE(query_confirm__block_confirmable__spend_coinbase_and_intern BOOST_REQUIRE_EQUAL(query.block_confirmable(2), error::integrity_get_prevouts); } -BOOST_AUTO_TEST_CASE(query_confirm__block_confirmable__confirmed_double_spend__confirmed_double_spend) +BOOST_AUTO_TEST_CASE(query_confirmed__block_confirmable__confirmed_double_spend__confirmed_double_spend) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); BOOST_REQUIRE(query.initialize(test::genesis)); // block1a has non-coinbase tx/outputs. @@ -671,13 +668,13 @@ BOOST_AUTO_TEST_CASE(query_confirm__block_confirmable__confirmed_double_spend__c BOOST_REQUIRE_EQUAL(query.block_confirmable(3), error::success); } -BOOST_AUTO_TEST_CASE(query_confirm__block_confirmable__unconfirmed_double_spend__success) +BOOST_AUTO_TEST_CASE(query_confirmed__block_confirmable__unconfirmed_double_spend__success) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); BOOST_REQUIRE(query.initialize(test::genesis)); // block1a has non-coinbase tx/outputs. diff --git a/test/query/consensus/consensus_block.cpp b/test/query/consensus/consensus_block.cpp new file mode 100644 index 00000000..5e26226f --- /dev/null +++ b/test/query/consensus/consensus_block.cpp @@ -0,0 +1,25 @@ +/** + * Copyright (c) 2011-2026 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +#include "../../test.hpp" +#include "../../mocks/blocks.hpp" +#include "../../mocks/chunk_store.hpp" + +BOOST_FIXTURE_TEST_SUITE(query_consensus_tests, test::directory_setup_fixture) + +BOOST_AUTO_TEST_SUITE_END() diff --git a/test/query/context.cpp b/test/query/consensus/consensus_chain_state.cpp similarity index 87% rename from test/query/context.cpp rename to test/query/consensus/consensus_chain_state.cpp index b2315451..56c51431 100644 --- a/test/query/context.cpp +++ b/test/query/consensus/consensus_chain_state.cpp @@ -16,15 +16,13 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -#include "../test.hpp" -#include "../mocks/blocks.hpp" -#include "../mocks/chunk_store.hpp" +#include "../../test.hpp" +#include "../../mocks/blocks.hpp" +#include "../../mocks/chunk_store.hpp" -BOOST_FIXTURE_TEST_SUITE(query_context_tests, test::directory_setup_fixture) +BOOST_FIXTURE_TEST_SUITE(query_consensus_tests, test::directory_setup_fixture) -const auto events_handler = [](auto, auto) {}; - -BOOST_AUTO_TEST_CASE(query_context__get_candidate_chain_state__genesis__expected) +BOOST_AUTO_TEST_CASE(query_consensus__get_candidate_chain_state__genesis__expected) { const system::settings system_settings{ system::chain::selection::mainnet }; const system::chain::context expected @@ -41,7 +39,7 @@ BOOST_AUTO_TEST_CASE(query_context__get_candidate_chain_state__genesis__expected database_settings.path = TEST_DIRECTORY; test::chunk_store store{ database_settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); BOOST_REQUIRE(query.initialize(test::genesis)); const auto state = query.get_candidate_chain_state(system_settings); @@ -56,7 +54,7 @@ BOOST_AUTO_TEST_CASE(query_context__get_candidate_chain_state__genesis__expected BOOST_REQUIRE(state->context() == expected); } -BOOST_AUTO_TEST_CASE(query_context__get_candidate_chain_state__block1__expected) +BOOST_AUTO_TEST_CASE(query_consensus__get_candidate_chain_state__block1__expected) { const system::settings system_settings{ system::chain::selection::mainnet }; const system::chain::context expected @@ -81,7 +79,7 @@ BOOST_AUTO_TEST_CASE(query_context__get_candidate_chain_state__block1__expected) database_settings.path = TEST_DIRECTORY; test::chunk_store store{ database_settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE(query.set(test::block1, context, true, false)); BOOST_REQUIRE(query.push_candidate(query.to_header(test::block1.hash()))); diff --git a/test/query/consensus/consensus_compact.cpp b/test/query/consensus/consensus_compact.cpp new file mode 100644 index 00000000..5e26226f --- /dev/null +++ b/test/query/consensus/consensus_compact.cpp @@ -0,0 +1,25 @@ +/** + * Copyright (c) 2011-2026 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +#include "../../test.hpp" +#include "../../mocks/blocks.hpp" +#include "../../mocks/chunk_store.hpp" + +BOOST_FIXTURE_TEST_SUITE(query_consensus_tests, test::directory_setup_fixture) + +BOOST_AUTO_TEST_SUITE_END() diff --git a/test/query/consensus/consensus_forks.cpp b/test/query/consensus/consensus_forks.cpp new file mode 100644 index 00000000..5e26226f --- /dev/null +++ b/test/query/consensus/consensus_forks.cpp @@ -0,0 +1,25 @@ +/** + * Copyright (c) 2011-2026 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +#include "../../test.hpp" +#include "../../mocks/blocks.hpp" +#include "../../mocks/chunk_store.hpp" + +BOOST_FIXTURE_TEST_SUITE(query_consensus_tests, test::directory_setup_fixture) + +BOOST_AUTO_TEST_SUITE_END() diff --git a/test/query/consensus/consensus_populate.cpp b/test/query/consensus/consensus_populate.cpp new file mode 100644 index 00000000..5e26226f --- /dev/null +++ b/test/query/consensus/consensus_populate.cpp @@ -0,0 +1,25 @@ +/** + * Copyright (c) 2011-2026 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +#include "../../test.hpp" +#include "../../mocks/blocks.hpp" +#include "../../mocks/chunk_store.hpp" + +BOOST_FIXTURE_TEST_SUITE(query_consensus_tests, test::directory_setup_fixture) + +BOOST_AUTO_TEST_SUITE_END() diff --git a/test/query/consensus/consensus_prevouts.cpp b/test/query/consensus/consensus_prevouts.cpp new file mode 100644 index 00000000..5e26226f --- /dev/null +++ b/test/query/consensus/consensus_prevouts.cpp @@ -0,0 +1,25 @@ +/** + * Copyright (c) 2011-2026 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +#include "../../test.hpp" +#include "../../mocks/blocks.hpp" +#include "../../mocks/chunk_store.hpp" + +BOOST_FIXTURE_TEST_SUITE(query_consensus_tests, test::directory_setup_fixture) + +BOOST_AUTO_TEST_SUITE_END() diff --git a/test/query/consensus/consensus_states.cpp b/test/query/consensus/consensus_states.cpp new file mode 100644 index 00000000..5e26226f --- /dev/null +++ b/test/query/consensus/consensus_states.cpp @@ -0,0 +1,25 @@ +/** + * Copyright (c) 2011-2026 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +#include "../../test.hpp" +#include "../../mocks/blocks.hpp" +#include "../../mocks/chunk_store.hpp" + +BOOST_FIXTURE_TEST_SUITE(query_consensus_tests, test::directory_setup_fixture) + +BOOST_AUTO_TEST_SUITE_END() diff --git a/test/query/consensus/consensus_strong.cpp b/test/query/consensus/consensus_strong.cpp new file mode 100644 index 00000000..5e26226f --- /dev/null +++ b/test/query/consensus/consensus_strong.cpp @@ -0,0 +1,25 @@ +/** + * Copyright (c) 2011-2026 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +#include "../../test.hpp" +#include "../../mocks/blocks.hpp" +#include "../../mocks/chunk_store.hpp" + +BOOST_FIXTURE_TEST_SUITE(query_consensus_tests, test::directory_setup_fixture) + +BOOST_AUTO_TEST_SUITE_END() diff --git a/test/query/consensus/consensus_transaction.cpp b/test/query/consensus/consensus_transaction.cpp new file mode 100644 index 00000000..5e26226f --- /dev/null +++ b/test/query/consensus/consensus_transaction.cpp @@ -0,0 +1,25 @@ +/** + * Copyright (c) 2011-2026 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +#include "../../test.hpp" +#include "../../mocks/blocks.hpp" +#include "../../mocks/chunk_store.hpp" + +BOOST_FIXTURE_TEST_SUITE(query_consensus_tests, test::directory_setup_fixture) + +BOOST_AUTO_TEST_SUITE_END() diff --git a/test/query/consensus/consensus_work.cpp b/test/query/consensus/consensus_work.cpp new file mode 100644 index 00000000..5e26226f --- /dev/null +++ b/test/query/consensus/consensus_work.cpp @@ -0,0 +1,25 @@ +/** + * Copyright (c) 2011-2026 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +#include "../../test.hpp" +#include "../../mocks/blocks.hpp" +#include "../../mocks/chunk_store.hpp" + +BOOST_FIXTURE_TEST_SUITE(query_consensus_tests, test::directory_setup_fixture) + +BOOST_AUTO_TEST_SUITE_END() diff --git a/test/query/extent.cpp b/test/query/extent.cpp index 0e204ac7..f5c119fa 100644 --- a/test/query/extent.cpp +++ b/test/query/extent.cpp @@ -22,9 +22,6 @@ BOOST_FIXTURE_TEST_SUITE(query_extent_tests, test::directory_setup_fixture) -// nop event handler. -const auto events_handler = [](auto, auto) {}; - BOOST_AUTO_TEST_CASE(query__is_full__chunk_store__false) { const settings configuration{}; @@ -39,7 +36,7 @@ BOOST_AUTO_TEST_CASE(query_extent__body_sizes__genesis__expected) settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE_EQUAL(query.header_body_size(), schema::header::minrow); @@ -69,7 +66,7 @@ BOOST_AUTO_TEST_CASE(query_extent__buckets__genesis__expected) settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE_EQUAL(query.header_buckets(), 128u); @@ -93,7 +90,7 @@ BOOST_AUTO_TEST_CASE(query_extent__records__genesis__expected) settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE_EQUAL(query.header_records(), one); @@ -115,7 +112,7 @@ BOOST_AUTO_TEST_CASE(query_extent__input_output_count__genesis__expected) settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE_EQUAL(query.input_count(0), one); @@ -135,7 +132,7 @@ BOOST_AUTO_TEST_CASE(query_extent__optionals_enabled__default__true) settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE(query.address_enabled()); BOOST_REQUIRE(query.filter_enabled()); @@ -148,7 +145,7 @@ BOOST_AUTO_TEST_CASE(query_extent__address_enabled__disabled__false) settings.address_buckets = 0; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE(!query.address_enabled()); BOOST_REQUIRE(query.filter_enabled()); @@ -161,7 +158,7 @@ BOOST_AUTO_TEST_CASE(query_extent__filter_enabled__disabled__false) settings.filter_tx_buckets = 0; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE(query.address_enabled()); BOOST_REQUIRE(!query.filter_enabled()); diff --git a/test/query/fees.cpp b/test/query/fee_rate.cpp similarity index 84% rename from test/query/fees.cpp rename to test/query/fee_rate.cpp index 629c1c2a..d17eb736 100644 --- a/test/query/fees.cpp +++ b/test/query/fee_rate.cpp @@ -24,10 +24,7 @@ // get_tx_virtual_size // get_block_virtual_size -BOOST_FIXTURE_TEST_SUITE(query_fees_tests, test::directory_setup_fixture) - -// nop event handler. -const auto events_handler = [](auto, auto) {}; +BOOST_FIXTURE_TEST_SUITE(query_fee_rate_tests, test::directory_setup_fixture) // get_tx_fee // get_tx_fees @@ -35,14 +32,14 @@ const auto events_handler = [](auto, auto) {}; // get_tx_spend // get_tx_virtual_size -BOOST_AUTO_TEST_CASE(query_fees__get_tx_fee__invalid__false) +BOOST_AUTO_TEST_CASE(query_fee_rate__get_tx_fee__invalid__false) { uint64_t out{}; settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK(!store.create(events_handler)); + BOOST_CHECK(!store.create(test::events_handler)); BOOST_CHECK(query.initialize(test::genesis)); BOOST_CHECK(!query.get_tx_fee(out, 42)); BOOST_CHECK(!query.get_tx_value(out, 42)); @@ -52,14 +49,14 @@ BOOST_AUTO_TEST_CASE(query_fees__get_tx_fee__invalid__false) BOOST_CHECK(!query.get_tx_fees(rate, 42)); } -BOOST_AUTO_TEST_CASE(query_fees__get_tx_fee__missing_prevouts__false) +BOOST_AUTO_TEST_CASE(query_fee_rate__get_tx_fee__missing_prevouts__false) { uint64_t out{}; settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK(!store.create(events_handler)); + BOOST_CHECK(!store.create(test::events_handler)); BOOST_CHECK(query.initialize(test::genesis)); BOOST_CHECK(query.get_tx_fee(out, 0)); BOOST_CHECK_EQUAL(out, 0u); @@ -85,14 +82,14 @@ BOOST_AUTO_TEST_CASE(query_fees__get_tx_fee__missing_prevouts__false) BOOST_CHECK(!query.get_tx_fees(rate, 3)); } -BOOST_AUTO_TEST_CASE(query_fees__get_tx_fee__coinbase__zero) +BOOST_AUTO_TEST_CASE(query_fee_rate__get_tx_fee__coinbase__zero) { uint64_t out{}; settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK(!store.create(events_handler)); + BOOST_CHECK(!store.create(test::events_handler)); BOOST_CHECK(query.initialize(test::genesis)); // Coinbase fee and value are always zero. @@ -107,14 +104,14 @@ BOOST_AUTO_TEST_CASE(query_fees__get_tx_fee__coinbase__zero) BOOST_CHECK(!query.get_tx_fees(rate, 0)); } -BOOST_AUTO_TEST_CASE(query_fees__get_tx_fee__valid_non_coinbase__expected) +BOOST_AUTO_TEST_CASE(query_fee_rate__get_tx_fee__valid_non_coinbase__expected) { uint64_t out{}; settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK(!store.create(events_handler)); + BOOST_CHECK(!store.create(test::events_handler)); BOOST_CHECK(query.initialize(test::genesis)); BOOST_CHECK(query.set(test::block1b, test::context, false, false)); BOOST_CHECK(query.set(test::block_valid_spend_internal_2b, test::context, false, false)); @@ -141,14 +138,14 @@ BOOST_AUTO_TEST_CASE(query_fees__get_tx_fee__valid_non_coinbase__expected) // get_block_spend // get_block_virtual_size -BOOST_AUTO_TEST_CASE(query_fees__get_block_fee__invalid__false) +BOOST_AUTO_TEST_CASE(query_fee_rate__get_block_fee__invalid__false) { uint64_t out{}; settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK(!store.create(events_handler)); + BOOST_CHECK(!store.create(test::events_handler)); BOOST_CHECK(query.initialize(test::genesis)); BOOST_CHECK(!query.get_block_fee(out, 24)); @@ -156,14 +153,14 @@ BOOST_AUTO_TEST_CASE(query_fees__get_block_fee__invalid__false) BOOST_CHECK(!query.get_block_fees(rates, 24)); } -BOOST_AUTO_TEST_CASE(query_fees__get_block_fee__block_missing_prevout__false) +BOOST_AUTO_TEST_CASE(query_fee_rate__get_block_fee__block_missing_prevout__false) { uint64_t out{}; settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK(!store.create(events_handler)); + BOOST_CHECK(!store.create(test::events_handler)); BOOST_CHECK(query.initialize(test::genesis)); BOOST_CHECK(query.set(test::block1b, test::context, false, false)); BOOST_CHECK(query.set(test::block_missing_prevout_2b, test::context, false, false)); @@ -173,14 +170,14 @@ BOOST_AUTO_TEST_CASE(query_fees__get_block_fee__block_missing_prevout__false) BOOST_CHECK(!query.get_block_fees(rates, 2)); } -BOOST_AUTO_TEST_CASE(query_fees__get_block_fee__coinbases__zero) +BOOST_AUTO_TEST_CASE(query_fee_rate__get_block_fee__coinbases__zero) { uint64_t out{}; settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK(!store.create(events_handler)); + BOOST_CHECK(!store.create(test::events_handler)); BOOST_CHECK(query.initialize(test::genesis)); BOOST_CHECK(query.set(test::block1, test::context, false, false)); BOOST_CHECK(query.set(test::block2, test::context, false, false)); @@ -192,14 +189,14 @@ BOOST_AUTO_TEST_CASE(query_fees__get_block_fee__coinbases__zero) BOOST_CHECK(rates.empty()); } -BOOST_AUTO_TEST_CASE(query_fees__get_block_fee__valid__expected) +BOOST_AUTO_TEST_CASE(query_fee_rate__get_block_fee__valid__expected) { uint64_t out{}; settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK(!store.create(events_handler)); + BOOST_CHECK(!store.create(test::events_handler)); BOOST_CHECK(query.initialize(test::genesis)); BOOST_CHECK(query.set(test::block1b, test::context, false, false)); BOOST_CHECK(query.set(test::block_valid_spend_internal_2b, test::context, false, false)); @@ -220,14 +217,14 @@ BOOST_AUTO_TEST_CASE(query_fees__get_block_fee__valid__expected) BOOST_CHECK_EQUAL(rates.at(1).fee, 0xb0u); } -BOOST_AUTO_TEST_CASE(query_fees__get_block_fee__genesis__zero) +BOOST_AUTO_TEST_CASE(query_fee_rate__get_block_fee__genesis__zero) { uint64_t out{}; settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK(!store.create(events_handler)); + BOOST_CHECK(!store.create(test::events_handler)); BOOST_CHECK(query.initialize(test::genesis)); BOOST_CHECK(query.get_block_fee(out, 0)); BOOST_CHECK_EQUAL(out, 0u); @@ -239,13 +236,13 @@ BOOST_AUTO_TEST_CASE(query_fees__get_block_fee__genesis__zero) // get_branch_fees -BOOST_AUTO_TEST_CASE(query_fees__get_branch_fees__zero__true_empty) +BOOST_AUTO_TEST_CASE(query_fee_rate__get_branch_fees__zero__true_empty) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK(!store.create(events_handler)); + BOOST_CHECK(!store.create(test::events_handler)); BOOST_CHECK(query.initialize(test::genesis)); std::atomic_bool cancel{}; @@ -254,13 +251,13 @@ BOOST_AUTO_TEST_CASE(query_fees__get_branch_fees__zero__true_empty) BOOST_CHECK(rates_sets.empty()); } -BOOST_AUTO_TEST_CASE(query_fees__get_branch_fees__genesis__true_one_empty) +BOOST_AUTO_TEST_CASE(query_fee_rate__get_branch_fees__genesis__true_one_empty) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK(!store.create(events_handler)); + BOOST_CHECK(!store.create(test::events_handler)); BOOST_CHECK(query.initialize(test::genesis)); std::atomic_bool cancel{}; @@ -270,13 +267,13 @@ BOOST_AUTO_TEST_CASE(query_fees__get_branch_fees__genesis__true_one_empty) BOOST_CHECK(rates_sets.front().empty()); } -BOOST_AUTO_TEST_CASE(query_fees__get_branch_fees__unconfirmed_blocks__false) +BOOST_AUTO_TEST_CASE(query_fee_rate__get_branch_fees__unconfirmed_blocks__false) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK(!store.create(events_handler)); + BOOST_CHECK(!store.create(test::events_handler)); BOOST_CHECK(query.initialize(test::genesis)); BOOST_CHECK(query.set(test::block1, test::context, false, false)); BOOST_CHECK(query.set(test::block2, test::context, false, false)); @@ -286,13 +283,13 @@ BOOST_AUTO_TEST_CASE(query_fees__get_branch_fees__unconfirmed_blocks__false) BOOST_CHECK(!query.get_branch_fees(cancel, rates_sets, 0, 3)); } -BOOST_AUTO_TEST_CASE(query_fees__get_branch_fees__confirmed_overflow__false) +BOOST_AUTO_TEST_CASE(query_fee_rate__get_branch_fees__confirmed_overflow__false) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK(!store.create(events_handler)); + BOOST_CHECK(!store.create(test::events_handler)); BOOST_CHECK(query.initialize(test::genesis)); BOOST_CHECK(query.set(test::block1, test::context, false, false)); BOOST_CHECK(query.set(test::block2, test::context, false, false)); @@ -307,13 +304,13 @@ BOOST_AUTO_TEST_CASE(query_fees__get_branch_fees__confirmed_overflow__false) BOOST_CHECK(!query.get_branch_fees(cancel, rates_sets, 3, 1)); } -BOOST_AUTO_TEST_CASE(query_fees__get_branch_fees__zero_over_top__true) +BOOST_AUTO_TEST_CASE(query_fee_rate__get_branch_fees__zero_over_top__true) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK(!store.create(events_handler)); + BOOST_CHECK(!store.create(test::events_handler)); BOOST_CHECK(query.initialize(test::genesis)); // A start of 1 is over the chain top, but requested count is zero (ok). @@ -322,13 +319,13 @@ BOOST_AUTO_TEST_CASE(query_fees__get_branch_fees__zero_over_top__true) BOOST_CHECK(query.get_branch_fees(cancel, rates_sets, 1, 0)); } -BOOST_AUTO_TEST_CASE(query_fees__get_branch_fees__confirmed_empty_blocks__all_empty) +BOOST_AUTO_TEST_CASE(query_fee_rate__get_branch_fees__confirmed_empty_blocks__all_empty) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK(!store.create(events_handler)); + BOOST_CHECK(!store.create(test::events_handler)); BOOST_CHECK(query.initialize(test::genesis)); BOOST_CHECK(query.set(test::block1, test::context, false, false)); BOOST_CHECK(query.set(test::block2, test::context, false, false)); @@ -359,13 +356,13 @@ BOOST_AUTO_TEST_CASE(query_fees__get_branch_fees__confirmed_empty_blocks__all_em BOOST_CHECK(rates_sets.empty()); } -BOOST_AUTO_TEST_CASE(query_fees__get_branch_fees__confirmed_non_empty_blocks__all_expected) +BOOST_AUTO_TEST_CASE(query_fee_rate__get_branch_fees__confirmed_non_empty_blocks__all_expected) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK(!store.create(events_handler)); + BOOST_CHECK(!store.create(test::events_handler)); BOOST_CHECK(query.initialize(test::genesis)); BOOST_CHECK(query.set(test::block1b, test::context, false, false)); BOOST_CHECK(query.set(test::block_valid_spend_internal_2b, test::context, false, false)); @@ -409,13 +406,13 @@ BOOST_AUTO_TEST_CASE(query_fees__get_branch_fees__confirmed_non_empty_blocks__al } -BOOST_AUTO_TEST_CASE(query_fees__get_branch_fees__cancel_zero__true_empty) +BOOST_AUTO_TEST_CASE(query_fee_rate__get_branch_fees__cancel_zero__true_empty) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK(!store.create(events_handler)); + BOOST_CHECK(!store.create(test::events_handler)); BOOST_CHECK(query.initialize(test::genesis)); std::atomic_bool cancel{ true }; @@ -424,13 +421,13 @@ BOOST_AUTO_TEST_CASE(query_fees__get_branch_fees__cancel_zero__true_empty) BOOST_CHECK(rates_sets.empty()); } -BOOST_AUTO_TEST_CASE(query_fees__get_branch_fees__cancel_genesis__false_empty) +BOOST_AUTO_TEST_CASE(query_fee_rate__get_branch_fees__cancel_genesis__false_empty) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK(!store.create(events_handler)); + BOOST_CHECK(!store.create(test::events_handler)); BOOST_CHECK(query.initialize(test::genesis)); std::atomic_bool cancel{ true }; @@ -439,13 +436,13 @@ BOOST_AUTO_TEST_CASE(query_fees__get_branch_fees__cancel_genesis__false_empty) BOOST_CHECK(rates_sets.empty()); } -BOOST_AUTO_TEST_CASE(query_fees__get_branch_fees__cancel_three_blocks__false_empty) +BOOST_AUTO_TEST_CASE(query_fee_rate__get_branch_fees__cancel_three_blocks__false_empty) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_CHECK(!store.create(events_handler)); + BOOST_CHECK(!store.create(test::events_handler)); BOOST_CHECK(query.initialize(test::genesis)); BOOST_CHECK(query.set(test::block1, test::context, false, false)); BOOST_CHECK(query.set(test::block2, test::context, false, false)); diff --git a/test/query/filters.cpp b/test/query/filters.cpp new file mode 100644 index 00000000..5b4c735b --- /dev/null +++ b/test/query/filters.cpp @@ -0,0 +1,55 @@ +/** + * Copyright (c) 2011-2026 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +#include "../test.hpp" +#include "../mocks/blocks.hpp" +#include "../mocks/chunk_store.hpp" + +BOOST_FIXTURE_TEST_SUITE(query_filters_tests, test::directory_setup_fixture) + +////BOOST_AUTO_TEST_CASE(query_filters__set_filter__get_filter_and_head__expected) +////{ +//// const auto& filter_head0 = system::null_hash; +//// const auto filter0 = system::base16_chunk("0102030405060708090a0b0c0d0e0f"); +//// const auto& filter_head1 = system::one_hash; +//// const auto filter1 = system::base16_chunk("102030405060708090a0b0c0d0e0f0102030405060708090a0b0c0d0e0f0"); +//// +//// settings settings{}; +//// settings.path = TEST_DIRECTORY; +//// test::chunk_store store{ settings }; +//// test::query_accessor query{ store }; +//// BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); +//// BOOST_REQUIRE(query.initialize(test::genesis)); +//// BOOST_REQUIRE(query.set(test::block1a, context{}, false, false)); +//// BOOST_REQUIRE(query.set_filter(0, filter_head0, filter0)); +//// BOOST_REQUIRE(query.set_filter(1, filter_head1, filter1)); +//// +//// hash_digest head{}; +//// BOOST_REQUIRE(query.get_filter_head(head, 0)); +//// BOOST_REQUIRE_EQUAL(head, filter_head0); +//// BOOST_REQUIRE(query.get_filter_head(head, 1)); +//// BOOST_REQUIRE_EQUAL(head, filter_head1); +//// +//// system::data_chunk out{}; +//// BOOST_REQUIRE(query.get_filter(out, 0)); +//// BOOST_REQUIRE_EQUAL(out, filter0); +//// BOOST_REQUIRE(query.get_filter(out, 1)); +//// BOOST_REQUIRE_EQUAL(out, filter1); +////} + +BOOST_AUTO_TEST_SUITE_END() diff --git a/test/query/height.cpp b/test/query/height.cpp index 16a91444..fe417bb2 100644 --- a/test/query/height.cpp +++ b/test/query/height.cpp @@ -22,8 +22,6 @@ BOOST_FIXTURE_TEST_SUITE(query_height_tests, test::directory_setup_fixture) -const auto events_handler = [](auto, auto) {}; - // get_candidate_hashes BOOST_AUTO_TEST_CASE(query_height__get_candidate_hashes__initialized__one) @@ -32,7 +30,7 @@ BOOST_AUTO_TEST_CASE(query_height__get_candidate_hashes__initialized__one) settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE_EQUAL(query.get_candidate_hashes({ 0, 1, 2, 4, 6, 8 }).size(), 1u); } @@ -43,7 +41,7 @@ BOOST_AUTO_TEST_CASE(query_height__get_candidate_hashes__gapped__expected) settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE(query.set(test::block1, test::context, false, false)); BOOST_REQUIRE(query.set(test::block2, test::context, false, false)); @@ -66,7 +64,7 @@ BOOST_AUTO_TEST_CASE(query_height__get_confirmed_hashes1__initialized__one) settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE_EQUAL(query.get_confirmed_hashes({ 0, 1, 2, 4, 6, 8 }).size(), 1u); } @@ -77,7 +75,7 @@ BOOST_AUTO_TEST_CASE(query_height__get_confirmed_hashes1__gapped__expected) settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE(query.set(test::block1, test::context, false, false)); BOOST_REQUIRE(query.set(test::block2, test::context, false, false)); @@ -100,7 +98,7 @@ BOOST_AUTO_TEST_CASE(query_height__get_confirmed_hashes2__various__expected_size settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE(query.set(test::block1, test::context, false, false)); BOOST_REQUIRE(query.set(test::block2, test::context, false, false)); @@ -135,7 +133,7 @@ BOOST_AUTO_TEST_CASE(query_height__get_confirmed_hashes2__three__ascending_order settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE(query.set(test::block1, test::context, false, false)); BOOST_REQUIRE(query.set(test::block2, test::context, false, false)); @@ -159,7 +157,7 @@ BOOST_AUTO_TEST_CASE(query_height__get_confirmed_headers__empty__empty) settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE_EQUAL(query.get_confirmed_headers(0, 0).size(), 0u); BOOST_REQUIRE_EQUAL(query.get_confirmed_headers(0, 42).size(), 1u); @@ -173,7 +171,7 @@ BOOST_AUTO_TEST_CASE(query_height__get_confirmed_headers__unconfirmeds__empty) settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE(query.set(test::block1, test::context, false, false)); BOOST_REQUIRE(query.set(test::block2, test::context, false, false)); @@ -193,7 +191,7 @@ BOOST_AUTO_TEST_CASE(query_height__get_confirmed_headers__confirmeds__expected_s settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE(query.set(test::block1, test::context, false, false)); BOOST_REQUIRE(query.set(test::block2, test::context, false, false)); @@ -224,7 +222,7 @@ BOOST_AUTO_TEST_CASE(query_height__get_confirmed_headers__confirmeds__expected_h settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE(query.set(test::block1, test::context, false, false)); BOOST_REQUIRE(query.set(test::block2, test::context, false, false)); @@ -245,7 +243,7 @@ BOOST_AUTO_TEST_CASE(query_height__get_confirmed_headers__over_top__reduced_coun settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE(query.set(test::block1, test::context, false, false)); BOOST_REQUIRE(query.set(test::block2, test::context, false, false)); @@ -284,7 +282,7 @@ BOOST_AUTO_TEST_CASE(query_height__get_confirmed_headers__under_top__full_count) settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE(query.set(test::block1, test::context, false, false)); BOOST_REQUIRE(query.set(test::block2, test::context, false, false)); diff --git a/test/query/initialize.cpp b/test/query/initialize.cpp index e65ab96c..95657c7f 100644 --- a/test/query/initialize.cpp +++ b/test/query/initialize.cpp @@ -22,9 +22,6 @@ BOOST_FIXTURE_TEST_SUITE(query_initialize_tests, test::directory_setup_fixture) -// nop event handler. -const auto events_handler = [](auto, auto) {}; - BOOST_AUTO_TEST_CASE(query_initialize__blocks__verify__expected) { BOOST_REQUIRE_EQUAL(test::block1.hash(), test::block1_hash); @@ -43,7 +40,7 @@ BOOST_AUTO_TEST_CASE(query_initialize__initialize__is_initialized__true) settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE(query.is_initialized()); } @@ -56,7 +53,7 @@ BOOST_AUTO_TEST_CASE(query_initialize__is_initialized__default__false) settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); BOOST_REQUIRE(!query.is_initialized()); } @@ -66,7 +63,7 @@ BOOST_AUTO_TEST_CASE(query_initialize__is_initialized__unconfirmed__false) settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); BOOST_REQUIRE(query.set(test::genesis, test::context, false, false)); BOOST_REQUIRE(query.push_candidate(query.to_header(test::genesis.hash()))); BOOST_REQUIRE(!query.is_initialized()); @@ -78,7 +75,7 @@ BOOST_AUTO_TEST_CASE(query_initialize__is_initialized__candidate__false) settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); BOOST_REQUIRE(query.set(test::genesis, test::context, false, false)); BOOST_REQUIRE(query.push_candidate(query.to_header(test::genesis.hash()))); BOOST_REQUIRE(!query.is_initialized()); @@ -90,7 +87,7 @@ BOOST_AUTO_TEST_CASE(query_initialize__is_initialized__confirmed__false) settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); BOOST_REQUIRE(query.set(test::genesis, test::context, false, false)); BOOST_REQUIRE(query.push_confirmed(query.to_header(test::genesis.hash()), false)); BOOST_REQUIRE(!query.is_initialized()); @@ -102,7 +99,7 @@ BOOST_AUTO_TEST_CASE(query_initialize__is_initialized__candidate_and_confirmed__ settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); BOOST_REQUIRE(query.set(test::genesis, test::context, false, false)); BOOST_REQUIRE(query.push_candidate(query.to_header(test::genesis.hash()))); BOOST_REQUIRE(query.push_confirmed(query.to_header(test::genesis.hash()), false)); @@ -117,7 +114,7 @@ BOOST_AUTO_TEST_CASE(query_initialize__get_top__genesis_confirmed__0) settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); BOOST_REQUIRE(query.set(test::genesis, test::context, false, false)); BOOST_REQUIRE(query.push_confirmed(query.to_header(test::genesis.hash()), false)); ////BOOST_REQUIRE(query.push_candidate(query.to_header(genesis.hash()))); @@ -130,7 +127,7 @@ BOOST_AUTO_TEST_CASE(query_initialize__get_top__three_blocks_confirmed__2) settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); BOOST_REQUIRE(query.set(test::genesis, test::context, false, false)); BOOST_REQUIRE(query.set(test::block1, test::context, false, false)); BOOST_REQUIRE(query.set(test::block2, test::context, false, false)); @@ -150,7 +147,7 @@ BOOST_AUTO_TEST_CASE(query_initialize__get_top_candidate__genesis_candidated__0) settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); BOOST_REQUIRE(query.set(test::genesis, test::context, false, false)); BOOST_REQUIRE(query.push_candidate(query.to_header(test::genesis.hash()))); ////BOOST_REQUIRE(query.push_confirmed(query.to_header(test::genesis.hash()), false)); @@ -163,7 +160,7 @@ BOOST_AUTO_TEST_CASE(query_initialize__get_top__three_blocks_candidated__2) settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); BOOST_REQUIRE(query.set(test::genesis, test::context, false, false)); BOOST_REQUIRE(query.set(test::block1, test::context, false, false)); BOOST_REQUIRE(query.set(test::block2, test::context, false, false)); @@ -183,7 +180,7 @@ BOOST_AUTO_TEST_CASE(query_initialize__get_fork__initialized__0) settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); BOOST_REQUIRE(query.set(test::genesis, test::context, false, false)); BOOST_REQUIRE(query.push_candidate(query.to_header(test::genesis.hash()))); BOOST_REQUIRE(query.push_confirmed(query.to_header(test::genesis.hash()), false)); @@ -196,7 +193,7 @@ BOOST_AUTO_TEST_CASE(query_initialize__get_fork__candidate_ahead__expected) settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); BOOST_REQUIRE(query.set(test::genesis, test::context, false, false)); BOOST_REQUIRE(query.set(test::block1, test::context, false, false)); BOOST_REQUIRE(query.set(test::block2, test::context, false, false)); @@ -214,7 +211,7 @@ BOOST_AUTO_TEST_CASE(query_initialize__get_fork__confirmed_ahead__expected) settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); BOOST_REQUIRE(query.set(test::genesis, test::context, false, false)); BOOST_REQUIRE(query.set(test::block1, test::context, false, false)); BOOST_REQUIRE(query.set(test::block2, test::context, false, false)); @@ -234,7 +231,7 @@ BOOST_AUTO_TEST_CASE(query_initialize__get_top_associated_from__terminal__max_si settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE_EQUAL(query.get_top_associated_from(max_size_t), max_size_t); BOOST_REQUIRE_EQUAL(query.get_top_associated_from(height_link::terminal), max_size_t); @@ -250,7 +247,7 @@ BOOST_AUTO_TEST_CASE(query_initialize__get_top_associated_from__initialized__zer settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE_EQUAL(query.get_top_associated(), 0u); BOOST_REQUIRE_EQUAL(query.get_top_associated_from(0), 0u); @@ -265,7 +262,7 @@ BOOST_AUTO_TEST_CASE(query_initialize__get_top_associated_from__non_candidate__e settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE(query.set(test::block1, test::context, false, false)); BOOST_REQUIRE(query.set(test::block2, test::context, false, false)); @@ -287,7 +284,7 @@ BOOST_AUTO_TEST_CASE(query_initialize__get_top_associated_from__gapped_candidate settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE(query.set(test::block1, test::context, false, false)); BOOST_REQUIRE(query.set(test::block2.header(), test::context, false)); // header only @@ -314,7 +311,7 @@ BOOST_AUTO_TEST_CASE(query_initialize__get_unassociated_above__initialized__empt settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE(query.get_all_unassociated().empty()); BOOST_REQUIRE(query.get_unassociated_above(0).empty()); @@ -327,7 +324,7 @@ BOOST_AUTO_TEST_CASE(query_initialize__get_unassociated_above__gapped_candidate_ settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); constexpr database::context context2 { @@ -438,7 +435,7 @@ BOOST_AUTO_TEST_CASE(query_initialize__get_unassociated_count_above__gapped_cand settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); constexpr database::context context2 { diff --git a/test/query/network.cpp b/test/query/locator.cpp similarity index 85% rename from test/query/network.cpp rename to test/query/locator.cpp index 4cbbd6e9..bad38e38 100644 --- a/test/query/network.cpp +++ b/test/query/locator.cpp @@ -20,9 +20,7 @@ #include "../mocks/blocks.hpp" #include "../mocks/chunk_store.hpp" -BOOST_FIXTURE_TEST_SUITE(query_network_tests, test::directory_setup_fixture) - -const auto events_handler = [](auto, auto) {}; +BOOST_FIXTURE_TEST_SUITE(query_locator_tests, test::directory_setup_fixture) class query_access : public test::query_accessor @@ -40,13 +38,13 @@ class query_access // get_headers -BOOST_AUTO_TEST_CASE(query_network__get_headers__empty_locator__returns_confirmed_headers) +BOOST_AUTO_TEST_CASE(query_locator__get_headers__empty_locator__returns_confirmed_headers) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; query_access query{ store }; - BOOST_REQUIRE(!store.create(events_handler)); + BOOST_REQUIRE(!store.create(test::events_handler)); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE(query.set(test::block1, context{ 0, 1, 0 }, false, false)); BOOST_REQUIRE(query.set(test::block2, context{ 0, 2, 0 }, false, false)); @@ -63,13 +61,13 @@ BOOST_AUTO_TEST_CASE(query_network__get_headers__empty_locator__returns_confirme BOOST_REQUIRE_EQUAL(headers[2]->hash(), test::block3_hash); } -BOOST_AUTO_TEST_CASE(query_network__get_headers__genesis_locator__returns_all_confirmed) +BOOST_AUTO_TEST_CASE(query_locator__get_headers__genesis_locator__returns_all_confirmed) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; query_access query{ store }; - BOOST_REQUIRE(!store.create(events_handler)); + BOOST_REQUIRE(!store.create(test::events_handler)); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE(query.set(test::block1, context{ 0, 1, 0 }, false, false)); BOOST_REQUIRE(query.set(test::block2, context{ 0, 2, 0 }, false, false)); @@ -83,13 +81,13 @@ BOOST_AUTO_TEST_CASE(query_network__get_headers__genesis_locator__returns_all_co BOOST_REQUIRE_EQUAL(headers[1]->hash(), test::block2_hash); } -BOOST_AUTO_TEST_CASE(query_network__get_headers__mid_chain_locator__starts_after_fork) +BOOST_AUTO_TEST_CASE(query_locator__get_headers__mid_chain_locator__starts_after_fork) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; query_access query{ store }; - BOOST_REQUIRE(!store.create(events_handler)); + BOOST_REQUIRE(!store.create(test::events_handler)); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE(query.set(test::block1, context{ 0, 1, 0 }, false, false)); BOOST_REQUIRE(query.set(test::block2, context{ 0, 2, 0 }, false, false)); @@ -105,13 +103,13 @@ BOOST_AUTO_TEST_CASE(query_network__get_headers__mid_chain_locator__starts_after BOOST_REQUIRE_EQUAL(headers[1]->hash(), test::block3_hash); } -BOOST_AUTO_TEST_CASE(query_network__get_headers__highest_first_locator__correct) +BOOST_AUTO_TEST_CASE(query_locator__get_headers__highest_first_locator__correct) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; query_access query{ store }; - BOOST_REQUIRE(!store.create(events_handler)); + BOOST_REQUIRE(!store.create(test::events_handler)); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE(query.set(test::block1, context{ 0, 1, 0 }, false, false)); BOOST_REQUIRE(query.set(test::block2, context{ 0, 2, 0 }, false, false)); @@ -126,13 +124,13 @@ BOOST_AUTO_TEST_CASE(query_network__get_headers__highest_first_locator__correct) BOOST_REQUIRE_EQUAL(headers[0]->hash(), test::block3_hash); } -BOOST_AUTO_TEST_CASE(query_network__get_headers__stop_hash__excludes_stop_and_later) +BOOST_AUTO_TEST_CASE(query_locator__get_headers__stop_hash__excludes_stop_and_later) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; query_access query{ store }; - BOOST_REQUIRE(!store.create(events_handler)); + BOOST_REQUIRE(!store.create(test::events_handler)); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE(query.set(test::block1, context{ 0, 1, 0 }, false, false)); BOOST_REQUIRE(query.set(test::block2, context{ 0, 2, 0 }, false, false)); @@ -147,13 +145,13 @@ BOOST_AUTO_TEST_CASE(query_network__get_headers__stop_hash__excludes_stop_and_la BOOST_REQUIRE_EQUAL(headers[0]->hash(), test::block1_hash); } -BOOST_AUTO_TEST_CASE(query_network__get_headers__limit__respects_limit) +BOOST_AUTO_TEST_CASE(query_locator__get_headers__limit__respects_limit) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; query_access query{ store }; - BOOST_REQUIRE(!store.create(events_handler)); + BOOST_REQUIRE(!store.create(test::events_handler)); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE(query.set(test::block1, context{ 0, 1, 0 }, false, false)); BOOST_REQUIRE(query.set(test::block2, context{ 0, 2, 0 }, false, false)); @@ -169,13 +167,13 @@ BOOST_AUTO_TEST_CASE(query_network__get_headers__limit__respects_limit) BOOST_REQUIRE_EQUAL(headers[1]->hash(), test::block2_hash); } -BOOST_AUTO_TEST_CASE(query_network__get_headers__no_confirmed_blocks__empty) +BOOST_AUTO_TEST_CASE(query_locator__get_headers__no_confirmed_blocks__empty) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; query_access query{ store }; - BOOST_REQUIRE(!store.create(events_handler)); + BOOST_REQUIRE(!store.create(test::events_handler)); BOOST_REQUIRE(query.initialize(test::genesis)); const hashes locator{}; @@ -183,13 +181,13 @@ BOOST_AUTO_TEST_CASE(query_network__get_headers__no_confirmed_blocks__empty) BOOST_REQUIRE(headers.empty()); } -BOOST_AUTO_TEST_CASE(query_network__get_headers__reorg_terminal__returns_empty) +BOOST_AUTO_TEST_CASE(query_locator__get_headers__reorg_terminal__returns_empty) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; query_access query{ store }; - BOOST_REQUIRE(!store.create(events_handler)); + BOOST_REQUIRE(!store.create(test::events_handler)); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE(query.set(test::block1, context{ 0, 1, 0 }, false, false)); BOOST_REQUIRE(query.set(test::block2, context{ 0, 2, 0 }, false, false)); @@ -205,13 +203,13 @@ BOOST_AUTO_TEST_CASE(query_network__get_headers__reorg_terminal__returns_empty) // get_blocks -BOOST_AUTO_TEST_CASE(query_network__get_blocks__empty_locator__confirmed_headers) +BOOST_AUTO_TEST_CASE(query_locator__get_blocks__empty_locator__confirmed_headers) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; query_access query{ store }; - BOOST_REQUIRE(!store.create(events_handler)); + BOOST_REQUIRE(!store.create(test::events_handler)); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE(query.set(test::block1, context{ 0, 1, 0 }, false, false)); BOOST_REQUIRE(query.set(test::block2, context{ 0, 2, 0 }, false, false)); @@ -228,13 +226,13 @@ BOOST_AUTO_TEST_CASE(query_network__get_blocks__empty_locator__confirmed_headers BOOST_REQUIRE_EQUAL(blocks[2], test::block3_hash); } -BOOST_AUTO_TEST_CASE(query_network__get_blocks__genesis_locator__all_confirmed) +BOOST_AUTO_TEST_CASE(query_locator__get_blocks__genesis_locator__all_confirmed) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; query_access query{ store }; - BOOST_REQUIRE(!store.create(events_handler)); + BOOST_REQUIRE(!store.create(test::events_handler)); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE(query.set(test::block1, context{ 0, 1, 0 }, false, false)); BOOST_REQUIRE(query.set(test::block2, context{ 0, 2, 0 }, false, false)); @@ -248,13 +246,13 @@ BOOST_AUTO_TEST_CASE(query_network__get_blocks__genesis_locator__all_confirmed) BOOST_REQUIRE_EQUAL(blocks[1], test::block2_hash); } -BOOST_AUTO_TEST_CASE(query_network__get_blocks__mid_chain_locator__starts_after_fork) +BOOST_AUTO_TEST_CASE(query_locator__get_blocks__mid_chain_locator__starts_after_fork) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; query_access query{ store }; - BOOST_REQUIRE(!store.create(events_handler)); + BOOST_REQUIRE(!store.create(test::events_handler)); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE(query.set(test::block1, context{ 0, 1, 0 }, false, false)); BOOST_REQUIRE(query.set(test::block2, context{ 0, 2, 0 }, false, false)); @@ -270,13 +268,13 @@ BOOST_AUTO_TEST_CASE(query_network__get_blocks__mid_chain_locator__starts_after_ BOOST_REQUIRE_EQUAL(blocks[1], test::block3_hash); } -BOOST_AUTO_TEST_CASE(query_network__get_blocks__highest_first_locator__expected) +BOOST_AUTO_TEST_CASE(query_locator__get_blocks__highest_first_locator__expected) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; query_access query{ store }; - BOOST_REQUIRE(!store.create(events_handler)); + BOOST_REQUIRE(!store.create(test::events_handler)); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE(query.set(test::block1, context{ 0, 1, 0 }, false, false)); BOOST_REQUIRE(query.set(test::block2, context{ 0, 2, 0 }, false, false)); @@ -291,13 +289,13 @@ BOOST_AUTO_TEST_CASE(query_network__get_blocks__highest_first_locator__expected) BOOST_REQUIRE_EQUAL(blocks[0], test::block3_hash); } -BOOST_AUTO_TEST_CASE(query_network__get_blocks__stop_hash__excludes_stop_and_after) +BOOST_AUTO_TEST_CASE(query_locator__get_blocks__stop_hash__excludes_stop_and_after) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; query_access query{ store }; - BOOST_REQUIRE(!store.create(events_handler)); + BOOST_REQUIRE(!store.create(test::events_handler)); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE(query.set(test::block1, context{ 0, 1, 0 }, false, false)); BOOST_REQUIRE(query.set(test::block2, context{ 0, 2, 0 }, false, false)); @@ -312,13 +310,13 @@ BOOST_AUTO_TEST_CASE(query_network__get_blocks__stop_hash__excludes_stop_and_aft BOOST_REQUIRE_EQUAL(blocks[0], test::block1_hash); } -BOOST_AUTO_TEST_CASE(query_network__get_blocks__limit__respects_limit) +BOOST_AUTO_TEST_CASE(query_locator__get_blocks__limit__respects_limit) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; query_access query{ store }; - BOOST_REQUIRE(!store.create(events_handler)); + BOOST_REQUIRE(!store.create(test::events_handler)); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE(query.set(test::block1, context{ 0, 1, 0 }, false, false)); BOOST_REQUIRE(query.set(test::block2, context{ 0, 2, 0 }, false, false)); @@ -334,13 +332,13 @@ BOOST_AUTO_TEST_CASE(query_network__get_blocks__limit__respects_limit) BOOST_REQUIRE_EQUAL(blocks[1], test::block2_hash); } -BOOST_AUTO_TEST_CASE(query_network__get_blocks__no_confirmed_blocks__empty) +BOOST_AUTO_TEST_CASE(query_locator__get_blocks__no_confirmed_blocks__empty) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; query_access query{ store }; - BOOST_REQUIRE(!store.create(events_handler)); + BOOST_REQUIRE(!store.create(test::events_handler)); BOOST_REQUIRE(query.initialize(test::genesis)); const hashes locator{}; @@ -348,13 +346,13 @@ BOOST_AUTO_TEST_CASE(query_network__get_blocks__no_confirmed_blocks__empty) BOOST_REQUIRE(blocks.empty()); } -BOOST_AUTO_TEST_CASE(query_network__get_blocks__reorg_terminal__returns_empty) +BOOST_AUTO_TEST_CASE(query_locator__get_blocks__reorg_terminal__returns_empty) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; query_access query{ store }; - BOOST_REQUIRE(!store.create(events_handler)); + BOOST_REQUIRE(!store.create(test::events_handler)); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE(query.set(test::block1, context{ 0, 1, 0 }, false, false)); BOOST_REQUIRE(query.set(test::block2, context{ 0, 2, 0 }, false, false)); @@ -370,13 +368,13 @@ BOOST_AUTO_TEST_CASE(query_network__get_blocks__reorg_terminal__returns_empty) // get_locator_span -BOOST_AUTO_TEST_CASE(query_network__get_locator_span__empty_locator__starts_after_genesis) +BOOST_AUTO_TEST_CASE(query_locator__get_locator_span__empty_locator__starts_after_genesis) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; query_access query{ store }; - BOOST_REQUIRE(!store.create(events_handler)); + BOOST_REQUIRE(!store.create(test::events_handler)); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE(query.set(test::block1, context{ 0, 1, 0 }, false, false)); BOOST_REQUIRE(query.set(test::block2, context{ 0, 2, 0 }, false, false)); @@ -392,13 +390,13 @@ BOOST_AUTO_TEST_CASE(query_network__get_locator_span__empty_locator__starts_afte BOOST_REQUIRE_EQUAL(span.size(), 3u); } -BOOST_AUTO_TEST_CASE(query_network__get_locator_span__genesis_locator__starts_after_genesis) +BOOST_AUTO_TEST_CASE(query_locator__get_locator_span__genesis_locator__starts_after_genesis) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; query_access query{ store }; - BOOST_REQUIRE(!store.create(events_handler)); + BOOST_REQUIRE(!store.create(test::events_handler)); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE(query.set(test::block1, context{ 0, 1, 0 }, false, false)); BOOST_REQUIRE(query.set(test::block2, context{ 0, 2, 0 }, false, false)); @@ -412,13 +410,13 @@ BOOST_AUTO_TEST_CASE(query_network__get_locator_span__genesis_locator__starts_af BOOST_REQUIRE_EQUAL(span.size(), 2u); } -BOOST_AUTO_TEST_CASE(query_network__get_locator_span__mid_chain_locator__starts_after_fork) +BOOST_AUTO_TEST_CASE(query_locator__get_locator_span__mid_chain_locator__starts_after_fork) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; query_access query{ store }; - BOOST_REQUIRE(!store.create(events_handler)); + BOOST_REQUIRE(!store.create(test::events_handler)); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE(query.set(test::block1, context{ 0, 1, 0 }, false, false)); BOOST_REQUIRE(query.set(test::block2, context{ 0, 2, 0 }, false, false)); @@ -434,13 +432,13 @@ BOOST_AUTO_TEST_CASE(query_network__get_locator_span__mid_chain_locator__starts_ BOOST_REQUIRE_EQUAL(span.size(), 2u); } -BOOST_AUTO_TEST_CASE(query_network__get_locator_span__stop_hash__limits_to_stop_exclusive) +BOOST_AUTO_TEST_CASE(query_locator__get_locator_span__stop_hash__limits_to_stop_exclusive) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; query_access query{ store }; - BOOST_REQUIRE(!store.create(events_handler)); + BOOST_REQUIRE(!store.create(test::events_handler)); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE(query.set(test::block1, context{ 0, 1, 0 }, false, false)); BOOST_REQUIRE(query.set(test::block2, context{ 0, 2, 0 }, false, false)); @@ -456,13 +454,13 @@ BOOST_AUTO_TEST_CASE(query_network__get_locator_span__stop_hash__limits_to_stop_ BOOST_REQUIRE_EQUAL(span.size(), 1u); } -BOOST_AUTO_TEST_CASE(query_network__get_locator_span__limit_smaller_than_range__respects_limit) +BOOST_AUTO_TEST_CASE(query_locator__get_locator_span__limit_smaller_than_range__respects_limit) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; query_access query{ store }; - BOOST_REQUIRE(!store.create(events_handler)); + BOOST_REQUIRE(!store.create(test::events_handler)); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE(query.set(test::block1, context{ 0, 1, 0 }, false, false)); BOOST_REQUIRE(query.set(test::block2, context{ 0, 2, 0 }, false, false)); @@ -478,13 +476,13 @@ BOOST_AUTO_TEST_CASE(query_network__get_locator_span__limit_smaller_than_range__ BOOST_REQUIRE_EQUAL(span.size(), 2u); } -BOOST_AUTO_TEST_CASE(query_network__get_locator_span__no_confirmed_blocks__empty_span) +BOOST_AUTO_TEST_CASE(query_locator__get_locator_span__no_confirmed_blocks__empty_span) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; query_access query{ store }; - BOOST_REQUIRE(!store.create(events_handler)); + BOOST_REQUIRE(!store.create(test::events_handler)); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE(query.set(test::block1, context{ 0, 1, 0 }, false, false)); @@ -495,13 +493,13 @@ BOOST_AUTO_TEST_CASE(query_network__get_locator_span__no_confirmed_blocks__empty BOOST_REQUIRE_EQUAL(span.size(), 0u); } -BOOST_AUTO_TEST_CASE(query_network__get_locator_span__stop_before_start__empty_span) +BOOST_AUTO_TEST_CASE(query_locator__get_locator_span__stop_before_start__empty_span) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; query_access query{ store }; - BOOST_REQUIRE(!store.create(events_handler)); + BOOST_REQUIRE(!store.create(test::events_handler)); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE(query.set(test::block1, context{ 0, 1, 0 }, false, false)); BOOST_REQUIRE(query.push_confirmed(1, false)); @@ -513,13 +511,13 @@ BOOST_AUTO_TEST_CASE(query_network__get_locator_span__stop_before_start__empty_s BOOST_REQUIRE_EQUAL(span.size(), 0u); } -BOOST_AUTO_TEST_CASE(query_network__get_locator_span__large_limit__capped_by_top_confirmed) +BOOST_AUTO_TEST_CASE(query_locator__get_locator_span__large_limit__capped_by_top_confirmed) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; query_access query{ store }; - BOOST_REQUIRE(!store.create(events_handler)); + BOOST_REQUIRE(!store.create(test::events_handler)); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE(query.set(test::block1, context{ 0, 1, 0 }, false, false)); BOOST_REQUIRE(query.push_confirmed(1, false)); @@ -533,35 +531,35 @@ BOOST_AUTO_TEST_CASE(query_network__get_locator_span__large_limit__capped_by_top // get_locator_start -BOOST_AUTO_TEST_CASE(query_network__get_locator_start__empty__zero) +BOOST_AUTO_TEST_CASE(query_locator__get_locator_start__empty__zero) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; query_access query{ store }; - BOOST_REQUIRE(!store.create(events_handler)); + BOOST_REQUIRE(!store.create(test::events_handler)); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE_EQUAL(query.get_locator_start({}), 0u); } -BOOST_AUTO_TEST_CASE(query_network__get_locator_start__genesis__zero) +BOOST_AUTO_TEST_CASE(query_locator__get_locator_start__genesis__zero) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; query_access query{ store }; - BOOST_REQUIRE(!store.create(events_handler)); + BOOST_REQUIRE(!store.create(test::events_handler)); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE_EQUAL(query.get_locator_start({ test::block0_hash }), 0u); } -BOOST_AUTO_TEST_CASE(query_network__get_locator_start__unconfirmed__zero) +BOOST_AUTO_TEST_CASE(query_locator__get_locator_start__unconfirmed__zero) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; query_access query{ store }; - BOOST_REQUIRE(!store.create(events_handler)); + BOOST_REQUIRE(!store.create(test::events_handler)); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE(query.set(test::block1, context{ 0, 1, 0 }, false, false)); BOOST_REQUIRE(query.set(test::block2, context{ 0, 2, 0 }, false, false)); @@ -569,13 +567,13 @@ BOOST_AUTO_TEST_CASE(query_network__get_locator_start__unconfirmed__zero) BOOST_REQUIRE_EQUAL(query.get_locator_start({ test::block1_hash }), 0u); } -BOOST_AUTO_TEST_CASE(query_network__get_locator_start__confirmed__first_match) +BOOST_AUTO_TEST_CASE(query_locator__get_locator_start__confirmed__first_match) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; query_access query{ store }; - BOOST_REQUIRE(!store.create(events_handler)); + BOOST_REQUIRE(!store.create(test::events_handler)); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE(query.set(test::block1, context{ 0, 1, 0 }, false, false)); BOOST_REQUIRE(query.set(test::block2, context{ 0, 2, 0 }, false, false)); @@ -588,13 +586,13 @@ BOOST_AUTO_TEST_CASE(query_network__get_locator_start__confirmed__first_match) // get_ancestry -BOOST_AUTO_TEST_CASE(query_network__get_ancestry__genesis__empty) +BOOST_AUTO_TEST_CASE(query_locator__get_ancestry__genesis__empty) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; query_access query{ store }; - BOOST_REQUIRE(!store.create(events_handler)); + BOOST_REQUIRE(!store.create(test::events_handler)); BOOST_REQUIRE(query.initialize(test::genesis)); header_links ancestry{}; @@ -602,13 +600,13 @@ BOOST_AUTO_TEST_CASE(query_network__get_ancestry__genesis__empty) BOOST_REQUIRE(ancestry.empty()); } -BOOST_AUTO_TEST_CASE(query_network__get_ancestry__genesis__itself) +BOOST_AUTO_TEST_CASE(query_locator__get_ancestry__genesis__itself) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; query_access query{ store }; - BOOST_REQUIRE(!store.create(events_handler)); + BOOST_REQUIRE(!store.create(test::events_handler)); BOOST_REQUIRE(query.initialize(test::genesis)); header_links ancestry{}; @@ -617,13 +615,13 @@ BOOST_AUTO_TEST_CASE(query_network__get_ancestry__genesis__itself) BOOST_REQUIRE_EQUAL(ancestry[0], 0u); } -BOOST_AUTO_TEST_CASE(query_network__get_ancestry__single_block__itself) +BOOST_AUTO_TEST_CASE(query_locator__get_ancestry__single_block__itself) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; query_access query{ store }; - BOOST_REQUIRE(!store.create(events_handler)); + BOOST_REQUIRE(!store.create(test::events_handler)); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE(query.set(test::block1, context{ 0, 1, 0 }, false, false)); @@ -634,13 +632,13 @@ BOOST_AUTO_TEST_CASE(query_network__get_ancestry__single_block__itself) BOOST_REQUIRE_EQUAL(ancestry[1], 0u); } -BOOST_AUTO_TEST_CASE(query_network__get_ancestry__linear_chain__full_ancestry) +BOOST_AUTO_TEST_CASE(query_locator__get_ancestry__linear_chain__full_ancestry) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; query_access query{ store }; - BOOST_REQUIRE(!store.create(events_handler)); + BOOST_REQUIRE(!store.create(test::events_handler)); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE(query.set(test::block1, context{ 0, 1, 0 }, false, false)); BOOST_REQUIRE(query.set(test::block2, context{ 0, 2, 0 }, false, false)); @@ -655,13 +653,13 @@ BOOST_AUTO_TEST_CASE(query_network__get_ancestry__linear_chain__full_ancestry) BOOST_REQUIRE_EQUAL(ancestry[3], 0u); } -BOOST_AUTO_TEST_CASE(query_network__get_ancestry__count_limit__truncated) +BOOST_AUTO_TEST_CASE(query_locator__get_ancestry__count_limit__truncated) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; query_access query{ store }; - BOOST_REQUIRE(!store.create(events_handler)); + BOOST_REQUIRE(!store.create(test::events_handler)); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE(query.set(test::block1, context{ 0, 1, 0 }, false, false)); BOOST_REQUIRE(query.set(test::block2, context{ 0, 2, 0 }, false, false)); @@ -674,13 +672,13 @@ BOOST_AUTO_TEST_CASE(query_network__get_ancestry__count_limit__truncated) BOOST_REQUIRE_EQUAL(ancestry[1], 2u); } -BOOST_AUTO_TEST_CASE(query_network__get_ancestry__count_exceeds_height__full_to_genesis) +BOOST_AUTO_TEST_CASE(query_locator__get_ancestry__count_exceeds_height__full_to_genesis) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; query_access query{ store }; - BOOST_REQUIRE(!store.create(events_handler)); + BOOST_REQUIRE(!store.create(test::events_handler)); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE(query.set(test::block1, context{ 0, 1, 0 }, false, false)); BOOST_REQUIRE(query.set(test::block2, context{ 0, 2, 0 }, false, false)); @@ -693,13 +691,13 @@ BOOST_AUTO_TEST_CASE(query_network__get_ancestry__count_exceeds_height__full_to_ BOOST_REQUIRE_EQUAL(ancestry[2], 0u); } -BOOST_AUTO_TEST_CASE(query_network__get_ancestry__nonexistent_link__false_empty) +BOOST_AUTO_TEST_CASE(query_locator__get_ancestry__nonexistent_link__false_empty) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; query_access query{ store }; - BOOST_REQUIRE(!store.create(events_handler)); + BOOST_REQUIRE(!store.create(test::events_handler)); BOOST_REQUIRE(query.initialize(test::genesis)); header_links ancestry{}; diff --git a/test/query/merkle.cpp b/test/query/merkle.cpp index 4df6557d..204c9f14 100644 --- a/test/query/merkle.cpp +++ b/test/query/merkle.cpp @@ -22,9 +22,6 @@ BOOST_FIXTURE_TEST_SUITE(query_merkle_tests, test::directory_setup_fixture) -// nop event handler. -const auto events_handler = [](auto, auto) {}; - // Example vector from electrumx documentation. // electrumx.readthedocs.io/en/latest/protocol-methods.html#cp-height-example //{ @@ -216,7 +213,7 @@ BOOST_AUTO_TEST_CASE(query_merkle__interval_span__11__2048) settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; merkle_accessor query{ store }; - BOOST_CHECK_EQUAL(store.create(events_handler), error::success); + BOOST_CHECK_EQUAL(store.create(test::events_handler), error::success); BOOST_CHECK(query.initialize(test::genesis)); BOOST_CHECK_EQUAL(query.interval_span(), 2048u); } @@ -228,7 +225,7 @@ BOOST_AUTO_TEST_CASE(query_merkle__interval_span__0__1) settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; merkle_accessor query{ store }; - BOOST_CHECK_EQUAL(store.create(events_handler), error::success); + BOOST_CHECK_EQUAL(store.create(test::events_handler), error::success); BOOST_CHECK(query.initialize(test::genesis)); BOOST_CHECK_EQUAL(query.interval_span(), 1u); } @@ -242,7 +239,7 @@ BOOST_AUTO_TEST_CASE(query_merkle__create_interval__depth_0__block_hash) settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; merkle_accessor query{ store }; - BOOST_CHECK_EQUAL(store.create(events_handler), error::success); + BOOST_CHECK_EQUAL(store.create(test::events_handler), error::success); BOOST_CHECK(query.initialize(test::genesis)); BOOST_CHECK(query.set(test::block1, context{ 0, 1, 0 }, false, false)); BOOST_CHECK(query.set(test::block2, context{ 0, 2, 0 }, false, false)); @@ -273,7 +270,7 @@ BOOST_AUTO_TEST_CASE(query_merkle__create_interval__depth_1__expected) settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; merkle_accessor query{ store }; - BOOST_CHECK_EQUAL(store.create(events_handler), error::success); + BOOST_CHECK_EQUAL(store.create(test::events_handler), error::success); BOOST_CHECK(query.initialize(test::genesis)); BOOST_CHECK(query.set(test::block1, context{ 0, 1, 0 }, false, false)); BOOST_CHECK(query.set(test::block2, context{ 0, 2, 0 }, false, false)); @@ -302,7 +299,7 @@ BOOST_AUTO_TEST_CASE(query_merkle__create_interval__depth_2__expected) settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; merkle_accessor query{ store }; - BOOST_CHECK_EQUAL(store.create(events_handler), error::success); + BOOST_CHECK_EQUAL(store.create(test::events_handler), error::success); BOOST_CHECK(query.initialize(test::genesis)); BOOST_CHECK(query.set(test::block1, context{ 0, 1, 0 }, false, false)); BOOST_CHECK(query.set(test::block2, context{ 0, 2, 0 }, false, false)); @@ -324,7 +321,7 @@ BOOST_AUTO_TEST_CASE(query_merkle__get_confirmed_interval__not_multiple__no_valu test::chunk_store store{ settings }; merkle_accessor query{ store }; BOOST_CHECK_EQUAL(query.interval_span(), system::power2(settings.interval_depth)); - BOOST_CHECK_EQUAL(store.create(events_handler), error::success); + BOOST_CHECK_EQUAL(store.create(test::events_handler), error::success); BOOST_CHECK(query.initialize(test::genesis)); BOOST_CHECK(!query.get_confirmed_interval(0).has_value()); BOOST_CHECK(!query.get_confirmed_interval(1).has_value()); @@ -342,7 +339,7 @@ BOOST_AUTO_TEST_CASE(query_merkle__get_confirmed_interval__multiple__expected_va test::chunk_store store{ settings }; merkle_accessor query{ store }; BOOST_CHECK_EQUAL(query.interval_span(), system::power2(settings.interval_depth)); - BOOST_CHECK_EQUAL(store.create(events_handler), error::success); + BOOST_CHECK_EQUAL(store.create(test::events_handler), error::success); BOOST_CHECK(query.initialize(test::genesis)); BOOST_CHECK(query.set(test::block1, context{ 0, 1, 0 }, false, false)); BOOST_CHECK(query.set(test::block2, context{ 0, 2, 0 }, false, false)); @@ -429,7 +426,7 @@ BOOST_AUTO_TEST_CASE(query_merkle__get_merkle_proof__no_confirmed_blocks__error_ settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; merkle_accessor query{ store }; - BOOST_CHECK_EQUAL(store.create(events_handler), error::success); + BOOST_CHECK_EQUAL(store.create(test::events_handler), error::success); BOOST_CHECK(query.initialize(test::genesis)); hashes proof{}; @@ -444,7 +441,7 @@ BOOST_AUTO_TEST_CASE(query_merkle__get_merkle_proof__target_in_first_interval__e settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; merkle_accessor query{ store }; - BOOST_CHECK_EQUAL(store.create(events_handler), error::success); + BOOST_CHECK_EQUAL(store.create(test::events_handler), error::success); BOOST_CHECK(query.initialize(test::genesis)); BOOST_CHECK(query.set(test::block1, context{ 0, 1, 0 }, false, false)); BOOST_CHECK(query.set(test::block2, context{ 0, 2, 0 }, false, false)); @@ -467,7 +464,7 @@ BOOST_AUTO_TEST_CASE(query_merkle__get_merkle_proof__multiple_intervals__expecte settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; merkle_accessor query{ store }; - BOOST_CHECK_EQUAL(store.create(events_handler), error::success); + BOOST_CHECK_EQUAL(store.create(test::events_handler), error::success); BOOST_CHECK(query.initialize(test::genesis)); BOOST_CHECK(query.set(test::block1, context{ 0, 1, 0 }, false, false)); BOOST_CHECK(query.set(test::block2, context{ 0, 2, 0 }, false, false)); @@ -497,7 +494,7 @@ BOOST_AUTO_TEST_CASE(query_merkle__get_merkle_subroots__waypoint_zero__genesis) settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; merkle_accessor query{ store }; - BOOST_CHECK_EQUAL(store.create(events_handler), error::success); + BOOST_CHECK_EQUAL(store.create(test::events_handler), error::success); BOOST_CHECK(query.initialize(test::genesis)); hashes roots{}; @@ -515,7 +512,7 @@ BOOST_AUTO_TEST_CASE(query_merkle__get_merkle_subroots__one_full_interval__expec settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; merkle_accessor query{ store }; - BOOST_CHECK_EQUAL(store.create(events_handler), error::success); + BOOST_CHECK_EQUAL(store.create(test::events_handler), error::success); BOOST_CHECK(query.initialize(test::genesis)); BOOST_CHECK(query.set(test::block1, context{ 0, 1, 0 }, false, false)); BOOST_CHECK(query.set(test::block2, context{ 0, 2, 0 }, false, false)); @@ -539,7 +536,7 @@ BOOST_AUTO_TEST_CASE(query_merkle__get_merkle_subroots__full_and_partial_interva settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; merkle_accessor query{ store }; - BOOST_CHECK_EQUAL(store.create(events_handler), error::success); + BOOST_CHECK_EQUAL(store.create(test::events_handler), error::success); BOOST_CHECK(query.initialize(test::genesis)); BOOST_CHECK(query.set(test::block1, context{ 0, 1, 0 }, false, false)); BOOST_CHECK(query.set(test::block2, context{ 0, 2, 0 }, false, false)); @@ -573,7 +570,7 @@ BOOST_AUTO_TEST_CASE(query_merkle__get_merkle_root_and_proof__target_equals_wayp settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; merkle_accessor query{ store }; - BOOST_CHECK_EQUAL(store.create(events_handler), error::success); + BOOST_CHECK_EQUAL(store.create(test::events_handler), error::success); BOOST_CHECK(query.initialize(test::genesis)); BOOST_CHECK(query.set(test::block1, context{ 0, 1, 0 }, false, false)); BOOST_CHECK(query.set(test::block2, context{ 0, 2, 0 }, false, false)); @@ -599,7 +596,7 @@ BOOST_AUTO_TEST_CASE(query_merkle__get_merkle_root_and_proof__target_less_than_w settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; merkle_accessor query{ store }; - BOOST_CHECK_EQUAL(store.create(events_handler), error::success); + BOOST_CHECK_EQUAL(store.create(test::events_handler), error::success); BOOST_CHECK(query.initialize(test::genesis)); BOOST_CHECK(query.set(test::block1, context{ 0, 1, 0 }, false, false)); BOOST_CHECK(query.set(test::block2, context{ 0, 2, 0 }, false, false)); @@ -646,7 +643,7 @@ BOOST_AUTO_TEST_CASE(query_merkle__get_merkle_root_and_proof__electrumx_example_ settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; merkle_accessor query{ store }; - BOOST_CHECK_EQUAL(store.create(events_handler), error::success); + BOOST_CHECK_EQUAL(store.create(test::events_handler), error::success); BOOST_CHECK(setup_eight_block_store(query)); hashes roots{}; @@ -682,7 +679,7 @@ BOOST_AUTO_TEST_CASE(query_merkle__get_merkle_root_and_proof__electrumx_example_ settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; merkle_accessor query{ store }; - BOOST_CHECK_EQUAL(store.create(events_handler), error::success); + BOOST_CHECK_EQUAL(store.create(test::events_handler), error::success); BOOST_CHECK(setup_eight_block_store(query)); hashes roots{}; @@ -714,7 +711,7 @@ BOOST_AUTO_TEST_CASE(query_merkle__get_merkle_root_and_proof__electrumx_example_ settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; merkle_accessor query{ store }; - BOOST_CHECK_EQUAL(store.create(events_handler), error::success); + BOOST_CHECK_EQUAL(store.create(test::events_handler), error::success); BOOST_CHECK(setup_eight_block_store(query)); hashes roots{}; @@ -744,7 +741,7 @@ BOOST_AUTO_TEST_CASE(query_merkle__get_merkle_root_and_proof__electrumx_example_ settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; merkle_accessor query{ store }; - BOOST_CHECK_EQUAL(store.create(events_handler), error::success); + BOOST_CHECK_EQUAL(store.create(test::events_handler), error::success); BOOST_CHECK(setup_eight_block_store(query)); hashes roots{}; @@ -773,7 +770,7 @@ BOOST_AUTO_TEST_CASE(query_merkle__get_merkle_root_and_proof__electrumx_example_ settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; merkle_accessor query{ store }; - BOOST_CHECK_EQUAL(store.create(events_handler), error::success); + BOOST_CHECK_EQUAL(store.create(test::events_handler), error::success); BOOST_CHECK(setup_eight_block_store(query)); hashes roots{}; @@ -801,7 +798,7 @@ BOOST_AUTO_TEST_CASE(query_merkle__get_merkle_root_and_proof__electrumx_example_ settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; merkle_accessor query{ store }; - BOOST_CHECK_EQUAL(store.create(events_handler), error::success); + BOOST_CHECK_EQUAL(store.create(test::events_handler), error::success); BOOST_CHECK(setup_eight_block_store(query)); hashes roots{}; @@ -830,7 +827,7 @@ BOOST_AUTO_TEST_CASE(query_merkle__get_merkle_root_and_proof__target_8_depth_0__ settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; merkle_accessor query{ store }; - BOOST_CHECK_EQUAL(store.create(events_handler), error::success); + BOOST_CHECK_EQUAL(store.create(test::events_handler), error::success); BOOST_CHECK(setup_eight_block_store(query)); hashes roots{}; @@ -866,7 +863,7 @@ BOOST_AUTO_TEST_CASE(query_merkle__get_merkle_root_and_proof__partial_interval_w settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; merkle_accessor query{ store }; - BOOST_CHECK_EQUAL(store.create(events_handler), error::success); + BOOST_CHECK_EQUAL(store.create(test::events_handler), error::success); BOOST_CHECK(setup_eight_block_store(query)); const auto root42 = system::sha256::double_hash(test::block4_hash, test::block4_hash); @@ -900,7 +897,7 @@ BOOST_AUTO_TEST_CASE(query_merkle__get_merkle_root_and_proof__target_greater_tha settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; merkle_accessor query{ store }; - BOOST_CHECK_EQUAL(store.create(events_handler), error::success); + BOOST_CHECK_EQUAL(store.create(test::events_handler), error::success); BOOST_CHECK(query.initialize(test::genesis)); hashes proof{}; @@ -916,7 +913,7 @@ BOOST_AUTO_TEST_CASE(query_merkle__get_merkle_root_and_proof__waypoint_beyond_to settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; merkle_accessor query{ store }; - BOOST_CHECK_EQUAL(store.create(events_handler), error::success); + BOOST_CHECK_EQUAL(store.create(test::events_handler), error::success); BOOST_CHECK(query.initialize(test::genesis)); hashes proof{}; diff --git a/test/query/navigate/navigate_arraymap.cpp b/test/query/navigate/navigate_arraymap.cpp new file mode 100644 index 00000000..7a36bb65 --- /dev/null +++ b/test/query/navigate/navigate_arraymap.cpp @@ -0,0 +1,45 @@ +/** + * Copyright (c) 2011-2026 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +#include "../../test.hpp" +#include "../../mocks/blocks.hpp" +#include "../../mocks/chunk_store.hpp" + +BOOST_FIXTURE_TEST_SUITE(query_navigate_tests, test::directory_setup_fixture) + +// to_txs + +BOOST_AUTO_TEST_CASE(query_navigate__to_txs__multiple__expected) +{ + settings settings{}; + settings.path = TEST_DIRECTORY; + test::chunk_store store{ settings }; + test::query_accessor query{ store }; + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); + BOOST_REQUIRE(query.initialize(test::genesis)); + BOOST_REQUIRE(query.set(test::block1a, test::context, false, false)); + BOOST_REQUIRE(query.set(test::block2a, test::context, false, false)); + + const tx_links expected_links2{ 2, 3 }; + BOOST_REQUIRE_EQUAL(query.to_transactions(0), tx_links{ 0 }); + BOOST_REQUIRE_EQUAL(query.to_transactions(1), tx_links{ 1 }); + BOOST_REQUIRE_EQUAL(query.to_transactions(2), expected_links2); + BOOST_REQUIRE(query.to_transactions(3).empty()); +} + +BOOST_AUTO_TEST_SUITE_END() diff --git a/test/query/navigate/navigate_forward.cpp b/test/query/navigate/navigate_forward.cpp new file mode 100644 index 00000000..c33c075b --- /dev/null +++ b/test/query/navigate/navigate_forward.cpp @@ -0,0 +1,127 @@ +/** + * Copyright (c) 2011-2026 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +#include "../../test.hpp" +#include "../../mocks/blocks.hpp" +#include "../../mocks/chunk_store.hpp" + +BOOST_FIXTURE_TEST_SUITE(query_navigate_tests, test::directory_setup_fixture) + +// to_point +// to_output +// to_previous_output + +// to_points1 +// to_points2 +// to_outputs1 +// to_outputs2 +// to_prevouts1 +// to_prevouts2 + +// to_block_points +// to_block_outputs +// to_block_prevouts + +// TODO: break this up. +BOOST_AUTO_TEST_CASE(query_navigate__to_output__various__expected) +{ + settings settings{}; + settings.path = TEST_DIRECTORY; + test::chunk_store store{ settings }; + test::query_accessor query{ store }; + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); + BOOST_REQUIRE(query.initialize(test::genesis)); + BOOST_REQUIRE(query.set(test::block1, test::context, false, false)); + BOOST_REQUIRE(query.set(test::block2, test::context, false, false)); + BOOST_REQUIRE(query.set(test::block3, test::context, false, false)); + BOOST_REQUIRE(query.set(test::block1a, test::context, false, false)); + + // All 5 blocks have one transaction with 1 output. + BOOST_REQUIRE_EQUAL(query.to_output_tx(0 * 0x51), 0u); + BOOST_REQUIRE_EQUAL(query.to_output_tx(1 * 0x51), 1u); + BOOST_REQUIRE_EQUAL(query.to_output_tx(2 * 0x51), 2u); + BOOST_REQUIRE_EQUAL(query.to_output_tx(3 * 0x51), 3u); + BOOST_REQUIRE_EQUAL(query.to_output_tx(4 * 0x51), 4u); + BOOST_REQUIRE_EQUAL(query.to_output_tx(4 * 0x51 + 7u), 4u); + + BOOST_REQUIRE_EQUAL(query.to_output(0, 0), 0u * 0x51u); + BOOST_REQUIRE_EQUAL(query.to_output(1, 0), 1u * 0x51u); + BOOST_REQUIRE_EQUAL(query.to_output(2, 0), 2u * 0x51u); + BOOST_REQUIRE_EQUAL(query.to_output(3, 0), 3u * 0x51u); + BOOST_REQUIRE_EQUAL(query.to_output(4, 0), 4u * 0x51u); + BOOST_REQUIRE_EQUAL(query.to_output(4, 1), 4u * 0x51u + 7u); + + const output_links expected_outputs4{ 4 * 0x51, 4 * 0x51 + 7 }; + BOOST_REQUIRE_EQUAL(query.to_outputs(0), output_links{ 0 * 0x51 }); + BOOST_REQUIRE_EQUAL(query.to_outputs(1), output_links{ 1 * 0x51 }); + BOOST_REQUIRE_EQUAL(query.to_outputs(2), output_links{ 2 * 0x51 }); + BOOST_REQUIRE_EQUAL(query.to_outputs(3), output_links{ 3 * 0x51 }); + BOOST_REQUIRE_EQUAL(query.to_outputs(4), expected_outputs4); + + // All blocks have one transaction. + BOOST_REQUIRE_EQUAL(query.to_block_outputs(0), output_links{ 0 * 0x51 }); + BOOST_REQUIRE_EQUAL(query.to_block_outputs(1), output_links{ 1 * 0x51 }); + BOOST_REQUIRE_EQUAL(query.to_block_outputs(2), output_links{ 2 * 0x51 }); + BOOST_REQUIRE_EQUAL(query.to_block_outputs(3), output_links{ 3 * 0x51 }); + BOOST_REQUIRE_EQUAL(query.to_block_outputs(4), expected_outputs4); + + // No prevouts that exist. + const output_links expected_prevouts4{ output_link::terminal, output_link::terminal, output_link::terminal }; + BOOST_REQUIRE_EQUAL(query.to_prevouts(0), output_links{ output_link::terminal }); + BOOST_REQUIRE_EQUAL(query.to_prevouts(1), output_links{ output_link::terminal }); + BOOST_REQUIRE_EQUAL(query.to_prevouts(2), output_links{ output_link::terminal }); + BOOST_REQUIRE_EQUAL(query.to_prevouts(3), output_links{ output_link::terminal }); + BOOST_REQUIRE_EQUAL(query.to_prevouts(4), expected_prevouts4); + + // All blocks have one transaction. + BOOST_REQUIRE_EQUAL(query.to_block_prevouts(0), output_links{}); + BOOST_REQUIRE_EQUAL(query.to_block_prevouts(1), output_links{}); + BOOST_REQUIRE_EQUAL(query.to_block_prevouts(2), output_links{}); + BOOST_REQUIRE_EQUAL(query.to_block_prevouts(3), output_links{}); + BOOST_REQUIRE_EQUAL(query.to_block_prevouts(4), output_links{}); + + // Past end. + BOOST_REQUIRE_EQUAL(query.to_output_tx(4 * 0x51 + 14), tx_link::terminal); + BOOST_REQUIRE_EQUAL(query.to_output(5, 0), output_link::terminal); + BOOST_REQUIRE(query.to_outputs(5).empty()); + BOOST_REQUIRE(query.to_block_outputs(5).empty()); +} + +// to_transactions +// to_spending_txs + +// to_coinbase + +BOOST_AUTO_TEST_CASE(query_navigate__to_coinbase__always__expected) +{ + settings settings{}; + settings.path = TEST_DIRECTORY; + test::chunk_store store{ settings }; + test::query_accessor query{ store }; + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); + BOOST_REQUIRE_EQUAL(query.to_header(test::genesis.hash()), header_link::terminal); + BOOST_REQUIRE(query.initialize(test::genesis)); + BOOST_REQUIRE_EQUAL(query.to_coinbase(0), 0u); + BOOST_REQUIRE(query.to_coinbase(1).is_terminal()); + BOOST_REQUIRE(query.set(test::block1, test::context, false, false)); + BOOST_REQUIRE_EQUAL(query.to_coinbase(1), 1u); +} + +// to_transaction + +BOOST_AUTO_TEST_SUITE_END() diff --git a/test/query/navigate/navigate_hashmap.cpp b/test/query/navigate/navigate_hashmap.cpp new file mode 100644 index 00000000..1a71155e --- /dev/null +++ b/test/query/navigate/navigate_hashmap.cpp @@ -0,0 +1,25 @@ +/** + * Copyright (c) 2011-2026 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +#include "../../test.hpp" +#include "../../mocks/blocks.hpp" +#include "../../mocks/chunk_store.hpp" + +BOOST_FIXTURE_TEST_SUITE(query_navigate_tests, test::directory_setup_fixture) + +BOOST_AUTO_TEST_SUITE_END() diff --git a/test/query/navigate/navigate_natural.cpp b/test/query/navigate/navigate_natural.cpp new file mode 100644 index 00000000..6913e7a9 --- /dev/null +++ b/test/query/navigate/navigate_natural.cpp @@ -0,0 +1,148 @@ +/** + * Copyright (c) 2011-2026 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +#include "../../test.hpp" +#include "../../mocks/blocks.hpp" +#include "../../mocks/chunk_store.hpp" + +BOOST_FIXTURE_TEST_SUITE(query_navigate_tests, test::directory_setup_fixture) + +// to_candidate + +BOOST_AUTO_TEST_CASE(query_navigate__to_candidate__always__expected) +{ + settings settings{}; + settings.path = TEST_DIRECTORY; + test::chunk_store store{ settings }; + test::query_accessor query{ store }; + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); + + // initialize pushes the genesis candidate. + BOOST_REQUIRE(query.initialize(test::genesis)); + BOOST_REQUIRE(query.set(test::block1, test::context, false, false)); + BOOST_REQUIRE(query.set(test::block2, test::context, false, false)); + BOOST_REQUIRE_EQUAL(query.to_candidate(0), 0u); + BOOST_REQUIRE_EQUAL(query.to_candidate(1), header_link::terminal); + BOOST_REQUIRE_EQUAL(query.to_candidate(2), header_link::terminal); + BOOST_REQUIRE_EQUAL(query.to_candidate(3), header_link::terminal); + BOOST_REQUIRE_EQUAL(query.to_candidate(4), header_link::terminal); + BOOST_REQUIRE_EQUAL(query.to_confirmed(0), 0u); + BOOST_REQUIRE_EQUAL(query.to_confirmed(1), header_link::terminal); + BOOST_REQUIRE_EQUAL(query.to_confirmed(2), header_link::terminal); + BOOST_REQUIRE_EQUAL(query.to_confirmed(3), header_link::terminal); + BOOST_REQUIRE_EQUAL(query.to_confirmed(4), header_link::terminal); + + // key-link translate of actual candidates. + BOOST_REQUIRE(query.push_candidate(1)); + BOOST_REQUIRE(query.push_candidate(2)); + BOOST_REQUIRE_EQUAL(query.to_candidate(0), 0u); + BOOST_REQUIRE_EQUAL(query.to_candidate(1), 1u); + BOOST_REQUIRE_EQUAL(query.to_candidate(2), 2u); + BOOST_REQUIRE_EQUAL(query.to_candidate(3), header_link::terminal); + BOOST_REQUIRE_EQUAL(query.to_candidate(4), header_link::terminal); + BOOST_REQUIRE_EQUAL(query.to_confirmed(0), 0u); + BOOST_REQUIRE_EQUAL(query.to_confirmed(1), header_link::terminal); + BOOST_REQUIRE_EQUAL(query.to_confirmed(2), header_link::terminal); + BOOST_REQUIRE_EQUAL(query.to_confirmed(3), header_link::terminal); + BOOST_REQUIRE_EQUAL(query.to_confirmed(4), header_link::terminal); +} + +// to_confirmed + +BOOST_AUTO_TEST_CASE(query_navigate__to_confirmed__always__expected) +{ + settings settings{}; + settings.path = TEST_DIRECTORY; + test::chunk_store store{ settings }; + test::query_accessor query{ store }; + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); + + // initialize pushes the genesis confirmed. + BOOST_REQUIRE(query.initialize(test::genesis)); + BOOST_REQUIRE(query.set(test::block1, test::context, false, false)); + BOOST_REQUIRE(query.set(test::block2, test::context, false, false)); + BOOST_REQUIRE_EQUAL(query.to_confirmed(0), 0u); + BOOST_REQUIRE_EQUAL(query.to_confirmed(1), header_link::terminal); + BOOST_REQUIRE_EQUAL(query.to_confirmed(2), header_link::terminal); + BOOST_REQUIRE_EQUAL(query.to_confirmed(3), header_link::terminal); + BOOST_REQUIRE_EQUAL(query.to_confirmed(4), header_link::terminal); + BOOST_REQUIRE_EQUAL(query.to_candidate(0), 0u); + BOOST_REQUIRE_EQUAL(query.to_candidate(1), header_link::terminal); + BOOST_REQUIRE_EQUAL(query.to_candidate(2), header_link::terminal); + BOOST_REQUIRE_EQUAL(query.to_candidate(3), header_link::terminal); + BOOST_REQUIRE_EQUAL(query.to_candidate(4), header_link::terminal); + + // key-link translate of actual confirmeds. + BOOST_REQUIRE(query.push_confirmed(1, false)); + BOOST_REQUIRE(query.push_confirmed(2, false)); + BOOST_REQUIRE_EQUAL(query.to_confirmed(0), 0u); + BOOST_REQUIRE_EQUAL(query.to_confirmed(1), 1u); + BOOST_REQUIRE_EQUAL(query.to_confirmed(2), 2u); + BOOST_REQUIRE_EQUAL(query.to_confirmed(3), header_link::terminal); + BOOST_REQUIRE_EQUAL(query.to_confirmed(4), header_link::terminal); + BOOST_REQUIRE_EQUAL(query.to_candidate(0), 0u); + BOOST_REQUIRE_EQUAL(query.to_candidate(1), header_link::terminal); + BOOST_REQUIRE_EQUAL(query.to_candidate(2), header_link::terminal); + BOOST_REQUIRE_EQUAL(query.to_candidate(3), header_link::terminal); + BOOST_REQUIRE_EQUAL(query.to_candidate(4), header_link::terminal); +} + +// to_header + +BOOST_AUTO_TEST_CASE(query_navigate__to_header__always__expected) +{ + settings settings{}; + settings.path = TEST_DIRECTORY; + test::chunk_store store{ settings }; + test::query_accessor query{ store }; + header_link link{}; + + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); + BOOST_REQUIRE_EQUAL(query.to_header(test::genesis.hash()), header_link::terminal); + BOOST_REQUIRE(query.initialize(test::genesis)); + BOOST_REQUIRE_EQUAL(query.to_header(test::genesis.hash()), 0u); + BOOST_REQUIRE_EQUAL(query.to_header(test::block1.hash()), header_link::terminal); + BOOST_REQUIRE_EQUAL(query.set_code(link, test::block1.header(), test::context, false), error::success); + BOOST_REQUIRE_EQUAL(link, 1u); + BOOST_REQUIRE_EQUAL(query.to_header(test::block1.hash()), 1u); +} + +// to_tx + +BOOST_AUTO_TEST_CASE(query_navigate__to_tx__transactions__expected) +{ + settings settings{}; + settings.path = TEST_DIRECTORY; + test::chunk_store store{ settings }; + test::query_accessor query{ store }; + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); + BOOST_REQUIRE(query.initialize(test::genesis)); + BOOST_REQUIRE(query.set(test::block1, test::context, false, false)); + BOOST_REQUIRE(query.set(test::block2, test::context, false, false)); + + // All four blocks have one transaction. + BOOST_REQUIRE_EQUAL(query.to_tx(test::genesis.transactions_ptr()->front()->hash(true)), 0u); + BOOST_REQUIRE_EQUAL(query.to_tx(test::block1.transactions_ptr()->front()->hash(true)), 1u); + BOOST_REQUIRE_EQUAL(query.to_tx(test::block2.transactions_ptr()->front()->hash(true)), 2u); + BOOST_REQUIRE_EQUAL(query.to_tx(test::block3.transactions_ptr()->front()->hash(true)), tx_link::terminal); +} + +// to_filter +// to_output + +BOOST_AUTO_TEST_SUITE_END() diff --git a/test/query/navigate/navigate_reverse.cpp b/test/query/navigate/navigate_reverse.cpp new file mode 100644 index 00000000..217ac290 --- /dev/null +++ b/test/query/navigate/navigate_reverse.cpp @@ -0,0 +1,217 @@ +/** + * Copyright (c) 2011-2026 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +#include "../../test.hpp" +#include "../../mocks/blocks.hpp" +#include "../../mocks/chunk_store.hpp" + +BOOST_FIXTURE_TEST_SUITE(query_navigate_tests, test::directory_setup_fixture) + +// to_parent + +BOOST_AUTO_TEST_CASE(query_navigate__to_parent__always__expected) +{ + settings settings{}; + settings.path = TEST_DIRECTORY; + test::chunk_store store{ settings }; + test::query_accessor query{ store }; + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); + BOOST_REQUIRE(query.initialize(test::genesis)); + BOOST_REQUIRE(query.set(test::block1, test::context, false, false)); + BOOST_REQUIRE(query.set(test::block2, test::context, false, false)); + BOOST_REQUIRE(query.set(test::block1a, test::context, false, false)); + BOOST_REQUIRE(query.set(test::block2a, test::context, false, false)); + BOOST_REQUIRE_EQUAL(query.to_parent(0), header_link::terminal); + BOOST_REQUIRE_EQUAL(query.to_parent(1), 0u); + BOOST_REQUIRE_EQUAL(query.to_parent(2), 1u); + BOOST_REQUIRE_EQUAL(query.to_parent(3), 0u); + BOOST_REQUIRE_EQUAL(query.to_parent(4), 3u); + BOOST_REQUIRE_EQUAL(query.to_parent(5), header_link::terminal); +} + +// to_address_outputs1 +// to_address_outputs2 + +BOOST_AUTO_TEST_CASE(query_address__to_address_outputs__genesis__expected) +{ + settings settings{}; + settings.path = TEST_DIRECTORY; + test::chunk_store store{ settings }; + test::query_accessor query{ store }; + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); + BOOST_REQUIRE(query.initialize(test::genesis)); + + output_links out{}; + std::atomic_bool cancel{}; + BOOST_REQUIRE(!query.to_address_outputs(cancel, out, test::genesis_address())); + BOOST_REQUIRE_EQUAL(out.size(), 1u); + BOOST_REQUIRE_EQUAL(out.front(), query.to_output(0, 0)); +} + +// to_spending_tx +// to_output_tx + +BOOST_AUTO_TEST_CASE(query_navigate__to_output_tx__to_output__expected) +{ + settings settings{}; + settings.path = TEST_DIRECTORY; + test::chunk_store store{ settings }; + test::query_accessor query{ store }; + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); + BOOST_REQUIRE(query.initialize(test::genesis)); + BOOST_REQUIRE(query.set(test::block1, test::context, false, false)); + BOOST_REQUIRE(query.set(test::block2, test::context, false, false)); + BOOST_REQUIRE(query.set(test::block3, test::context, false, false)); + BOOST_REQUIRE(query.set(test::block1a, test::context, false, false)); + + // All 5 blocks have one transaction with 1 output. + BOOST_REQUIRE_EQUAL(query.to_output_tx(0 * 0x51), 0u); + BOOST_REQUIRE_EQUAL(query.to_output_tx(1 * 0x51), 1u); + BOOST_REQUIRE_EQUAL(query.to_output_tx(2 * 0x51), 2u); + BOOST_REQUIRE_EQUAL(query.to_output_tx(3 * 0x51), 3u); + BOOST_REQUIRE_EQUAL(query.to_output_tx(4 * 0x51), 4u); + BOOST_REQUIRE_EQUAL(query.to_output_tx(4 * 0x51 + 7u), 4u); + + BOOST_REQUIRE_EQUAL(query.to_output(0, 0), 0u * 0x51u); + BOOST_REQUIRE_EQUAL(query.to_output(1, 0), 1u * 0x51u); + BOOST_REQUIRE_EQUAL(query.to_output(2, 0), 2u * 0x51u); + BOOST_REQUIRE_EQUAL(query.to_output(3, 0), 3u * 0x51u); + BOOST_REQUIRE_EQUAL(query.to_output(4, 0), 4u * 0x51u); + BOOST_REQUIRE_EQUAL(query.to_output(4, 1), 4u * 0x51u + 7u); + + const output_links expected_outputs4{ 4 * 0x51, 4 * 0x51 + 7 }; + BOOST_REQUIRE_EQUAL(query.to_outputs(0), output_links{ 0 * 0x51 }); + BOOST_REQUIRE_EQUAL(query.to_outputs(1), output_links{ 1 * 0x51 }); + BOOST_REQUIRE_EQUAL(query.to_outputs(2), output_links{ 2 * 0x51 }); + BOOST_REQUIRE_EQUAL(query.to_outputs(3), output_links{ 3 * 0x51 }); + BOOST_REQUIRE_EQUAL(query.to_outputs(4), expected_outputs4); + + // All blocks have one transaction. + BOOST_REQUIRE_EQUAL(query.to_block_outputs(0), output_links{ 0 * 0x51 }); + BOOST_REQUIRE_EQUAL(query.to_block_outputs(1), output_links{ 1 * 0x51 }); + BOOST_REQUIRE_EQUAL(query.to_block_outputs(2), output_links{ 2 * 0x51 }); + BOOST_REQUIRE_EQUAL(query.to_block_outputs(3), output_links{ 3 * 0x51 }); + BOOST_REQUIRE_EQUAL(query.to_block_outputs(4), expected_outputs4); + + // No prevouts that exist. + const output_links expected_prevouts4{ output_link::terminal, output_link::terminal, output_link::terminal }; + BOOST_REQUIRE_EQUAL(query.to_prevouts(0), output_links{ output_link::terminal }); + BOOST_REQUIRE_EQUAL(query.to_prevouts(1), output_links{ output_link::terminal }); + BOOST_REQUIRE_EQUAL(query.to_prevouts(2), output_links{ output_link::terminal }); + BOOST_REQUIRE_EQUAL(query.to_prevouts(3), output_links{ output_link::terminal }); + BOOST_REQUIRE_EQUAL(query.to_prevouts(4), expected_prevouts4); + + // All blocks have one transaction. + BOOST_REQUIRE_EQUAL(query.to_block_prevouts(0), output_links{}); + BOOST_REQUIRE_EQUAL(query.to_block_prevouts(1), output_links{}); + BOOST_REQUIRE_EQUAL(query.to_block_prevouts(2), output_links{}); + BOOST_REQUIRE_EQUAL(query.to_block_prevouts(3), output_links{}); + BOOST_REQUIRE_EQUAL(query.to_block_prevouts(4), output_links{}); + + // Past end. + BOOST_REQUIRE_EQUAL(query.to_output_tx(4 * 0x51 + 14), tx_link::terminal); + BOOST_REQUIRE_EQUAL(query.to_output(5, 0), output_link::terminal); + BOOST_REQUIRE(query.to_outputs(5).empty()); + BOOST_REQUIRE(query.to_block_outputs(5).empty()); +} + +// to_prevout_tx + +BOOST_AUTO_TEST_CASE(query_navigate__to_prevout_tx__to_prevout__expected) +{ + settings settings{}; + settings.tx_buckets = 3; + settings.path = TEST_DIRECTORY; + test::chunk_store store{ settings }; + test::query_accessor query{ store }; + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); + BOOST_REQUIRE(query.initialize(test::genesis)); + BOOST_REQUIRE(query.set(test::block1a, test::context, false, false)); + BOOST_REQUIRE(query.set(test::block2a, test::context, false, false)); + + // inputs in link order. + BOOST_REQUIRE_EQUAL(query.to_prevout_tx(0), tx_link::terminal); + BOOST_REQUIRE_EQUAL(query.to_prevout_tx(1), tx_link::terminal); + BOOST_REQUIRE_EQUAL(query.to_prevout_tx(2), tx_link::terminal); + BOOST_REQUIRE_EQUAL(query.to_prevout_tx(3), tx_link::terminal); + BOOST_REQUIRE_EQUAL(query.to_prevout_tx(4), 1u); // block1a:0 (second serialized tx) + BOOST_REQUIRE_EQUAL(query.to_prevout_tx(5), 1u); // block1a:0 (second serialized tx) + BOOST_REQUIRE_EQUAL(query.to_prevout_tx(6), tx_link::terminal); + BOOST_REQUIRE_EQUAL(query.to_prevout_tx(7), tx_link::terminal); + + const output_links expected_prevouts1{ output_link::terminal }; + const output_links expected_prevouts2{ output_link::terminal, output_link::terminal }; + const output_links expected_prevouts3{ output_link::terminal, output_link::terminal, output_link::terminal }; + const output_links expected_prevouts{ 0x51u, 0x51u + 7u }; + BOOST_REQUIRE_EQUAL(query.to_prevouts(0), expected_prevouts1); + BOOST_REQUIRE_EQUAL(query.to_prevouts(1), expected_prevouts3); + BOOST_REQUIRE_EQUAL(query.to_prevouts(2), expected_prevouts); + BOOST_REQUIRE_EQUAL(query.to_prevouts(3), expected_prevouts2); + + // First tx is coinbase, or tx has undefined prevouts. + BOOST_REQUIRE_EQUAL(query.to_block_prevouts(0), output_links{}); + BOOST_REQUIRE_EQUAL(query.to_block_prevouts(1), output_links{}); + BOOST_REQUIRE_EQUAL(query.to_block_prevouts(2), expected_prevouts2); + + // Past end. + BOOST_REQUIRE_EQUAL(query.to_prevout_tx(8), tx_link::terminal); +} + +// to_spenders1 +// to_spenders2 +// to_duplicates + +// to_block + +BOOST_AUTO_TEST_CASE(query_navigate__to_block__always__expected) +{ + settings settings{}; + settings.path = TEST_DIRECTORY; + test::chunk_store store{ settings }; + + class accessor + : public test::query_accessor + { + public: + using test::query_accessor::query_accessor; + using test::query_accessor::to_block; + }; + + accessor query{ store }; + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); + BOOST_REQUIRE(query.initialize(test::genesis)); + BOOST_REQUIRE(query.set(test::block1, test::context, false, false)); + BOOST_REQUIRE(query.set(test::block2, test::context, false, false)); + + // for to_strong/to_strongs + const auto hash0 = test::genesis.transaction_hashes(false).front(); + const auto hash1 = test::block1.transaction_hashes(false).front(); + const auto hash2 = test::block2.transaction_hashes(false).front(); + const auto hash3 = test::block3.transaction_hashes(false).front(); + + // Either not strong or not found, except genesis. + BOOST_REQUIRE(!query.to_block(0).is_terminal()); + BOOST_REQUIRE(query.to_block(1).is_terminal()); + BOOST_REQUIRE(query.to_block(2).is_terminal()); + BOOST_REQUIRE(query.to_block(3).is_terminal()); +} + +// to_input_index +// to_output_index + +BOOST_AUTO_TEST_SUITE_END() diff --git a/test/query/validate.cpp b/test/query/properties_block.cpp similarity index 53% rename from test/query/validate.cpp rename to test/query/properties_block.cpp index 00f261f3..db21fa72 100644 --- a/test/query/validate.cpp +++ b/test/query/properties_block.cpp @@ -20,18 +20,15 @@ #include "../mocks/blocks.hpp" #include "../mocks/chunk_store.hpp" -BOOST_FIXTURE_TEST_SUITE(query_validate_tests, test::directory_setup_fixture) +BOOST_FIXTURE_TEST_SUITE(query_properties_block_tests, test::directory_setup_fixture) -// nop event handler. -const auto events_handler = [](auto, auto) {}; - -BOOST_AUTO_TEST_CASE(query_validate__get_top_timestamp__always__expected) +BOOST_AUTO_TEST_CASE(query_properties_block__get_top_timestamp__always__expected) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE(query.set(test::block1, context{}, false, false)); BOOST_REQUIRE(query.set(test::block2, context{}, false, false)); @@ -50,13 +47,13 @@ BOOST_AUTO_TEST_CASE(query_validate__get_top_timestamp__always__expected) BOOST_REQUIRE_EQUAL(query.get_top_timestamp(false), 0x4966bcb0_u32); } -BOOST_AUTO_TEST_CASE(query_validate__get_timestamp__genesis__expected) +BOOST_AUTO_TEST_CASE(query_properties_block__get_timestamp__genesis__expected) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); BOOST_REQUIRE(query.initialize(test::genesis)); uint32_t timestamp{}; @@ -65,13 +62,13 @@ BOOST_AUTO_TEST_CASE(query_validate__get_timestamp__genesis__expected) BOOST_REQUIRE_EQUAL(timestamp, 0x495fab29_u32); } -BOOST_AUTO_TEST_CASE(query_validate__get_version__genesis__expected) +BOOST_AUTO_TEST_CASE(query_properties_block__get_version__genesis__expected) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); BOOST_REQUIRE(query.initialize(test::genesis)); uint32_t version{}; @@ -80,13 +77,13 @@ BOOST_AUTO_TEST_CASE(query_validate__get_version__genesis__expected) BOOST_REQUIRE_EQUAL(version, 0x00000001_u32); } -BOOST_AUTO_TEST_CASE(query_validate__get_bits__genesis__expected) +BOOST_AUTO_TEST_CASE(query_properties_block__get_bits__genesis__expected) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); BOOST_REQUIRE(query.initialize(test::genesis)); uint32_t bits{}; @@ -95,13 +92,13 @@ BOOST_AUTO_TEST_CASE(query_validate__get_bits__genesis__expected) BOOST_REQUIRE_EQUAL(bits, 0x1d00ffff_u32); } -BOOST_AUTO_TEST_CASE(query_validate__get_context__genesis__default) +BOOST_AUTO_TEST_CASE(query_properties_block__get_context__genesis__default) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); BOOST_REQUIRE(query.initialize(test::genesis)); context ctx{}; @@ -113,13 +110,13 @@ BOOST_AUTO_TEST_CASE(query_validate__get_context__genesis__default) BOOST_REQUIRE(chain_ctx == system::chain::context{}); } -BOOST_AUTO_TEST_CASE(query_validate__get_context__invalid__default) +BOOST_AUTO_TEST_CASE(query_properties_block__get_context__invalid__default) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); BOOST_REQUIRE(query.initialize(test::genesis)); context ctx{}; @@ -133,13 +130,13 @@ BOOST_AUTO_TEST_CASE(query_validate__get_context__invalid__default) BOOST_REQUIRE(chain_ctx == system::chain::context{}); } -BOOST_AUTO_TEST_CASE(query_validate__get_context__block1__expected) +BOOST_AUTO_TEST_CASE(query_properties_block__get_context__block1__expected) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); BOOST_REQUIRE(query.initialize(test::genesis)); const context expected{ 12, 34, 56 }; @@ -155,13 +152,13 @@ BOOST_AUTO_TEST_CASE(query_validate__get_context__block1__expected) BOOST_REQUIRE(chain_ctx == chain_expected); } -BOOST_AUTO_TEST_CASE(query_validate__get_block_state__invalid_link__unassociated) +BOOST_AUTO_TEST_CASE(query_properties_block__get_block_state__invalid_link__unassociated) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); BOOST_REQUIRE(query.initialize(test::genesis)); uint64_t fees{}; @@ -170,13 +167,13 @@ BOOST_AUTO_TEST_CASE(query_validate__get_block_state__invalid_link__unassociated BOOST_REQUIRE_EQUAL(fees, 0u); } -BOOST_AUTO_TEST_CASE(query_validate__get_block_state__unassociated_link__unassociated) +BOOST_AUTO_TEST_CASE(query_properties_block__get_block_state__unassociated_link__unassociated) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE(query.set(test::block1.header(), context{}, false)); BOOST_REQUIRE(query.set(*test::block1.transactions_ptr()->front())); @@ -187,13 +184,13 @@ BOOST_AUTO_TEST_CASE(query_validate__get_block_state__unassociated_link__unassoc BOOST_REQUIRE_EQUAL(fees, 0u); } -BOOST_AUTO_TEST_CASE(query_validate__get_block_state__unvalidated_link__unvalidated) +BOOST_AUTO_TEST_CASE(query_properties_block__get_block_state__unvalidated_link__unvalidated) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE(query.set(test::block1, context{}, false, false)); @@ -203,13 +200,13 @@ BOOST_AUTO_TEST_CASE(query_validate__get_block_state__unvalidated_link__unvalida BOOST_REQUIRE_EQUAL(fees, 0u); } -BOOST_AUTO_TEST_CASE(query_validate__get_block_state__confirmable__block_confirmable) +BOOST_AUTO_TEST_CASE(query_properties_block__get_block_state__confirmable__block_confirmable) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE(query.set(test::block1, context{}, false, false)); @@ -224,13 +221,13 @@ BOOST_AUTO_TEST_CASE(query_validate__get_block_state__confirmable__block_confirm BOOST_REQUIRE_EQUAL(fees, 0u); } -BOOST_AUTO_TEST_CASE(query_validate__get_block_state__valid__block_valid) +BOOST_AUTO_TEST_CASE(query_properties_block__get_block_state__valid__block_valid) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE(query.set(test::block1, context{}, false, false)); @@ -239,13 +236,13 @@ BOOST_AUTO_TEST_CASE(query_validate__get_block_state__valid__block_valid) BOOST_REQUIRE_EQUAL(query.get_block_state(1), error::block_valid); } -BOOST_AUTO_TEST_CASE(query_validate__get_block_state__unconfirmable__block_unconfirmable) +BOOST_AUTO_TEST_CASE(query_properties_block__get_block_state__unconfirmable__block_unconfirmable) { settings settings{}; settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE(query.set(test::block1, context{}, false, false)); @@ -254,117 +251,4 @@ BOOST_AUTO_TEST_CASE(query_validate__get_block_state__unconfirmable__block_uncon BOOST_REQUIRE_EQUAL(query.get_block_state(1), error::block_unconfirmable); } -BOOST_AUTO_TEST_CASE(query_validate__get_tx_state__invalid_link__unvalidated) -{ - settings settings{}; - settings.path = TEST_DIRECTORY; - test::chunk_store store{ settings }; - test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); - BOOST_REQUIRE(query.initialize(test::genesis)); - - uint64_t fee{}; - size_t sigops{}; - BOOST_REQUIRE_EQUAL(query.get_tx_state(1, {}), error::unvalidated); - BOOST_REQUIRE_EQUAL(query.get_tx_state(fee, sigops, 1, {}), error::unvalidated); - BOOST_REQUIRE_EQUAL(fee, 0u); -} - -BOOST_AUTO_TEST_CASE(query_validate__get_tx_state__unvalidated__unvalidated) -{ - settings settings{}; - settings.path = TEST_DIRECTORY; - test::chunk_store store{ settings }; - test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); - BOOST_REQUIRE(query.initialize(test::genesis)); - BOOST_REQUIRE(query.set(test::block1, context{}, false, false)); - - uint64_t fee{}; - size_t sigops{}; - BOOST_REQUIRE_EQUAL(query.get_tx_state(1, {}), error::unvalidated); - BOOST_REQUIRE_EQUAL(query.get_tx_state(fee, sigops, 1, {}), error::unvalidated); - BOOST_REQUIRE_EQUAL(fee, 0u); -} - -BOOST_AUTO_TEST_CASE(query_validate__get_tx_state__connected_out_of_context__unvalidated) -{ - settings settings{}; - settings.path = TEST_DIRECTORY; - settings.validated_tx_buckets = 1; - test::chunk_store store{ settings }; - test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); - BOOST_REQUIRE(query.initialize(test::genesis)); - BOOST_REQUIRE(query.set(test::block1, context{}, false, false)); - BOOST_REQUIRE(query.set(test::block2, context{}, false, false)); - BOOST_REQUIRE(query.set(test::block3, context{}, false, false)); - - uint64_t fee{}; - size_t sigops{}; - constexpr context ctx{ 7, 8, 9 }; - - // Set a context which does not match ctx. - BOOST_REQUIRE(query.set_tx_connected(0, { 1, 5, 9 }, 0, 0)); - BOOST_REQUIRE(query.set_tx_connected(1, { 2, 6, 0 }, 0, 0)); - BOOST_REQUIRE(query.set_tx_connected(2, { 3, 7, 1 }, 0, 0)); - BOOST_REQUIRE(query.set_tx_connected(3, { 4, 8, 2 }, 0, 0)); - BOOST_REQUIRE_EQUAL(query.get_tx_state(1, ctx), error::unvalidated); - BOOST_REQUIRE_EQUAL(query.get_tx_state(fee, sigops, 1, ctx), error::unvalidated); - BOOST_REQUIRE_EQUAL(fee, 0u); - BOOST_REQUIRE_EQUAL(sigops, 0u); -} - -BOOST_AUTO_TEST_CASE(query_validate__get_tx_state__connected_in_context__tx_connected) -{ - settings settings{}; - settings.path = TEST_DIRECTORY; - settings.validated_tx_buckets = 1; - test::chunk_store store{ settings }; - test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); - BOOST_REQUIRE(query.initialize(test::genesis)); - BOOST_REQUIRE(query.set(test::block1, context{}, false, false)); - BOOST_REQUIRE(query.set(test::block2, context{}, false, false)); - BOOST_REQUIRE(query.set(test::block3, context{}, false, false)); - - uint64_t fee{}; - size_t sigops{}; - constexpr uint64_t expected_fee = 42; - constexpr size_t expected_sigops = 24; - constexpr context ctx{ 7, 8, 9 }; - BOOST_REQUIRE(query.set_tx_connected(0, ctx, 11, 12)); - BOOST_REQUIRE(query.set_tx_connected(1, ctx, 13, 14)); - BOOST_REQUIRE(query.set_tx_connected(2, ctx, expected_fee, expected_sigops)); - BOOST_REQUIRE(query.set_tx_connected(2, { 1, 5, 9 }, 15, 16)); - BOOST_REQUIRE(query.set_tx_connected(2, { 2, 6, 0 }, 17, 18)); - BOOST_REQUIRE(query.set_tx_connected(3, ctx, 19, 20)); - BOOST_REQUIRE_EQUAL(query.get_tx_state(2, ctx), error::tx_connected); - BOOST_REQUIRE_EQUAL(query.get_tx_state(fee, sigops, 2, ctx), error::tx_connected); - BOOST_REQUIRE_EQUAL(fee, expected_fee); - BOOST_REQUIRE_EQUAL(sigops, expected_sigops); -} - -BOOST_AUTO_TEST_CASE(query_validate__get_tx_state__connected_in_context__tx_disconnected) -{ - settings settings{}; - settings.path = TEST_DIRECTORY; - test::chunk_store store{ settings }; - test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); - BOOST_REQUIRE(query.initialize(test::genesis)); - BOOST_REQUIRE(query.set(test::block1, context{}, false, false)); - BOOST_REQUIRE(query.set(test::block2, context{}, false, false)); - BOOST_REQUIRE(query.set(test::block3, context{}, false, false)); - - uint64_t fee{}; - size_t sigops{}; - constexpr context ctx{ 7, 8, 9 }; - BOOST_REQUIRE(query.set_tx_disconnected(4, ctx)); - BOOST_REQUIRE_EQUAL(query.get_tx_state(4, ctx), error::tx_disconnected); - BOOST_REQUIRE_EQUAL(query.get_tx_state(fee, sigops, 4, ctx), error::tx_disconnected); - BOOST_REQUIRE_EQUAL(fee, 0u); - BOOST_REQUIRE_EQUAL(sigops, 0u); -} - BOOST_AUTO_TEST_SUITE_END() diff --git a/test/query/properties_tx.cpp b/test/query/properties_tx.cpp new file mode 100644 index 00000000..10e5e386 --- /dev/null +++ b/test/query/properties_tx.cpp @@ -0,0 +1,138 @@ +/** + * Copyright (c) 2011-2026 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +#include "../test.hpp" +#include "../mocks/blocks.hpp" +#include "../mocks/chunk_store.hpp" + +BOOST_FIXTURE_TEST_SUITE(query_properties_tx_tests, test::directory_setup_fixture) + +BOOST_AUTO_TEST_CASE(query_properties_tx__get_tx_state__invalid_link__unvalidated) +{ + settings settings{}; + settings.path = TEST_DIRECTORY; + test::chunk_store store{ settings }; + test::query_accessor query{ store }; + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); + BOOST_REQUIRE(query.initialize(test::genesis)); + + uint64_t fee{}; + size_t sigops{}; + BOOST_REQUIRE_EQUAL(query.get_tx_state(1, {}), error::unvalidated); + BOOST_REQUIRE_EQUAL(query.get_tx_state(fee, sigops, 1, {}), error::unvalidated); + BOOST_REQUIRE_EQUAL(fee, 0u); +} + +BOOST_AUTO_TEST_CASE(query_properties_tx__get_tx_state__unvalidated__unvalidated) +{ + settings settings{}; + settings.path = TEST_DIRECTORY; + test::chunk_store store{ settings }; + test::query_accessor query{ store }; + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); + BOOST_REQUIRE(query.initialize(test::genesis)); + BOOST_REQUIRE(query.set(test::block1, context{}, false, false)); + + uint64_t fee{}; + size_t sigops{}; + BOOST_REQUIRE_EQUAL(query.get_tx_state(1, {}), error::unvalidated); + BOOST_REQUIRE_EQUAL(query.get_tx_state(fee, sigops, 1, {}), error::unvalidated); + BOOST_REQUIRE_EQUAL(fee, 0u); +} + +BOOST_AUTO_TEST_CASE(query_properties_tx__get_tx_state__connected_out_of_context__unvalidated) +{ + settings settings{}; + settings.path = TEST_DIRECTORY; + settings.validated_tx_buckets = 1; + test::chunk_store store{ settings }; + test::query_accessor query{ store }; + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); + BOOST_REQUIRE(query.initialize(test::genesis)); + BOOST_REQUIRE(query.set(test::block1, context{}, false, false)); + BOOST_REQUIRE(query.set(test::block2, context{}, false, false)); + BOOST_REQUIRE(query.set(test::block3, context{}, false, false)); + + uint64_t fee{}; + size_t sigops{}; + constexpr context ctx{ 7, 8, 9 }; + + // Set a context which does not match ctx. + BOOST_REQUIRE(query.set_tx_connected(0, { 1, 5, 9 }, 0, 0)); + BOOST_REQUIRE(query.set_tx_connected(1, { 2, 6, 0 }, 0, 0)); + BOOST_REQUIRE(query.set_tx_connected(2, { 3, 7, 1 }, 0, 0)); + BOOST_REQUIRE(query.set_tx_connected(3, { 4, 8, 2 }, 0, 0)); + BOOST_REQUIRE_EQUAL(query.get_tx_state(1, ctx), error::unvalidated); + BOOST_REQUIRE_EQUAL(query.get_tx_state(fee, sigops, 1, ctx), error::unvalidated); + BOOST_REQUIRE_EQUAL(fee, 0u); + BOOST_REQUIRE_EQUAL(sigops, 0u); +} + +BOOST_AUTO_TEST_CASE(query_properties_tx__get_tx_state__connected_in_context__tx_connected) +{ + settings settings{}; + settings.path = TEST_DIRECTORY; + settings.validated_tx_buckets = 1; + test::chunk_store store{ settings }; + test::query_accessor query{ store }; + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); + BOOST_REQUIRE(query.initialize(test::genesis)); + BOOST_REQUIRE(query.set(test::block1, context{}, false, false)); + BOOST_REQUIRE(query.set(test::block2, context{}, false, false)); + BOOST_REQUIRE(query.set(test::block3, context{}, false, false)); + + uint64_t fee{}; + size_t sigops{}; + constexpr uint64_t expected_fee = 42; + constexpr size_t expected_sigops = 24; + constexpr context ctx{ 7, 8, 9 }; + BOOST_REQUIRE(query.set_tx_connected(0, ctx, 11, 12)); + BOOST_REQUIRE(query.set_tx_connected(1, ctx, 13, 14)); + BOOST_REQUIRE(query.set_tx_connected(2, ctx, expected_fee, expected_sigops)); + BOOST_REQUIRE(query.set_tx_connected(2, { 1, 5, 9 }, 15, 16)); + BOOST_REQUIRE(query.set_tx_connected(2, { 2, 6, 0 }, 17, 18)); + BOOST_REQUIRE(query.set_tx_connected(3, ctx, 19, 20)); + BOOST_REQUIRE_EQUAL(query.get_tx_state(2, ctx), error::tx_connected); + BOOST_REQUIRE_EQUAL(query.get_tx_state(fee, sigops, 2, ctx), error::tx_connected); + BOOST_REQUIRE_EQUAL(fee, expected_fee); + BOOST_REQUIRE_EQUAL(sigops, expected_sigops); +} + +BOOST_AUTO_TEST_CASE(query_properties_tx__get_tx_state__connected_in_context__tx_disconnected) +{ + settings settings{}; + settings.path = TEST_DIRECTORY; + test::chunk_store store{ settings }; + test::query_accessor query{ store }; + BOOST_REQUIRE_EQUAL(store.create(test::events_handler), error::success); + BOOST_REQUIRE(query.initialize(test::genesis)); + BOOST_REQUIRE(query.set(test::block1, context{}, false, false)); + BOOST_REQUIRE(query.set(test::block2, context{}, false, false)); + BOOST_REQUIRE(query.set(test::block3, context{}, false, false)); + + uint64_t fee{}; + size_t sigops{}; + constexpr context ctx{ 7, 8, 9 }; + BOOST_REQUIRE(query.set_tx_disconnected(4, ctx)); + BOOST_REQUIRE_EQUAL(query.get_tx_state(4, ctx), error::tx_disconnected); + BOOST_REQUIRE_EQUAL(query.get_tx_state(fee, sigops, 4, ctx), error::tx_disconnected); + BOOST_REQUIRE_EQUAL(fee, 0u); + BOOST_REQUIRE_EQUAL(sigops, 0u); +} + +BOOST_AUTO_TEST_SUITE_END() diff --git a/test/query/consensus.cpp b/test/query/sequences.cpp similarity index 82% rename from test/query/consensus.cpp rename to test/query/sequences.cpp index c2ee0834..8f6307a6 100644 --- a/test/query/consensus.cpp +++ b/test/query/sequences.cpp @@ -20,13 +20,6 @@ #include "../mocks/blocks.hpp" #include "../mocks/chunk_store.hpp" -BOOST_FIXTURE_TEST_SUITE(query_consensus_tests, test::directory_setup_fixture) - -////const auto events_handler = [](auto, auto) {}; - -BOOST_AUTO_TEST_CASE(query_consensus_test) -{ - BOOST_REQUIRE(true); -} +BOOST_FIXTURE_TEST_SUITE(query_sequences_tests, test::directory_setup_fixture) BOOST_AUTO_TEST_SUITE_END() diff --git a/test/query/sizes.cpp b/test/query/sizes.cpp new file mode 100644 index 00000000..e126ab73 --- /dev/null +++ b/test/query/sizes.cpp @@ -0,0 +1,25 @@ +/** + * Copyright (c) 2011-2026 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +#include "../test.hpp" +#include "../mocks/blocks.hpp" +#include "../mocks/chunk_store.hpp" + +BOOST_FIXTURE_TEST_SUITE(query_sizes_tests, test::directory_setup_fixture) + +BOOST_AUTO_TEST_SUITE_END() diff --git a/test/query/translate.cpp b/test/query/translate.cpp deleted file mode 100644 index 2352ae19..00000000 --- a/test/query/translate.cpp +++ /dev/null @@ -1,1013 +0,0 @@ -/////** -//// * Copyright (c) 2011-2026 libbitcoin developers (see AUTHORS) -//// * -//// * This file is part of libbitcoin. -//// * -//// * This program is free software: you can redistribute it and/or modify -//// * it under the terms of the GNU Affero General Public License as published by -//// * the Free Software Foundation, either version 3 of the License, or -//// * (at your option) any later version. -//// * -//// * This program is distributed in the hope that it will be useful, -//// * but WITHOUT ANY WARRANTY; without even the implied warranty of -//// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//// * GNU Affero General Public License for more details. -//// * -//// * You should have received a copy of the GNU Affero General Public License -//// * along with this program. If not, see . -//// */ -////#include "../test.hpp" -////#include "../mocks/blocks.hpp" -////#include "../mocks/chunk_store.hpp" -//// -////BOOST_FIXTURE_TEST_SUITE(query_translate_tests, test::directory_setup_fixture) -//// -////// nop event handler. -////const auto events_handler = [](auto, auto) {}; -//// -////// to_candidate -//// -////BOOST_AUTO_TEST_CASE(query_translate__to_candidate__always__expected) -////{ -//// settings settings{}; -//// settings.path = TEST_DIRECTORY; -//// test::chunk_store store{ settings }; -//// test::query_accessor query{ store }; -//// BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); -//// -//// // initialize pushes the genesis candidate. -//// BOOST_REQUIRE(query.initialize(test::genesis)); -//// BOOST_REQUIRE(query.set(test::block1, test::context, false, false)); -//// BOOST_REQUIRE(query.set(test::block2, test::context, false, false)); -//// BOOST_REQUIRE_EQUAL(query.to_candidate(0), 0u); -//// BOOST_REQUIRE_EQUAL(query.to_candidate(1), header_link::terminal); -//// BOOST_REQUIRE_EQUAL(query.to_candidate(2), header_link::terminal); -//// BOOST_REQUIRE_EQUAL(query.to_candidate(3), header_link::terminal); -//// BOOST_REQUIRE_EQUAL(query.to_candidate(4), header_link::terminal); -//// BOOST_REQUIRE_EQUAL(query.to_confirmed(0), 0u); -//// BOOST_REQUIRE_EQUAL(query.to_confirmed(1), header_link::terminal); -//// BOOST_REQUIRE_EQUAL(query.to_confirmed(2), header_link::terminal); -//// BOOST_REQUIRE_EQUAL(query.to_confirmed(3), header_link::terminal); -//// BOOST_REQUIRE_EQUAL(query.to_confirmed(4), header_link::terminal); -//// -//// // key-link translate of actual candidates. -//// BOOST_REQUIRE(query.push_candidate(1)); -//// BOOST_REQUIRE(query.push_candidate(2)); -//// BOOST_REQUIRE_EQUAL(query.to_candidate(0), 0u); -//// BOOST_REQUIRE_EQUAL(query.to_candidate(1), 1u); -//// BOOST_REQUIRE_EQUAL(query.to_candidate(2), 2u); -//// BOOST_REQUIRE_EQUAL(query.to_candidate(3), header_link::terminal); -//// BOOST_REQUIRE_EQUAL(query.to_candidate(4), header_link::terminal); -//// BOOST_REQUIRE_EQUAL(query.to_confirmed(0), 0u); -//// BOOST_REQUIRE_EQUAL(query.to_confirmed(1), header_link::terminal); -//// BOOST_REQUIRE_EQUAL(query.to_confirmed(2), header_link::terminal); -//// BOOST_REQUIRE_EQUAL(query.to_confirmed(3), header_link::terminal); -//// BOOST_REQUIRE_EQUAL(query.to_confirmed(4), header_link::terminal); -////} -//// -////// to_confirmed -//// -////BOOST_AUTO_TEST_CASE(query_translate__to_confirmed__always__expected) -////{ -//// settings settings{}; -//// settings.path = TEST_DIRECTORY; -//// test::chunk_store store{ settings }; -//// test::query_accessor query{ store }; -//// BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); -//// -//// // initialize pushes the genesis confirmed. -//// BOOST_REQUIRE(query.initialize(test::genesis)); -//// BOOST_REQUIRE(query.set(test::block1, test::context, false, false)); -//// BOOST_REQUIRE(query.set(test::block2, test::context, false, false)); -//// BOOST_REQUIRE_EQUAL(query.to_confirmed(0), 0u); -//// BOOST_REQUIRE_EQUAL(query.to_confirmed(1), header_link::terminal); -//// BOOST_REQUIRE_EQUAL(query.to_confirmed(2), header_link::terminal); -//// BOOST_REQUIRE_EQUAL(query.to_confirmed(3), header_link::terminal); -//// BOOST_REQUIRE_EQUAL(query.to_confirmed(4), header_link::terminal); -//// BOOST_REQUIRE_EQUAL(query.to_candidate(0), 0u); -//// BOOST_REQUIRE_EQUAL(query.to_candidate(1), header_link::terminal); -//// BOOST_REQUIRE_EQUAL(query.to_candidate(2), header_link::terminal); -//// BOOST_REQUIRE_EQUAL(query.to_candidate(3), header_link::terminal); -//// BOOST_REQUIRE_EQUAL(query.to_candidate(4), header_link::terminal); -//// -//// // key-link translate of actual confirmeds. -//// BOOST_REQUIRE(query.push_confirmed(1, false)); -//// BOOST_REQUIRE(query.push_confirmed(2, false)); -//// BOOST_REQUIRE_EQUAL(query.to_confirmed(0), 0u); -//// BOOST_REQUIRE_EQUAL(query.to_confirmed(1), 1u); -//// BOOST_REQUIRE_EQUAL(query.to_confirmed(2), 2u); -//// BOOST_REQUIRE_EQUAL(query.to_confirmed(3), header_link::terminal); -//// BOOST_REQUIRE_EQUAL(query.to_confirmed(4), header_link::terminal); -//// BOOST_REQUIRE_EQUAL(query.to_candidate(0), 0u); -//// BOOST_REQUIRE_EQUAL(query.to_candidate(1), header_link::terminal); -//// BOOST_REQUIRE_EQUAL(query.to_candidate(2), header_link::terminal); -//// BOOST_REQUIRE_EQUAL(query.to_candidate(3), header_link::terminal); -//// BOOST_REQUIRE_EQUAL(query.to_candidate(4), header_link::terminal); -////} -//// -////// to_header -//// -////BOOST_AUTO_TEST_CASE(query_translate__to_header__always__expected) -////{ -//// settings settings{}; -//// settings.path = TEST_DIRECTORY; -//// test::chunk_store store{ settings }; -//// test::query_accessor query{ store }; -//// header_link link{}; -//// -//// BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); -//// BOOST_REQUIRE_EQUAL(query.to_header(test::genesis.hash()), header_link::terminal); -//// BOOST_REQUIRE(query.initialize(test::genesis)); -//// BOOST_REQUIRE_EQUAL(query.to_header(test::genesis.hash()), 0u); -//// BOOST_REQUIRE_EQUAL(query.to_header(test::block1.hash()), header_link::terminal); -//// BOOST_REQUIRE_EQUAL(query.set_code(link, test::block1.header(), test::context, false), error::success); -//// BOOST_REQUIRE_EQUAL(link, 1u); -//// BOOST_REQUIRE_EQUAL(query.to_header(test::block1.hash()), 1u); -////} -//// -////BOOST_AUTO_TEST_CASE(query_translate__to_coinbase__always__expected) -////{ -//// settings settings{}; -//// settings.path = TEST_DIRECTORY; -//// test::chunk_store store{ settings }; -//// test::query_accessor query{ store }; -//// BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); -//// BOOST_REQUIRE_EQUAL(query.to_header(test::genesis.hash()), header_link::terminal); -//// BOOST_REQUIRE(query.initialize(test::genesis)); -//// BOOST_REQUIRE_EQUAL(query.to_coinbase(0), 0u); -//// BOOST_REQUIRE(query.to_coinbase(1).is_terminal()); -//// BOOST_REQUIRE(query.set(test::block1, test::context, false, false)); -//// BOOST_REQUIRE_EQUAL(query.to_coinbase(1), 1u); -////} -//// -////// to_point -//// -////BOOST_AUTO_TEST_CASE(query_translate__to_point__null_points__empty_points_table) -////{ -//// settings settings{}; -//// settings.path = TEST_DIRECTORY; -//// test::chunk_store store{ settings }; -//// test::query_accessor query{ store }; -//// BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); -//// -//// // The four blocks have only null points, which are not archived. -//// BOOST_REQUIRE(query.initialize(test::genesis)); -//// BOOST_REQUIRE(query.set(test::block1, test::context, false, false)); -//// BOOST_REQUIRE(query.set(test::block2, test::context, false, false)); -//// BOOST_REQUIRE(query.set(test::block3, test::context, false, false)); -//// BOOST_REQUIRE(store.point_body().empty()); -////} -//// -////// to_tx -//// -////BOOST_AUTO_TEST_CASE(query_translate__to_tx__txs__expected) -////{ -//// settings settings{}; -//// settings.path = TEST_DIRECTORY; -//// test::chunk_store store{ settings }; -//// test::query_accessor query{ store }; -//// BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); -//// BOOST_REQUIRE(query.initialize(test::genesis)); -//// BOOST_REQUIRE(query.set(test::block1, test::context, false, false)); -//// BOOST_REQUIRE(query.set(test::block2, test::context, false, false)); -//// -//// // All four blocks have one transaction. -//// BOOST_REQUIRE_EQUAL(query.to_tx(test::genesis.transactions_ptr()->front()->hash(true)), 0u); -//// BOOST_REQUIRE_EQUAL(query.to_tx(test::block1.transactions_ptr()->front()->hash(true)), 1u); -//// BOOST_REQUIRE_EQUAL(query.to_tx(test::block2.transactions_ptr()->front()->hash(true)), 2u); -//// BOOST_REQUIRE_EQUAL(query.to_tx(test::block3.transactions_ptr()->front()->hash(true)), tx_link::terminal); -////} -//// -////// to_spending_tx/to_spend/to_spends/get_spend_key/get_point_sets -//// -////class accessor -//// : public test::query_accessor -////{ -////public: -//// using test::query_accessor::query_accessor; -//// bool get_point_set_(point_set& set, const tx_link& link) const NOEXCEPT -//// { -//// set.spends.clear(); -//// return test::query_accessor::get_point_set(set, link); -//// } -////}; -//// -////BOOST_AUTO_TEST_CASE(query_translate__to_spending_tx__to_spend__expected) -////{ -//// settings settings{}; -//// settings.path = TEST_DIRECTORY; -//// settings.spend_buckets = 3; -//// test::chunk_store store{ settings }; -//// accessor query{ store }; -//// BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); -//// BOOST_REQUIRE(query.initialize(test::genesis)); -//// BOOST_REQUIRE(query.set(test::block1, test::context, false, false)); -//// BOOST_REQUIRE(query.set(test::block2, test::context, false, false)); -//// BOOST_REQUIRE(query.set(test::block3, test::context, false, false)); -//// -//// // block1a has no true coinbase. -//// BOOST_REQUIRE(query.set(test::block1a, test::context, false, false)); -//// -//// // First 4 blocks have one transaction with 1 input, block1a has 3. -//// BOOST_REQUIRE_EQUAL(query.to_spending_tx(0), 0u); -//// BOOST_REQUIRE_EQUAL(query.to_spending_tx(1), 1u); -//// BOOST_REQUIRE_EQUAL(query.to_spending_tx(2), 2u); -//// BOOST_REQUIRE_EQUAL(query.to_spending_tx(3), 3u); -//// BOOST_REQUIRE_EQUAL(query.to_spending_tx(4), 4u); -//// BOOST_REQUIRE_EQUAL(query.to_spending_tx(5), 4u); -//// BOOST_REQUIRE_EQUAL(query.to_spending_tx(6), 4u); -//// -//// BOOST_REQUIRE_EQUAL(query.to_spend(0, 0), 0u); -//// BOOST_REQUIRE_EQUAL(query.to_spend(1, 0), 1u); -//// BOOST_REQUIRE_EQUAL(query.to_spend(2, 0), 2u); -//// BOOST_REQUIRE_EQUAL(query.to_spend(3, 0), 3u); -//// BOOST_REQUIRE_EQUAL(query.to_spend(4, 0), 4u); -//// BOOST_REQUIRE_EQUAL(query.to_spend(4, 1), 5u); -//// BOOST_REQUIRE_EQUAL(query.to_spend(4, 2), 6u); -//// -//// using namespace system; -//// BOOST_REQUIRE_EQUAL(query.get_spend_key(query.to_spend(0, 0)), base16_array("00000000ffffff")); -//// BOOST_REQUIRE_EQUAL(query.get_spend_key(query.to_spend(1, 0)), base16_array("00000000ffffff")); -//// BOOST_REQUIRE_EQUAL(query.get_spend_key(query.to_spend(2, 0)), base16_array("00000000ffffff")); -//// BOOST_REQUIRE_EQUAL(query.get_spend_key(query.to_spend(3, 0)), base16_array("00000000ffffff")); -//// BOOST_REQUIRE_EQUAL(query.get_spend_key(query.to_spend(4, 0)), base16_array("01000000180000")); -//// BOOST_REQUIRE_EQUAL(query.get_spend_key(query.to_spend(4, 1)), base16_array("010000002a0000")); -//// BOOST_REQUIRE_EQUAL(query.get_spend_key(query.to_spend(4, 2)), base16_array("020000002b0000")); -//// -//// const spend_links expected_links4{ 4, 5, 6 }; -//// BOOST_REQUIRE_EQUAL(query.to_spends(0), spend_links{ 0 }); -//// BOOST_REQUIRE_EQUAL(query.to_spends(1), spend_links{ 1 }); -//// BOOST_REQUIRE_EQUAL(query.to_spends(2), spend_links{ 2 }); -//// BOOST_REQUIRE_EQUAL(query.to_spends(3), spend_links{ 3 }); -//// BOOST_REQUIRE_EQUAL(query.to_spends(4), expected_links4); -//// -//// point_set set{}; -//// BOOST_REQUIRE(query.get_point_set_(set, 0)); -//// BOOST_REQUIRE_EQUAL(set.tx, 0u); -//// BOOST_REQUIRE_EQUAL(set.spends.size(), 1u); -//// ////BOOST_REQUIRE(set.spends.front().is_null()); -//// BOOST_REQUIRE_EQUAL(set.version, test::genesis.transactions_ptr()->front()->version()); -//// -//// BOOST_REQUIRE(query.get_point_set_(set, 1)); -//// BOOST_REQUIRE_EQUAL(set.tx, 1u); -//// BOOST_REQUIRE_EQUAL(set.spends.size(), 1u); -//// ////BOOST_REQUIRE(set.spends.front().is_null()); -//// BOOST_REQUIRE_EQUAL(set.version, test::block1.transactions_ptr()->front()->version()); -//// -//// BOOST_REQUIRE(query.get_point_set_(set, 2)); -//// BOOST_REQUIRE_EQUAL(set.tx, 2u); -//// BOOST_REQUIRE_EQUAL(set.spends.size(), 1u); -//// ////BOOST_REQUIRE(set.spends.front().is_null()); -//// BOOST_REQUIRE_EQUAL(set.version, test::block2.transactions_ptr()->front()->version()); -//// -//// BOOST_REQUIRE(query.get_point_set_(set, 3)); -//// BOOST_REQUIRE_EQUAL(set.tx, 3u); -//// BOOST_REQUIRE_EQUAL(set.spends.size(), 1u); -//// ////BOOST_REQUIRE(set.spends.front().is_null()); -//// BOOST_REQUIRE_EQUAL(set.version, test::block3.transactions_ptr()->front()->version()); -//// -//// // block1a has no first coinbase. -//// BOOST_REQUIRE(query.get_point_set_(set, 4)); -//// BOOST_REQUIRE_EQUAL(set.tx, 4u); -//// BOOST_REQUIRE_EQUAL(set.spends.size(), 3u); -//// ////BOOST_REQUIRE(!set.spends[0].is_null()); -//// ////BOOST_REQUIRE(!set.spends[1].is_null()); -//// ////BOOST_REQUIRE(!set.spends[2].is_null()); -//// BOOST_REQUIRE_EQUAL(set.spends[0].sequence, 42u); -//// BOOST_REQUIRE_EQUAL(set.spends[1].sequence, 24u); -//// BOOST_REQUIRE_EQUAL(set.spends[2].sequence, 25u); -//// BOOST_REQUIRE_EQUAL(set.spends[0].point_index, 24u); -//// BOOST_REQUIRE_EQUAL(set.spends[1].point_index, 42u); -//// BOOST_REQUIRE_EQUAL(set.spends[2].point_index, 43u); -//// BOOST_REQUIRE_EQUAL(set.spends[0].point_index, (*test::block1a.transactions_ptr()->front()->inputs_ptr())[0]->point().index()); -//// BOOST_REQUIRE_EQUAL(set.spends[1].point_index, (*test::block1a.transactions_ptr()->front()->inputs_ptr())[1]->point().index()); -//// BOOST_REQUIRE_EQUAL(set.spends[2].point_index, (*test::block1a.transactions_ptr()->front()->inputs_ptr())[2]->point().index()); -//// BOOST_REQUIRE_EQUAL(set.version, test::block1a.transactions_ptr()->front()->version()); -//// -//// // COINBASE TXS! -//// // TODO: All blocks have one transaction. -//// ////point_sets sets{}; -//// ////BOOST_REQUIRE(query.get_point_sets_(sets, 0)); -//// ////BOOST_REQUIRE_EQUAL(sets.size(), 0u); -//// ////BOOST_REQUIRE(query.get_point_sets_(sets, 1)); -//// ////BOOST_REQUIRE_EQUAL(sets.size(), 0u); -//// ////BOOST_REQUIRE(query.get_point_sets_(sets, 2)); -//// ////BOOST_REQUIRE_EQUAL(sets.size(), 0u); -//// ////BOOST_REQUIRE(query.get_point_sets_(sets, 3)); -//// ////BOOST_REQUIRE_EQUAL(sets.size(), 0u); -//// ////BOOST_REQUIRE(query.get_point_sets_(sets, 4)); -//// ////BOOST_REQUIRE_EQUAL(sets.size(), 0u); -//// -//// // Past end. -//// BOOST_REQUIRE_EQUAL(query.to_spending_tx(7), tx_link::terminal); -//// BOOST_REQUIRE_EQUAL(query.to_spend(5, 0), spend_link::terminal); -//// BOOST_REQUIRE_EQUAL(query.get_spend_key(spend_link::terminal), spend_key{}); -//// BOOST_REQUIRE_EQUAL(query.get_spend_key(query.to_spend(5, 0)), spend_key{}); -//// BOOST_REQUIRE(query.to_spends(5).empty()); -//// /////BOOST_REQUIRE(query.get_point_sets_(sets, 5)); -//// ////BOOST_REQUIRE_EQUAL(sets.size(), 0u); -//// -//// // Verify expectations. -//// const auto spend_head = base16_chunk -//// ( -//// "00000000" // size -//// "04000000" // pk->4 -//// "ffffffff" -//// "ffffffff" -//// "05000000" // pk->5 -//// "ffffffff" -//// ); -//// const auto spend_body = base16_chunk -//// ( -//// "ffffffff" // terminal-> -//// "ffffffff" // fp: point_stub -//// "ffffff" // fp: point_index (null) -//// "00000000" // parent_fk-> -//// "ffffffff" // sequence -//// "0000000000" // input_fk-> -//// -//// "00000000" // pk->0 -//// "ffffffff" // fp: point_stub -//// "ffffff" // fp: point_index (null) -//// "01000000" // parent_fk-> -//// "ffffffff" // sequence -//// "4f00000000" // input_fk-> -//// -//// "01000000" // pk->1 -//// "ffffffff" // fp: point_stub -//// "ffffff" // fp: point_index (null) -//// "02000000" // parent_fk-> -//// "ffffffff" // sequence -//// "5800000000" // input_fk-> -//// -//// "02000000" // pk->2 -//// "ffffffff" // fp: point_stub -//// "ffffff" // fp: point_index (null) -//// "03000000" // parent_fk-> -//// "ffffffff" // sequence -//// "6100000000" // input_fk-> -//// -//// "06000000" // pk->6 -//// "00000000" // fp: point_stub -//// "180000" // fp: point_index -//// "04000000" // parent_fk-> -//// "2a000000" // sequence -//// "6a00000000" // input_fk-> -//// -//// "ffffffff" // terminal-> -//// "00000000" // fp: point_stub -//// "2a0000" // fp: point_index -//// "04000000" // parent_fk-> -//// "18000000" // sequence -//// "7200000000" // input_fk-> -//// -//// "ffffffff" // terminal-> -//// "01000000" // fp: point_stub -//// "2b0000" // fp: point_index -//// "04000000" // parent_fk-> -//// "19000000" // sequence -//// "7a00000000" // input_fk-> -//// ); -//// const auto input_head = base16_chunk -//// ( -//// "0000000000" -//// ); -//// const auto input_body = base16_chunk -//// ( -//// "4d04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b7300" -//// "0704ffff001d010400" -//// "0704ffff001d010b00" -//// "0704ffff001d010e00" -//// "026a790103242424" -//// "026a7a0103313131" -//// "026a7a0103424242" -//// ); -//// ////BOOST_REQUIRE_EQUAL(store.spend_head(), spend_head); -//// ////BOOST_REQUIRE_EQUAL(store.spend_body(), spend_body); -//// ////BOOST_REQUIRE_EQUAL(store.input_head(), input_head); -//// ////BOOST_REQUIRE_EQUAL(store.input_body(), input_body); -////} -//// -////////BOOST_AUTO_TEST_CASE(query_translate__get_point_sets__populated__expected) -////////{ -//////// settings settings{}; -//////// settings.path = TEST_DIRECTORY; -//////// test::chunk_store store{ settings }; -//////// accessor query{ store }; -//////// BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); -//////// -//////// // coinbase only (null and first). -//////// point_sets sets{}; -//////// BOOST_REQUIRE(query.initialize(test::genesis)); -//////// BOOST_REQUIRE(query.get_point_sets_(sets, 0)); -//////// BOOST_REQUIRE_EQUAL(sets.size(), 0u); -//////// BOOST_REQUIRE(query.get_point_sets_(sets, 1)); -//////// BOOST_REQUIRE_EQUAL(sets.size(), 0u); -//////// BOOST_REQUIRE(query.get_point_sets_(sets, 2)); -//////// BOOST_REQUIRE_EQUAL(sets.size(), 0u); -//////// -//////// BOOST_REQUIRE_EQUAL(store.point_body(), system::base16_chunk("")); -//////// BOOST_REQUIRE_EQUAL(store.spend_body(), -//////// system::base16_chunk("ffffffff00000000ffffffffffffff00000000ffffffff0000000000")); -//////// BOOST_REQUIRE_EQUAL(store.input_body(), -//////// system::base16_chunk("4d04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73""00")); -//////// BOOST_REQUIRE_EQUAL(store.output_body(), -//////// system::base16_chunk("00000000""ff00f2052a01000000""434104678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5fac")); -//////// -//////// // coinbase only (null and first). -//////// BOOST_REQUIRE(query.set(test::block1b, context{ 0, 1, 0 }, false, false)); -//////// BOOST_REQUIRE(query.get_point_sets_(sets, 0)); -//////// BOOST_REQUIRE_EQUAL(sets.size(), 0u); -//////// BOOST_REQUIRE(query.get_point_sets_(sets, 1)); -//////// BOOST_REQUIRE_EQUAL(sets.size(), 0u); -//////// BOOST_REQUIRE(query.get_point_sets_(sets, 2)); -//////// BOOST_REQUIRE_EQUAL(sets.size(), 0u); -//////// -//////// BOOST_REQUIRE_EQUAL(store.point_body(), system::base16_chunk("")); -//////// BOOST_REQUIRE_EQUAL(store.spend_body(), -//////// system::base16_chunk("ffffffff00000000ffffffffffffff00000000ffffffff00000000000000000000000000ffffffffffffff01000000b10000004f00000000")); -//////// BOOST_REQUIRE_EQUAL(store.input_body(), -//////// system::base16_chunk("4d04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73""00" -//////// "02ae82""00")); -//////// BOOST_REQUIRE_EQUAL(store.output_body(), -//////// system::base16_chunk("00000000""ff00f2052a01000000""434104678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5fac" -//////// "01000000""b1""0179" -//////// "01000000""b1""0179")); -//////// -//////// // COINBASE TX -//////// // 2 inputs (block1b and tx2b). -//////// BOOST_REQUIRE(query.set(test::block_spend_internal_2b, context{ 0, 101, 0 }, false, false)); -//////// BOOST_REQUIRE(query.get_point_sets_(sets, 0)); -//////// BOOST_REQUIRE_EQUAL(sets.size(), 0u); -//////// BOOST_REQUIRE(query.get_point_sets_(sets, 1)); -//////// BOOST_REQUIRE_EQUAL(sets.size(), 0u); -//////// -//////// // Two points because non-null, but only one is non-first (also coinbase criteria). -//////// // block_spend_internal_2b first tx (tx2b) is first but with non-null input. -//////// // block_spend_internal_2b second tx spends block1b. Archival keys on pont-nullness. -//////// BOOST_REQUIRE_EQUAL(store.point_body(), -//////// system::base16_chunk("ffffffff""730460db96b2968de1fe1fbf5cc5aa229f936943ac400ea0047899af03c89ac9" -//////// "ffffffff""cad29b6decf1a6d4d47482e7f2c3b50e0a757ca618f7f9e01d4373ab3437c02d")); -//////// ////BOOST_REQUIRE_EQUAL(store.spend_body(), -//////// //// system::base16_chunk("ffffffff""ffffffffffffff""00000000""ffffffff""0000000000" -//////// //// "00000000""ffffffffffffff""01000000""b1000000""4f00000000" -//////// //// "ffffffff""00000000000000""02000000""b1000000""5300000000" -//////// //// "ffffffff""01000000000000""03000000""b2000000""5700000000")); -//////// ////BOOST_REQUIRE_EQUAL(store.input_body(), -//////// //// system::base16_chunk("4d04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73""00" -//////// //// "02ae82""00" -//////// //// "02ae82""00" -//////// //// "02ae82""00")); -//////// ////BOOST_REQUIRE_EQUAL(store.output_body(), -//////// //// system::base16_chunk("00000000""ff00f2052a01000000""434104678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5fac" -//////// //// "01000000""b1""0179" -//////// //// "01000000""b1""0179" -//////// //// "02000000""b1""0179" -//////// //// "03000000""b2""0179")); -//////// -//////// ////// Populated spend requires associated prevout. -//////// ////BOOST_REQUIRE(!query.get_point_sets_(sets, 2)); -//////// -//////// ////// Internal coinbase spend is treated as a transaction lock fault. -//////// ////// This results in the one spend being initialized (block internal). -//////// ////BOOST_REQUIRE(!test::block_spend_internal_2b.populate(system::chain::context{})); -//////// -//////// ////// Internal spends are always set to terminal/coinbase. -//////// ////BOOST_REQUIRE(query.set_prevouts(2, test::block_spend_internal_2b)); -//////// -//////// ////// get_point_sets keys on first-tx-ness, so only one input despite two points. -//////// ////BOOST_REQUIRE(query.get_point_sets_(sets, 2)); -//////// ////BOOST_REQUIRE_EQUAL(sets.size(), 1u); -//////// ////BOOST_REQUIRE_EQUAL(sets[0].tx, 3u); -//////// ////BOOST_REQUIRE_EQUAL(sets[0].spends.size(), 1u); -//////// ////BOOST_REQUIRE_EQUAL(sets[0].spends[0].point_stub, 1u); -//////// ////BOOST_REQUIRE_EQUAL(sets[0].spends[0].point_index, 0u); -//////// ////BOOST_REQUIRE_EQUAL(sets[0].spends[0].sequence, 0xb2u); -//////// -//////// ////// Internal spend is terminal/coinbase. -//////// ////BOOST_REQUIRE(sets[0].spends[0].coinbase); -//////// ////BOOST_REQUIRE_EQUAL(sets[0].spends[0].prevout_tx, tx_link::terminal); -////////} -//// -////// to_output_tx/to_output/to_outputs/to_prevouts/to_block_outputs -//// -////BOOST_AUTO_TEST_CASE(query_translate__to_output_tx__to_output__expected) -////{ -//// settings settings{}; -//// settings.path = TEST_DIRECTORY; -//// test::chunk_store store{ settings }; -//// test::query_accessor query{ store }; -//// BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); -//// BOOST_REQUIRE(query.initialize(test::genesis)); -//// BOOST_REQUIRE(query.set(test::block1, test::context, false, false)); -//// BOOST_REQUIRE(query.set(test::block2, test::context, false, false)); -//// BOOST_REQUIRE(query.set(test::block3, test::context, false, false)); -//// BOOST_REQUIRE(query.set(test::block1a, test::context, false, false)); -//// -//// // All 5 blocks have one transaction with 1 output. -//// BOOST_REQUIRE_EQUAL(query.to_output_tx(0 * 0x51), 0u); -//// BOOST_REQUIRE_EQUAL(query.to_output_tx(1 * 0x51), 1u); -//// BOOST_REQUIRE_EQUAL(query.to_output_tx(2 * 0x51), 2u); -//// BOOST_REQUIRE_EQUAL(query.to_output_tx(3 * 0x51), 3u); -//// BOOST_REQUIRE_EQUAL(query.to_output_tx(4 * 0x51), 4u); -//// BOOST_REQUIRE_EQUAL(query.to_output_tx(4 * 0x51 + 7u), 4u); -//// -//// BOOST_REQUIRE_EQUAL(query.to_output(0, 0), 0u * 0x51u); -//// BOOST_REQUIRE_EQUAL(query.to_output(1, 0), 1u * 0x51u); -//// BOOST_REQUIRE_EQUAL(query.to_output(2, 0), 2u * 0x51u); -//// BOOST_REQUIRE_EQUAL(query.to_output(3, 0), 3u * 0x51u); -//// BOOST_REQUIRE_EQUAL(query.to_output(4, 0), 4u * 0x51u); -//// BOOST_REQUIRE_EQUAL(query.to_output(4, 1), 4u * 0x51u + 7u); -//// -//// const output_links expected_outputs4{ 4 * 0x51, 4 * 0x51 + 7 }; -//// BOOST_REQUIRE_EQUAL(query.to_outputs(0), output_links{ 0 * 0x51 }); -//// BOOST_REQUIRE_EQUAL(query.to_outputs(1), output_links{ 1 * 0x51 }); -//// BOOST_REQUIRE_EQUAL(query.to_outputs(2), output_links{ 2 * 0x51 }); -//// BOOST_REQUIRE_EQUAL(query.to_outputs(3), output_links{ 3 * 0x51 }); -//// BOOST_REQUIRE_EQUAL(query.to_outputs(4), expected_outputs4); -//// -//// // All blocks have one transaction. -//// BOOST_REQUIRE_EQUAL(query.to_block_outputs(0), output_links{ 0 * 0x51 }); -//// BOOST_REQUIRE_EQUAL(query.to_block_outputs(1), output_links{ 1 * 0x51 }); -//// BOOST_REQUIRE_EQUAL(query.to_block_outputs(2), output_links{ 2 * 0x51 }); -//// BOOST_REQUIRE_EQUAL(query.to_block_outputs(3), output_links{ 3 * 0x51 }); -//// BOOST_REQUIRE_EQUAL(query.to_block_outputs(4), expected_outputs4); -//// -//// // No prevouts that exist. -//// const output_links expected_prevouts4{ output_link::terminal, output_link::terminal, output_link::terminal }; -//// BOOST_REQUIRE_EQUAL(query.to_prevouts(0), output_links{ output_link::terminal }); -//// BOOST_REQUIRE_EQUAL(query.to_prevouts(1), output_links{ output_link::terminal }); -//// BOOST_REQUIRE_EQUAL(query.to_prevouts(2), output_links{ output_link::terminal }); -//// BOOST_REQUIRE_EQUAL(query.to_prevouts(3), output_links{ output_link::terminal }); -//// BOOST_REQUIRE_EQUAL(query.to_prevouts(4), expected_prevouts4); -//// -//// // All blocks have one transaction. -//// BOOST_REQUIRE_EQUAL(query.to_block_prevouts(0), output_links{}); -//// BOOST_REQUIRE_EQUAL(query.to_block_prevouts(1), output_links{}); -//// BOOST_REQUIRE_EQUAL(query.to_block_prevouts(2), output_links{}); -//// BOOST_REQUIRE_EQUAL(query.to_block_prevouts(3), output_links{}); -//// BOOST_REQUIRE_EQUAL(query.to_block_prevouts(4), output_links{}); -//// -//// // Past end. -//// BOOST_REQUIRE_EQUAL(query.to_output_tx(4 * 0x51 + 14), tx_link::terminal); -//// BOOST_REQUIRE_EQUAL(query.to_output(5, 0), output_link::terminal); -//// BOOST_REQUIRE(query.to_outputs(5).empty()); -//// BOOST_REQUIRE(query.to_block_outputs(5).empty()); -//// -//// // Verify expectations. -//// const auto output_body = system::base16_chunk -//// ( -//// // 0, 1, 2, 3, 4, 4 -//// "00000000""ff00f2052a01000000434104678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5fac" -//// "01000000""ff00f2052a0100000043410496b538e853519c726a2c91e61ec11600ae1390813a627c66fb8be7947be63c52da7589379515d4e0a604f8141781e62294721166bf621e73a82cbf2342c858eeac" -//// "02000000""ff00f2052a010000004341047211a824f55b505228e4c3d5194c1fcfaa15a456abdf37f9b9d97a4040afc073dee6c89064984f03385237d92167c13e236446b417ab79a0fcae412ae3316b77ac" -//// "03000000""ff00f2052a0100000043410494b9d3e76c5b1629ecf97fff95d7a4bbdac87cc26099ada28066c6ff1eb9191223cd897194a08d0c2726c5747f1db49e8cf90e75dc3e3550ae9b30086f3cd5aaac" -//// "04000000""180179" -//// "04000000""2a017a" -//// ); -//// BOOST_REQUIRE_EQUAL(store.output_body(), output_body); -////} -//// -////// to_prevout_tx/to_prevout/to_prevouts -//// -////BOOST_AUTO_TEST_CASE(query_translate__to_prevout_tx__to_prevout__expected) -////{ -//// settings settings{}; -//// settings.tx_buckets = 3; -//// settings.path = TEST_DIRECTORY; -//// test::chunk_store store{ settings }; -//// test::query_accessor query{ store }; -//// BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); -//// BOOST_REQUIRE(query.initialize(test::genesis)); -//// BOOST_REQUIRE(query.set(test::block1a, test::context, false, false)); -//// BOOST_REQUIRE(query.set(test::block2a, test::context, false, false)); -//// -//// // inputs in link order. -//// BOOST_REQUIRE_EQUAL(query.to_prevout_tx(0), tx_link::terminal); -//// BOOST_REQUIRE_EQUAL(query.to_prevout_tx(1), tx_link::terminal); -//// BOOST_REQUIRE_EQUAL(query.to_prevout_tx(2), tx_link::terminal); -//// BOOST_REQUIRE_EQUAL(query.to_prevout_tx(3), tx_link::terminal); -//// BOOST_REQUIRE_EQUAL(query.to_prevout_tx(4), 1u); // block1a:0 (second serialized tx) -//// BOOST_REQUIRE_EQUAL(query.to_prevout_tx(5), 1u); // block1a:0 (second serialized tx) -//// BOOST_REQUIRE_EQUAL(query.to_prevout_tx(6), tx_link::terminal); -//// BOOST_REQUIRE_EQUAL(query.to_prevout_tx(7), tx_link::terminal); -//// -//// BOOST_REQUIRE_EQUAL(query.to_prevout(0), output_link::terminal); -//// BOOST_REQUIRE_EQUAL(query.to_prevout(1), output_link::terminal); -//// BOOST_REQUIRE_EQUAL(query.to_prevout(2), output_link::terminal); -//// BOOST_REQUIRE_EQUAL(query.to_prevout(3), output_link::terminal); -//// BOOST_REQUIRE_EQUAL(query.to_prevout(4), 0x51u); // block1a:0:0 (second serialized tx:0) -//// BOOST_REQUIRE_EQUAL(query.to_prevout(5), 0x51u + 7u); // block1a:0:1 (second serialized tx:1) -//// BOOST_REQUIRE_EQUAL(query.to_prevout(6), output_link::terminal); -//// BOOST_REQUIRE_EQUAL(query.to_prevout(7), output_link::terminal); -//// -//// const output_links expected_prevouts1{ output_link::terminal }; -//// const output_links expected_prevouts2{ output_link::terminal, output_link::terminal }; -//// const output_links expected_prevouts3{ output_link::terminal, output_link::terminal, output_link::terminal }; -//// const output_links expected_prevouts{ 0x51u, 0x51u + 7u }; -//// BOOST_REQUIRE_EQUAL(query.to_prevouts(0), expected_prevouts1); -//// BOOST_REQUIRE_EQUAL(query.to_prevouts(1), expected_prevouts3); -//// BOOST_REQUIRE_EQUAL(query.to_prevouts(2), expected_prevouts); -//// BOOST_REQUIRE_EQUAL(query.to_prevouts(3), expected_prevouts2); -//// -//// // First tx is coinbase, or tx has undefined prevouts. -//// BOOST_REQUIRE_EQUAL(query.to_block_prevouts(0), output_links{}); -//// BOOST_REQUIRE_EQUAL(query.to_block_prevouts(1), output_links{}); -//// BOOST_REQUIRE_EQUAL(query.to_block_prevouts(2), expected_prevouts2); -//// -//// // Past end. -//// BOOST_REQUIRE_EQUAL(query.to_prevout_tx(8), tx_link::terminal); -//// BOOST_REQUIRE_EQUAL(query.to_prevout(8), output_link::terminal); -//// -//// // Verify expectations. -//// const auto input_head = system::base16_chunk -//// ( -//// "0000000000" -//// ); -//// const auto input_body = system::base16_chunk -//// ( -//// "4d04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73""00" -//// "026a79""0103242424" -//// "026a7a""0103313131" -//// "026a7a""0103424242" -//// "02ae79""0103242424" -//// "02ae7a""0103313131" -//// "02ae79""0103242424" -//// "02ae7a""0103313131" -//// ); -//// const auto output_head = system::base16_chunk -//// ( -//// "0000000000" -//// ); -//// const auto output_body = system::base16_chunk -//// ( -//// // parent value script -//// "00000000""ff00f2052a01000000""434104678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5fac" -//// "01000000""18""0179" -//// "01000000""2a""017a" -//// "02000000""81""0179" -//// "03000000""81""0179" -//// ); -//// const auto tx_head = system::base16_chunk -//// ( -//// "00000000" // size -//// "03000000" -//// "ffffffff" -//// "ffffffff" -//// "01000000" -//// "02000000" -//// ); -//// const auto tx_body = system::base16_chunk -//// ( -//// "ffffffff" // genesis:0 [0]->terminal -//// "3ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a" -//// "01cc0000cc00000000000001000000010000010000""0000000000" -//// "00000000" // block1a:0 [1]->[0] -//// "d19c4584d53264e5d0f9d2f852578c4d4382b69abee853bfbd6bc580f84069cf" -//// "009f0000b00000180000002a000000030000020000""0900000000" -//// "ffffffff" // block2a:0 [2]->terminal -//// "c67bfbf8f354bd8f26d7a8b60c20b591dddf8760e02a1fcc3fd7af60b4253e67" -//// "006a000076000081000000a2000000020000010000""1f00000000" -//// "ffffffff" // block2a:1 [3]->terminal -//// "64a86f067651854e2242b6ac9430b6d6806ea2b24dd7edec7b61dd885cf4a40c" -//// "006a000076000081000000a2000000020000010000""2c00000000" -//// ); -//// -//// BOOST_REQUIRE_EQUAL(store.input_head(), input_head); -//// BOOST_REQUIRE_EQUAL(store.input_body(), input_body); -//// BOOST_REQUIRE_EQUAL(store.output_head(), output_head); -//// BOOST_REQUIRE_EQUAL(store.output_body(), output_body); -//// BOOST_REQUIRE_EQUAL(store.tx_head(), tx_head); -//// BOOST_REQUIRE_EQUAL(store.tx_body(), tx_body); -////} -//// -////// to_block/set_strong/set_unstrong/to_strong/to_strongs -//// -////// Duplicate tx hashes not tested (cannot set duplicates with guard in place). -////BOOST_AUTO_TEST_CASE(query_translate__to_block__set_strong__expected) -////{ -//// settings settings{}; -//// settings.path = TEST_DIRECTORY; -//// test::chunk_store store{ settings }; -//// -//// class accessor -//// : public test::query_accessor -//// { -//// public: -//// using test::query_accessor::query_accessor; -//// tx_links find_strong_txs_(const tx_link& link) const NOEXCEPT -//// { -//// return find_strong_txs(link); -//// } -//// tx_links find_strong_txs_(const hash_digest& tx_hash) const NOEXCEPT -//// { -//// return find_strong_txs(tx_hash); -//// } -//// ////strong_pair find_strong_(const hash_digest& tx_hash) const NOEXCEPT -//// ////{ -//// //// return find_strong(tx_hash); -//// ////} -//// }; -//// -//// accessor query{ store }; -//// BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); -//// BOOST_REQUIRE(query.initialize(test::genesis)); -//// BOOST_REQUIRE(query.set(test::block1, test::context, false, false)); -//// BOOST_REQUIRE(query.set(test::block2, test::context, false, false)); -//// -//// // for to_strong/to_strongs -//// const auto hash0 = test::genesis.transaction_hashes(false).front(); -//// const auto hash1 = test::block1.transaction_hashes(false).front(); -//// const auto hash2 = test::block2.transaction_hashes(false).front(); -//// const auto hash3 = test::block3.transaction_hashes(false).front(); -//// -//// // Either not strong or not found, except genesis. -//// BOOST_REQUIRE_EQUAL(query.to_block(0), 0u); -//// BOOST_REQUIRE_EQUAL(query.to_block(1), header_link::terminal); -//// BOOST_REQUIRE_EQUAL(query.to_block(2), header_link::terminal); -//// BOOST_REQUIRE_EQUAL(query.to_block(3), header_link::terminal); -//// ////BOOST_REQUIRE_EQUAL(query.find_strong_(hash0).block, 0u); -//// ////BOOST_REQUIRE_EQUAL(query.find_strong_(hash0).tx, 0u); -//// ////BOOST_REQUIRE_EQUAL(query.find_strong_(hash1).block, header_link::terminal); -//// ////BOOST_REQUIRE_EQUAL(query.find_strong_(hash1).tx, 1u); -//// ////BOOST_REQUIRE_EQUAL(query.find_strong_(hash2).block, header_link::terminal); -//// ////BOOST_REQUIRE_EQUAL(query.find_strong_(hash2).tx, 2u); -//// ////BOOST_REQUIRE_EQUAL(query.find_strong_(hash3).block, header_link::terminal); -//// ////BOOST_REQUIRE_EQUAL(query.find_strong_(hash3).tx, tx_link::terminal); -//// BOOST_REQUIRE_EQUAL(query.find_strong_txs_(hash0).size(), 1u); -//// BOOST_REQUIRE_EQUAL(query.find_strong_txs_(hash0).front(), 0u); -//// BOOST_REQUIRE(query.find_strong_txs_(hash1).empty()); -//// BOOST_REQUIRE(query.find_strong_txs_(hash2).empty()); -//// BOOST_REQUIRE(query.find_strong_txs_(hash3).empty()); -//// -//// // push_candidate/push_confirmed has no effect. -//// BOOST_REQUIRE(query.push_candidate(query.to_header(test::genesis.hash()))); -//// BOOST_REQUIRE(query.push_confirmed(query.to_header(test::genesis.hash()), false)); -//// BOOST_REQUIRE_EQUAL(query.to_block(0), 0u); -//// BOOST_REQUIRE_EQUAL(query.to_block(1), header_link::terminal); -//// BOOST_REQUIRE_EQUAL(query.to_block(2), header_link::terminal); -//// BOOST_REQUIRE_EQUAL(query.to_block(3), header_link::terminal); -//// ////BOOST_REQUIRE_EQUAL(query.find_strong_(hash0).block, 0u); -//// ////BOOST_REQUIRE_EQUAL(query.find_strong_(hash0).tx, 0u); -//// ////BOOST_REQUIRE_EQUAL(query.find_strong_(hash1).block, header_link::terminal); -//// ////BOOST_REQUIRE_EQUAL(query.find_strong_(hash1).tx, 1u); -//// ////BOOST_REQUIRE_EQUAL(query.find_strong_(hash2).block, header_link::terminal); -//// ////BOOST_REQUIRE_EQUAL(query.find_strong_(hash2).tx, 2u); -//// ////BOOST_REQUIRE_EQUAL(query.find_strong_(hash3).block, header_link::terminal); -//// ////BOOST_REQUIRE_EQUAL(query.find_strong_(hash3).tx, tx_link::terminal); -//// BOOST_REQUIRE_EQUAL(query.find_strong_txs_(hash0).size(), 1u); -//// BOOST_REQUIRE_EQUAL(query.find_strong_txs_(hash0).front(), 0u); -//// BOOST_REQUIRE(query.find_strong_txs_(hash1).empty()); -//// BOOST_REQUIRE(query.find_strong_txs_(hash2).empty()); -//// BOOST_REQUIRE(query.find_strong_txs_(hash3).empty()); -//// -//// // set_strong sets strong_by (only), and is idempotent. -//// // However this second genesis set_strong creates an additional tx link, -//// // which increments the link values returnedby find_strong_txs_(). -//// BOOST_REQUIRE(query.set_strong(query.to_header(test::genesis.hash()))); -//// BOOST_REQUIRE(query.set_strong(query.to_header(test::block1.hash()))); -//// BOOST_REQUIRE_EQUAL(query.to_block(0), 0u); -//// BOOST_REQUIRE_EQUAL(query.to_block(1), 1u); -//// BOOST_REQUIRE_EQUAL(query.to_block(2), header_link::terminal); -//// BOOST_REQUIRE_EQUAL(query.to_block(3), header_link::terminal); -//// ////BOOST_REQUIRE_EQUAL(query.find_strong_(hash0).block, 0u); -//// ////BOOST_REQUIRE_EQUAL(query.find_strong_(hash0).tx, 0u); -//// ////BOOST_REQUIRE_EQUAL(query.find_strong_(hash1).block, 1u); -//// ////BOOST_REQUIRE_EQUAL(query.find_strong_(hash1).tx, 1u); -//// ////BOOST_REQUIRE_EQUAL(query.find_strong_(hash2).block, header_link::terminal); -//// ////BOOST_REQUIRE_EQUAL(query.find_strong_(hash2).tx, 2u); -//// ////BOOST_REQUIRE_EQUAL(query.find_strong_(hash3).block, header_link::terminal); -//// ////BOOST_REQUIRE_EQUAL(query.find_strong_(hash3).tx, tx_link::terminal); -//// BOOST_REQUIRE_EQUAL(query.find_strong_txs_(hash0).size(), 1u); -//// BOOST_REQUIRE_EQUAL(query.find_strong_txs_(hash0).front(), 1u); -//// BOOST_REQUIRE_EQUAL(query.find_strong_txs_(hash1).size(), 1u); -//// BOOST_REQUIRE_EQUAL(query.find_strong_txs_(hash1).front(), 2u); -//// BOOST_REQUIRE(query.find_strong_txs_(hash2).empty()); -//// BOOST_REQUIRE(query.find_strong_txs_(hash3).empty()); -//// -//// // candidate/confirmed unaffected. -//// BOOST_REQUIRE(query.is_candidate_header(query.to_header(test::genesis.hash()))); -//// BOOST_REQUIRE(query.is_confirmed_block(query.to_header(test::genesis.hash()))); -//// BOOST_REQUIRE(!query.is_candidate_header(query.to_header(test::block1.hash()))); -//// BOOST_REQUIRE(!query.is_confirmed_block(query.to_header(test::block1.hash()))); -//// -//// // set_unstrong unsets strong_by, and is idempotent. -//// BOOST_REQUIRE(query.set_unstrong(query.to_header(test::genesis.hash()))); -//// BOOST_REQUIRE(query.set_unstrong(query.to_header(test::block1.hash()))); -//// BOOST_REQUIRE(query.set_unstrong(query.to_header(test::block2.hash()))); -//// BOOST_REQUIRE_EQUAL(query.to_block(0), header_link::terminal); -//// BOOST_REQUIRE_EQUAL(query.to_block(1), header_link::terminal); -//// BOOST_REQUIRE_EQUAL(query.to_block(2), header_link::terminal); -//// BOOST_REQUIRE_EQUAL(query.to_block(3), header_link::terminal); -//// ////BOOST_REQUIRE_EQUAL(query.find_strong_(hash0).block, header_link::terminal); -//// ////BOOST_REQUIRE_EQUAL(query.find_strong_(hash1).block, header_link::terminal); -//// ////BOOST_REQUIRE_EQUAL(query.find_strong_(hash2).block, header_link::terminal); -//// ////BOOST_REQUIRE_EQUAL(query.find_strong_(hash3).block, header_link::terminal); -//// BOOST_REQUIRE(query.find_strong_txs_(hash0).empty()); -//// BOOST_REQUIRE(query.find_strong_txs_(hash1).empty()); -//// BOOST_REQUIRE(query.find_strong_txs_(hash2).empty()); -//// BOOST_REQUIRE(query.find_strong_txs_(hash3).empty()); -////} -//// -////// _to_parent -//// -////BOOST_AUTO_TEST_CASE(query_translate__to_parent__always__expected) -////{ -//// settings settings{}; -//// settings.path = TEST_DIRECTORY; -//// test::chunk_store store{ settings }; -//// test::query_accessor query{ store }; -//// BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); -//// BOOST_REQUIRE(query.initialize(test::genesis)); -//// BOOST_REQUIRE(query.set(test::block1, test::context, false, false)); -//// BOOST_REQUIRE(query.set(test::block2, test::context, false, false)); -//// BOOST_REQUIRE(query.set(test::block1a, test::context, false, false)); -//// BOOST_REQUIRE(query.set(test::block2a, test::context, false, false)); -//// BOOST_REQUIRE_EQUAL(query.to_parent(0), header_link::terminal); -//// BOOST_REQUIRE_EQUAL(query.to_parent(1), 0u); -//// BOOST_REQUIRE_EQUAL(query.to_parent(2), 1u); -//// BOOST_REQUIRE_EQUAL(query.to_parent(3), 0u); -//// BOOST_REQUIRE_EQUAL(query.to_parent(4), 3u); -//// BOOST_REQUIRE_EQUAL(query.to_parent(5), header_link::terminal); -////} -//// -////// to_txs -//// -////BOOST_AUTO_TEST_CASE(query_translate__to_txs__always__expected) -////{ -//// settings settings{}; -//// settings.path = TEST_DIRECTORY; -//// test::chunk_store store{ settings }; -//// test::query_accessor query{ store }; -//// BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); -//// BOOST_REQUIRE(query.initialize(test::genesis)); -//// BOOST_REQUIRE(query.set(test::block1a, test::context, false, false)); -//// BOOST_REQUIRE(query.set(test::block2a, test::context, false, false)); -//// -//// const tx_links expected_links2{ 2, 3 }; -//// BOOST_REQUIRE_EQUAL(query.to_transactions(0), tx_links{ 0 }); -//// BOOST_REQUIRE_EQUAL(query.to_transactions(1), tx_links{ 1 }); -//// BOOST_REQUIRE_EQUAL(query.to_transactions(2), expected_links2); -//// BOOST_REQUIRE(query.to_transactions(3).empty()); -////} -//// -////// to_spenders -//// -////BOOST_AUTO_TEST_CASE(query_translate__to_spenders__point__expected) -////{ -//// settings settings{}; -//// settings.tx_buckets = 3; -//// settings.spend_buckets = 3; -//// settings.path = TEST_DIRECTORY; -//// test::chunk_store store{ settings }; -//// test::query_accessor query{ store }; -//// BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); -//// BOOST_REQUIRE(query.initialize(test::genesis)); -//// BOOST_REQUIRE(query.set(test::block1a, test::context, false, false)); -//// BOOST_REQUIRE(query.set(test::block2a, test::context, false, false)); -//// BOOST_REQUIRE(query.set(test::tx4)); -//// BOOST_REQUIRE(query.to_spenders({ test::genesis.hash(), 0 }).empty()); -//// -//// const auto point2 = system::base16_array("d19c4584d53264e5d0f9d2f852578c4d4382b69abee853bfbd6bc580f84069cf"); -//// BOOST_REQUIRE_EQUAL(test::block1a.transactions_ptr()->front()->hash(false), point2); -//// -//// // switch to record index -//// const auto expected0 = spend_links{ 8, 4 }; -//// const auto expected1 = spend_links{ 9, 5 }; -//// const auto spenders0a = query.to_spenders({ point2, 0 }); -//// const auto spenders1a = query.to_spenders({ point2, 1 }); -//// BOOST_REQUIRE_EQUAL(spenders0a, expected0); -//// BOOST_REQUIRE_EQUAL(spenders1a, expected1); -//// BOOST_REQUIRE(query.to_spenders({ test::block2a.transactions_ptr()->front()->hash(false), 0 }).empty()); -//// BOOST_REQUIRE(query.to_spenders({ test::block2a.transactions_ptr()->back()->hash(false), 0 }).empty()); -//// BOOST_REQUIRE(query.to_spenders({ test::tx4.hash(false), 0 }).empty()); -//// BOOST_REQUIRE(query.to_spenders({ test::tx4.hash(false), 1 }).empty()); // n/a, only one output -//// BOOST_REQUIRE(query.to_spenders({ system::null_hash, 0xffffffff }).empty()); -//// -//// BOOST_REQUIRE(query.to_spenders(0x00).empty()); -//// const auto spenders0b = query.to_spenders(0x51 + 0 * 7); -//// const auto spenders1b = query.to_spenders(0x51 + 1 * 7); -//// BOOST_REQUIRE_EQUAL(spenders0b, expected0); -//// BOOST_REQUIRE_EQUAL(spenders1b, expected1); -//// BOOST_REQUIRE(query.to_spenders(0x51 + 2 * 7).empty()); -//// BOOST_REQUIRE(query.to_spenders(0x51 + 3 * 7).empty()); -//// BOOST_REQUIRE(query.to_spenders(0x51 + 4 * 7).empty()); -//// BOOST_REQUIRE(query.to_spenders(output_link::terminal).empty()); -//// -//// BOOST_REQUIRE(query.to_spenders(0, 0).empty()); -//// const auto spenders0c = query.to_spenders(1, 0); -//// const auto spenders1c = query.to_spenders(1, 1); -//// BOOST_REQUIRE_EQUAL(spenders0c, expected0); -//// BOOST_REQUIRE_EQUAL(spenders1c, expected1); -//// BOOST_REQUIRE(query.to_spenders(2, 0).empty()); -//// BOOST_REQUIRE(query.to_spenders(3, 0).empty()); -//// BOOST_REQUIRE(query.to_spenders(4, 0).empty()); -//// BOOST_REQUIRE(query.to_spenders(4, 1).empty()); // n/a, only one output -//// BOOST_REQUIRE(query.to_spenders(tx_link::terminal, 0).empty()); -//// -//// // Verify expectations. -//// const auto point_body = system::base16_chunk -//// ( -//// "0100000000000000000000000000000000000000000000000000000000000000" // block1a:tx1(0) invalid spend -//// "0100000000000000000000000000000000000000000000000000000000000000" // block1a:tx1(1) invalid spend -//// "0200000000000000000000000000000000000000000000000000000000000000" // block1a:tx1(2) invalid spend -//// "d19c4584d53264e5d0f9d2f852578c4d4382b69abee853bfbd6bc580f84069cf" // block2a:tx1(0) valid spend of block1a:tx1(0,1) -//// "d19c4584d53264e5d0f9d2f852578c4d4382b69abee853bfbd6bc580f84069cf" // block2a:tx1(1) valid spend of block1a:tx1(0,1) -//// "0100000000000000000000000000000000000000000000000000000000000000" // block2a:tx2(0) invalid spend -//// "0100000000000000000000000000000000000000000000000000000000000000" // block2a:tx2(1) invalid spend -//// "d19c4584d53264e5d0f9d2f852578c4d4382b69abee853bfbd6bc580f84069cf" // tx4 valid spends of block1a:tx1(0,1) -//// "d19c4584d53264e5d0f9d2f852578c4d4382b69abee853bfbd6bc580f84069cf" // tx4 valid spends of block1a:tx1(0,1) -//// ); -//// const auto spend_head = system::base16_chunk -//// ( -//// "00000000" // size -//// "01000000" -//// "08000000" -//// "09000000" -//// "06000000" -//// "07000000" -//// ); -//// const auto spend_body = system::base16_chunk -//// ( -//// "ffffffff""ffffffff""ffffff""00000000""ffffffff""0000000000" -//// "03000000""00000000""180000""01000000""2a000000""4f00000000" -//// "ffffffff""00000000""2a0000""01000000""18000000""5700000000" -//// "ffffffff""01000000""2b0000""01000000""19000000""5f00000000" -//// "02000000""02000000""000000""02000000""a2000000""6700000000" -//// "ffffffff""02000000""010000""02000000""81000000""6f00000000" -//// "04000000""00000000""200000""03000000""a2000000""7700000000" -//// "05000000""00000000""210000""03000000""81000000""7f00000000" -//// "06000000""02000000""000000""04000000""a5000000""8700000000" -//// "07000000""02000000""010000""04000000""85000000""8f00000000" -//// ); -//// const auto input_head = system::base16_chunk -//// ( -//// "0000000000" // size -//// ); -//// const auto input_body = system::base16_chunk -//// ( -//// "4d04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73""00" -//// "026a7901""03242424" // 1a:0:0 -//// "026a7a01""03313131" // 1a:0:1 -//// "026a7a01""03424242" // 1a:0:2 -//// "02ae7901""03242424" // 2a:0:0 -//// "02ae7a01""03313131" // 2a:0:1 -//// "02ae7901""03242424" // 2a:1:0 -//// "02ae7a01""03313131" // 2a:1:1 -//// "02ae7901""03252525" // tx4:0 -//// "02ae7a01""03353535" // tx4:1 -//// ); -//// const auto output_head = system::base16_chunk -//// ( -//// "0000000000" // size -//// ); -//// const auto output_body = system::base16_chunk -//// ( -//// // parent value script -//// "00000000""ff00f2052a01000000""434104678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5fac" -//// "01000000""18""0179" -//// "01000000""2a""017a" -//// "02000000""81""0179" -//// "03000000""81""0179" -//// "04000000""85""0179" -//// ); -//// const auto tx_head = system::base16_chunk -//// ( -//// "00000000" // size -//// "03000000" -//// "ffffffff" -//// "04000000" -//// "01000000" -//// "02000000" -//// ); -//// const auto tx_body = system::base16_chunk -//// ( -//// "ffffffff" // genesis:0 [0]->terminal -//// "3ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a" -//// "01""cc0000""cc0000""00000000""01000000""010000""010000""0000000000" -//// "00000000" // block1a:0 [1]->[0] -//// "d19c4584d53264e5d0f9d2f852578c4d4382b69abee853bfbd6bc580f84069cf" -//// "00""9f0000""b00000""18000000""2a000000""030000""020000""0900000000" -//// "ffffffff" // block2a:0 [2]->terminal -//// "c67bfbf8f354bd8f26d7a8b60c20b591dddf8760e02a1fcc3fd7af60b4253e67" -//// "00""6a0000""760000""81000000""a2000000""020000""010000""1f00000000" -//// "ffffffff" // block2a:1 [3]->terminal -//// "64a86f067651854e2242b6ac9430b6d6806ea2b24dd7edec7b61dd885cf4a40c" -//// "00""6a0000""760000""81000000""a2000000""020000""010000""2c00000000" -//// "ffffffff" // tx4 [4]->terminal -//// "abee882062e8df25c967717d0f97e0133af9be84861a427dd4e3f7370549c441" -//// "00""6a0000""760000""85000000""a5000000""020000""010000""3900000000" -//// ); -//// -//// BOOST_REQUIRE_EQUAL(store.point_body(), point_body); -//// BOOST_REQUIRE_EQUAL(store.spend_head(), spend_head); -//// ////BOOST_REQUIRE_EQUAL(store.spend_body(), spend_body); -//// ////BOOST_REQUIRE_EQUAL(store.input_head(), input_head); -//// ////BOOST_REQUIRE_EQUAL(store.input_body(), input_body); -//// ////BOOST_REQUIRE_EQUAL(store.output_head(), output_head); -//// ////BOOST_REQUIRE_EQUAL(store.output_body(), output_body); -//// ////BOOST_REQUIRE_EQUAL(store.tx_head(), tx_head); -//// ////BOOST_REQUIRE_EQUAL(store.tx_body(), tx_body); -////} -//// -////BOOST_AUTO_TEST_SUITE_END() diff --git a/test/tables/archives/ins.cpp b/test/tables/archives/ins.cpp new file mode 100644 index 00000000..17da3b27 --- /dev/null +++ b/test/tables/archives/ins.cpp @@ -0,0 +1,29 @@ +/** + * Copyright (c) 2011-2026 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +#include "../../test.hpp" +#include "../../mocks/chunk_storage.hpp" + +BOOST_AUTO_TEST_SUITE(ins_tests) + +BOOST_AUTO_TEST_CASE(ins_test) +{ + BOOST_REQUIRE(true); +} + +BOOST_AUTO_TEST_SUITE_END() diff --git a/test/tables/archives/outs.cpp b/test/tables/archives/outs.cpp new file mode 100644 index 00000000..8108ed52 --- /dev/null +++ b/test/tables/archives/outs.cpp @@ -0,0 +1,29 @@ +/** + * Copyright (c) 2011-2026 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +#include "../../test.hpp" +#include "../../mocks/chunk_storage.hpp" + +BOOST_AUTO_TEST_SUITE(outs_tests) + +BOOST_AUTO_TEST_CASE(outs_test) +{ + BOOST_REQUIRE(true); +} + +BOOST_AUTO_TEST_SUITE_END() diff --git a/test/tables/archives/puts.cpp b/test/tables/archives/puts.cpp deleted file mode 100644 index 98aa8a8f..00000000 --- a/test/tables/archives/puts.cpp +++ /dev/null @@ -1,113 +0,0 @@ -/////** -//// * Copyright (c) 2011-2026 libbitcoin developers (see AUTHORS) -//// * -//// * This file is part of libbitcoin. -//// * -//// * This program is free software: you can redistribute it and/or modify -//// * it under the terms of the GNU Affero General Public License as published by -//// * the Free Software Foundation, either version 3 of the License, or -//// * (at your option) any later version. -//// * -//// * This program is distributed in the hope that it will be useful, -//// * but WITHOUT ANY WARRANTY; without even the implied warranty of -//// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//// * GNU Affero General Public License for more details. -//// * -//// * You should have received a copy of the GNU Affero General Public License -//// * along with this program. If not, see . -//// */ -////#include "../../test.hpp" -////#include "../../mocks/chunk_storage.hpp" -//// -////BOOST_AUTO_TEST_SUITE(outs_tests) -//// -////using namespace system; -////const table::outs::record expected0{}; -////const table::outs::record expected1 -////{ -//// {}, // schema::outs [all const static members] -//// std::vector -//// { -//// 0x56341211_u32 -//// }, -//// std::vector -//// { -//// } -////}; -////const table::outs::record expected2 -////{ -//// {}, // schema::outs [all const static members] -//// std::vector -//// { -//// 0x56341221_u32 -//// }, -//// std::vector -//// { -//// 0x0000007856341222_u64 -//// } -////}; -////const table::outs::record expected3 -////{ -//// {}, // schema::outs [all const static members] -//// std::vector -//// { -//// 0x56341231_u32 -//// }, -//// std::vector -//// { -//// 0x0000007856341232_u64, -//// 0x0000007856341233_u64 -//// } -////}; -////const data_chunk expected_file -////{ -//// // expected1 (0) -//// 0x11, 0x12, 0x34, 0x56, -//// -//// // expected2 (4) -//// 0x21, 0x12, 0x34, 0x56, -//// 0x22, 0x12, 0x34, 0x56, 0x78, -//// -//// // expected3 (13) -//// 0x31, 0x12, 0x34, 0x56, -//// 0x32, 0x12, 0x34, 0x56, 0x78, -//// 0x33, 0x12, 0x34, 0x56, 0x78 -////}; -//// -////BOOST_AUTO_TEST_CASE(outs__put__get__expected) -////{ -//// test::chunk_storage head_store{}; -//// test::chunk_storage body_store{}; -//// table::outs instance{ head_store, body_store }; -//// BOOST_REQUIRE(!instance.put_link(expected0).is_terminal()); -//// BOOST_REQUIRE(!instance.put_link(expected1).is_terminal()); -//// BOOST_REQUIRE(!instance.put_link(expected2).is_terminal()); -//// BOOST_REQUIRE(!instance.put_link(expected3).is_terminal()); -//// BOOST_REQUIRE_EQUAL(body_store.buffer(), expected_file); -//// -//// table::outs::record record0{}; -//// BOOST_REQUIRE(instance.get(0, record0)); -//// BOOST_REQUIRE(record0 == expected0); -//// -//// table::outs::record record1{}; -//// record1.point_fks.resize(1); -//// BOOST_REQUIRE(instance.get(0, record1)); -//// BOOST_REQUIRE(record1.point_fks == expected1.point_fks); -//// BOOST_REQUIRE(record1.out_fks.empty()); -//// -//// table::outs::record record2{}; -//// record2.point_fks.resize(1); -//// record2.out_fks.resize(1); -//// BOOST_REQUIRE(instance.get(4, record2)); -//// BOOST_REQUIRE(record2.point_fks == expected2.point_fks); -//// BOOST_REQUIRE(record2.out_fks == expected2.out_fks); -//// -//// table::outs::record record3{}; -//// record3.point_fks.resize(1); -//// record3.out_fks.resize(2); -//// BOOST_REQUIRE(instance.get(13, record3)); -//// BOOST_REQUIRE(record3.point_fks == expected3.point_fks); -//// BOOST_REQUIRE(record3.out_fks == expected3.out_fks); -////} -//// -////BOOST_AUTO_TEST_SUITE_END() diff --git a/test/types.cpp b/test/types.cpp new file mode 100644 index 00000000..6850ecc3 --- /dev/null +++ b/test/types.cpp @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2011-2026 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +#include "test.hpp" + +BOOST_AUTO_TEST_SUITE(types_tests) + +BOOST_AUTO_TEST_CASE(types_test) +{ + BOOST_REQUIRE(true); +} + +BOOST_AUTO_TEST_SUITE_END()