2525
2626import pytest
2727
28+ from aea .helpers .base import CertRequest
2829from aea .mail .base import Envelope
2930from aea .multiplexer import Multiplexer
3031from aea .test_tools .test_cases import AEATestCaseEmpty
5556PUBLIC_DHT_MADDRS = [PUBLIC_DHT_P2P_MADDR_1 , PUBLIC_DHT_P2P_MADDR_2 ]
5657PUBLIC_DHT_DELEGATE_URIS = [PUBLIC_DHT_DELEGATE_URI_1 , PUBLIC_DHT_DELEGATE_URI_2 ]
5758PUBLIC_DHT_PUBLIC_KEYS = [PUBLIC_DHT_P2P_PUBLIC_KEY_1 , PUBLIC_DHT_P2P_PUBLIC_KEY_2 ]
58- AEA_DEFAULT_LAUNCH_TIMEOUT = 15
59- AEA_LIBP2P_LAUNCH_TIMEOUT = 15
59+ AEA_DEFAULT_LAUNCH_TIMEOUT = 20
60+ AEA_LIBP2P_LAUNCH_TIMEOUT = 20
6061
6162
6263@pytest .mark .integration
@@ -321,7 +322,7 @@ def test_communication_indirect(self):
321322 continue
322323
323324 connection2 = _make_libp2p_client_connection (
324- PUBLIC_DHT_PUBLIC_KEYS [i ], uri = PUBLIC_DHT_DELEGATE_URIS [j ]
325+ PUBLIC_DHT_PUBLIC_KEYS [j ], uri = PUBLIC_DHT_DELEGATE_URIS [j ]
325326 )
326327 multiplexer2 = Multiplexer ([connection2 ])
327328 multiplexer2 .connect ()
@@ -371,6 +372,13 @@ class TestLibp2pConnectionPublicDHTRelayAEACli(AEATestCaseEmpty):
371372 def test_connectivity (self ):
372373 """Test connectivity."""
373374 self .log_files = []
375+ self .conn_key_file = os .path .join (
376+ os .path .abspath (os .getcwd ()), "./conn_key.txt"
377+ )
378+ self .generate_private_key ()
379+ self .add_private_key ()
380+ self .generate_private_key (private_key_file = self .conn_key_file )
381+ self .add_private_key (private_key_filepath = self .conn_key_file , connection = True )
374382 self .add_item ("connection" , str (P2P_CONNECTION_PUBLIC_ID ))
375383 self .run_cli_command ("build" , cwd = self ._get_cwd ())
376384
@@ -390,6 +398,8 @@ def test_connectivity(self):
390398 },
391399 )
392400
401+ self .run_cli_command ("issue-certificates" , cwd = self ._get_cwd ())
402+
393403 self .log_files = [log_file ]
394404 process = self .run_agent ()
395405
@@ -420,12 +430,41 @@ class TestLibp2pConnectionPublicDHTDelegateAEACli(AEATestCaseEmpty):
420430
421431 def test_connectivity (self ):
422432 """Test connectivity."""
433+ self .generate_private_key ()
434+ self .add_private_key ()
423435 self .add_item ("connection" , str (P2P_CLIENT_CONNECTION_PUBLIC_ID ))
424436 config_path = "vendor.fetchai.connections.p2p_libp2p_client.config"
425437 self .nested_set_config (
426438 config_path ,
427439 {"nodes" : [{"uri" : "{}" .format (uri )} for uri in PUBLIC_DHT_DELEGATE_URIS ]},
428440 )
441+ conn_path = "vendor.fetchai.connections.p2p_libp2p_client"
442+ self .nested_set_config (
443+ conn_path + ".config" ,
444+ {
445+ "nodes" : [
446+ {"uri" : uri , "public_key" : PUBLIC_DHT_PUBLIC_KEYS [i ]}
447+ for i , uri in enumerate (PUBLIC_DHT_DELEGATE_URIS )
448+ ]
449+ },
450+ )
451+
452+ # generate certificates for connection
453+ self .nested_set_config (
454+ conn_path + ".cert_requests" ,
455+ [
456+ CertRequest (
457+ identifier = "acn" ,
458+ ledger_id = "fetchai" ,
459+ not_after = "2022-01-01" ,
460+ not_before = "2021-01-01" ,
461+ public_key = public_key ,
462+ save_path = f"./cli_test_cert_{ public_key } .txt" ,
463+ )
464+ for public_key in PUBLIC_DHT_PUBLIC_KEYS
465+ ],
466+ )
467+ self .run_cli_command ("issue-certificates" , cwd = self ._get_cwd ())
429468
430469 process = self .run_agent ()
431470 is_running = self .is_running (process , timeout = AEA_DEFAULT_LAUNCH_TIMEOUT )
0 commit comments