7
7
Test that permissions are correctly calculated and applied
8
8
"""
9
9
10
- from test_framework .address import ADDRESS_BCRT1_P2WSH_OP_TRUE
11
10
from test_framework .messages import (
12
- CTxInWitness ,
13
- tx_from_hex ,
11
+ SEQUENCE_FINAL ,
14
12
)
15
13
from test_framework .p2p import P2PDataStore
16
- from test_framework .script import (
17
- CScript ,
18
- OP_TRUE ,
19
- )
20
14
from test_framework .test_node import ErrorMatch
21
15
from test_framework .test_framework import BitcoinTestFramework
22
16
from test_framework .util import (
23
17
assert_equal ,
24
18
p2p_port ,
25
19
)
20
+ from test_framework .wallet import MiniWallet
26
21
27
22
28
23
class P2PPermissionsTests (BitcoinTestFramework ):
29
24
def set_test_params (self ):
30
25
self .num_nodes = 2
31
- self .setup_clean_chain = True
32
26
33
27
def run_test (self ):
28
+ self .wallet = MiniWallet (self .nodes [0 ])
29
+ self .wallet .rescan_utxos ()
30
+
34
31
self .check_tx_relay ()
35
32
36
33
self .checkpermission (
@@ -94,8 +91,6 @@ def run_test(self):
94
91
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 )
95
92
96
93
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
-
99
94
self .log .debug ("Create a connection from a forcerelay peer that rebroadcasts raw txs" )
100
95
# A test framework p2p connection is needed to send the raw transaction directly. If a full node was used, it could only
101
96
# rebroadcast via the inv-getdata mechanism. However, even for forcerelay connections, a full node would
@@ -104,18 +99,7 @@ def check_tx_relay(self):
104
99
p2p_rebroadcast_wallet = self .nodes [1 ].add_p2p_connection (P2PDataStore ())
105
100
106
101
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' ]
119
103
txid = tx .rehash ()
120
104
121
105
self .log .debug ("Wait until tx is in node[1]'s mempool" )
0 commit comments