aboutsummaryrefslogtreecommitdiff
path: root/test/functional
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2017-12-17 12:23:07 +0100
committerWladimir J. van der Laan <laanwj@gmail.com>2017-12-17 12:23:25 +0100
commit2559a19e6fdb91cd69b05ac3e8aed91c3be8882c (patch)
treee6e14c98ffdd4dee22178e5685f5a33a25b0c614 /test/functional
parenta69cc077d9464898cefe4e75b0cd1880e66a2cf6 (diff)
parent7af24577b52d3ee0aea2c66889b8f94b65d4ab27 (diff)
downloadbitcoin-2559a19e6fdb91cd69b05ac3e8aed91c3be8882c.tar.xz
Merge #11647: 0.15: Backports
7af2457 contrib/init: Update openrc-run filename (Luke Dashjr) 3f1db56 Wrap dumpwallet warning and note scripts aren't dumped (MeshCollider) 42ea47d Add wallet backup text to import*, add* and dumpwallet RPCs (MeshCollider) 3a6cdd4 Add test for multiwallet batch RPC calls (Russell Yanofsky) 1c8c7f8 Add missing batch rpc calls to python coverage logs (Russell Yanofsky) 1036c43 Add missing multiwallet rpc calls to python coverage logs (Russell Yanofsky) 2eea279 Make AuthServiceProxy._batch method usable (Russell Yanofsky) 305f768 Limit AuthServiceProxyWrapper.__getattr__ wrapping (Russell Yanofsky) 7026845 Fix uninitialized URI in batch RPC requests (Russell Yanofsky) 6372a75 [Wallet] always show help-line of wallet encryption calls (Jonas Schnelli) Pull request description: This fixes some multiwallet issues on the 0.15 branch... Tree-SHA512: 304a6c6acbce22c8b7338d1e618451978ab2cd04938c71a3daf40fe9996ef14e324645d642fbc21950a5481fb993254082d54da1cb953a739ebaeaab34c080d4
Diffstat (limited to 'test/functional')
-rwxr-xr-xtest/functional/multiwallet.py4
-rw-r--r--test/functional/test_framework/authproxy.py15
-rw-r--r--test/functional/test_framework/coverage.py26
3 files changed, 28 insertions, 17 deletions
diff --git a/test/functional/multiwallet.py b/test/functional/multiwallet.py
index ba6b659ddc..7a0fbce477 100755
--- a/test/functional/multiwallet.py
+++ b/test/functional/multiwallet.py
@@ -82,5 +82,9 @@ class MultiWalletTest(BitcoinTestFramework):
assert_equal(w2.getbalance(), 1)
assert_equal(w3.getbalance(), 2)
+ batch = w1.batch([w1.getblockchaininfo.get_request(), w1.getwalletinfo.get_request()])
+ assert_equal(batch[0]["result"]["chain"], "regtest")
+ assert_equal(batch[1]["result"]["walletname"], "w1")
+
if __name__ == '__main__':
MultiWalletTest().main()
diff --git a/test/functional/test_framework/authproxy.py b/test/functional/test_framework/authproxy.py
index b3671cbdc5..747bda309c 100644
--- a/test/functional/test_framework/authproxy.py
+++ b/test/functional/test_framework/authproxy.py
@@ -138,17 +138,20 @@ class AuthServiceProxy(object):
self.__conn.request(method, path, postdata, headers)
return self._get_response()
- def __call__(self, *args, **argsn):
+ def get_request(self, *args, **argsn):
AuthServiceProxy.__id_count += 1
log.debug("-%s-> %s %s"%(AuthServiceProxy.__id_count, self._service_name,
json.dumps(args, default=EncodeDecimal, ensure_ascii=self.ensure_ascii)))
if args and argsn:
raise ValueError('Cannot handle both named and positional arguments')
- postdata = json.dumps({'version': '1.1',
- 'method': self._service_name,
- 'params': args or argsn,
- 'id': AuthServiceProxy.__id_count}, default=EncodeDecimal, ensure_ascii=self.ensure_ascii)
+ return {'version': '1.1',
+ 'method': self._service_name,
+ 'params': args or argsn,
+ 'id': AuthServiceProxy.__id_count}
+
+ def __call__(self, *args, **argsn):
+ postdata = json.dumps(self.get_request(*args, **argsn), default=EncodeDecimal, ensure_ascii=self.ensure_ascii)
response = self._request('POST', self.__url.path, postdata.encode('utf-8'))
if response['error'] is not None:
raise JSONRPCException(response['error'])
@@ -158,7 +161,7 @@ class AuthServiceProxy(object):
else:
return response['result']
- def _batch(self, rpc_call_list):
+ def batch(self, rpc_call_list):
postdata = json.dumps(list(rpc_call_list), default=EncodeDecimal, ensure_ascii=self.ensure_ascii)
log.debug("--> "+postdata)
return self._request('POST', self.__url.path, postdata.encode('utf-8'))
diff --git a/test/functional/test_framework/coverage.py b/test/functional/test_framework/coverage.py
index 227b1a17af..84049e76bc 100644
--- a/test/functional/test_framework/coverage.py
+++ b/test/functional/test_framework/coverage.py
@@ -31,10 +31,11 @@ class AuthServiceProxyWrapper(object):
self.auth_service_proxy_instance = auth_service_proxy_instance
self.coverage_logfile = coverage_logfile
- def __getattr__(self, *args, **kwargs):
- return_val = self.auth_service_proxy_instance.__getattr__(
- *args, **kwargs)
-
+ def __getattr__(self, name):
+ return_val = getattr(self.auth_service_proxy_instance, name)
+ if not isinstance(return_val, type(self.auth_service_proxy_instance)):
+ # If proxy getattr returned an unwrapped value, do the same here.
+ return return_val
return AuthServiceProxyWrapper(return_val, self.coverage_logfile)
def __call__(self, *args, **kwargs):
@@ -44,20 +45,23 @@ class AuthServiceProxyWrapper(object):
"""
return_val = self.auth_service_proxy_instance.__call__(*args, **kwargs)
+ self._log_call()
+ return return_val
+
+ def _log_call(self):
rpc_method = self.auth_service_proxy_instance._service_name
if self.coverage_logfile:
with open(self.coverage_logfile, 'a+', encoding='utf8') as f:
f.write("%s\n" % rpc_method)
- return return_val
-
- @property
- def url(self):
- return self.auth_service_proxy_instance.url
-
def __truediv__(self, relative_uri):
- return AuthServiceProxyWrapper(self.auth_service_proxy_instance / relative_uri)
+ return AuthServiceProxyWrapper(self.auth_service_proxy_instance / relative_uri,
+ self.coverage_logfile)
+
+ def get_request(self, *args, **kwargs):
+ self._log_call()
+ return self.auth_service_proxy_instance.get_request(*args, **kwargs)
def get_filename(dirname, n_node):
"""