"""Tests for GarlicConfig and CloveConfig.""" from i2p_data.garlic_config import GarlicConfig, CloveConfig, NULL_CERT def test_garlic_config_add_cloves(): gc = GarlicConfig(recipient_public_key=b"\x01" * 32, message_id=1, expiration=999) c1 = CloveConfig.for_local(message_data=b"hello", clove_id=1, expiration=999) c2 = CloveConfig.for_local(message_data=b"world", clove_id=2, expiration=999) gc.add_clove(c1) gc.add_clove(c2) assert gc.clove_count() == 2 assert gc.cloves[0] is c1 assert gc.cloves[1] is c2 def test_clove_config_for_destination(): cc = CloveConfig.for_destination( dest_hash=b"\x02" * 32, message_data=b"data", clove_id=1, expiration=100 ) assert cc.delivery_type == 1 # DESTINATION assert cc.dest_hash == b"\x02" * 32 def test_clove_config_for_local(): cc = CloveConfig.for_local(message_data=b"data", clove_id=1, expiration=100) assert cc.delivery_type == 0 # LOCAL def test_clove_config_for_tunnel(): cc = CloveConfig.for_tunnel( router_hash=b"\x03" * 32, tunnel_id=42, message_data=b"data", clove_id=1, expiration=100, ) assert cc.delivery_type == 3 # TUNNEL assert cc.router_hash == b"\x03" * 32 assert cc.tunnel_id == 42 def test_clove_config_default_certificate(): cc = CloveConfig.for_local(message_data=b"x", clove_id=1, expiration=1) assert cc.certificate == NULL_CERT