Changeset View
Changeset View
Standalone View
Standalone View
test/functional/feature_bip68_sequence.py
Show First 20 Lines • Show All 198 Lines • ▼ Show 20 Lines | def test_sequence_lock_confirmed_inputs(self): | ||||
orig_time = self.get_median_time_past( | orig_time = self.get_median_time_past( | ||||
utxos[j]["confirmations"]) | utxos[j]["confirmations"]) | ||||
# MTP of the tip | # MTP of the tip | ||||
cur_time = self.get_median_time_past(0) | cur_time = self.get_median_time_past(0) | ||||
# can only timelock this input if it's not too old -- | # can only timelock this input if it's not too old -- | ||||
# otherwise use height | # otherwise use height | ||||
can_time_lock = True | can_time_lock = True | ||||
if ((cur_time - orig_time) >> SEQUENCE_LOCKTIME_GRANULARITY) >= SEQUENCE_LOCKTIME_MASK: | if ((cur_time - orig_time) | ||||
>> SEQUENCE_LOCKTIME_GRANULARITY) >= SEQUENCE_LOCKTIME_MASK: | |||||
can_time_lock = False | can_time_lock = False | ||||
# if time-lockable, then 50% chance we make this a time | # if time-lockable, then 50% chance we make this a time | ||||
# lock | # lock | ||||
if random.randint(0, 1) and can_time_lock: | if random.randint(0, 1) and can_time_lock: | ||||
# Find first time-lock value that fails, or latest one | # Find first time-lock value that fails, or latest one | ||||
# that succeeds | # that succeeds | ||||
time_delta = sequence_value << SEQUENCE_LOCKTIME_GRANULARITY | time_delta = sequence_value << SEQUENCE_LOCKTIME_GRANULARITY | ||||
▲ Show 20 Lines • Show All 75 Lines • ▼ Show 20 Lines | def test_sequence_lock_unconfirmed_inputs(self): | ||||
pad_tx(tx) | pad_tx(tx) | ||||
tx.rehash() | tx.rehash() | ||||
if (orig_tx.hash in node.getrawmempool()): | if (orig_tx.hash in node.getrawmempool()): | ||||
# sendrawtransaction should fail if the tx is in the mempool | # sendrawtransaction should fail if the tx is in the mempool | ||||
assert_raises_rpc_error(-26, NOT_FINAL_ERROR, | assert_raises_rpc_error(-26, NOT_FINAL_ERROR, | ||||
node.sendrawtransaction, ToHex(tx)) | node.sendrawtransaction, ToHex(tx)) | ||||
else: | else: | ||||
# sendrawtransaction should succeed if the tx is not in the mempool | # sendrawtransaction should succeed if the tx is not in the | ||||
# mempool | |||||
node.sendrawtransaction(ToHex(tx)) | node.sendrawtransaction(ToHex(tx)) | ||||
return tx | return tx | ||||
test_nonzero_locks( | test_nonzero_locks( | ||||
tx2, self.nodes[0], use_height_lock=True) | tx2, self.nodes[0], use_height_lock=True) | ||||
test_nonzero_locks( | test_nonzero_locks( | ||||
tx2, self.nodes[0], use_height_lock=False) | tx2, self.nodes[0], use_height_lock=False) | ||||
▲ Show 20 Lines • Show All 185 Lines • Show Last 20 Lines |