Skip to content

Commit 3e187f2

Browse files
committed
Fix BIP65 p2p test
create_coinbase() was being called with the wrong arguments
1 parent 8f3b3cd commit 3e187f2

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

qa/rpc-tests/bip65-cltv-p2p.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,32 +67,35 @@ def create_transaction(self, node, coinbase, to_address, amount):
6767
def get_tests(self):
6868

6969
self.coinbase_blocks = self.nodes[0].generate(2)
70+
height = 3 # height of the next block to build
7071
self.tip = int ("0x" + self.nodes[0].getbestblockhash() + "L", 0)
7172
self.nodeaddress = self.nodes[0].getnewaddress()
7273
self.last_block_time = time.time()
7374

7475
''' 98 more version 3 blocks '''
7576
test_blocks = []
7677
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)
7879
block.nVersion = 3
7980
block.rehash()
8081
block.solve()
8182
test_blocks.append([block, True])
8283
self.last_block_time += 1
8384
self.tip = block.sha256
85+
height += 1
8486
yield TestInstance(test_blocks, sync_every_block=False)
8587

8688
''' Mine 749 version 4 blocks '''
8789
test_blocks = []
8890
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)
9092
block.nVersion = 4
9193
block.rehash()
9294
block.solve()
9395
test_blocks.append([block, True])
9496
self.last_block_time += 1
9597
self.tip = block.sha256
98+
height += 1
9699
yield TestInstance(test_blocks, sync_every_block=False)
97100

98101
'''
@@ -104,7 +107,7 @@ def get_tests(self):
104107
cltv_invalidate(spendtx)
105108
spendtx.rehash()
106109

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)
108111
block.nVersion = 4
109112
block.vtx.append(spendtx)
110113
block.hashMerkleRoot = block.calc_merkle_root()
@@ -113,6 +116,7 @@ def get_tests(self):
113116

114117
self.last_block_time += 1
115118
self.tip = block.sha256
119+
height += 1
116120
yield TestInstance([[block, True]])
117121

118122
'''
@@ -124,7 +128,7 @@ def get_tests(self):
124128
cltv_invalidate(spendtx)
125129
spendtx.rehash()
126130

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)
128132
block.nVersion = 4
129133
block.vtx.append(spendtx)
130134
block.hashMerkleRoot = block.calc_merkle_root()
@@ -136,35 +140,38 @@ def get_tests(self):
136140
''' Mine 199 new version blocks on last valid tip '''
137141
test_blocks = []
138142
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)
140144
block.nVersion = 4
141145
block.rehash()
142146
block.solve()
143147
test_blocks.append([block, True])
144148
self.last_block_time += 1
145149
self.tip = block.sha256
150+
height += 1
146151
yield TestInstance(test_blocks, sync_every_block=False)
147152

148153
''' 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)
150155
block.nVersion = 3
151156
block.rehash()
152157
block.solve()
153158
self.last_block_time += 1
154159
self.tip = block.sha256
160+
height += 1
155161
yield TestInstance([[block, True]])
156162

157163
''' 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)
159165
block.nVersion = 4
160166
block.rehash()
161167
block.solve()
162168
self.last_block_time += 1
163169
self.tip = block.sha256
170+
height += 1
164171
yield TestInstance([[block, True]])
165172

166173
''' 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)
168175
block.nVersion = 3
169176
block.rehash()
170177
block.solve()

0 commit comments

Comments
 (0)