Changeset View
Changeset View
Standalone View
Standalone View
test/functional/bip68-sequence.py
Show All 18 Lines | |||||
SEQUENCE_LOCKTIME_GRANULARITY = 9 # this is a bit-shift | SEQUENCE_LOCKTIME_GRANULARITY = 9 # this is a bit-shift | ||||
SEQUENCE_LOCKTIME_MASK = 0x0000ffff | SEQUENCE_LOCKTIME_MASK = 0x0000ffff | ||||
# RPC error for non-BIP68 final transactions | # RPC error for non-BIP68 final transactions | ||||
NOT_FINAL_ERROR = "64: non-BIP68-final" | NOT_FINAL_ERROR = "64: non-BIP68-final" | ||||
class BIP68Test(BitcoinTestFramework): | class BIP68Test(BitcoinTestFramework): | ||||
def add_options(self, parser): | |||||
parser.add_argument("--magnetic-anomaly-time", dest="magnetic_anomaly_time", type=long, default=0, | |||||
help="Test Magnetic Anomaly activation at a particular time (0 for never, 1 for startup)") | |||||
def set_test_params(self): | def set_test_params(self): | ||||
self.num_nodes = 2 | self.num_nodes = 2 | ||||
self.extra_args = [["-blockprioritypercentage=0"], | self.extra_args = [["-blockprioritypercentage=0"], | ||||
["-blockprioritypercentage=0", "-acceptnonstdtxn=0"]] | ["-blockprioritypercentage=0", "-acceptnonstdtxn=0"]] | ||||
activation_time = self.options.magnetic_anomaly_time | |||||
if activation_time != 0: | |||||
for args in self.extra_args: | |||||
args.append( | |||||
"-magneticanomalyactivationtime={}".format(activation_time)) | |||||
def run_test(self): | def run_test(self): | ||||
self.relayfee = self.nodes[0].getnetworkinfo()["relayfee"] | self.relayfee = self.nodes[0].getnetworkinfo()["relayfee"] | ||||
# Generate some coins | # Generate some coins | ||||
self.nodes[0].generate(110) | self.nodes[0].generate(110) | ||||
self.log.info("Running test disable flag") | self.log.info("Running test disable flag") | ||||
self.test_disable_flag() | self.test_disable_flag() | ||||
▲ Show 20 Lines • Show All 381 Lines • ▼ Show 20 Lines | def test_bip68_not_consensus(self): | ||||
assert_raises_rpc_error(-26, NOT_FINAL_ERROR, | assert_raises_rpc_error(-26, NOT_FINAL_ERROR, | ||||
self.nodes[0].sendrawtransaction, ToHex(tx3)) | self.nodes[0].sendrawtransaction, ToHex(tx3)) | ||||
# make a block that violates bip68; ensure that the tip updates | # make a block that violates bip68; ensure that the tip updates | ||||
tip = int(self.nodes[0].getbestblockhash(), 16) | tip = int(self.nodes[0].getbestblockhash(), 16) | ||||
block = create_block( | block = create_block( | ||||
tip, create_coinbase(self.nodes[0].getblockcount() + 1)) | tip, create_coinbase(self.nodes[0].getblockcount() + 1)) | ||||
block.nVersion = 3 | block.nVersion = 3 | ||||
if self.options.magnetic_anomaly_time == 0: | |||||
block.vtx.extend([tx1, tx2, tx3]) | |||||
else: | |||||
block.vtx.extend( | block.vtx.extend( | ||||
sorted([tx1, tx2, tx3], key=lambda tx: tx.get_id())) | sorted([tx1, tx2, tx3], key=lambda tx: tx.get_id())) | ||||
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): | ||||
Show All 33 Lines |