From 1ceb4c19cce09e6792f2607c1a505184aa807845 Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Fri, 10 Feb 2023 23:51:56 +0000 Subject: [PATCH] qa: Extend `wallet_deprecation` to test `allowdeprecated` in config file Co-authored-by: Daira Hopwood --- qa/rpc-tests/wallet_deprecation.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/qa/rpc-tests/wallet_deprecation.py b/qa/rpc-tests/wallet_deprecation.py index f1fed7209..ddbfc8a55 100755 --- a/qa/rpc-tests/wallet_deprecation.py +++ b/qa/rpc-tests/wallet_deprecation.py @@ -12,6 +12,8 @@ from test_framework.util import ( ) from test_framework.authproxy import JSONRPCException +import os.path + # Pick a subset of the deprecated RPC methods to test with. This test assumes that # the deprecation feature name is the same as the RPC method name, and that the RPC # method works without any arguments. @@ -29,6 +31,12 @@ class WalletDeprecationTest(BitcoinTestFramework): super().__init__() self.num_nodes = 1 + def setup_chain(self): + super().setup_chain() + # Save a copy of node 0's zcash.conf + with open(os.path.join(self.options.tmpdir, "node0", "zcash.conf"), 'r', encoding='utf8') as f: + self.conf_lines = f.readlines() + def setup_network(self): self.setup_network_with_args([]) @@ -39,6 +47,13 @@ class WalletDeprecationTest(BitcoinTestFramework): self.num_nodes, self.options.tmpdir, extra_args=[dep_args] * self.num_nodes) + def setup_network_with_config(self, allowed_deprecated): + conf_lines = self.conf_lines + ["allowdeprecated={}\n".format(v) for v in allowed_deprecated] + with open(os.path.join(self.options.tmpdir, "node0", "zcash.conf"), 'w', encoding='utf8') as f: + f.writelines(conf_lines) + + self.nodes = start_nodes(self.num_nodes, self.options.tmpdir) + def verify_enabled(self, function): try: getattr(self.nodes[0], function)() @@ -80,7 +95,7 @@ class WalletDeprecationTest(BitcoinTestFramework): for function in DEFAULT_DISABLED: self.verify_disabled(function) - for start_mode in (self.setup_network_with_args,): + for start_mode in (self.setup_network_with_args, self.setup_network_with_config): # restart with a specific selection of deprecated methods enabled self.test_case(start_mode, DEFAULT_DISABLED, self.verify_enabled)