4
4
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
5
5
"""Test node responses to invalid transactions.
6
6
7
- In this test we connect to one node over p2p, and test tx requests.
8
- """
9
-
10
- from test_framework .test_framework import ComparisonTestFramework
11
- from test_framework .comptool import TestManager , TestInstance , RejectResult
12
- from test_framework .blocktools import *
7
+ In this test we connect to one node over p2p, and test tx requests."""
13
8
import time
14
9
10
+ from test_framework .blocktools import create_block , create_coinbase , create_transaction
11
+ from test_framework .comptool import RejectResult , TestInstance , TestManager
12
+ from test_framework .messages import COIN
13
+ from test_framework .mininode import network_thread_start
14
+ from test_framework .test_framework import ComparisonTestFramework
15
15
16
-
17
- # Use the ComparisonTestFramework with 1 node: only use --testbinary.
18
16
class InvalidTxRequestTest (ComparisonTestFramework ):
19
17
20
- ''' Can either run this test as 1 node with expected answers, or two and compare them.
21
- Change the "outcome" variable from each TestInstance object to only do the comparison. '''
22
18
def set_test_params (self ):
23
19
self .num_nodes = 1
24
20
self .setup_clean_chain = True
@@ -32,13 +28,10 @@ def run_test(self):
32
28
test .run ()
33
29
34
30
def get_tests (self ):
35
- if self .tip is None :
36
- self .tip = int ("0x" + self .nodes [0 ].getbestblockhash (), 0 )
37
- self .block_time = int (time .time ())+ 1
31
+ self .tip = int ("0x" + self .nodes [0 ].getbestblockhash (), 0 )
32
+ self .block_time = int (time .time ()) + 1
38
33
39
- '''
40
- Create a new block with an anyone-can-spend coinbase
41
- '''
34
+ self .log .info ("Create a new block with an anyone-can-spend coinbase." )
42
35
height = 1
43
36
block = create_block (self .tip , create_coinbase (height ), self .block_time )
44
37
self .block_time += 1
@@ -49,9 +42,7 @@ def get_tests(self):
49
42
height += 1
50
43
yield TestInstance ([[block , True ]])
51
44
52
- '''
53
- Now we need that block to mature so we can spend the coinbase.
54
- '''
45
+ self .log .info ("Mature the block." )
55
46
test = TestInstance (sync_every_block = False )
56
47
for i in range (100 ):
57
48
block = create_block (self .tip , create_coinbase (height ), self .block_time )
0 commit comments