mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-29 14:59:39 -04:00
test, contrib: Fix signer/miner command line escaping
Pass bitcoin binary command lines from test framework to signet/miner utility using shell escaping so they are unambigous and don't get mangled if they contain spaces. This change is not needed for tests to pass currently, but is a useful change to avoid CI failures in followup PR https://github.com/bitcoin/bitcoin/pull/31375 and to avoid other bugs.
This commit is contained in:
parent
0d2eefca8b
commit
d190f0facc
2 changed files with 7 additions and 6 deletions
|
@ -9,7 +9,7 @@ import logging
|
|||
import math
|
||||
import os
|
||||
import re
|
||||
import struct
|
||||
import shlex
|
||||
import sys
|
||||
import time
|
||||
import subprocess
|
||||
|
@ -86,7 +86,7 @@ def finish_block(block, signet_solution, grind_cmd):
|
|||
block.solve()
|
||||
else:
|
||||
headhex = CBlockHeader.serialize(block).hex()
|
||||
cmd = grind_cmd.split(" ") + [headhex]
|
||||
cmd = shlex.split(grind_cmd) + [headhex]
|
||||
newheadhex = subprocess.run(cmd, stdout=subprocess.PIPE, input=b"", check=True).stdout.strip()
|
||||
newhead = from_hex(CBlockHeader(), newheadhex.decode('utf8'))
|
||||
block.nNonce = newhead.nNonce
|
||||
|
@ -479,7 +479,7 @@ def do_calibrate(args):
|
|||
header.nTime = i
|
||||
header.nNonce = 0
|
||||
headhex = header.serialize().hex()
|
||||
cmd = args.grind_cmd.split(" ") + [headhex]
|
||||
cmd = shlex.split(args.grind_cmd) + [headhex]
|
||||
newheadhex = subprocess.run(cmd, stdout=subprocess.PIPE, input=b"", check=True).stdout.strip()
|
||||
|
||||
avg = (time.time() - start) * 1.0 / TRIALS
|
||||
|
@ -549,7 +549,7 @@ def main():
|
|||
|
||||
args = parser.parse_args(sys.argv[1:])
|
||||
|
||||
args.bcli = lambda *a, input=b"", **kwargs: bitcoin_cli(args.cli.split(" "), list(a), input=input, **kwargs)
|
||||
args.bcli = lambda *a, input=b"", **kwargs: bitcoin_cli(shlex.split(args.cli), list(a), input=input, **kwargs)
|
||||
|
||||
if hasattr(args, "address") and hasattr(args, "descriptor"):
|
||||
args.derived_addresses = {}
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
"""Test signet miner tool"""
|
||||
|
||||
import os.path
|
||||
import shlex
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
|
@ -54,10 +55,10 @@ class SignetMinerTest(BitcoinTestFramework):
|
|||
subprocess.run([
|
||||
sys.executable,
|
||||
signet_miner_path,
|
||||
f'--cli={" ".join(rpc_argv)}',
|
||||
f'--cli={shlex.join(rpc_argv)}',
|
||||
'generate',
|
||||
f'--address={node.getnewaddress()}',
|
||||
f'--grind-cmd={" ".join(util_argv)}',
|
||||
f'--grind-cmd={shlex.join(util_argv)}',
|
||||
f'--nbits={DIFF_1_N_BITS:08x}',
|
||||
f'--set-block-time={int(time.time())}',
|
||||
'--poolnum=99',
|
||||
|
|
Loading…
Add table
Reference in a new issue