From 23ba460c1abe1e089c64e87abe919e87a320b32d Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Tue, 16 Apr 2019 13:12:54 -0400 Subject: test: Add test that addmultisigaddress fails for watchonly addresses Github-Pull: #15831 Rebased-From: fab6a0a659bb856e4598af3e0679fc37d5239478 --- test/functional/rpc_createmultisig.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/test/functional/rpc_createmultisig.py b/test/functional/rpc_createmultisig.py index 553be2d2bd..6411b0e285 100755 --- a/test/functional/rpc_createmultisig.py +++ b/test/functional/rpc_createmultisig.py @@ -5,6 +5,9 @@ """Test multisig RPCs""" from test_framework.test_framework import BitcoinTestFramework +from test_framework.util import ( + assert_raises_rpc_error, +) import decimal @@ -26,7 +29,9 @@ class RpcCreateMultiSigTest(BitcoinTestFramework): def run_test(self): node0, node1, node2 = self.nodes - # 50 BTC each, rest will be 25 BTC each + self.check_addmultisigaddress_errors() + + self.log.info('Generating blocks ...') node0.generate(149) self.sync_all() @@ -39,6 +44,15 @@ class RpcCreateMultiSigTest(BitcoinTestFramework): self.checkbalances() + def check_addmultisigaddress_errors(self): + self.log.info('Check that addmultisigaddress fails when the private keys are missing') + addresses = [self.nodes[1].getnewaddress(address_type='legacy') for _ in range(2)] + assert_raises_rpc_error(-5, 'no full public key for address', lambda: self.nodes[0].addmultisigaddress(nrequired=1, keys=addresses)) + for a in addresses: + # Importing all addresses should not change the result + self.nodes[0].importaddress(a) + assert_raises_rpc_error(-5, 'no full public key for address', lambda: self.nodes[0].addmultisigaddress(nrequired=1, keys=addresses)) + def checkbalances(self): node0, node1, node2 = self.nodes node0.generate(100) -- cgit v1.2.3