From e5e639ae22f0d52a2e8f25a9758cf04343cf89bc Mon Sep 17 00:00:00 2001 From: mdr0id Date: Thu, 12 Mar 2020 10:27:12 -0700 Subject: [PATCH] Update RPCs to support cross platform paths and libs --- qa/rpc-tests/test_framework/blockstore.py | 2 +- qa/rpc-tests/test_framework/netutil.py | 3 ++- qa/rpc-tests/test_framework/util.py | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/qa/rpc-tests/test_framework/blockstore.py b/qa/rpc-tests/test_framework/blockstore.py index 6b75afbab..7f59250bb 100644 --- a/qa/rpc-tests/test_framework/blockstore.py +++ b/qa/rpc-tests/test_framework/blockstore.py @@ -7,7 +7,7 @@ from .mininode import CBlock, CBlockHeader, CBlockLocator, CTransaction, msg_blo import sys import io -import dbm +import dbm.dumb as dbm class BlockStore(): def __init__(self, datadir): diff --git a/qa/rpc-tests/test_framework/netutil.py b/qa/rpc-tests/test_framework/netutil.py index d09460cc0..d0af6ee56 100644 --- a/qa/rpc-tests/test_framework/netutil.py +++ b/qa/rpc-tests/test_framework/netutil.py @@ -6,7 +6,6 @@ # Linux network utilities import sys import socket -import fcntl import struct import array import os @@ -88,6 +87,8 @@ def all_interfaces(): ''' Return all interfaces that are up ''' + import fcntl + is_64bits = sys.maxsize > 2**32 struct_size = 40 if is_64bits else 32 s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) diff --git a/qa/rpc-tests/test_framework/util.py b/qa/rpc-tests/test_framework/util.py index 42ad2fa60..fabb41d91 100644 --- a/qa/rpc-tests/test_framework/util.py +++ b/qa/rpc-tests/test_framework/util.py @@ -137,7 +137,7 @@ def initialize_chain(test_dir): shutil.rmtree("cache") if not os.path.isdir(os.path.join("cache", "node0")): - devnull = open("/dev/null", "w+") + devnull = open(os.devnull, "w+") # Create cache directories, run bitcoinds: for i in range(4): datadir=initialize_datadir("cache", i) @@ -240,7 +240,7 @@ def start_node(i, dirname, extra_args=None, rpchost=None, timewait=None, binary= ]) if extra_args is not None: args.extend(extra_args) bitcoind_processes[i] = subprocess.Popen(args) - devnull = open("/dev/null", "w+") + devnull = open(os.devnull, "w+") if os.getenv("PYTHON_DEBUG", ""): print("start_node: bitcoind started, calling bitcoin-cli -rpcwait getblockcount") subprocess.check_call([ os.getenv("BITCOINCLI", "bitcoin-cli"), "-datadir="+datadir] +