diff --git a/src/test/transaction_tests.cpp b/src/test/transaction_tests.cpp index d10b180111..b152fc5584 100644 --- a/src/test/transaction_tests.cpp +++ b/src/test/transaction_tests.cpp @@ -1030,10 +1030,10 @@ BOOST_AUTO_TEST_CASE(test_IsStandard) BOOST_AUTO_TEST_CASE(test_TxidFromString) { - // TxidFromString currently ignores string_view length and reads the whole - // string, not the specified substring. + // Make sure TxidFromString respects string_view length and stops reading at + // end of the substring. BOOST_CHECK_EQUAL(TxidFromString(std::string_view("ABCD1234", 4)).ToString(), - "00000000000000000000000000000000000000000000000000000000abcd1234"); + "000000000000000000000000000000000000000000000000000000000000abcd"); } BOOST_AUTO_TEST_SUITE_END() diff --git a/src/test/txpackage_tests.cpp b/src/test/txpackage_tests.cpp index 8c873c85a3..f16c0cdafd 100644 --- a/src/test/txpackage_tests.cpp +++ b/src/test/txpackage_tests.cpp @@ -47,7 +47,7 @@ inline CTransactionRef create_placeholder_tx(size_t num_inputs, size_t num_outpu // Create a Wtxid from a hex string inline Wtxid WtxidFromString(std::string_view str) { - return Wtxid::FromUint256(uint256S(str.data())); + return Wtxid::FromUint256(uint256S(str)); } BOOST_FIXTURE_TEST_CASE(package_hash_tests, TestChain100Setup) diff --git a/src/util/transaction_identifier.h b/src/util/transaction_identifier.h index d4a0ede25a..1ca48a0454 100644 --- a/src/util/transaction_identifier.h +++ b/src/util/transaction_identifier.h @@ -68,7 +68,7 @@ using Wtxid = transaction_identifier; inline Txid TxidFromString(std::string_view str) { - return Txid::FromUint256(uint256S(str.data())); + return Txid::FromUint256(uint256S(str)); } #endif // BITCOIN_UTIL_TRANSACTION_IDENTIFIER_H