(self)
| 389 | assert_equal(block["tx"][0]["vin"][0]["sequence"], MAX_SEQUENCE_NONFINAL) |
| 390 | |
| 391 | def run_test(self): |
| 392 | node = self.nodes[0] |
| 393 | self.wallet = MiniWallet(node) |
| 394 | self.mine_chain() |
| 395 | |
| 396 | self.log.info('getmininginfo') |
| 397 | mining_info = node.getmininginfo() |
| 398 | assert_equal(mining_info['blocks'], 200) |
| 399 | assert_equal(mining_info['chain'], self.chain) |
| 400 | assert 'currentblocktx' not in mining_info |
| 401 | assert 'currentblockweight' not in mining_info |
| 402 | assert_equal(mining_info['bits'], nbits_str(REGTEST_N_BITS)) |
| 403 | assert_equal(mining_info['target'], target_str(REGTEST_TARGET)) |
| 404 | # We don't care about precision, round to avoid mismatch under Valgrind: |
| 405 | assert_equal(round(mining_info['difficulty'], 10), Decimal('0.0000000005')) |
| 406 | assert_equal(mining_info['next']['height'], 201) |
| 407 | assert_equal(mining_info['next']['target'], target_str(REGTEST_TARGET)) |
| 408 | assert_equal(mining_info['next']['bits'], nbits_str(REGTEST_N_BITS)) |
| 409 | assert_equal(round(mining_info['next']['difficulty'], 10), Decimal('0.0000000005')) |
| 410 | assert_equal(round(mining_info['networkhashps'], 5), Decimal('0.00333')) |
| 411 | assert_equal(mining_info['pooledtx'], 0) |
| 412 | |
| 413 | self.log.info("getblocktemplate: Test default witness commitment") |
| 414 | txid = int(self.wallet.send_self_transfer(from_node=node)['wtxid'], 16) |
| 415 | tmpl = node.getblocktemplate(NORMAL_GBT_REQUEST_PARAMS) |
| 416 | |
| 417 | # Check that default_witness_commitment is present. |
| 418 | assert 'default_witness_commitment' in tmpl |
| 419 | witness_commitment = tmpl['default_witness_commitment'] |
| 420 | |
| 421 | # Check that default_witness_commitment is correct. |
| 422 | witness_root = CBlock.get_merkle_root([ser_uint256(0), |
| 423 | ser_uint256(txid)]) |
| 424 | script = get_witness_script(witness_root, 0) |
| 425 | assert_equal(witness_commitment, script.hex()) |
| 426 | |
| 427 | # Mine a block to leave initial block download and clear the mempool |
| 428 | self.generatetoaddress(node, 1, node.get_deterministic_priv_key().address) |
| 429 | tmpl = node.getblocktemplate(NORMAL_GBT_REQUEST_PARAMS) |
| 430 | self.log.info("getblocktemplate: Test capability advertised") |
| 431 | assert 'proposal' in tmpl['capabilities'] |
| 432 | assert 'coinbasetxn' not in tmpl |
| 433 | |
| 434 | next_height = int(tmpl["height"]) |
| 435 | coinbase_tx = create_coinbase(height=next_height) |
| 436 | # sequence numbers must not be max for nLockTime to have effect |
| 437 | coinbase_tx.vin[0].nSequence = 2**32 - 2 |
| 438 | |
| 439 | block = CBlock() |
| 440 | block.nVersion = tmpl["version"] |
| 441 | block.hashPrevBlock = int(tmpl["previousblockhash"], 16) |
| 442 | block.nTime = tmpl["curtime"] |
| 443 | block.nBits = int(tmpl["bits"], 16) |
| 444 | block.nNonce = 0 |
| 445 | block.vtx = [coinbase_tx] |
| 446 | block.hashMerkleRoot = block.calc_merkle_root() |
| 447 | |
| 448 | self.log.info("getblocktemplate: segwit rule must be set") |
nothing calls this directly
no test coverage detected