Skip to content

Commit

Permalink
test: replace WtxidFromString with Wtxid::FromHex
Browse files Browse the repository at this point in the history
The newly introduced Wtxid::FromHex is more robust and removes
the need for a WtxidFromString helper function
  • Loading branch information
stickies-v committed Jul 31, 2024
1 parent 9a0b2a6 commit 285ab50
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions src/test/txpackage_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,6 @@ inline CTransactionRef create_placeholder_tx(size_t num_inputs, size_t num_outpu
}
return MakeTransactionRef(mtx);
}

// Create a Wtxid from a hex string
inline Wtxid WtxidFromString(std::string_view str)
{
return Wtxid::FromUint256(uint256S(str));
}

BOOST_FIXTURE_TEST_CASE(package_hash_tests, TestChain100Setup)
{
// Random real segwit transaction
Expand All @@ -74,9 +67,9 @@ BOOST_FIXTURE_TEST_CASE(package_hash_tests, TestChain100Setup)
CTransactionRef ptx_3{MakeTransactionRef(tx_3)};

// It's easy to see that wtxids are sorted in lexicographical order:
Wtxid wtxid_1{WtxidFromString("0x85cd1a31eb38f74ed5742ec9cb546712ab5aaf747de28a9168b53e846cbda17f")};
Wtxid wtxid_2{WtxidFromString("0xb4749f017444b051c44dfd2720e88f314ff94f3dd6d56d40ef65854fcd7fff6b")};
Wtxid wtxid_3{WtxidFromString("0xe065bac15f62bb4e761d761db928ddee65a47296b2b776785abb912cdec474e3")};
Wtxid wtxid_1{Wtxid::FromHex("85cd1a31eb38f74ed5742ec9cb546712ab5aaf747de28a9168b53e846cbda17f").value()};
Wtxid wtxid_2{Wtxid::FromHex("b4749f017444b051c44dfd2720e88f314ff94f3dd6d56d40ef65854fcd7fff6b").value()};
Wtxid wtxid_3{Wtxid::FromHex("e065bac15f62bb4e761d761db928ddee65a47296b2b776785abb912cdec474e3").value()};
BOOST_CHECK_EQUAL(tx_1.GetWitnessHash(), wtxid_1);
BOOST_CHECK_EQUAL(tx_2.GetWitnessHash(), wtxid_2);
BOOST_CHECK_EQUAL(tx_3.GetWitnessHash(), wtxid_3);
Expand Down

0 comments on commit 285ab50

Please sign in to comment.