mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-04-15 10:07:41 +02:00
test: split equality asserts joined by and
Some tests combine multiple equality checks in one `assert`. Split those checks into separate assertions so failures point at the exact mismatch. This also removes mixed `==` expressions that the later cleanup should not touch.
This commit is contained in:
@@ -918,7 +918,10 @@ class PSBTTest(BitcoinTestFramework):
|
||||
assert "final_scriptwitness" in psbt2_decoded['inputs'][0] and "final_scriptSig" in psbt2_decoded['inputs'][0]
|
||||
joined = self.nodes[0].joinpsbts([psbt, psbt2])
|
||||
joined_decoded = self.nodes[0].decodepsbt(joined)
|
||||
assert len(joined_decoded['inputs']) == 4 and len(joined_decoded['outputs']) == 2 and "final_scriptwitness" not in joined_decoded['inputs'][3] and "final_scriptSig" not in joined_decoded['inputs'][3]
|
||||
assert_equal(len(joined_decoded['inputs']), 4)
|
||||
assert_equal(len(joined_decoded['outputs']), 2)
|
||||
assert "final_scriptwitness" not in joined_decoded['inputs'][3]
|
||||
assert "final_scriptSig" not in joined_decoded['inputs'][3]
|
||||
|
||||
# Check that joining shuffles the inputs and outputs
|
||||
# 10 attempts should be enough to get a shuffled join
|
||||
@@ -937,20 +940,31 @@ class PSBTTest(BitcoinTestFramework):
|
||||
self.generate(self.nodes[0], 6)[0]
|
||||
psbt = self.nodes[1].createpsbt([utxo], {self.nodes[0].getnewaddress("", "p2sh-segwit"):Decimal('6.999')})
|
||||
analyzed = self.nodes[0].analyzepsbt(psbt)
|
||||
assert not analyzed['inputs'][0]['has_utxo'] and not analyzed['inputs'][0]['is_final'] and analyzed['inputs'][0]['next'] == 'updater' and analyzed['next'] == 'updater'
|
||||
assert not analyzed['inputs'][0]['has_utxo']
|
||||
assert not analyzed['inputs'][0]['is_final']
|
||||
assert_equal(analyzed['inputs'][0]['next'], 'updater')
|
||||
assert_equal(analyzed['next'], 'updater')
|
||||
|
||||
# After update with wallet, only needs signing
|
||||
updated = self.nodes[1].walletprocesspsbt(psbt, False, 'ALL', True)['psbt']
|
||||
analyzed = self.nodes[0].analyzepsbt(updated)
|
||||
assert analyzed['inputs'][0]['has_utxo'] and not analyzed['inputs'][0]['is_final'] and analyzed['inputs'][0]['next'] == 'signer' and analyzed['next'] == 'signer' and analyzed['inputs'][0]['missing']['signatures'][0] == addrinfo['embedded']['witness_program']
|
||||
assert analyzed['inputs'][0]['has_utxo']
|
||||
assert not analyzed['inputs'][0]['is_final']
|
||||
assert_equal(analyzed['inputs'][0]['next'], 'signer')
|
||||
assert_equal(analyzed['next'], 'signer')
|
||||
assert_equal(analyzed['inputs'][0]['missing']['signatures'][0], addrinfo['embedded']['witness_program'])
|
||||
|
||||
# Check fee and size things
|
||||
assert analyzed['fee'] == Decimal('0.001') and analyzed['estimated_vsize'] == 134 and analyzed['estimated_feerate'] == Decimal('0.00746268')
|
||||
assert_equal(analyzed['fee'], Decimal('0.001'))
|
||||
assert_equal(analyzed['estimated_vsize'], 134)
|
||||
assert_equal(analyzed['estimated_feerate'], Decimal('0.00746268'))
|
||||
|
||||
# After signing and finalizing, needs extracting
|
||||
signed = self.nodes[1].walletprocesspsbt(updated)['psbt']
|
||||
analyzed = self.nodes[0].analyzepsbt(signed)
|
||||
assert analyzed['inputs'][0]['has_utxo'] and analyzed['inputs'][0]['is_final'] and analyzed['next'] == 'extractor'
|
||||
assert analyzed['inputs'][0]['has_utxo']
|
||||
assert analyzed['inputs'][0]['is_final']
|
||||
assert_equal(analyzed['next'], 'extractor')
|
||||
|
||||
self.log.info("PSBT spending unspendable outputs should have error message and Creator as next")
|
||||
analysis = self.nodes[0].analyzepsbt('cHNidP8BAJoCAAAAAljoeiG1ba8MI76OcHBFbDNvfLqlyHV5JPVFiHuyq911AAAAAAD/////g40EJ9DsZQpoqka7CwmK6kQiwHGyyng1Kgd5WdB86h0BAAAAAP////8CcKrwCAAAAAAWAEHYXCtx0AYLCcmIauuBXlCZHdoSTQDh9QUAAAAAFv8/wADXYP/7//////8JxOh0LR2HAI8AAAAAAAEBIADC6wsAAAAAF2oUt/X69ELjeX2nTof+fZ10l+OyAokDAQcJAwEHEAABAACAAAEBIADC6wsAAAAAF2oUt/X69ELjeX2nTof+fZ10l+OyAokDAQcJAwEHENkMak8AAAAA')
|
||||
|
||||
@@ -723,12 +723,14 @@ class ImportDescriptorsTest(BitcoinTestFramework):
|
||||
try:
|
||||
self.nodes[0].cli("-rpcwallet=encrypted_wallet").walletlock()
|
||||
except JSONRPCException as e:
|
||||
assert e.error["code"] == -4 and "Error: the wallet is currently being used to rescan the blockchain for related transactions. Please call `abortrescan` before locking the wallet." in e.error["message"]
|
||||
assert_equal(e.error["code"], -4)
|
||||
assert "Error: the wallet is currently being used to rescan the blockchain for related transactions. Please call `abortrescan` before locking the wallet." in e.error["message"]
|
||||
|
||||
try:
|
||||
self.nodes[0].cli("-rpcwallet=encrypted_wallet").walletpassphrasechange("passphrase", "newpassphrase")
|
||||
except JSONRPCException as e:
|
||||
assert e.error["code"] == -4 and "Error: the wallet is currently being used to rescan the blockchain for related transactions. Please call `abortrescan` before changing the passphrase." in e.error["message"]
|
||||
assert_equal(e.error["code"], -4)
|
||||
assert "Error: the wallet is currently being used to rescan the blockchain for related transactions. Please call `abortrescan` before changing the passphrase." in e.error["message"]
|
||||
|
||||
assert_equal(importing.result(), [{"success": True}])
|
||||
|
||||
|
||||
@@ -243,7 +243,8 @@ class WalletMiniscriptTest(BitcoinTestFramework):
|
||||
lambda: len(self.ms_wo_wallet.listunspent(minconf=0, addresses=[addr])) == 1
|
||||
)
|
||||
utxo = self.ms_wo_wallet.listunspent(minconf=0, addresses=[addr])[0]
|
||||
assert utxo["txid"] == txid and utxo["solvable"]
|
||||
assert_equal(utxo["txid"], txid)
|
||||
assert utxo["solvable"]
|
||||
|
||||
def signing_test(
|
||||
self, desc, sequence, locktime, sigs_count, stack_size, sha256_preimages
|
||||
@@ -271,7 +272,8 @@ class WalletMiniscriptTest(BitcoinTestFramework):
|
||||
self.wait_until(lambda: txid in self.funder.getrawmempool())
|
||||
self.funder.generatetoaddress(1, self.funder.getnewaddress())
|
||||
utxo = self.ms_sig_wallet.listunspent(addresses=[addr])[0]
|
||||
assert txid == utxo["txid"] and utxo["solvable"]
|
||||
assert_equal(txid, utxo["txid"])
|
||||
assert utxo["solvable"]
|
||||
|
||||
self.log.info("Creating a transaction spending these funds")
|
||||
dest_addr = self.funder.getnewaddress()
|
||||
|
||||
Reference in New Issue
Block a user