@@ -88,8 +88,17 @@ BOOST_AUTO_TEST_CASE(electrum__blockchain_scripthash_get_balance__missing_argume
8888 REQUIRE_NO_THROW_TRUE (response.at (" dropped" ).as_bool ());
8989}
9090
91+ BOOST_AUTO_TEST_CASE (electrum__blockchain_scripthash_get_balance__insufficient_version__dropped)
92+ {
93+ BOOST_REQUIRE (handshake (electrum::version::v1_0));
94+
95+ const auto response = get (R"( {"id":902,"method":"blockchain.scripthash.get_balance","params":[""]})" " \n " );
96+ REQUIRE_NO_THROW_TRUE (response.at (" error" ).as_object ().at (" code" ).is_int64 ());
97+ BOOST_REQUIRE_EQUAL (response.at (" error" ).as_object ().at (" code" ).as_int64 (), wrong_version.value ());
98+ }
99+
91100// Not yet.
92- // //BOOST_AUTO_TEST_CASE(electrum__blockchain_scripthash_get_balance__empty_v1_7__wrong_version )
101+ // //BOOST_AUTO_TEST_CASE(electrum__blockchain_scripthash_get_balance__obsoleted_version__wrong_version )
93102// //{
94103// // BOOST_REQUIRE(handshake(electrum::version::v1_7));
95104// //
@@ -156,8 +165,17 @@ BOOST_AUTO_TEST_CASE(electrum__blockchain_scripthash_get_history__missing_argume
156165 REQUIRE_NO_THROW_TRUE (response.at (" dropped" ).as_bool ());
157166}
158167
168+ BOOST_AUTO_TEST_CASE (electrum__blockchain_scripthash_get_history__insufficient_version__dropped)
169+ {
170+ BOOST_REQUIRE (handshake (electrum::version::v1_0));
171+
172+ const auto response = get (R"( {"id":902,"method":"blockchain.scripthash.get_history","params":[""]})" " \n " );
173+ REQUIRE_NO_THROW_TRUE (response.at (" error" ).as_object ().at (" code" ).is_int64 ());
174+ BOOST_REQUIRE_EQUAL (response.at (" error" ).as_object ().at (" code" ).as_int64 (), wrong_version.value ());
175+ }
176+
159177// Not yet.
160- // //BOOST_AUTO_TEST_CASE(electrum__blockchain_scripthash_get_history__empty_v1_7__wrong_version )
178+ // //BOOST_AUTO_TEST_CASE(electrum__blockchain_scripthash_get_history__obsoleted_version__wrong_version )
161179// //{
162180// // BOOST_REQUIRE(handshake(electrum::version::v1_7));
163181// //
@@ -205,20 +223,23 @@ BOOST_AUTO_TEST_CASE(electrum__blockchain_scripthash_get_history__confirmed_and_
205223 const auto & tx1 = history.at (0 ).as_object ();
206224 REQUIRE_NO_THROW_TRUE (tx1.at (" height" ).is_int64 ());
207225 REQUIRE_NO_THROW_TRUE (tx1.at (" tx_hash" ).is_string ());
226+ BOOST_CHECK (!tx1.contains (" fee" ));
208227 BOOST_REQUIRE_EQUAL (tx1.at (" height" ).as_int64 (), 10 );
209228 BOOST_REQUIRE_EQUAL (tx1.at (" tx_hash" ).as_string (), encode_hash (hash1));
210229
211230 const auto hash2 = test::bogus_block11.transactions_ptr ()->at (0 )->hash (false );
212231 const auto & tx2 = history.at (1 ).as_object ();
213232 REQUIRE_NO_THROW_TRUE (tx2.at (" height" ).is_int64 ());
214233 REQUIRE_NO_THROW_TRUE (tx2.at (" tx_hash" ).is_string ());
234+ BOOST_CHECK_EQUAL (tx2.at (" fee" ).as_int64 (), floored_subtract (5'000'000'000 + 5'000'000'000 , 0x10 + 0x11 + 0x12 + 0x13 + 0x14 ));
215235 BOOST_REQUIRE_EQUAL (tx2.at (" height" ).as_int64 (), 0 ); // rooted
216236 BOOST_REQUIRE_EQUAL (tx2.at (" tx_hash" ).as_string (), encode_hash (hash2));
217237
218238 const auto hash3 = test::bogus_block12.transactions_ptr ()->at (0 )->hash (false );
219239 const auto & tx3 = history.at (2 ).as_object ();
220240 REQUIRE_NO_THROW_TRUE (tx3.at (" height" ).is_int64 ());
221241 REQUIRE_NO_THROW_TRUE (tx3.at (" tx_hash" ).is_string ());
242+ BOOST_CHECK_EQUAL (tx3.at (" fee" ).as_int64 (), floored_subtract (0x10 + 0x11 , 0x0a ));
222243 BOOST_REQUIRE_EQUAL (tx3.at (" height" ).as_int64 (), -1 ); // not rooted
223244 BOOST_REQUIRE_EQUAL (tx3.at (" tx_hash" ).as_string (), encode_hash (hash3));
224245}
@@ -234,8 +255,17 @@ BOOST_AUTO_TEST_CASE(electrum__blockchain_scripthash_get_mempool__missing_argume
234255 REQUIRE_NO_THROW_TRUE (response.at (" dropped" ).as_bool ());
235256}
236257
258+ BOOST_AUTO_TEST_CASE (electrum__blockchain_scripthash_get_mempool__insufficient_version__dropped)
259+ {
260+ BOOST_REQUIRE (handshake (electrum::version::v1_0));
261+
262+ const auto response = get (R"( {"id":902,"method":"blockchain.scripthash.get_mempool","params":[""]})" " \n " );
263+ REQUIRE_NO_THROW_TRUE (response.at (" error" ).as_object ().at (" code" ).is_int64 ());
264+ BOOST_REQUIRE_EQUAL (response.at (" error" ).as_object ().at (" code" ).as_int64 (), wrong_version.value ());
265+ }
266+
237267// Not yet.
238- // //BOOST_AUTO_TEST_CASE(electrum__blockchain_scripthash_get_mempool__empty_v1_7__wrong_version )
268+ // //BOOST_AUTO_TEST_CASE(electrum__blockchain_scripthash_get_mempool__obsoleted_version__wrong_version )
239269// //{
240270// // BOOST_REQUIRE(handshake(electrum::version::v1_7));
241271// //
@@ -283,13 +313,15 @@ BOOST_AUTO_TEST_CASE(electrum__blockchain_scripthash_get_mempool__confirmed_and_
283313 const auto & tx1 = history.at (0 ).as_object ();
284314 REQUIRE_NO_THROW_TRUE (tx1.at (" height" ).is_int64 ());
285315 REQUIRE_NO_THROW_TRUE (tx1.at (" tx_hash" ).is_string ());
316+ BOOST_CHECK_EQUAL (tx1.at (" fee" ).as_int64 (), floored_subtract (5'000'000'000 + 5'000'000'000 , 0x10 + 0x11 + 0x12 + 0x13 + 0x14 ));
286317 BOOST_REQUIRE_EQUAL (tx1.at (" height" ).as_int64 (), 0 ); // rooted
287318 BOOST_REQUIRE_EQUAL (tx1.at (" tx_hash" ).as_string (), encode_hash (hash1));
288319
289320 const auto hash2 = test::bogus_block12.transactions_ptr ()->at (0 )->hash (false );
290321 const auto & tx2 = history.at (1 ).as_object ();
291322 REQUIRE_NO_THROW_TRUE (tx2.at (" height" ).is_int64 ());
292323 REQUIRE_NO_THROW_TRUE (tx2.at (" tx_hash" ).is_string ());
324+ BOOST_CHECK_EQUAL (tx1.at (" fee" ).as_int64 (), floored_subtract (5'000'000'000 + 5'000'000'000 , 0x10 + 0x11 + 0x12 + 0x13 + 0x14 ));
293325 BOOST_REQUIRE_EQUAL (tx2.at (" height" ).as_int64 (), -1 ); // not rooted
294326 BOOST_REQUIRE_EQUAL (tx2.at (" tx_hash" ).as_string (), encode_hash (hash2));
295327}
@@ -305,8 +337,17 @@ BOOST_AUTO_TEST_CASE(electrum__blockchain_scripthash_list_unspent__missing_argum
305337 REQUIRE_NO_THROW_TRUE (response.at (" dropped" ).as_bool ());
306338}
307339
340+ BOOST_AUTO_TEST_CASE (electrum__blockchain_scripthash_list_unspent__insufficient_version__dropped)
341+ {
342+ BOOST_REQUIRE (handshake (electrum::version::v1_0));
343+
344+ const auto response = get (R"( {"id":902,"method":"blockchain.scripthash.listunspent","params":[""]})" " \n " );
345+ REQUIRE_NO_THROW_TRUE (response.at (" error" ).as_object ().at (" code" ).is_int64 ());
346+ BOOST_REQUIRE_EQUAL (response.at (" error" ).as_object ().at (" code" ).as_int64 (), wrong_version.value ());
347+ }
348+
308349// Not yet.
309- // //BOOST_AUTO_TEST_CASE(electrum__blockchain_scripthash_list_unspent__empty_v1_7__wrong_version )
350+ // //BOOST_AUTO_TEST_CASE(electrum__blockchain_scripthash_list_unspent__obsoleted_version__wrong_version )
310351// //{
311352// // BOOST_REQUIRE(handshake(electrum::version::v1_7));
312353// //
0 commit comments