Skip to content

Commit 914bd78

Browse files
MarcoFalkePastaPastaPasta
MarcoFalke
authored andcommitted
Merge bitcoin#9972: Fix extended rpc tests broken by bitcoin#9768
d055bd6 Fix extended rpc tests broken by 8910b47 (John Newbery) Tree-SHA512: 30e019bd7e17013143e419777491ac0efd9760dddac7232d320c9afe80bc2fb383acd331e20cd5b3e21df1177c0e4a5221c99f831e90cf869d3affca206b9728
1 parent dad8c67 commit 914bd78

File tree

3 files changed

+19
-12
lines changed

3 files changed

+19
-12
lines changed

qa/rpc-tests/maxblocksinflight.py

+2
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ def setup_network(self):
8787

8888
def run_test(self):
8989
test = TestManager()
90+
# pass log handler through to the test manager object
91+
test.log = self.log
9092
test.add_new_connection(NodeConn('127.0.0.1', p2p_port(0), self.nodes[0], test))
9193
NetworkThread().start() # Start up network handling in another thread
9294
test.run()

qa/rpc-tests/pruning.py

+11-11
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def test_height_min(self):
8080
if not os.path.isfile(self.prunedir+"blk00000.dat"):
8181
raise AssertionError("blk00000.dat is missing, pruning too early")
8282
self.log.info("Success")
83-
self.log.info("Though we're already using more than 550MiB, current usage:", calc_usage(self.prunedir))
83+
self.log.info("Though we're already using more than 550MiB, current usage: %d" % calc_usage(self.prunedir))
8484
self.log.info("Mining 25 more blocks should cause the first block file to be pruned")
8585
# Pruning doesn't run until we're allocating another chunk, 20 full blocks past the height cutoff will ensure this
8686
for i in range(25):
@@ -94,7 +94,7 @@ def test_height_min(self):
9494

9595
self.log.info("Success")
9696
usage = calc_usage(self.prunedir)
97-
self.log.info("Usage should be below target:", usage)
97+
self.log.info("Usage should be below target: %d" % usage)
9898
if (usage > 550):
9999
raise AssertionError("Pruning target not being met")
100100

@@ -124,7 +124,7 @@ def create_chain_with_staleblocks(self):
124124
connect_nodes(self.nodes[2], 0)
125125
sync_blocks(self.nodes[0:3])
126126

127-
self.log.info("Usage can be over target because of high stale rate:", calc_usage(self.prunedir))
127+
self.log.info("Usage can be over target because of high stale rate: %d" % calc_usage(self.prunedir))
128128

129129
def reorg_test(self):
130130
# Node 1 will mine a 300 block chain starting 287 blocks back from Node 0 and Node 2's tip
@@ -135,11 +135,11 @@ def reorg_test(self):
135135
self.nodes[1]=start_node(1, self.options.tmpdir, ["-maxreceivebuffer=20000","-blockmaxsize=5000", "-checkblocks=5", "-disablesafemode"], timewait=900)
136136

137137
height = self.nodes[1].getblockcount()
138-
self.log.info("Current block height:", height)
138+
self.log.info("Current block height: %d" % height)
139139

140140
invalidheight = height-287
141141
badhash = self.nodes[1].getblockhash(invalidheight)
142-
self.log.info("Invalidating block at height:",invalidheight,badhash)
142+
self.log.info("Invalidating block %s at height %d" % (badhash,invalidheight))
143143
self.nodes[1].invalidateblock(badhash)
144144

145145
# We've now switched to our previously mined-24 block fork on node 1, but thats not what we want
@@ -151,7 +151,7 @@ def reorg_test(self):
151151
curhash = self.nodes[1].getblockhash(invalidheight - 1)
152152

153153
assert(self.nodes[1].getblockcount() == invalidheight - 1)
154-
self.log.info("New best height", self.nodes[1].getblockcount())
154+
self.log.info("New best height: %d" % self.nodes[1].getblockcount())
155155

156156
# Reboot node1 to clear those giant tx's from mempool
157157
self.stop_node(1)
@@ -165,8 +165,8 @@ def reorg_test(self):
165165
connect_nodes(self.nodes[2], 1)
166166
sync_blocks(self.nodes[0:3], timeout=120)
167167

168-
self.log.info("Verify height on node 2:",self.nodes[2].getblockcount())
169-
self.log.info("Usage possibly still high bc of stale blocks in block files:", calc_usage(self.prunedir))
168+
self.log.info("Verify height on node 2: %d" % self.nodes[2].getblockcount())
169+
self.log.info("Usage possibly still high bc of stale blocks in block files: %d" % calc_usage(self.prunedir))
170170

171171
self.log.info("Mine 220 more blocks so we have requisite history (some blocks will be big and cause pruning of previous chain)")
172172
for i in range(22):
@@ -176,7 +176,7 @@ def reorg_test(self):
176176
sync_blocks(self.nodes[0:3], timeout=300)
177177

178178
usage = calc_usage(self.prunedir)
179-
self.log.info("Usage should be below target:", usage)
179+
self.log.info("Usage should be below target: %d" % usage)
180180
if (usage > 550):
181181
raise AssertionError("Pruning target not being met")
182182

@@ -185,7 +185,7 @@ def reorg_test(self):
185185
def reorg_back(self):
186186
# Verify that a block on the old main chain fork has been pruned away
187187
assert_raises_jsonrpc(-1, "Block not available (pruned data)", self.nodes[2].getblock, self.forkhash)
188-
self.log.info("Will need to redownload block",self.forkheight)
188+
self.log.info("Will need to redownload block %d" % self.forkheight)
189189

190190
# Verify that we have enough history to reorg back to the fork point
191191
# Although this is more than 288 blocks, because this chain was written more recently
@@ -209,7 +209,7 @@ def reorg_back(self):
209209
# At this point node 2 is within 288 blocks of the fork point so it will preserve its ability to reorg
210210
if self.nodes[2].getblockcount() < self.mainchainheight:
211211
blocks_to_mine = first_reorg_height + 1 - self.mainchainheight
212-
self.log.info("Rewind node 0 to prev main chain to mine longer chain to trigger redownload. Blocks needed:", blocks_to_mine)
212+
self.log.info("Rewind node 0 to prev main chain to mine longer chain to trigger redownload. Blocks needed: %d" % blocks_to_mine)
213213
self.nodes[0].invalidateblock(curchainhash)
214214
assert(self.nodes[0].getblockcount() == self.mainchainheight)
215215
assert(self.nodes[0].getbestblockhash() == self.mainchainhash2)

qa/rpc-tests/smartfees.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
# 4 bytes of OP_TRUE and push 2-byte redeem script of "OP_1 OP_DROP" or "OP_2 OP_DROP"
1818
SCRIPT_SIG = ["0451025175", "0451025275"]
1919

20+
global log
21+
2022
class DecimalEncoder(json.JSONEncoder):
2123
def default(self, o):
2224
if isinstance(o, Decimal):
@@ -120,7 +122,7 @@ def check_estimates(node, fees_seen, max_invalid, print_estimates = True):
120122
"""
121123
all_estimates = [ node.estimatefee(i) for i in range(1,26) ]
122124
if print_estimates:
123-
self.log.info([str(all_estimates[e-1]) for e in [1,2,3,6,15,25]])
125+
log.info([str(all_estimates[e-1]) for e in [1,2,3,6,15,25]])
124126
delta = 1.0e-6 # account for rounding error
125127
last_e = max(fees_seen)
126128
for e in [x for x in all_estimates if x >= 0]:
@@ -257,6 +259,9 @@ def transact_and_mine(self, numblocks, mining_node):
257259
self.memutxo = newmem
258260

259261
def run_test(self):
262+
# Make log handler available to helper functions
263+
global log
264+
log = self.log
260265
self.fees_per_kb = []
261266
self.memutxo = []
262267
self.confutxo = self.txouts # Start with the set of confirmed txouts after splitting

0 commit comments

Comments
 (0)