test: add function to convert to json for height_or_hash params

This is necessary for bitcoin-cli because a string without quotes
is not a valid json.
This commit is contained in:
Martin Zumsande
2025-04-16 17:36:06 -04:00
parent 54d28722ba
commit 6530d0015b
5 changed files with 18 additions and 14 deletions

View File

@@ -8,6 +8,7 @@ import configparser
from enum import Enum
import argparse
from datetime import datetime, timezone
import json
import logging
import os
import platform
@@ -1072,3 +1073,8 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
def has_blockfile(self, node, filenum: str):
return (node.blocks_path/ f"blk{filenum}.dat").is_file()
def convert_to_json_for_cli(self, text):
if self.options.usecli:
return json.dumps(text)
return text