Skip to content

Commit bc90b8d

Browse files
committed
[move only] remove is_wallet_compiled checks
1 parent 0bfbf7f commit bc90b8d

File tree

1 file changed

+127
-138
lines changed

1 file changed

+127
-138
lines changed

test/functional/interface_zmq.py

Lines changed: 127 additions & 138 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,6 @@ def caused_notification(self, notification):
103103
class ZMQTest (BitcoinTestFramework):
104104
def set_test_params(self):
105105
self.num_nodes = 2
106-
if self.is_wallet_compiled():
107-
self.requires_wallet = True
108106
# This test isn't testing txn relay/timing, so set whitelist on the
109107
# peers for instant txn relay. This speeds up the test run time 2-3x.
110108
self.extra_args = [["[email protected]"]] * self.num_nodes
@@ -215,26 +213,25 @@ def test_basic(self):
215213
assert_equal([txid.hex()], self.nodes[1].getblock(hash)["tx"])
216214

217215

218-
if self.is_wallet_compiled():
219-
self.wallet.rescan_utxos()
220-
self.log.info("Wait for tx from second node")
221-
payment_tx = self.wallet.send_self_transfer(from_node=self.nodes[1])
222-
payment_txid = payment_tx['txid']
223-
self.sync_all()
224-
# Should receive the broadcasted txid.
225-
txid = hashtx.receive()
226-
assert_equal(payment_txid, txid.hex())
216+
self.wallet.rescan_utxos()
217+
self.log.info("Wait for tx from second node")
218+
payment_tx = self.wallet.send_self_transfer(from_node=self.nodes[1])
219+
payment_txid = payment_tx['txid']
220+
self.sync_all()
221+
# Should receive the broadcasted txid.
222+
txid = hashtx.receive()
223+
assert_equal(payment_txid, txid.hex())
227224

228-
# Should receive the broadcasted raw transaction.
229-
hex = rawtx.receive()
230-
assert_equal(payment_tx['wtxid'], hash256_reversed(hex).hex())
225+
# Should receive the broadcasted raw transaction.
226+
hex = rawtx.receive()
227+
assert_equal(payment_tx['wtxid'], hash256_reversed(hex).hex())
231228

232-
# Mining the block with this tx should result in second notification
233-
# after coinbase tx notification
234-
self.generatetoaddress(self.nodes[0], 1, ADDRESS_BCRT1_UNSPENDABLE)
235-
hashtx.receive()
236-
txid = hashtx.receive()
237-
assert_equal(payment_txid, txid.hex())
229+
# Mining the block with this tx should result in second notification
230+
# after coinbase tx notification
231+
self.generatetoaddress(self.nodes[0], 1, ADDRESS_BCRT1_UNSPENDABLE)
232+
hashtx.receive()
233+
txid = hashtx.receive()
234+
assert_equal(payment_txid, txid.hex())
238235

239236

240237
self.log.info("Test the getzmqnotifications RPC")
@@ -248,9 +245,6 @@ def test_basic(self):
248245
assert_equal(self.nodes[1].getzmqnotifications(), [])
249246

250247
def test_reorg(self):
251-
if not self.is_wallet_compiled():
252-
self.log.info("Skipping reorg test because wallet is disabled")
253-
return
254248

255249
address = 'tcp://127.0.0.1:28333'
256250

@@ -330,129 +324,124 @@ def test_sequence(self):
330324
assert_equal((self.nodes[1].getblockhash(block_count-1), "C", None), seq.receive_sequence())
331325
assert_equal((self.nodes[1].getblockhash(block_count), "C", None), seq.receive_sequence())
332326

333-
# Rest of test requires wallet functionality
334-
if self.is_wallet_compiled():
335-
self.log.info("Wait for tx from second node")
336-
payment_tx = self.wallet.send_self_transfer(from_node=self.nodes[1])
337-
payment_txid = payment_tx['txid']
338-
self.sync_all()
339-
self.log.info("Testing sequence notifications with mempool sequence values")
340-
341-
# Should receive the broadcasted txid.
342-
assert_equal((payment_txid, "A", seq_num), seq.receive_sequence())
343-
seq_num += 1
344-
345-
self.log.info("Testing RBF notification")
346-
# Replace it to test eviction/addition notification
347-
payment_tx['tx'].vout[0].nValue -= 1000
348-
rbf_txid = self.nodes[1].sendrawtransaction(payment_tx['tx'].serialize().hex())
349-
self.sync_all()
350-
assert_equal((payment_txid, "R", seq_num), seq.receive_sequence())
351-
seq_num += 1
352-
assert_equal((rbf_txid, "A", seq_num), seq.receive_sequence())
353-
seq_num += 1
354-
355-
# Doesn't get published when mined, make a block and tx to "flush" the possibility
356-
# though the mempool sequence number does go up by the number of transactions
357-
# removed from the mempool by the block mining it.
358-
mempool_size = len(self.nodes[0].getrawmempool())
359-
c_block = self.generatetoaddress(self.nodes[0], 1, ADDRESS_BCRT1_UNSPENDABLE)[0]
360-
# Make sure the number of mined transactions matches the number of txs out of mempool
361-
mempool_size_delta = mempool_size - len(self.nodes[0].getrawmempool())
362-
assert_equal(len(self.nodes[0].getblock(c_block)["tx"])-1, mempool_size_delta)
363-
seq_num += mempool_size_delta
364-
payment_txid_2 = self.wallet.send_self_transfer(from_node=self.nodes[1])['txid']
365-
self.sync_all()
366-
assert_equal((c_block, "C", None), seq.receive_sequence())
367-
assert_equal((payment_txid_2, "A", seq_num), seq.receive_sequence())
368-
seq_num += 1
369-
370-
# Spot check getrawmempool results that they only show up when asked for
371-
assert type(self.nodes[0].getrawmempool()) is list
372-
assert type(self.nodes[0].getrawmempool(mempool_sequence=False)) is list
373-
assert "mempool_sequence" not in self.nodes[0].getrawmempool(verbose=True)
374-
assert_raises_rpc_error(-8, "Verbose results cannot contain mempool sequence values.", self.nodes[0].getrawmempool, True, True)
375-
assert_equal(self.nodes[0].getrawmempool(mempool_sequence=True)["mempool_sequence"], seq_num)
376-
377-
self.log.info("Testing reorg notifications")
378-
# Manually invalidate the last block to test mempool re-entry
379-
# N.B. This part could be made more lenient in exact ordering
380-
# since it greatly depends on inner-workings of blocks/mempool
381-
# during "deep" re-orgs. Probably should "re-construct"
382-
# blockchain/mempool state from notifications instead.
383-
block_count = self.nodes[0].getblockcount()
384-
best_hash = self.nodes[0].getbestblockhash()
385-
self.nodes[0].invalidateblock(best_hash)
386-
sleep(2) # Bit of room to make sure transaction things happened
387-
388-
# Make sure getrawmempool mempool_sequence results aren't "queued" but immediately reflective
389-
# of the time they were gathered.
390-
assert self.nodes[0].getrawmempool(mempool_sequence=True)["mempool_sequence"] > seq_num
391-
392-
assert_equal((best_hash, "D", None), seq.receive_sequence())
393-
assert_equal((rbf_txid, "A", seq_num), seq.receive_sequence())
394-
seq_num += 1
395-
396-
# Other things may happen but aren't wallet-deterministic so we don't test for them currently
397-
self.nodes[0].reconsiderblock(best_hash)
398-
self.generatetoaddress(self.nodes[1], 1, ADDRESS_BCRT1_UNSPENDABLE)
399-
400-
self.log.info("Evict mempool transaction by block conflict")
401-
orig_tx = self.wallet.send_self_transfer(from_node=self.nodes[0])
402-
orig_txid = orig_tx['txid']
403-
404-
# More to be simply mined
405-
more_tx = []
406-
for _ in range(5):
407-
more_tx.append(self.wallet.send_self_transfer(from_node=self.nodes[0]))
408-
409-
orig_tx['tx'].vout[0].nValue -= 1000
410-
bump_txid = self.nodes[0].sendrawtransaction(orig_tx['tx'].serialize().hex())
411-
# Mine the pre-bump tx
412-
txs_to_add = [orig_tx['hex']] + [tx['hex'] for tx in more_tx]
413-
block = create_block(int(self.nodes[0].getbestblockhash(), 16), create_coinbase(self.nodes[0].getblockcount()+1), txlist=txs_to_add)
414-
add_witness_commitment(block)
415-
block.solve()
416-
assert_equal(self.nodes[0].submitblock(block.serialize().hex()), None)
417-
tip = self.nodes[0].getbestblockhash()
418-
assert_equal(int(tip, 16), block.sha256)
419-
orig_txid_2 = self.wallet.send_self_transfer(from_node=self.nodes[0])['txid']
420-
421-
# Flush old notifications until evicted tx original entry
327+
self.log.info("Wait for tx from second node")
328+
payment_tx = self.wallet.send_self_transfer(from_node=self.nodes[1])
329+
payment_txid = payment_tx['txid']
330+
self.sync_all()
331+
self.log.info("Testing sequence notifications with mempool sequence values")
332+
333+
# Should receive the broadcasted txid.
334+
assert_equal((payment_txid, "A", seq_num), seq.receive_sequence())
335+
seq_num += 1
336+
337+
self.log.info("Testing RBF notification")
338+
# Replace it to test eviction/addition notification
339+
payment_tx['tx'].vout[0].nValue -= 1000
340+
rbf_txid = self.nodes[1].sendrawtransaction(payment_tx['tx'].serialize().hex())
341+
self.sync_all()
342+
assert_equal((payment_txid, "R", seq_num), seq.receive_sequence())
343+
seq_num += 1
344+
assert_equal((rbf_txid, "A", seq_num), seq.receive_sequence())
345+
seq_num += 1
346+
347+
# Doesn't get published when mined, make a block and tx to "flush" the possibility
348+
# though the mempool sequence number does go up by the number of transactions
349+
# removed from the mempool by the block mining it.
350+
mempool_size = len(self.nodes[0].getrawmempool())
351+
c_block = self.generatetoaddress(self.nodes[0], 1, ADDRESS_BCRT1_UNSPENDABLE)[0]
352+
# Make sure the number of mined transactions matches the number of txs out of mempool
353+
mempool_size_delta = mempool_size - len(self.nodes[0].getrawmempool())
354+
assert_equal(len(self.nodes[0].getblock(c_block)["tx"])-1, mempool_size_delta)
355+
seq_num += mempool_size_delta
356+
payment_txid_2 = self.wallet.send_self_transfer(from_node=self.nodes[1])['txid']
357+
self.sync_all()
358+
assert_equal((c_block, "C", None), seq.receive_sequence())
359+
assert_equal((payment_txid_2, "A", seq_num), seq.receive_sequence())
360+
seq_num += 1
361+
362+
# Spot check getrawmempool results that they only show up when asked for
363+
assert type(self.nodes[0].getrawmempool()) is list
364+
assert type(self.nodes[0].getrawmempool(mempool_sequence=False)) is list
365+
assert "mempool_sequence" not in self.nodes[0].getrawmempool(verbose=True)
366+
assert_raises_rpc_error(-8, "Verbose results cannot contain mempool sequence values.", self.nodes[0].getrawmempool, True, True)
367+
assert_equal(self.nodes[0].getrawmempool(mempool_sequence=True)["mempool_sequence"], seq_num)
368+
369+
self.log.info("Testing reorg notifications")
370+
# Manually invalidate the last block to test mempool re-entry
371+
# N.B. This part could be made more lenient in exact ordering
372+
# since it greatly depends on inner-workings of blocks/mempool
373+
# during "deep" re-orgs. Probably should "re-construct"
374+
# blockchain/mempool state from notifications instead.
375+
block_count = self.nodes[0].getblockcount()
376+
best_hash = self.nodes[0].getbestblockhash()
377+
self.nodes[0].invalidateblock(best_hash)
378+
sleep(2) # Bit of room to make sure transaction things happened
379+
380+
# Make sure getrawmempool mempool_sequence results aren't "queued" but immediately reflective
381+
# of the time they were gathered.
382+
assert self.nodes[0].getrawmempool(mempool_sequence=True)["mempool_sequence"] > seq_num
383+
384+
assert_equal((best_hash, "D", None), seq.receive_sequence())
385+
assert_equal((rbf_txid, "A", seq_num), seq.receive_sequence())
386+
seq_num += 1
387+
388+
# Other things may happen but aren't wallet-deterministic so we don't test for them currently
389+
self.nodes[0].reconsiderblock(best_hash)
390+
self.generatetoaddress(self.nodes[1], 1, ADDRESS_BCRT1_UNSPENDABLE)
391+
392+
self.log.info("Evict mempool transaction by block conflict")
393+
orig_tx = self.wallet.send_self_transfer(from_node=self.nodes[0])
394+
orig_txid = orig_tx['txid']
395+
396+
# More to be simply mined
397+
more_tx = []
398+
for _ in range(5):
399+
more_tx.append(self.wallet.send_self_transfer(from_node=self.nodes[0]))
400+
401+
orig_tx['tx'].vout[0].nValue -= 1000
402+
bump_txid = self.nodes[0].sendrawtransaction(orig_tx['tx'].serialize().hex())
403+
# Mine the pre-bump tx
404+
txs_to_add = [orig_tx['hex']] + [tx['hex'] for tx in more_tx]
405+
block = create_block(int(self.nodes[0].getbestblockhash(), 16), create_coinbase(self.nodes[0].getblockcount()+1), txlist=txs_to_add)
406+
add_witness_commitment(block)
407+
block.solve()
408+
assert_equal(self.nodes[0].submitblock(block.serialize().hex()), None)
409+
tip = self.nodes[0].getbestblockhash()
410+
assert_equal(int(tip, 16), block.sha256)
411+
orig_txid_2 = self.wallet.send_self_transfer(from_node=self.nodes[0])['txid']
412+
413+
# Flush old notifications until evicted tx original entry
414+
(hash_str, label, mempool_seq) = seq.receive_sequence()
415+
while hash_str != orig_txid:
422416
(hash_str, label, mempool_seq) = seq.receive_sequence()
423-
while hash_str != orig_txid:
424-
(hash_str, label, mempool_seq) = seq.receive_sequence()
425-
mempool_seq += 1
417+
mempool_seq += 1
426418

427-
# Added original tx
428-
assert_equal(label, "A")
429-
# More transactions to be simply mined
430-
for i in range(len(more_tx)):
431-
assert_equal((more_tx[i]['txid'], "A", mempool_seq), seq.receive_sequence())
432-
mempool_seq += 1
433-
# Bumped by rbf
434-
assert_equal((orig_txid, "R", mempool_seq), seq.receive_sequence())
435-
mempool_seq += 1
436-
assert_equal((bump_txid, "A", mempool_seq), seq.receive_sequence())
419+
# Added original tx
420+
assert_equal(label, "A")
421+
# More transactions to be simply mined
422+
for i in range(len(more_tx)):
423+
assert_equal((more_tx[i]['txid'], "A", mempool_seq), seq.receive_sequence())
437424
mempool_seq += 1
438-
# Conflict announced first, then block
439-
assert_equal((bump_txid, "R", mempool_seq), seq.receive_sequence())
440-
mempool_seq += 1
441-
assert_equal((tip, "C", None), seq.receive_sequence())
442-
mempool_seq += len(more_tx)
443-
# Last tx
444-
assert_equal((orig_txid_2, "A", mempool_seq), seq.receive_sequence())
445-
mempool_seq += 1
446-
self.generatetoaddress(self.nodes[0], 1, ADDRESS_BCRT1_UNSPENDABLE)
447-
self.sync_all() # want to make sure we didn't break "consensus" for other tests
425+
# Bumped by rbf
426+
assert_equal((orig_txid, "R", mempool_seq), seq.receive_sequence())
427+
mempool_seq += 1
428+
assert_equal((bump_txid, "A", mempool_seq), seq.receive_sequence())
429+
mempool_seq += 1
430+
# Conflict announced first, then block
431+
assert_equal((bump_txid, "R", mempool_seq), seq.receive_sequence())
432+
mempool_seq += 1
433+
assert_equal((tip, "C", None), seq.receive_sequence())
434+
mempool_seq += len(more_tx)
435+
# Last tx
436+
assert_equal((orig_txid_2, "A", mempool_seq), seq.receive_sequence())
437+
mempool_seq += 1
438+
self.generatetoaddress(self.nodes[0], 1, ADDRESS_BCRT1_UNSPENDABLE)
439+
self.sync_all() # want to make sure we didn't break "consensus" for other tests
448440

449441
def test_mempool_sync(self):
450442
"""
451443
Use sequence notification plus getrawmempool sequence results to "sync mempool"
452444
"""
453-
if not self.is_wallet_compiled():
454-
self.log.info("Skipping mempool sync test")
455-
return
456445

457446
self.log.info("Testing 'mempool sync' usage of sequence notifier")
458447
[seq] = self.setup_zmq_test([("sequence", "tcp://127.0.0.1:28333")])

0 commit comments

Comments
 (0)