Merge commit 'f318f98fc794b8b1513721454730ada70fb048b7' into checkpoint/long_lived_atari_from_main_f318f98fc794b8b1513721454730ada70fb048b7

This commit is contained in:
Amine Khaldi 2022-08-16 13:39:08 +01:00
commit 3371c1607c
No known key found for this signature in database
GPG Key ID: B1C074FFC904E2D9
2 changed files with 12 additions and 4 deletions

View File

@ -8,7 +8,7 @@ NO_REPLY_EXPECTED = [
pmt.new_signage_point_or_end_of_sub_slot,
pmt.request_mempool_transactions,
pmt.new_compact_vdf,
pmt.request_mempool_transactions,
pmt.coin_state_update,
]
"""
@ -28,11 +28,20 @@ VALID_REPLY_MESSAGE_MAP = {
pmt.request_blocks: [pmt.respond_blocks, pmt.reject_blocks],
pmt.request_unfinished_block: [pmt.respond_unfinished_block],
pmt.request_block_header: [pmt.respond_block_header, pmt.reject_header_request],
pmt.request_removals: [pmt.respond_removals, pmt.reject_removals_request],
pmt.request_additions: [pmt.respond_additions, pmt.reject_additions_request],
pmt.request_signage_point_or_end_of_sub_slot: [pmt.respond_signage_point, pmt.respond_end_of_sub_slot],
pmt.request_compact_vdf: [pmt.respond_compact_vdf],
pmt.request_peers: [pmt.respond_peers],
pmt.request_header_blocks: [pmt.respond_header_blocks, pmt.reject_header_blocks],
pmt.register_interest_in_puzzle_hash: [pmt.respond_to_ph_update],
pmt.register_interest_in_coin: [pmt.respond_to_coin_update],
pmt.request_children: [pmt.respond_children],
pmt.request_ses_hashes: [pmt.respond_ses_hashes],
pmt.request_block_headers: [pmt.respond_block_headers, pmt.reject_block_headers],
pmt.request_peers_introducer: [pmt.respond_peers_introducer],
pmt.request_puzzle_solution: [pmt.respond_puzzle_solution, pmt.reject_puzzle_solution],
pmt.send_transaction: [pmt.transaction_ack],
}
@ -57,8 +66,7 @@ def message_response_ok(sent: ProtocolMessageTypes, received: ProtocolMessageTyp
"""
# Errors below are runtime protocol message mismatches from peers
if sent in VALID_REPLY_MESSAGE_MAP:
if received not in VALID_REPLY_MESSAGE_MAP[sent]:
return False
return received in VALID_REPLY_MESSAGE_MAP[sent]
return True

View File

@ -33,7 +33,7 @@ def test_missing_messages_state_machine() -> None:
# to the visitor in build_network_protocol_files.py and rerun it. Then
# update this test
assert (
len(VALID_REPLY_MESSAGE_MAP) == 11
len(VALID_REPLY_MESSAGE_MAP) == 20
), "A message was added to the protocol state machine. Make sure to update the protocol message regression test to include the new message"
assert (
len(NO_REPLY_EXPECTED) == 7