Changeset View
Changeset View
Standalone View
Standalone View
test/functional/example_test.py
Show First 20 Lines • Show All 45 Lines • ▼ Show 20 Lines | def __init__(self): | ||||
needs of most tests. | needs of most tests. | ||||
Call super().__init__() first for standard initialization and then | Call super().__init__() first for standard initialization and then | ||||
initialize custom properties.""" | initialize custom properties.""" | ||||
super().__init__() | super().__init__() | ||||
# Stores a dictionary of all blocks received | # Stores a dictionary of all blocks received | ||||
self.block_receive_map = defaultdict(int) | self.block_receive_map = defaultdict(int) | ||||
def on_block(self, conn, message): | def on_block(self, message): | ||||
"""Override the standard on_block callback | """Override the standard on_block callback | ||||
Store the hash of a received block in the dictionary.""" | Store the hash of a received block in the dictionary.""" | ||||
message.block.calc_sha256() | message.block.calc_sha256() | ||||
self.block_receive_map[message.block.sha256] += 1 | self.block_receive_map[message.block.sha256] += 1 | ||||
def on_inv(self, conn, message): | def on_inv(self, message): | ||||
"""Override the standard on_inv callback""" | """Override the standard on_inv callback""" | ||||
pass | pass | ||||
def custom_function(): | def custom_function(): | ||||
"""Do some custom behaviour | """Do some custom behaviour | ||||
If this function is more generally useful for other tests, consider | If this function is more generally useful for other tests, consider | ||||
▲ Show 20 Lines • Show All 155 Lines • Show Last 20 Lines |