mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-09-11 21:20:39 +02:00
test: cover enforce BIP68 to tx versions higher than 2
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
#include <test/data/tx_valid.json.h>
|
||||
#include <test/util/setup_common.h>
|
||||
|
||||
#include <chain.h>
|
||||
#include <checkqueue.h>
|
||||
#include <clientversion.h>
|
||||
#include <consensus/amount.h>
|
||||
@@ -1190,6 +1191,30 @@ BOOST_AUTO_TEST_CASE(isfinaltx_sequences_test)
|
||||
check_final(/*sequences=*/{CTxIn::MAX_SEQUENCE_NONFINAL, CTxIn::SEQUENCE_FINAL}, /*expected_final=*/false);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(calculatesequencelocks_tx_version_test)
|
||||
{
|
||||
constexpr int coin_height{100};
|
||||
|
||||
// A single input with a height-based relative locktime of one block. Only the
|
||||
// height branch is taken, so the block index is never dereferenced.
|
||||
auto check_min_height{[](uint32_t version, int expected_min_height) {
|
||||
CMutableTransaction mtx;
|
||||
mtx.version = version;
|
||||
mtx.vin.emplace_back(COutPoint{}, CScript{}, /*nSequenceIn=*/1);
|
||||
|
||||
std::vector<int> prev_heights{coin_height};
|
||||
const CBlockIndex block{};
|
||||
const auto lock_pair{CalculateSequenceLocks(CTransaction{mtx}, LOCKTIME_VERIFY_SEQUENCE, prev_heights, block)};
|
||||
BOOST_CHECK_EQUAL(lock_pair.first, expected_min_height);
|
||||
}};
|
||||
|
||||
// BIP68 only applies to versions 2 and up
|
||||
check_min_height(/*version=*/0, /*expected_min_height=*/-1);
|
||||
check_min_height(/*version=*/1, /*expected_min_height=*/-1);
|
||||
check_min_height(/*version=*/2, /*expected_min_height=*/coin_height);
|
||||
check_min_height(/*version=*/std::numeric_limits<uint32_t>::max(), /*expected_min_height=*/coin_height);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(getvalueout_out_of_range_throws)
|
||||
{
|
||||
CMutableTransaction mtx;
|
||||
|
||||
Reference in New Issue
Block a user