Changeset View
Changeset View
Standalone View
Standalone View
test/functional/rpc_getblockstats.py
Show First 20 Lines • Show All 90 Lines • ▼ Show 20 Lines | def generate_test_data(self, filename): | ||||
blocks.append(self.nodes[0].getblock(blockhash, 0)) | blocks.append(self.nodes[0].getblock(blockhash, 0)) | ||||
height += 1 | height += 1 | ||||
to_dump = { | to_dump = { | ||||
'blocks': blocks, | 'blocks': blocks, | ||||
'mocktime': int(mocktime), | 'mocktime': int(mocktime), | ||||
'stats': self.expected_stats, | 'stats': self.expected_stats, | ||||
} | } | ||||
with open(filename, 'w') as f: | with open(filename, 'w', encoding="utf8") as f: | ||||
json.dump(to_dump, f, sort_keys=True, | json.dump(to_dump, f, sort_keys=True, | ||||
indent=2, default=EncodeDecimal) | indent=2, default=EncodeDecimal) | ||||
def load_test_data(self, filename): | def load_test_data(self, filename): | ||||
with open(filename, 'r') as f: | with open(filename, 'r', encoding="utf8") as f: | ||||
d = json.load(f, parse_float=decimal.Decimal) | d = json.load(f, parse_float=decimal.Decimal) | ||||
blocks = d['blocks'] | blocks = d['blocks'] | ||||
mocktime = d['mocktime'] | mocktime = d['mocktime'] | ||||
self.expected_stats = d['stats'] | self.expected_stats = d['stats'] | ||||
self.log.info(self.expected_stats) | self.log.info(self.expected_stats) | ||||
# Set the timestamps from the file so that the nodes can get out of Initial Block Download | # Set the timestamps from the file so that the nodes can get out of Initial Block Download | ||||
self.nodes[0].setmocktime(mocktime) | self.nodes[0].setmocktime(mocktime) | ||||
▲ Show 20 Lines • Show All 92 Lines • Show Last 20 Lines |