Merge #18974: test: Check that invalid witness destinations can not be imported

facede18a42ccbf45cb5156bd4e5c9cabb359821 test: Check that invalid witness destinations can not be imported (MarcoFalke)

Pull request description:

ACKs for top commit:
  practicalswift:
    ACK facede18a42ccbf45cb5156bd4e5c9cabb359821 -- thanks for adding!

Tree-SHA512: 87000606fac2e6f2780ca75cdeeb2dc1f0528d9b8f13e4156e8304ce7a6b1eb014781b6f0c59d11544bf360ba3dc5f99549470b0876132e189b9107f2c6bb38d
This commit is contained in:
MarcoFalke 2020-06-03 07:30:58 -04:00 committed by Konstantin Akimov
parent b2258ab1d2
commit 6668e21e1f
No known key found for this signature in database
GPG Key ID: 2176C4A5D01EA524

View File

@ -137,6 +137,33 @@ class WalletLabelsTest(BitcoinTestFramework):
# in the label. This is a no-op.
change_label(node, labels[2].addresses[0], labels[2], labels[2])
self.log.info('Check watchonly labels')
node.createwallet(wallet_name='watch_only', disable_private_keys=True, descriptors=False)
wallet_watch_only = node.get_wallet_rpc('watch_only')
VALID = {
'_a1': 'yMNJePdcKvXtWWQnFYHNeJ5u8TF2v1dfK4',
'_a2': 'yeMpGzMj3rhtnz48XsfpB8itPHhHtgxLc3',
'_a3': '93bVhahvUKmQu8gu9g3QnPPa2cxFK98pMB',
}
INVALID = {
'❌_b1': 'y000000000000000000000000000000000',
'❌_b2': 'y000000000000000000000000000000001',
}
for l in VALID:
ad = VALID[l]
wallet_watch_only.importaddress(label=l, rescan=False, address=ad)
node.generatetoaddress(1, ad)
assert_equal(wallet_watch_only.getaddressesbylabel(label=l), {ad: {'purpose': 'receive'}})
assert_equal(wallet_watch_only.getreceivedbylabel(label=l), 0)
for l in INVALID:
ad = INVALID[l]
assert_raises_rpc_error(
-5,
"Invalid Dash address or script",
lambda: wallet_watch_only.importaddress(label=l, rescan=False, address=ad),
)
class Label:
def __init__(self, name):
# Label name