Test RandomX submitheader PoW rejection

This commit is contained in:
Capri 2026-09-17 11:12:37 +00:00
commit 6aac94466e
Signed by: VextaProject
SSH key fingerprint: SHA256:739BZv8LvIDY2tR7lXLy/IQ6MaGTQtYcG9GNvCjmpVM

View file

@ -8,6 +8,7 @@
import threading import threading
from test_framework.address import ADDRESS_BCRT1_UNSPENDABLE_DESCRIPTOR from test_framework.address import ADDRESS_BCRT1_UNSPENDABLE_DESCRIPTOR
from test_framework.authproxy import JSONRPCException
from test_framework.blocktools import NORMAL_GBT_REQUEST_PARAMS from test_framework.blocktools import NORMAL_GBT_REQUEST_PARAMS
from test_framework.messages import CBlock, CBlockHeader, from_hex from test_framework.messages import CBlock, CBlockHeader, from_hex
from test_framework.test_framework import DigiByteTestFramework from test_framework.test_framework import DigiByteTestFramework
@ -408,6 +409,29 @@ class RandomXGetBlockTemplateTest(DigiByteTestFramework):
) )
assert_equal(submit_node.getblockcount(), 0) assert_equal(submit_node.getblockcount(), 0)
self.log.info("submitheader rejects invalid RandomX proof of work")
invalid_header_block = from_hex(CBlock(), randomx_proposal_block)
original_nonce = invalid_header_block.nNonce
saw_high_hash = False
for nonce_offset in range(1, 33):
invalid_header_block.nNonce = (
original_nonce + nonce_offset
) & 0xffffffff
try:
submit_node.submitheader(
CBlockHeader(invalid_header_block).serialize().hex()
)
except JSONRPCException as e:
if "high-hash" in e.error["message"]:
saw_high_hash = True
break
raise
assert saw_high_hash
assert_equal(submit_node.getblockcount(), 0)
self.log.info("Submit the mixed SHA256D and RandomX headers first") self.log.info("Submit the mixed SHA256D and RandomX headers first")
for height in range(1, 7): for height in range(1, 7):
block_hash = node.getblockhash(height) block_hash = node.getblockhash(height)