test: rename .rpc to ._rpc and remove unnecessary uses
It is usually not necessary, and makes it impossible to use --usecli
This commit is contained in:
1 parent
5b08885986
commit
8f8ce9e174
7 files changed
+20
-20
No files matched your search
@@ -19,7 +19,7 @@ class DeprecatedRpcTest(BitcoinTestFramework):
|
|||||||
# such RPCs are fully removed. For example:
|
# such RPCs are fully removed. For example:
|
||||||
#
|
#
|
||||||
# self.log.info("Test generate RPC")
|
# self.log.info("Test generate RPC")
|
||||||
# assert_raises_rpc_error(-32, 'The wallet generate rpc method is deprecated', self.nodes[0].rpc.generate, 1)
|
# assert_raises_rpc_error(-32, 'The wallet generate rpc method is deprecated', self.nodes[0].generate, 1)
|
||||||
#
|
#
|
||||||
# Please ensure that for all the RPC methods tested here, there is
|
# Please ensure that for all the RPC methods tested here, there is
|
||||||
# at least one other functional test that still tests the RPCs
|
# at least one other functional test that still tests the RPCs
|
||||||
@@ -32,7 +32,7 @@ class DeprecatedRpcTest(BitcoinTestFramework):
|
|||||||
self.log.info("Tests for deprecated wallet-related RPC methods (if any)")
|
self.log.info("Tests for deprecated wallet-related RPC methods (if any)")
|
||||||
self.log.info("Test settxfee RPC deprecation")
|
self.log.info("Test settxfee RPC deprecation")
|
||||||
self.nodes[0].createwallet("settxfeerpc")
|
self.nodes[0].createwallet("settxfeerpc")
|
||||||
assert_raises_rpc_error(-32, 'settxfee is deprecated and will be fully removed in v31.0.', self.nodes[0].rpc.settxfee, 0.01)
|
assert_raises_rpc_error(-32, 'settxfee is deprecated and will be fully removed in v31.0.', self.nodes[0].settxfee, 0.01)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
DeprecatedRpcTest(__file__).main()
|
DeprecatedRpcTest(__file__).main()
|
||||||
@@ -125,7 +125,7 @@ class RPCGenerateTest(BitcoinTestFramework):
|
|||||||
)
|
)
|
||||||
|
|
||||||
self.log.info("Test rpc generate raises with message to use cli option")
|
self.log.info("Test rpc generate raises with message to use cli option")
|
||||||
assert_raises_rpc_error(-32601, message, self.nodes[0].rpc.generate)
|
assert_raises_rpc_error(-32601, message, self.nodes[0]._rpc.generate)
|
||||||
|
|
||||||
self.log.info("Test rpc generate help prints message to use cli option")
|
self.log.info("Test rpc generate help prints message to use cli option")
|
||||||
assert_equal(message, self.nodes[0].help("generate"))
|
assert_equal(message, self.nodes[0].help("generate"))
|
||||||
|
|||||||
@@ -593,7 +593,7 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
|
|||||||
node.wait_for_rpc_connection()
|
node.wait_for_rpc_connection()
|
||||||
|
|
||||||
if self.options.coveragedir is not None:
|
if self.options.coveragedir is not None:
|
||||||
coverage.write_all_rpc_commands(self.options.coveragedir, node.rpc)
|
coverage.write_all_rpc_commands(self.options.coveragedir, node._rpc)
|
||||||
|
|
||||||
def start_nodes(self, extra_args=None, *args, **kwargs):
|
def start_nodes(self, extra_args=None, *args, **kwargs):
|
||||||
"""Start multiple bitcoinds"""
|
"""Start multiple bitcoinds"""
|
||||||
@@ -608,7 +608,7 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
|
|||||||
|
|
||||||
if self.options.coveragedir is not None:
|
if self.options.coveragedir is not None:
|
||||||
for node in self.nodes:
|
for node in self.nodes:
|
||||||
coverage.write_all_rpc_commands(self.options.coveragedir, node.rpc)
|
coverage.write_all_rpc_commands(self.options.coveragedir, node._rpc)
|
||||||
|
|
||||||
def stop_node(self, i, expected_stderr='', wait=0):
|
def stop_node(self, i, expected_stderr='', wait=0):
|
||||||
"""Stop a bitcoind test node"""
|
"""Stop a bitcoind test node"""
|
||||||
|
|||||||
@@ -155,7 +155,7 @@ class TestNode():
|
|||||||
self.running = False
|
self.running = False
|
||||||
self.process = None
|
self.process = None
|
||||||
self.rpc_connected = False
|
self.rpc_connected = False
|
||||||
self.rpc = None
|
self._rpc = None # Should usually not be accessed directly in tests to allow for --usecli mode
|
||||||
self.reuse_http_connections = True # Must be set before calling get_rpc_proxy() i.e. before restarting node
|
self.reuse_http_connections = True # Must be set before calling get_rpc_proxy() i.e. before restarting node
|
||||||
self.url = None
|
self.url = None
|
||||||
self.log = logging.getLogger('TestFramework.node%d' % i)
|
self.log = logging.getLogger('TestFramework.node%d' % i)
|
||||||
@@ -212,8 +212,8 @@ class TestNode():
|
|||||||
if self.use_cli:
|
if self.use_cli:
|
||||||
return getattr(self.cli, name)
|
return getattr(self.cli, name)
|
||||||
else:
|
else:
|
||||||
assert self.rpc_connected and self.rpc is not None, self._node_msg("Error: no RPC connection")
|
assert self.rpc_connected and self._rpc is not None, self._node_msg("Error: no RPC connection")
|
||||||
return getattr(self.rpc, name)
|
return getattr(self._rpc, name)
|
||||||
|
|
||||||
def start(self, extra_args=None, *, cwd=None, stdout=None, stderr=None, env=None, **kwargs):
|
def start(self, extra_args=None, *, cwd=None, stdout=None, stderr=None, env=None, **kwargs):
|
||||||
"""Start the node."""
|
"""Start the node."""
|
||||||
@@ -317,8 +317,8 @@ class TestNode():
|
|||||||
self.rpc_connected = True
|
self.rpc_connected = True
|
||||||
if self.use_cli:
|
if self.use_cli:
|
||||||
return
|
return
|
||||||
self.rpc = rpc
|
self._rpc = rpc
|
||||||
self.url = self.rpc.rpc_url
|
self.url = self._rpc.rpc_url
|
||||||
return
|
return
|
||||||
except JSONRPCException as e:
|
except JSONRPCException as e:
|
||||||
# Suppress these as they are expected during initialization.
|
# Suppress these as they are expected during initialization.
|
||||||
@@ -395,9 +395,9 @@ class TestNode():
|
|||||||
if self.use_cli:
|
if self.use_cli:
|
||||||
return self.cli("-rpcwallet={}".format(wallet_name))
|
return self.cli("-rpcwallet={}".format(wallet_name))
|
||||||
else:
|
else:
|
||||||
assert self.rpc_connected and self.rpc, self._node_msg("RPC not connected")
|
assert self.rpc_connected and self._rpc, self._node_msg("RPC not connected")
|
||||||
wallet_path = "wallet/{}".format(urllib.parse.quote(wallet_name))
|
wallet_path = "wallet/{}".format(urllib.parse.quote(wallet_name))
|
||||||
return self.rpc / wallet_path
|
return self._rpc / wallet_path
|
||||||
|
|
||||||
def version_is_at_least(self, ver):
|
def version_is_at_least(self, ver):
|
||||||
return self.version is None or self.version >= ver
|
return self.version is None or self.version >= ver
|
||||||
@@ -452,7 +452,7 @@ class TestNode():
|
|||||||
self.running = False
|
self.running = False
|
||||||
self.process = None
|
self.process = None
|
||||||
self.rpc_connected = False
|
self.rpc_connected = False
|
||||||
self.rpc = None
|
self._rpc = None
|
||||||
self.log.debug("Node stopped")
|
self.log.debug("Node stopped")
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|||||||
@@ -327,7 +327,7 @@ class BackwardsCompatibilityTest(BitcoinTestFramework):
|
|||||||
for node in descriptors_nodes:
|
for node in descriptors_nodes:
|
||||||
self.log.info(f"- {node.version}")
|
self.log.info(f"- {node.version}")
|
||||||
wallet_name = f"up_{node.version}"
|
wallet_name = f"up_{node.version}"
|
||||||
node.rpc.createwallet(wallet_name=wallet_name, descriptors=True)
|
node.createwallet(wallet_name=wallet_name, descriptors=True)
|
||||||
wallet_prev = node.get_wallet_rpc(wallet_name)
|
wallet_prev = node.get_wallet_rpc(wallet_name)
|
||||||
address = wallet_prev.getnewaddress('', "bech32")
|
address = wallet_prev.getnewaddress('', "bech32")
|
||||||
addr_info = wallet_prev.getaddressinfo(address)
|
addr_info = wallet_prev.getaddressinfo(address)
|
||||||
@@ -395,9 +395,9 @@ class BackwardsCompatibilityTest(BitcoinTestFramework):
|
|||||||
self.log.info(f"- {node.version}")
|
self.log.info(f"- {node.version}")
|
||||||
wallet_name = f"legacy_up_{node.version}"
|
wallet_name = f"legacy_up_{node.version}"
|
||||||
if self.major_version_at_least(node, 21):
|
if self.major_version_at_least(node, 21):
|
||||||
node.rpc.createwallet(wallet_name=wallet_name, descriptors=False)
|
node.createwallet(wallet_name=wallet_name, descriptors=False)
|
||||||
else:
|
else:
|
||||||
node.rpc.createwallet(wallet_name=wallet_name)
|
node.createwallet(wallet_name=wallet_name)
|
||||||
wallet_prev = node.get_wallet_rpc(wallet_name)
|
wallet_prev = node.get_wallet_rpc(wallet_name)
|
||||||
address = wallet_prev.getnewaddress('', "bech32")
|
address = wallet_prev.getnewaddress('', "bech32")
|
||||||
addr_info = wallet_prev.getaddressinfo(address)
|
addr_info = wallet_prev.getaddressinfo(address)
|
||||||
|
|||||||
@@ -454,14 +454,14 @@ class WalletTest(BitcoinTestFramework):
|
|||||||
# - True: unicode escaped as \u....
|
# - True: unicode escaped as \u....
|
||||||
# - False: unicode directly as UTF-8
|
# - False: unicode directly as UTF-8
|
||||||
for mode in [True, False]:
|
for mode in [True, False]:
|
||||||
self.nodes[0].rpc.ensure_ascii = mode
|
self.nodes[0]._rpc.ensure_ascii = mode
|
||||||
# unicode check: Basic Multilingual Plane, Supplementary Plane respectively
|
# unicode check: Basic Multilingual Plane, Supplementary Plane respectively
|
||||||
for label in [u'рыба', u'𝅘𝅥𝅯']:
|
for label in [u'рыба', u'𝅘𝅥𝅯']:
|
||||||
addr = self.nodes[0].getnewaddress()
|
addr = self.nodes[0].getnewaddress()
|
||||||
self.nodes[0].setlabel(addr, label)
|
self.nodes[0].setlabel(addr, label)
|
||||||
test_address(self.nodes[0], addr, labels=[label])
|
test_address(self.nodes[0], addr, labels=[label])
|
||||||
assert label in self.nodes[0].listlabels()
|
assert label in self.nodes[0].listlabels()
|
||||||
self.nodes[0].rpc.ensure_ascii = True # restore to default
|
self.nodes[0]._rpc.ensure_ascii = True # restore to default
|
||||||
|
|
||||||
# -reindex tests
|
# -reindex tests
|
||||||
chainlimit = 6
|
chainlimit = 6
|
||||||
|
|||||||
@@ -297,14 +297,14 @@ class WalletMiniscriptTest(BitcoinTestFramework):
|
|||||||
psbt.i[0].map[k] = bytes.fromhex(preimage)
|
psbt.i[0].map[k] = bytes.fromhex(preimage)
|
||||||
psbt = psbt.to_base64()
|
psbt = psbt.to_base64()
|
||||||
res = self.ms_sig_wallet.walletprocesspsbt(psbt=psbt, finalize=False)
|
res = self.ms_sig_wallet.walletprocesspsbt(psbt=psbt, finalize=False)
|
||||||
psbtin = self.nodes[0].rpc.decodepsbt(res["psbt"])["inputs"][0]
|
psbtin = self.nodes[0].decodepsbt(res["psbt"])["inputs"][0]
|
||||||
sigs_field_name = "taproot_script_path_sigs" if is_taproot else "partial_signatures"
|
sigs_field_name = "taproot_script_path_sigs" if is_taproot else "partial_signatures"
|
||||||
assert len(psbtin[sigs_field_name]) == sigs_count
|
assert len(psbtin[sigs_field_name]) == sigs_count
|
||||||
res = self.ms_sig_wallet.finalizepsbt(res["psbt"])
|
res = self.ms_sig_wallet.finalizepsbt(res["psbt"])
|
||||||
assert res["complete"] == (stack_size is not None)
|
assert res["complete"] == (stack_size is not None)
|
||||||
|
|
||||||
if stack_size is not None:
|
if stack_size is not None:
|
||||||
txin = self.nodes[0].rpc.decoderawtransaction(res["hex"])["vin"][0]
|
txin = self.nodes[0].decoderawtransaction(res["hex"])["vin"][0]
|
||||||
assert len(txin["txinwitness"]) == stack_size, txin["txinwitness"]
|
assert len(txin["txinwitness"]) == stack_size, txin["txinwitness"]
|
||||||
self.log.info("Broadcasting the transaction.")
|
self.log.info("Broadcasting the transaction.")
|
||||||
# If necessary, satisfy a relative timelock
|
# If necessary, satisfy a relative timelock
|
||||||
|
|||||||
Reference in new issue
Block a user