77Test that permissions are correctly calculated and applied
88"""
99
10- from test_framework .address import ADDRESS_BCRT1_P2WSH_OP_TRUE
1110from test_framework .messages import (
12- CTxInWitness ,
13- tx_from_hex ,
11+ SEQUENCE_FINAL ,
1412)
1513from test_framework .p2p import P2PDataStore
16- from test_framework .script import (
17- CScript ,
18- OP_TRUE ,
19- )
2014from test_framework .test_node import ErrorMatch
2115from test_framework .test_framework import BitcoinTestFramework
2216from test_framework .util import (
2317 assert_equal ,
2418 p2p_port ,
2519)
20+ from test_framework .wallet import MiniWallet
2621
2722
2823class P2PPermissionsTests (BitcoinTestFramework ):
2924 def set_test_params (self ):
3025 self .num_nodes = 2
31- self .setup_clean_chain = True
3226
3327 def run_test (self ):
28+ self .wallet = MiniWallet (self .nodes [0 ])
29+ self .wallet .rescan_utxos ()
30+
3431 self .check_tx_relay ()
3532
3633 self .checkpermission (
@@ -94,8 +91,6 @@ def run_test(self):
9491 self .
nodes [
1 ].
assert_start_raises_init_error ([
"[email protected] " ,
"-bind=127.0.0.1" ,
"-listen=0" ],
"Cannot set -bind or -whitebind together with -listen=0" ,
match = ErrorMatch .
PARTIAL_REGEX )
9592
9693 def check_tx_relay (self ):
97- block_op_true = self .nodes [0 ].getblock (self .generatetoaddress (self .nodes [0 ], 100 , ADDRESS_BCRT1_P2WSH_OP_TRUE )[0 ])
98-
9994 self .log .debug ("Create a connection from a forcerelay peer that rebroadcasts raw txs" )
10095 # A test framework p2p connection is needed to send the raw transaction directly. If a full node was used, it could only
10196 # rebroadcast via the inv-getdata mechanism. However, even for forcerelay connections, a full node would
@@ -104,18 +99,7 @@ def check_tx_relay(self):
10499 p2p_rebroadcast_wallet = self .nodes [1 ].add_p2p_connection (P2PDataStore ())
105100
106101 self .log .debug ("Send a tx from the wallet initially" )
107- tx = tx_from_hex (
108- self .nodes [0 ].createrawtransaction (
109- inputs = [{
110- 'txid' : block_op_true ['tx' ][0 ],
111- 'vout' : 0 ,
112- }], outputs = [{
113- ADDRESS_BCRT1_P2WSH_OP_TRUE : 5 ,
114- }],
115- replaceable = False ),
116- )
117- tx .wit .vtxinwit = [CTxInWitness ()]
118- tx .wit .vtxinwit [0 ].scriptWitness .stack = [CScript ([OP_TRUE ])]
102+ tx = self .wallet .create_self_transfer (sequence = SEQUENCE_FINAL )['tx' ]
119103 txid = tx .rehash ()
120104
121105 self .log .debug ("Wait until tx is in node[1]'s mempool" )
0 commit comments