Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add test to cover stress.py fails #3089

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions nightly/pytest-sanity.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# python sanity tests
pytest sanity/proxy_loose_block_messages.py
pytest sanity/proxy_loose_block_messages.py --features nightly_protocol,nightly_protocol_features
pytest sanity/block_production.py
pytest sanity/block_production.py --features nightly_protocol,nightly_protocol_features
pytest sanity/transactions.py
Expand Down
51 changes: 51 additions & 0 deletions pytest/tests/sanity/proxy_loose_block_messages.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import sys
import time

sys.path.append('lib')

from cluster import start_cluster
from peer import *
from proxy import ProxyHandler

from multiprocessing import Value

TIMEOUT = 120
NODES = 9
ignored_messages = set()
max_height = Value('i', 0)


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you explain what this test does?

class Handler(ProxyHandler):

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

async def handle(self, msg, fr, to):
if msg.enum == 'Block':
h = msg.Block.BlockV2.header.inner_lite().height
if h > max_height.value:
max_height.value = h
print(h, fr, to, msg, msg.Block.enum)
tpl = (h, fr, to)

if h == NODES - 1 and to < (NODES -
1) / 2 and tpl not in ignored_messages:
ignored_messages.add(tpl)
print("skipping msg from %d to %d" % (fr, to))
return False

return True


if __name__ == '__main__':
start_cluster(NODES, 0, 1, None, [], {}, message_handler=Handler)

start = time.time()
while True:
print("max_height", max_height.value)
if time.time() - start >= TIMEOUT or max_height.value > 3 * NODES:
print("DONE")
break
time.sleep(1)

assert max_height.value > 3 * NODES