Skip to content

Commit 285ab50

Browse files
committed
test: replace WtxidFromString with Wtxid::FromHex
The newly introduced Wtxid::FromHex is more robust and removes the need for a WtxidFromString helper function
1 parent 9a0b2a6 commit 285ab50

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

src/test/txpackage_tests.cpp

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,6 @@ inline CTransactionRef create_placeholder_tx(size_t num_inputs, size_t num_outpu
4343
}
4444
return MakeTransactionRef(mtx);
4545
}
46-
47-
// Create a Wtxid from a hex string
48-
inline Wtxid WtxidFromString(std::string_view str)
49-
{
50-
return Wtxid::FromUint256(uint256S(str));
51-
}
52-
5346
BOOST_FIXTURE_TEST_CASE(package_hash_tests, TestChain100Setup)
5447
{
5548
// Random real segwit transaction
@@ -74,9 +67,9 @@ BOOST_FIXTURE_TEST_CASE(package_hash_tests, TestChain100Setup)
7467
CTransactionRef ptx_3{MakeTransactionRef(tx_3)};
7568

7669
// It's easy to see that wtxids are sorted in lexicographical order:
77-
Wtxid wtxid_1{WtxidFromString("0x85cd1a31eb38f74ed5742ec9cb546712ab5aaf747de28a9168b53e846cbda17f")};
78-
Wtxid wtxid_2{WtxidFromString("0xb4749f017444b051c44dfd2720e88f314ff94f3dd6d56d40ef65854fcd7fff6b")};
79-
Wtxid wtxid_3{WtxidFromString("0xe065bac15f62bb4e761d761db928ddee65a47296b2b776785abb912cdec474e3")};
70+
Wtxid wtxid_1{Wtxid::FromHex("85cd1a31eb38f74ed5742ec9cb546712ab5aaf747de28a9168b53e846cbda17f").value()};
71+
Wtxid wtxid_2{Wtxid::FromHex("b4749f017444b051c44dfd2720e88f314ff94f3dd6d56d40ef65854fcd7fff6b").value()};
72+
Wtxid wtxid_3{Wtxid::FromHex("e065bac15f62bb4e761d761db928ddee65a47296b2b776785abb912cdec474e3").value()};
8073
BOOST_CHECK_EQUAL(tx_1.GetWitnessHash(), wtxid_1);
8174
BOOST_CHECK_EQUAL(tx_2.GetWitnessHash(), wtxid_2);
8275
BOOST_CHECK_EQUAL(tx_3.GetWitnessHash(), wtxid_3);

0 commit comments

Comments
 (0)