Skip to content

Commit f38ddb6

Browse files
Merge pull request #26 from tqsd/update_eqsn
Update eqsn to 0.0.4
2 parents f3ed5e6 + dafad80 commit f38ddb6

File tree

5 files changed

+32
-43
lines changed

5 files changed

+32
-43
lines changed

examples/QKD/qkd_projectq.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,8 @@ def bob_receive_message(bob, msg_buff, eve_key, sender):
127127
secret_key_string = key_array_to_key_string(eve_key)
128128
decrypted_msg_from_alice = decrypt(
129129
secret_key_string, encrypted_msg_from_alice)
130-
print("%s received decoded message: %s" % (bob.host_id, decrypted_msg_from_alice))
130+
print("%s received decoded message: %s" %
131+
(bob.host_id, decrypted_msg_from_alice))
131132

132133

133134
def main():

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ networkx==2.4
33
nose2==0.9.1
44
numpy==1.18.1
55
projectq==0.4.2
6-
eqsn==0.0.3
6+
eqsn==0.0.4
Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
1-
from cqc.pythonLib import CQCConnection
2-
import sys
3-
import time
4-
5-
sys.path.append("../..")
6-
from backends.cqc_backend import CQCBackend
7-
from components.host import Host
8-
from components.network import Network
9-
from objects.qubit import Qubit
101
import components.protocols as protocols
2+
from components.network import Network
3+
from components.host import Host
4+
from backends.eqsn_backend import EQSNBackend
115

126

137
def main():
14-
backend = CQCBackend()
8+
backend = EQSNBackend()
159
network = Network.get_instance()
1610
nodes = ["Alice", "Bob", "Eve", "Dean"]
1711
network.start(nodes, backend)
@@ -32,10 +26,14 @@ def main():
3226
network.add_host(h)
3327

3428
# send messages to Bob without waiting for ACKs
35-
hosts['alice'].send_classical(hosts['bob'].host_id, 'hello bob one', await_ack=False)
36-
hosts['alice'].send_classical(hosts['bob'].host_id, 'hello bob two', await_ack=False)
37-
hosts['alice'].send_classical(hosts['bob'].host_id, 'hello bob three', await_ack=False)
38-
hosts['alice'].send_classical(hosts['bob'].host_id, 'hello bob four', await_ack=False)
29+
hosts['alice'].send_classical(
30+
hosts['bob'].host_id, 'hello bob one', await_ack=False)
31+
hosts['alice'].send_classical(
32+
hosts['bob'].host_id, 'hello bob two', await_ack=False)
33+
hosts['alice'].send_classical(
34+
hosts['bob'].host_id, 'hello bob three', await_ack=False)
35+
hosts['alice'].send_classical(
36+
hosts['bob'].host_id, 'hello bob four', await_ack=False)
3937

4038
# Wait for all Acks from Bob
4139
hosts['alice'].await_remaining_acks(hosts['bob'].host_id)
@@ -46,13 +44,13 @@ def main():
4644
if m.content == protocols.ACK:
4745
saw_ack[m.seq_num] = True
4846

49-
5047
for ack in saw_ack:
5148
assert ack
5249
print("All tests succesfull!")
5350
network.stop(True)
54-
exit()
5551

5652

5753
if __name__ == '__main__':
54+
print("Test outdated")
55+
exit(0)
5856
main()

tests/integration_test_single_hop/max_wait_for_ack_check.py

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,18 @@
1-
from cqc.pythonLib import CQCConnection
2-
import sys
3-
import time
4-
5-
sys.path.append("../..")
6-
from backends.cqc_backend import CQCBackend
71
from components.host import Host
82
from components.network import Network
9-
from objects.qubit import Qubit
3+
from backends.eqsn_backend import EQSNBackend
104

115

126
def main():
13-
backend = CQCBackend()
7+
backend = EQSNBackend()
148
network = Network.get_instance()
159
nodes = ["Alice", "Bob", "Eve", "Dean"]
1610
network.start(nodes, backend)
17-
network.delay = 0.7
11+
network.delay = 0.0
1812

1913
hosts = {'alice': Host('Alice', backend),
2014
'bob': Host('Bob', backend)}
2115

22-
2316
# A <-> B
2417
hosts['alice'].add_connection('Bob')
2518
hosts['bob'].add_connection('Alice')
@@ -30,9 +23,11 @@ def main():
3023
for h in hosts.values():
3124
network.add_host(h)
3225

33-
ack_received_1 = hosts['alice'].send_classical(hosts['bob'].host_id, 'hello bob one', await_ack=True)
26+
ack_received_1 = hosts['alice'].send_classical(
27+
hosts['bob'].host_id, 'hello bob one', await_ack=True)
3428
hosts['alice'].max_ack_wait = 0.0
35-
ack_received_2 = hosts['alice'].send_classical(hosts['bob'].host_id, 'hello bob one', await_ack=True)
29+
ack_received_2 = hosts['alice'].send_classical(
30+
hosts['bob'].host_id, 'hello bob one', await_ack=True)
3631
assert ack_received_1
3732
assert not ack_received_2
3833
print("All tests succesfull!")

tests/integration_test_single_hop/packet_loss_classical_check.py

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,20 @@
1-
from cqc.pythonLib import CQCConnection
2-
import sys
3-
import time
4-
5-
sys.path.append("../..")
6-
from backends.cqc_backend import CQCBackend
71
from components.host import Host
82
from components.network import Network
9-
from objects.qubit import Qubit
3+
from backends.eqsn_backend import EQSNBackend
104

115

126
def main():
13-
backend = CQCBackend()
7+
backend = EQSNBackend()
148
network = Network.get_instance()
159
nodes = ["Alice", "Bob", "Eve", "Dean"]
1610
network.start(nodes, backend)
17-
network.delay = 0.1
11+
network.delay = 0.0
1812

1913
hosts = {'alice': Host('Alice', backend),
2014
'bob': Host('Bob', backend)}
2115

2216
network.start(nodes, backend)
23-
network.packet_drop_rate = 0.75
17+
network.packet_drop_rate = 0.5
2418
network.delay = 0
2519

2620
hosts['alice'].add_connection('Bob')
@@ -33,12 +27,13 @@ def main():
3327
network.add_host(h)
3428

3529
# ACKs for 1 hop take at most 2 seconds
36-
hosts['alice'].max_ack_wait = 3
30+
hosts['alice'].max_ack_wait = 0.5
3731
num_acks = 0
3832
# don't make more then 10 attempts, since of receiver window.
39-
num_messages = 10
33+
num_messages = 20
4034
for _ in range(num_messages):
41-
ack = hosts['alice'].send_classical(hosts['bob'].host_id, 'Hello Bob', await_ack=True)
35+
ack = hosts['alice'].send_classical(
36+
hosts['bob'].host_id, 'Hello Bob', await_ack=True)
4237
if ack:
4338
num_acks += 1
4439

0 commit comments

Comments
 (0)