Best Python code snippet using localstack_python
build_network_protocol_files.py
Source:build_network_protocol_files.py
...7version = "1.0"8def get_network_protocol_filename() -> Path:9 tests_dir = Path(os.path.dirname(os.path.abspath(__file__)))10 return tests_dir / Path("protocol_messages_bytes-v" + version)11def encode_data(data) -> bytes:12 data_bytes = bytes(data)13 size = uint32(len(data_bytes))14 return size.to_bytes(4, "big") + data_bytes15def get_farmer_protocol_bytes() -> bytes:16 result = b""17 result += encode_data(new_signage_point)18 result += encode_data(declare_proof_of_space)19 result += encode_data(request_signed_values)20 result += encode_data(farming_info)21 result += encode_data(signed_values)22 return result23def get_full_node_bytes() -> bytes:24 result = b""25 result += encode_data(new_peak)26 result += encode_data(new_transaction)27 result += encode_data(request_transaction)28 result += encode_data(respond_transaction)29 result += encode_data(request_proof_of_weight)30 result += encode_data(respond_proof_of_weight)31 result += encode_data(request_block)32 result += encode_data(reject_block)33 result += encode_data(request_blocks)34 result += encode_data(respond_blocks)35 result += encode_data(reject_blocks)36 result += encode_data(respond_block)37 result += encode_data(new_unfinished_block)38 result += encode_data(request_unfinished_block)39 result += encode_data(respond_unfinished_block)40 result += encode_data(new_signage_point_or_end_of_subslot)41 result += encode_data(request_signage_point_or_end_of_subslot)42 result += encode_data(respond_signage_point)43 result += encode_data(respond_end_of_subslot)44 result += encode_data(request_mempool_transaction)45 result += encode_data(new_compact_vdf)46 result += encode_data(request_compact_vdf)47 result += encode_data(respond_compact_vdf)48 result += encode_data(request_peers)49 result += encode_data(respond_peers)50 return result51def get_wallet_protocol_bytes() -> bytes:52 result = b""53 result += encode_data(request_puzzle_solution)54 result += encode_data(puzzle_solution_response)55 result += encode_data(respond_puzzle_solution)56 result += encode_data(reject_puzzle_solution)57 result += encode_data(send_transaction)58 result += encode_data(transaction_ack)59 result += encode_data(new_peak_wallet)60 result += encode_data(request_block_header)61 result += encode_data(respond_header_block)62 result += encode_data(reject_header_request)63 result += encode_data(request_removals)64 result += encode_data(respond_removals)65 result += encode_data(reject_removals_request)66 result += encode_data(request_additions)67 result += encode_data(respond_additions)68 result += encode_data(reject_additions)69 result += encode_data(request_header_blocks)70 result += encode_data(reject_header_blocks)71 result += encode_data(respond_header_blocks)72 result += encode_data(coin_state)73 result += encode_data(register_for_ph_updates)74 result += encode_data(respond_to_ph_updates)75 result += encode_data(register_for_coin_updates)76 result += encode_data(respond_to_coin_updates)77 result += encode_data(coin_state_update)78 result += encode_data(request_children)79 result += encode_data(respond_children)80 result += encode_data(request_ses_info)81 result += encode_data(respond_ses_info)82 return result83def get_harvester_protocol_bytes() -> bytes:84 result = b""85 result += encode_data(pool_difficulty)86 result += encode_data(harvester_handhsake)87 result += encode_data(new_signage_point_harvester)88 result += encode_data(new_proof_of_space)89 result += encode_data(request_signatures)90 result += encode_data(respond_signatures)91 result += encode_data(plot)92 result += encode_data(request_plots)93 result += encode_data(respond_plots)94 return result95def get_introducer_protocol_bytes() -> bytes:96 result = b""97 result += encode_data(request_peers_introducer)98 result += encode_data(respond_peers_introducer)99 return result100def get_pool_protocol_bytes() -> bytes:101 result = b""102 result += encode_data(authentication_payload)103 result += encode_data(get_pool_info_response)104 result += encode_data(post_partial_payload)105 result += encode_data(post_partial_request)106 result += encode_data(post_partial_response)107 result += encode_data(get_farmer_response)108 result += encode_data(post_farmer_payload)109 result += encode_data(post_farmer_request)110 result += encode_data(post_farmer_response)111 result += encode_data(put_farmer_payload)112 result += encode_data(put_farmer_request)113 result += encode_data(put_farmer_response)114 result += encode_data(error_response)115 return result116def get_timelord_protocol_bytes() -> bytes:117 result = b""118 result += encode_data(new_peak_timelord)119 result += encode_data(new_unfinished_block_timelord)120 result += encode_data(new_infusion_point_vdf)121 result += encode_data(new_signage_point_vdf)122 result += encode_data(new_end_of_sub_slot_bundle)123 result += encode_data(request_compact_proof_of_time)124 result += encode_data(respond_compact_proof_of_time)125 return result126def get_protocol_bytes() -> bytes:127 return (128 get_farmer_protocol_bytes()129 + get_full_node_bytes()130 + get_wallet_protocol_bytes()131 + get_harvester_protocol_bytes()132 + get_introducer_protocol_bytes()133 + get_pool_protocol_bytes()134 + get_timelord_protocol_bytes()135 )136if __name__ == "__main__":137 filename = get_network_protocol_filename()138 data = get_protocol_bytes()...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!