Changeset View
Changeset View
Standalone View
Standalone View
test/functional/feature_bip68_sequence.py
Show First 20 Lines • Show All 62 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
self.log.info("Running test sequence-lock-unconfirmed-inputs") | self.log.info("Running test sequence-lock-unconfirmed-inputs") | ||||
self.test_sequence_lock_unconfirmed_inputs() | self.test_sequence_lock_unconfirmed_inputs() | ||||
self.log.info( | self.log.info( | ||||
"Running test BIP68 not consensus before versionbits activation") | "Running test BIP68 not consensus before versionbits activation") | ||||
self.test_bip68_not_consensus() | self.test_bip68_not_consensus() | ||||
self.log.info("Verifying nVersion=2 transactions aren't standard") | |||||
self.test_version2_relay(before_activation=True) | |||||
self.log.info("Activating BIP68 (and 112/113)") | self.log.info("Activating BIP68 (and 112/113)") | ||||
self.activateCSV() | self.activateCSV() | ||||
self.log.info("Verifying nVersion=2 transactions are now standard") | print("Verifying nVersion=2 transactions are standard.") | ||||
self.test_version2_relay(before_activation=False) | print("Note that with current versions of bitcoin software, nVersion=2 transactions are always standard (independent of BIP68 activation status).") | ||||
self.test_version2_relay() | |||||
self.log.info("Passed") | self.log.info("Passed") | ||||
# Test that BIP68 is not in effect if tx version is 1, or if | # Test that BIP68 is not in effect if tx version is 1, or if | ||||
# the first sequence bit is set. | # the first sequence bit is set. | ||||
def test_disable_flag(self): | def test_disable_flag(self): | ||||
# Create some unconfirmed inputs | # Create some unconfirmed inputs | ||||
new_addr = self.nodes[0].getnewaddress() | new_addr = self.nodes[0].getnewaddress() | ||||
▲ Show 20 Lines • Show All 382 Lines • ▼ Show 20 Lines | def activateCSV(self): | ||||
self.nodes[0].generate(1) | self.nodes[0].generate(1) | ||||
assert_equal(self.get_csv_status(), True) | assert_equal(self.get_csv_status(), True) | ||||
# We have a block that has CSV activated, but we want to be at | # We have a block that has CSV activated, but we want to be at | ||||
# the activation point, so we invalidate the tip. | # the activation point, so we invalidate the tip. | ||||
self.nodes[0].invalidateblock(self.nodes[0].getbestblockhash()) | self.nodes[0].invalidateblock(self.nodes[0].getbestblockhash()) | ||||
connect_nodes(self.nodes[0], self.nodes[1]) | connect_nodes(self.nodes[0], self.nodes[1]) | ||||
sync_blocks(self.nodes) | sync_blocks(self.nodes) | ||||
# Use self.nodes[1] to test standardness relay policy | # Use self.nodes[1] to test that version 2 transactions are standard. | ||||
def test_version2_relay(self, before_activation): | def test_version2_relay(self): | ||||
inputs = [] | inputs = [] | ||||
outputs = {self.nodes[1].getnewaddress(): 1.0} | outputs = {self.nodes[1].getnewaddress(): 1.0} | ||||
rawtx = self.nodes[1].createrawtransaction(inputs, outputs) | rawtx = self.nodes[1].createrawtransaction(inputs, outputs) | ||||
rawtxfund = self.nodes[1].fundrawtransaction(rawtx)['hex'] | rawtxfund = self.nodes[1].fundrawtransaction(rawtx)['hex'] | ||||
tx = FromHex(CTransaction(), rawtxfund) | tx = FromHex(CTransaction(), rawtxfund) | ||||
tx.nVersion = 2 | tx.nVersion = 2 | ||||
tx_signed = self.nodes[1].signrawtransactionwithwallet(ToHex(tx))[ | tx_signed = self.nodes[1].signrawtransactionwithwallet(ToHex(tx))[ | ||||
"hex"] | "hex"] | ||||
try: | |||||
self.nodes[1].sendrawtransaction(tx_signed) | self.nodes[1].sendrawtransaction(tx_signed) | ||||
assert not before_activation | |||||
except: | |||||
assert before_activation | |||||
if __name__ == '__main__': | if __name__ == '__main__': | ||||
BIP68Test().main() | BIP68Test().main() |