Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F13115628
D8847.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Subscribers
None
D8847.diff
View Options
diff --git a/test/functional/feature_block.py b/test/functional/feature_block.py
--- a/test/functional/feature_block.py
+++ b/test/functional/feature_block.py
@@ -495,9 +495,10 @@
self.log.info("Reject a block with invalid work")
self.move_tip(44)
- b47 = self.next_block(47, solve=False)
+ b47 = self.next_block(47)
target = uint256_from_compact(b47.nBits)
while b47.sha256 <= target:
+ # Rehash nonces until an invalid too-high-hash block is found.
b47.nNonce += 1
b47.rehash()
self.send_blocks(
@@ -509,8 +510,9 @@
self.log.info("Reject a block with a timestamp >2 hours in the future")
self.move_tip(44)
- b48 = self.next_block(48, solve=False)
+ b48 = self.next_block(48)
b48.nTime = int(time.time()) + 60 * 60 * 3
+ # Header timestamp has changed. Re-solve the block.
b48.solve()
self.send_blocks([b48], False, force_send=True,
reject_reason='time-too-new')
@@ -1193,7 +1195,7 @@
return tx
def next_block(self, number, spend=None, additional_coinbase_value=0,
- script=CScript([OP_TRUE]), solve=True, *, version=1):
+ script=CScript([OP_TRUE]), *, version=1):
if self.tip is None:
base_block_hash = self.genesis_hash
block_time = int(time.time()) + 1
@@ -1225,10 +1227,8 @@
self.sign_tx(tx, spend)
self.add_transactions_to_block(block, [tx])
block.hashMerkleRoot = block.calc_merkle_root()
- if solve:
- block.solve()
- else:
- block.rehash()
+ # Block is created. Find a valid nonce.
+ block.solve()
self.tip = block
self.block_heights[block.sha256] = height
assert number not in self.blocks
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Mar 1, 11:34 (6 h, 31 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5187640
Default Alt Text
D8847.diff (1 KB)
Attached To
D8847: tests: simplify next_block() function in feature_block
Event Timeline
Log In to Comment