mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-08 10:31:50 -05:00
test: pep-8 mining_basic
Can be reviewed with the git options --word-diff-regex=. --ignore-all-space -U0
This commit is contained in:
parent
41fb69404c
commit
faedb50d89
1 changed files with 21 additions and 10 deletions
|
@ -18,11 +18,9 @@ from test_framework.blocktools import (
|
|||
from test_framework.messages import (
|
||||
CBlock,
|
||||
CBlockHeader,
|
||||
BLOCK_HEADER_SIZE
|
||||
)
|
||||
from test_framework.mininode import (
|
||||
P2PDataStore,
|
||||
BLOCK_HEADER_SIZE,
|
||||
)
|
||||
from test_framework.mininode import P2PDataStore
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.util import (
|
||||
assert_equal,
|
||||
|
@ -30,10 +28,15 @@ from test_framework.util import (
|
|||
connect_nodes,
|
||||
)
|
||||
|
||||
|
||||
def assert_template(node, block, expect, rehash=True):
|
||||
if rehash:
|
||||
block.hashMerkleRoot = block.calc_merkle_root()
|
||||
rsp = node.getblocktemplate(template_request={'data': block.serialize().hex(), 'mode': 'proposal', 'rules': ['segwit']})
|
||||
rsp = node.getblocktemplate(template_request={
|
||||
'data': block.serialize().hex(),
|
||||
'mode': 'proposal',
|
||||
'rules': ['segwit'],
|
||||
})
|
||||
assert_equal(rsp, expect)
|
||||
|
||||
|
||||
|
@ -116,7 +119,11 @@ class MiningTest(BitcoinTestFramework):
|
|||
assert_raises_rpc_error(-22, "Block does not start with a coinbase", node.submitblock, bad_block.serialize().hex())
|
||||
|
||||
self.log.info("getblocktemplate: Test truncated final transaction")
|
||||
assert_raises_rpc_error(-22, "Block decode failed", node.getblocktemplate, {'data': block.serialize()[:-1].hex(), 'mode': 'proposal', 'rules': ['segwit']})
|
||||
assert_raises_rpc_error(-22, "Block decode failed", node.getblocktemplate, {
|
||||
'data': block.serialize()[:-1].hex(),
|
||||
'mode': 'proposal',
|
||||
'rules': ['segwit'],
|
||||
})
|
||||
|
||||
self.log.info("getblocktemplate: Test duplicate transaction")
|
||||
bad_block = copy.deepcopy(block)
|
||||
|
@ -145,7 +152,11 @@ class MiningTest(BitcoinTestFramework):
|
|||
bad_block_sn = bytearray(block.serialize())
|
||||
assert_equal(bad_block_sn[BLOCK_HEADER_SIZE], 1)
|
||||
bad_block_sn[BLOCK_HEADER_SIZE] += 1
|
||||
assert_raises_rpc_error(-22, "Block decode failed", node.getblocktemplate, {'data': bad_block_sn.hex(), 'mode': 'proposal', 'rules': ['segwit']})
|
||||
assert_raises_rpc_error(-22, "Block decode failed", node.getblocktemplate, {
|
||||
'data': bad_block_sn.hex(),
|
||||
'mode': 'proposal',
|
||||
'rules': ['segwit'],
|
||||
})
|
||||
|
||||
self.log.info("getblocktemplate: Test bad bits")
|
||||
bad_block = copy.deepcopy(block)
|
||||
|
|
Loading…
Add table
Reference in a new issue