Skip to content

Commit faedb50

Browse files
author
MarcoFalke
committed
test: pep-8 mining_basic
Can be reviewed with the git options --word-diff-regex=. --ignore-all-space -U0
1 parent 41fb694 commit faedb50

File tree

1 file changed

+21
-10
lines changed

1 file changed

+21
-10
lines changed

test/functional/mining_basic.py

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,25 @@
1818
from test_framework.messages import (
1919
CBlock,
2020
CBlockHeader,
21-
BLOCK_HEADER_SIZE
22-
)
23-
from test_framework.mininode import (
24-
P2PDataStore,
21+
BLOCK_HEADER_SIZE,
2522
)
23+
from test_framework.mininode import P2PDataStore
2624
from test_framework.test_framework import BitcoinTestFramework
2725
from test_framework.util import (
2826
assert_equal,
2927
assert_raises_rpc_error,
3028
connect_nodes,
3129
)
3230

31+
3332
def assert_template(node, block, expect, rehash=True):
3433
if rehash:
3534
block.hashMerkleRoot = block.calc_merkle_root()
36-
rsp = node.getblocktemplate(template_request={'data': block.serialize().hex(), 'mode': 'proposal', 'rules': ['segwit']})
35+
rsp = node.getblocktemplate(template_request={
36+
'data': block.serialize().hex(),
37+
'mode': 'proposal',
38+
'rules': ['segwit'],
39+
})
3740
assert_equal(rsp, expect)
3841

3942

@@ -85,7 +88,7 @@ def assert_submitblock(block, result_str_1, result_str_2=None):
8588
next_height = int(tmpl["height"])
8689
coinbase_tx = create_coinbase(height=next_height)
8790
# sequence numbers must not be max for nLockTime to have effect
88-
coinbase_tx.vin[0].nSequence = 2 ** 32 - 2
91+
coinbase_tx.vin[0].nSequence = 2**32 - 2
8992
coinbase_tx.rehash()
9093

9194
# round-trip the encoded bip34 block height commitment
@@ -116,7 +119,11 @@ def assert_submitblock(block, result_str_1, result_str_2=None):
116119
assert_raises_rpc_error(-22, "Block does not start with a coinbase", node.submitblock, bad_block.serialize().hex())
117120

118121
self.log.info("getblocktemplate: Test truncated final transaction")
119-
assert_raises_rpc_error(-22, "Block decode failed", node.getblocktemplate, {'data': block.serialize()[:-1].hex(), 'mode': 'proposal', 'rules': ['segwit']})
122+
assert_raises_rpc_error(-22, "Block decode failed", node.getblocktemplate, {
123+
'data': block.serialize()[:-1].hex(),
124+
'mode': 'proposal',
125+
'rules': ['segwit'],
126+
})
120127

121128
self.log.info("getblocktemplate: Test duplicate transaction")
122129
bad_block = copy.deepcopy(block)
@@ -135,7 +142,7 @@ def assert_submitblock(block, result_str_1, result_str_2=None):
135142

136143
self.log.info("getblocktemplate: Test nonfinal transaction")
137144
bad_block = copy.deepcopy(block)
138-
bad_block.vtx[0].nLockTime = 2 ** 32 - 1
145+
bad_block.vtx[0].nLockTime = 2**32 - 1
139146
bad_block.vtx[0].rehash()
140147
assert_template(node, bad_block, 'bad-txns-nonfinal')
141148
assert_submitblock(bad_block, 'bad-txns-nonfinal')
@@ -145,7 +152,11 @@ def assert_submitblock(block, result_str_1, result_str_2=None):
145152
bad_block_sn = bytearray(block.serialize())
146153
assert_equal(bad_block_sn[BLOCK_HEADER_SIZE], 1)
147154
bad_block_sn[BLOCK_HEADER_SIZE] += 1
148-
assert_raises_rpc_error(-22, "Block decode failed", node.getblocktemplate, {'data': bad_block_sn.hex(), 'mode': 'proposal', 'rules': ['segwit']})
155+
assert_raises_rpc_error(-22, "Block decode failed", node.getblocktemplate, {
156+
'data': bad_block_sn.hex(),
157+
'mode': 'proposal',
158+
'rules': ['segwit'],
159+
})
149160

150161
self.log.info("getblocktemplate: Test bad bits")
151162
bad_block = copy.deepcopy(block)
@@ -160,7 +171,7 @@ def assert_submitblock(block, result_str_1, result_str_2=None):
160171

161172
self.log.info("getblocktemplate: Test bad timestamps")
162173
bad_block = copy.deepcopy(block)
163-
bad_block.nTime = 2 ** 31 - 1
174+
bad_block.nTime = 2**31 - 1
164175
assert_template(node, bad_block, 'time-too-new')
165176
assert_submitblock(bad_block, 'time-too-new', 'time-too-new')
166177
bad_block.nTime = 0

0 commit comments

Comments
 (0)