@@ -67,32 +67,35 @@ def create_transaction(self, node, coinbase, to_address, amount):
67
67
def get_tests (self ):
68
68
69
69
self .coinbase_blocks = self .nodes [0 ].generate (2 )
70
+ height = 3 # height of the next block to build
70
71
self .tip = int ("0x" + self .nodes [0 ].getbestblockhash () + "L" , 0 )
71
72
self .nodeaddress = self .nodes [0 ].getnewaddress ()
72
73
self .last_block_time = time .time ()
73
74
74
75
''' 98 more version 3 blocks '''
75
76
test_blocks = []
76
77
for i in xrange (98 ):
77
- block = create_block (self .tip , create_coinbase (2 ), self .last_block_time + 1 )
78
+ block = create_block (self .tip , create_coinbase (height ), self .last_block_time + 1 )
78
79
block .nVersion = 3
79
80
block .rehash ()
80
81
block .solve ()
81
82
test_blocks .append ([block , True ])
82
83
self .last_block_time += 1
83
84
self .tip = block .sha256
85
+ height += 1
84
86
yield TestInstance (test_blocks , sync_every_block = False )
85
87
86
88
''' Mine 749 version 4 blocks '''
87
89
test_blocks = []
88
90
for i in xrange (749 ):
89
- block = create_block (self .tip , create_coinbase (2 ), self .last_block_time + 1 )
91
+ block = create_block (self .tip , create_coinbase (height ), self .last_block_time + 1 )
90
92
block .nVersion = 4
91
93
block .rehash ()
92
94
block .solve ()
93
95
test_blocks .append ([block , True ])
94
96
self .last_block_time += 1
95
97
self .tip = block .sha256
98
+ height += 1
96
99
yield TestInstance (test_blocks , sync_every_block = False )
97
100
98
101
'''
@@ -104,7 +107,7 @@ def get_tests(self):
104
107
cltv_invalidate (spendtx )
105
108
spendtx .rehash ()
106
109
107
- block = create_block (self .tip , create_coinbase (2 ), self .last_block_time + 1 )
110
+ block = create_block (self .tip , create_coinbase (height ), self .last_block_time + 1 )
108
111
block .nVersion = 4
109
112
block .vtx .append (spendtx )
110
113
block .hashMerkleRoot = block .calc_merkle_root ()
@@ -113,6 +116,7 @@ def get_tests(self):
113
116
114
117
self .last_block_time += 1
115
118
self .tip = block .sha256
119
+ height += 1
116
120
yield TestInstance ([[block , True ]])
117
121
118
122
'''
@@ -124,7 +128,7 @@ def get_tests(self):
124
128
cltv_invalidate (spendtx )
125
129
spendtx .rehash ()
126
130
127
- block = create_block (self .tip , create_coinbase (1 ), self .last_block_time + 1 )
131
+ block = create_block (self .tip , create_coinbase (height ), self .last_block_time + 1 )
128
132
block .nVersion = 4
129
133
block .vtx .append (spendtx )
130
134
block .hashMerkleRoot = block .calc_merkle_root ()
@@ -136,35 +140,38 @@ def get_tests(self):
136
140
''' Mine 199 new version blocks on last valid tip '''
137
141
test_blocks = []
138
142
for i in xrange (199 ):
139
- block = create_block (self .tip , create_coinbase (1 ), self .last_block_time + 1 )
143
+ block = create_block (self .tip , create_coinbase (height ), self .last_block_time + 1 )
140
144
block .nVersion = 4
141
145
block .rehash ()
142
146
block .solve ()
143
147
test_blocks .append ([block , True ])
144
148
self .last_block_time += 1
145
149
self .tip = block .sha256
150
+ height += 1
146
151
yield TestInstance (test_blocks , sync_every_block = False )
147
152
148
153
''' Mine 1 old version block '''
149
- block = create_block (self .tip , create_coinbase (1 ), self .last_block_time + 1 )
154
+ block = create_block (self .tip , create_coinbase (height ), self .last_block_time + 1 )
150
155
block .nVersion = 3
151
156
block .rehash ()
152
157
block .solve ()
153
158
self .last_block_time += 1
154
159
self .tip = block .sha256
160
+ height += 1
155
161
yield TestInstance ([[block , True ]])
156
162
157
163
''' Mine 1 new version block '''
158
- block = create_block (self .tip , create_coinbase (1 ), self .last_block_time + 1 )
164
+ block = create_block (self .tip , create_coinbase (height ), self .last_block_time + 1 )
159
165
block .nVersion = 4
160
166
block .rehash ()
161
167
block .solve ()
162
168
self .last_block_time += 1
163
169
self .tip = block .sha256
170
+ height += 1
164
171
yield TestInstance ([[block , True ]])
165
172
166
173
''' Mine 1 old version block, should be invalid '''
167
- block = create_block (self .tip , create_coinbase (1 ), self .last_block_time + 1 )
174
+ block = create_block (self .tip , create_coinbase (height ), self .last_block_time + 1 )
168
175
block .nVersion = 3
169
176
block .rehash ()
170
177
block .solve ()
0 commit comments