(self)
| 46 | self.skip_if_no_wallet() |
| 47 | |
| 48 | def run_test(self): |
| 49 | |
| 50 | # Create transaction with 3-second block delay, should fail to enter the template |
| 51 | txid = self.nodes[0].sendtoaddress(self.nodes[0].getnewaddress(), 1) |
| 52 | block = self.nodes[0].getnewblockhex(min_tx_age=3) |
| 53 | self.nodes[0].submitblock(block) |
| 54 | assert txid in self.nodes[0].getrawmempool() |
| 55 | time.sleep(3) |
| 56 | block = self.nodes[0].getnewblockhex(min_tx_age=3) |
| 57 | self.nodes[0].submitblock(block) |
| 58 | assert txid not in self.nodes[0].getrawmempool() |
| 59 | # Once more with no delay (default is 0, just testing default arg) |
| 60 | txid = self.nodes[0].sendtoaddress(self.nodes[0].getnewaddress(), 1) |
| 61 | block = self.nodes[0].getnewblockhex(min_tx_age=0) |
| 62 | self.nodes[0].submitblock(block) |
| 63 | assert txid not in self.nodes[0].getrawmempool() |
| 64 | assert_raises_rpc_error(-8, "min_tx_age must be non-negative.", self.nodes[0].getnewblockhex, -1) |
| 65 | |
| 66 | # Mine some blocks and have them mature. |
| 67 | peer_inv_store = self.nodes[0].add_p2p_connection(P2PTxInvStore()) # keep track of invs |
| 68 | self.generate(self.nodes[0], COINBASE_MATURITY + 1) |
| 69 | utxos = [] |
| 70 | for utxo in self.nodes[0].listunspent(10): |
| 71 | # Skip change/fees we scooped up |
| 72 | if utxo['amount'] != Decimal(50): |
| 73 | continue |
| 74 | utxos.append(utxo) |
| 75 | assert_greater_than(len(utxos), 1) |
| 76 | |
| 77 | txid = utxos[0]['txid'] |
| 78 | vout = utxos[0]['vout'] |
| 79 | value = utxos[0]['amount'] |
| 80 | assert 'ancestorcount' not in utxos[0] |
| 81 | assert 'ancestorsize' not in utxos[0] |
| 82 | assert 'ancestorfees' not in utxos[0] |
| 83 | |
| 84 | fee = Decimal("0.0001") |
| 85 | # MAX_ANCESTORS transactions off a confirmed tx should be fine |
| 86 | chain = [] |
| 87 | witness_chain = [] |
| 88 | ancestor_vsize = 0 |
| 89 | ancestor_fees = Decimal(0) |
| 90 | for i in range(MAX_ANCESTORS): |
| 91 | (txid, sent_value) = chain_transaction(self.nodes[0], [txid], [0], value, fee, 1) |
| 92 | value = sent_value |
| 93 | chain.append(txid) |
| 94 | # We need the wtxids to check P2P announcements |
| 95 | witnesstx = self.nodes[0].gettransaction(txid=txid, verbose=True)['decoded'] |
| 96 | witness_chain.append(witnesstx['hash']) |
| 97 | |
| 98 | # Check that listunspent ancestor{count, size, fees} yield the correct results |
| 99 | wallet_unspent = self.nodes[0].listunspent(minconf=0) |
| 100 | this_unspent = next(utxo_info for utxo_info in wallet_unspent if utxo_info['txid'] == txid) |
| 101 | assert_equal(this_unspent['ancestorcount'], i + 1) |
| 102 | ancestor_vsize += self.nodes[0].getrawtransaction(txid=txid, verbose=True)['vsize'] |
| 103 | assert_equal(this_unspent['ancestorsize'], ancestor_vsize) |
| 104 | print(self.nodes[0].gettransaction(txid=txid)) |
| 105 | ancestor_fees -= self.nodes[0].gettransaction(txid=txid)['fee']['bitcoin'] |
nothing calls this directly
no test coverage detected