Skip to content

Commit cc8c682

Browse files
committed
test: use MiniWallet for p2p_leak_tx.py
This test can now be run even with the Bitcoin Core wallet disabled.
1 parent 12a1c3a commit cc8c682

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

test/functional/p2p_leak_tx.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from test_framework.util import (
1111
assert_equal,
1212
)
13+
from test_framework.wallet import MiniWallet
1314

1415

1516
class P2PNode(P2PDataStore):
@@ -21,20 +22,20 @@ class P2PLeakTxTest(BitcoinTestFramework):
2122
def set_test_params(self):
2223
self.num_nodes = 1
2324

24-
def skip_test_if_missing_module(self):
25-
self.skip_if_no_wallet()
26-
2725
def run_test(self):
2826
gen_node = self.nodes[0] # The block and tx generating node
29-
gen_node.generate(1)
27+
miniwallet = MiniWallet(gen_node)
28+
# Add enough mature utxos to the wallet, so that all txs spend confirmed coins
29+
miniwallet.generate(1)
30+
gen_node.generate(100)
3031

3132
inbound_peer = self.nodes[0].add_p2p_connection(P2PNode()) # An "attacking" inbound peer
3233

3334
MAX_REPEATS = 100
3435
self.log.info("Running test up to {} times.".format(MAX_REPEATS))
3536
for i in range(MAX_REPEATS):
3637
self.log.info('Run repeat {}'.format(i + 1))
37-
txid = gen_node.sendtoaddress(gen_node.getnewaddress(), 0.01)
38+
txid = miniwallet.send_self_transfer(from_node=gen_node)['wtxid']
3839

3940
want_tx = msg_getdata()
4041
want_tx.inv.append(CInv(t=MSG_TX, h=int(txid, 16)))

0 commit comments

Comments
 (0)