@@ -201,6 +201,34 @@ BOOST_AUTO_TEST_CASE(electrum__blockchain_transaction_get_merkle__genesis_coinba
201201 BOOST_CHECK (result.at (" merkle" ).as_array ().empty ());
202202}
203203
204+ BOOST_AUTO_TEST_CASE (electrum__blockchain_transaction_get_merkle__mutiple_txs_block__expected)
205+ {
206+ BOOST_CHECK (handshake ());
207+
208+ const auto & txs = *bogus_block10.transactions_ptr ();
209+ const auto & tx0 = *txs.at (0 );
210+ const auto & tx1 = *txs.at (1 );
211+ const auto & tx2 = *txs.at (2 );
212+ const auto tx0_hash = tx0.hash (false );
213+ const auto tx1_hash = tx1.hash (false );
214+ const auto tx2_hash = tx2.hash (false );
215+
216+ // Add a multi-tx block.
217+ query_.set (bogus_block10, database::context{ 0 , 10 , 0 }, false , false );
218+ query_.push_confirmed (query_.to_header (bogus_block10.hash ()), false );
219+
220+ const auto request = R"( {"id":104,"method":"blockchain.transaction.get_merkle","params":["%1%",10]})" " \n " ;
221+ const auto response = get ((boost::format (request) % encode_hash (tx1_hash)).str ());
222+ const auto & result = response.at (" result" ).as_object ();
223+ BOOST_CHECK_EQUAL (result.at (" block_height" ).as_int64 (), 10 );
224+ BOOST_CHECK_EQUAL (result.at (" pos" ).as_int64 (), 1 );
225+
226+ const auto & merkle = result.at (" merkle" ).as_array ();
227+ BOOST_CHECK_EQUAL (merkle.size (), 2u );
228+ BOOST_CHECK_EQUAL (merkle.at (0 ).as_string (), encode_hash (tx0_hash));
229+ BOOST_CHECK_EQUAL (merkle.at (1 ).as_string (), encode_hash (bitcoin_hash (tx2_hash, tx2_hash)));
230+ }
231+
204232BOOST_AUTO_TEST_CASE (electrum__blockchain_transaction_get_merkle__missing_param__dropped)
205233{
206234 BOOST_CHECK (handshake ());
0 commit comments