get better error on RPC failure

This commit is contained in:
Brannon King 2021-12-21 15:25:48 -05:00 committed by Jack Robison
parent a10eb30771
commit 07d584133e
No known key found for this signature in database
GPG key ID: DF25C68FE0239BB2
2 changed files with 9 additions and 6 deletions

View file

@ -591,9 +591,12 @@ class LBCWalletNode:
*cmnd_args, stdout=subprocess.PIPE, stderr=subprocess.PIPE
)
out, err = await process.communicate()
if err and b'creating a default config file' not in err:
log.warning(err)
result = out.decode().strip()
err = err.decode().strip()
if len(result) <= 0 and err.startswith('-'):
raise Exception(err)
if err and 'creating a default config file' not in err:
log.warning(err)
self.log.info(result)
if result.startswith('error code'):
raise Exception(result)

View file

@ -61,10 +61,10 @@ class TestSegwit(CommandTestCase):
bech32_address3 = await self.blockchain.get_new_address(self.blockchain.BECH32_ADDRESS)
# fund specific addresses for later use
p2sh_txid1 = await self.send_to_address_and_wait(p2sh_address1, '1.0')
p2sh_txid2 = await self.send_to_address_and_wait(p2sh_address2, '1.0')
bech32_txid1 = await self.send_to_address_and_wait(bech32_address1, '1.0')
bech32_txid2 = await self.send_to_address_and_wait(bech32_address2, '1.0')
p2sh_txid1 = await self.blockchain.send_to_address(p2sh_address1, '1.0')
p2sh_txid2 = await self.blockchain.send_to_address(p2sh_address2, '1.0')
bech32_txid1 = await self.blockchain.send_to_address(bech32_address1, '1.0')
bech32_txid2 = await self.blockchain.send_to_address(bech32_address2, '1.0')
await self.generate(1)
# P2SH & BECH32 can pay to P2SH address