@@ -144,6 +144,89 @@ BOOST_AUTO_TEST_CASE(query_confirmed__is_confirmed_tx__confirm__expected)
144144 BOOST_REQUIRE (query.is_confirmed_tx (2 ));
145145}
146146
147+ BOOST_AUTO_TEST_CASE (query_confirmed__find_strong__unconfirmed_duplicate__expected)
148+ {
149+ settings settings{};
150+ settings.path = TEST_DIRECTORY ;
151+ test::chunk_store store{ settings };
152+ test::query_accessor query{ store };
153+ BOOST_REQUIRE (!store.create (test::events_handler));
154+ BOOST_REQUIRE (query.initialize (test::genesis));
155+ BOOST_REQUIRE (query.set (test::block1a, context{ 0 , 1 , 0 }, false , false ));
156+ BOOST_REQUIRE (query.set_strong (1 ));
157+
158+ BOOST_REQUIRE (query.set (test::tx4));
159+ const auto unconfirmed = query.to_tx (test::tx4.hash (false ));
160+
161+ BOOST_REQUIRE (query.set (test::block_spend_1a, context{ 0 , 2 , 0 }, false , false ));
162+ BOOST_REQUIRE (query.set_strong (2 ));
163+
164+ BOOST_REQUIRE_EQUAL (query.find_strong (unconfirmed),
165+ query.to_header (test::block_spend_1a.hash ()));
166+ }
167+
168+ BOOST_AUTO_TEST_CASE (query_confirmed__find_strong_spender_height__unspent__terminal)
169+ {
170+ settings settings{};
171+ settings.path = TEST_DIRECTORY ;
172+ test::chunk_store store{ settings };
173+ test::query_accessor query{ store };
174+ BOOST_REQUIRE (!store.create (test::events_handler));
175+ BOOST_REQUIRE (query.initialize (test::genesis));
176+ BOOST_REQUIRE (query.set (test::block1a, context{ 0 , 1 , 0 }, false , false ));
177+ BOOST_REQUIRE (query.set_strong (1 ));
178+
179+ const system::chain::point point
180+ {
181+ test::block1a.transactions_ptr ()->front ()->hash (false ), 0
182+ };
183+
184+ BOOST_REQUIRE (query.find_strong_spender_height (point).is_terminal ());
185+ }
186+
187+ BOOST_AUTO_TEST_CASE (query_confirmed__find_strong_spender_height__unconfirmed__terminal)
188+ {
189+ settings settings{};
190+ settings.path = TEST_DIRECTORY ;
191+ test::chunk_store store{ settings };
192+ test::query_accessor query{ store };
193+ BOOST_REQUIRE (!store.create (test::events_handler));
194+ BOOST_REQUIRE (query.initialize (test::genesis));
195+ BOOST_REQUIRE (query.set (test::block1a, context{ 0 , 1 , 0 }, false , false ));
196+ BOOST_REQUIRE (query.set_strong (1 ));
197+ BOOST_REQUIRE (query.set (test::tx5));
198+
199+ const system::chain::point point
200+ {
201+ test::block1a.transactions_ptr ()->front ()->hash (false ), 0
202+ };
203+
204+ BOOST_REQUIRE (query.find_strong_spender_height (point).is_terminal ());
205+ }
206+
207+ BOOST_AUTO_TEST_CASE (query_confirmed__find_strong_spender_height__confirmed__expected)
208+ {
209+ settings settings{};
210+ settings.path = TEST_DIRECTORY ;
211+ test::chunk_store store{ settings };
212+ test::query_accessor query{ store };
213+ BOOST_REQUIRE (!store.create (test::events_handler));
214+ BOOST_REQUIRE (query.initialize (test::genesis));
215+ BOOST_REQUIRE (query.set (test::block1a, context{ 0 , 1 , 0 }, false , false ));
216+ BOOST_REQUIRE (query.set_strong (1 ));
217+ BOOST_REQUIRE (query.set (test::block_spend_1a, context{ 0 , 2 , 0 }, false , false ));
218+ BOOST_REQUIRE (query.set_strong (2 ));
219+
220+ const system::chain::point point
221+ {
222+ test::block1a.transactions_ptr ()->front ()->hash (false ), 0
223+ };
224+
225+ const auto height = query.find_strong_spender_height (point);
226+ BOOST_REQUIRE (!height.is_terminal ());
227+ BOOST_REQUIRE_EQUAL (height.value , 2u );
228+ }
229+
147230BOOST_AUTO_TEST_CASE (query_confirmed__is_confirmed_input__genesis__true)
148231{
149232 settings settings{};
0 commit comments