Merge #575: mempool_package: make sure small UTXOs aren't selected for spending c…

fb184c830 mempool_package: make sure small UTXOs aren't selected for spending chain (Gregory Sanders)

Pull request description:

  …hain

  Was causing random errors depending on the response of listunspent, which may be including smaller UTXOs for whatever reason.

Tree-SHA512: 1a083026f67131374478cc70abd41a3c4918f7867d0ede75a3ddf331e485ed11bc8a46477a7ecf733faa40130529f2b83f7b1a8a56d8434a3908a0592cdd61ef
This commit is contained in:
Steven Roose 2019-04-15 16:05:56 +01:00
commit aea8fa2a82
No known key found for this signature in database
GPG key ID: 7FC91380BB4CE800

View file

@ -8,12 +8,11 @@ from decimal import Decimal
from test_framework.messages import COIN
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_equal, assert_raises_rpc_error, satoshi_round, sync_blocks, sync_mempools
from test_framework.util import assert_equal, assert_raises_rpc_error, satoshi_round, sync_blocks, sync_mempools, assert_greater_than
import time
MAX_ANCESTORS = 25
MAX_DESCENDANTS = 25
class MempoolPackagesTest(BitcoinTestFramework):
def set_test_params(self):
self.num_nodes = 2
@ -58,10 +57,17 @@ class MempoolPackagesTest(BitcoinTestFramework):
# Mine some blocks and have them mature.
self.nodes[0].generate(101)
utxo = self.nodes[0].listunspent(10)
txid = utxo[0]['txid']
vout = utxo[0]['vout']
value = utxo[0]['amount']
utxos = []
for utxo in self.nodes[0].listunspent(10):
# Skip change/fees we scooped up
if utxo['amount'] != Decimal(50):
continue
utxos.append(utxo)
assert_greater_than(len(utxos), 1)
txid = utxos[0]['txid']
vout = utxos[0]['vout']
value = utxos[0]['amount']
fee = Decimal("0.0001")
# MAX_ANCESTORS transactions off a confirmed tx should be fine
@ -208,9 +214,9 @@ class MempoolPackagesTest(BitcoinTestFramework):
# TODO: test ancestor size limits
# Now test descendant chain limits
txid = utxo[1]['txid']
value = utxo[1]['amount']
vout = utxo[1]['vout']
txid = utxos[1]['txid']
value = utxos[1]['amount']
vout = utxos[1]['vout']
transaction_package = []
tx_children = []