Skip to content

Commit 1f87c37

Browse files
committed
Simplify comparison in rpc_blockchain.py.
The test for gettxoutsetinfo in rpc_blockchain.py verifies that the result is the same as before after invalidating and reconsidering a block. The comparison has to exclude the 'disk_size' field, though, as it is not deterministic. Instead of comparing all the other fields for equality, this change explicitly removes the 'disk_size' field and then compares the full objects. This makes the intent more explicit (compare everything except for disk_size, not compare just a given list of fields) and also the code simpler.
1 parent df9f712 commit 1f87c37

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

test/functional/rpc_blockchain.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -194,13 +194,10 @@ def _test_gettxoutsetinfo(self):
194194
node.reconsiderblock(b1hash)
195195

196196
res3 = node.gettxoutsetinfo()
197-
assert_equal(res['total_amount'], res3['total_amount'])
198-
assert_equal(res['transactions'], res3['transactions'])
199-
assert_equal(res['height'], res3['height'])
200-
assert_equal(res['txouts'], res3['txouts'])
201-
assert_equal(res['bogosize'], res3['bogosize'])
202-
assert_equal(res['bestblock'], res3['bestblock'])
203-
assert_equal(res['hash_serialized_2'], res3['hash_serialized_2'])
197+
# The field 'disk_size' is non-deterministic and can thus not be
198+
# compared between res and res3. Everything else should be the same.
199+
del res['disk_size'], res3['disk_size']
200+
assert_equal(res, res3)
204201

205202
def _test_getblockheader(self):
206203
node = self.nodes[0]

0 commit comments

Comments
 (0)