Changeset View
Changeset View
Standalone View
Standalone View
test/functional/bip68-sequence.py
Show First 20 Lines • Show All 356 Lines • ▼ Show 20 Lines | def test_sequence_lock_unconfirmed_inputs(self): | ||||
assert(tx2.hash in mempool) | assert(tx2.hash in mempool) | ||||
# Reset the chain and get rid of the mocktimed-blocks | # Reset the chain and get rid of the mocktimed-blocks | ||||
self.nodes[0].setmocktime(0) | self.nodes[0].setmocktime(0) | ||||
self.nodes[0].invalidateblock( | self.nodes[0].invalidateblock( | ||||
self.nodes[0].getblockhash(cur_height + 1)) | self.nodes[0].getblockhash(cur_height + 1)) | ||||
self.nodes[0].generate(10) | self.nodes[0].generate(10) | ||||
def get_csv_status(self): | |||||
softforks = self.nodes[0].getblockchaininfo()['softforks'] | |||||
for sf in softforks: | |||||
if sf['id'] == 'csv' and sf['version'] == 5: | |||||
return sf['reject']['status'] | |||||
raise AssertionError('Cannot find CSV fork activation informations') | |||||
# Make sure that BIP68 isn't being used to validate blocks, prior to | # Make sure that BIP68 isn't being used to validate blocks, prior to | ||||
# versionbits activation. If more blocks are mined prior to this test | # versionbits activation. If more blocks are mined prior to this test | ||||
# being run, then it's possible the test has activated the soft fork, and | # being run, then it's possible the test has activated the soft fork, and | ||||
# this test should be moved to run earlier, or deleted. | # this test should be moved to run earlier, or deleted. | ||||
def test_bip68_not_consensus(self): | def test_bip68_not_consensus(self): | ||||
assert(get_bip9_status(self.nodes[0], 'csv')['status'] != 'active') | assert_equal(self.get_csv_status(), False) | ||||
txid = self.nodes[0].sendtoaddress(self.nodes[0].getnewaddress(), 2) | txid = self.nodes[0].sendtoaddress(self.nodes[0].getnewaddress(), 2) | ||||
tx1 = FromHex(CTransaction(), self.nodes[0].getrawtransaction(txid)) | tx1 = FromHex(CTransaction(), self.nodes[0].getrawtransaction(txid)) | ||||
tx1.rehash() | tx1.rehash() | ||||
# Make an anyone-can-spend transaction | # Make an anyone-can-spend transaction | ||||
tx2 = CTransaction() | tx2 = CTransaction() | ||||
tx2.nVersion = 1 | tx2.nVersion = 1 | ||||
Show All 30 Lines | def test_bip68_not_consensus(self): | ||||
block.hashMerkleRoot = block.calc_merkle_root() | block.hashMerkleRoot = block.calc_merkle_root() | ||||
block.rehash() | block.rehash() | ||||
block.solve() | block.solve() | ||||
self.nodes[0].submitblock(ToHex(block)) | self.nodes[0].submitblock(ToHex(block)) | ||||
assert_equal(self.nodes[0].getbestblockhash(), block.hash) | assert_equal(self.nodes[0].getbestblockhash(), block.hash) | ||||
def activateCSV(self): | def activateCSV(self): | ||||
# activation should happen at block height 432 (3 periods) | # activation should happen at block height 576 | ||||
# getblockchaininfo will show CSV as active at block 431 (144 * 3 -1) since it's returning whether CSV is active for the next block. | csv_activation_height = 576 | ||||
min_activation_height = 432 | |||||
height = self.nodes[0].getblockcount() | height = self.nodes[0].getblockcount() | ||||
assert_greater_than(min_activation_height - height, 2) | assert_greater_than(csv_activation_height - height, 1) | ||||
self.nodes[0].generate(min_activation_height - height - 2) | self.nodes[0].generate(csv_activation_height - height - 1) | ||||
assert_equal(get_bip9_status(self.nodes[0], 'csv')[ | assert_equal(self.get_csv_status(), False) | ||||
'status'], "locked_in") | |||||
self.nodes[0].generate(1) | self.nodes[0].generate(1) | ||||
assert_equal(get_bip9_status(self.nodes[0], 'csv')['status'], "active") | assert_equal(self.get_csv_status(), True) | ||||
# We have a block that has CSV activated, but we want to be at | |||||
# the activation point, so we invalidate the tip. | |||||
self.nodes[0].invalidateblock(self.nodes[0].getbestblockhash()) | |||||
sync_blocks(self.nodes) | sync_blocks(self.nodes) | ||||
# Use self.nodes[1] to test standardness relay policy | # Use self.nodes[1] to test standardness relay policy | ||||
def test_version2_relay(self, before_activation): | def test_version2_relay(self, before_activation): | ||||
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'] | ||||
Show All 12 Lines |