From bf41a367d0d598e555b79f20b0db7857cc42c838 Mon Sep 17 00:00:00 2001 From: Youngjoon Lee <5462944+youngjoon-lee@users.noreply.github.com> Date: Fri, 19 Jul 2024 13:37:06 +0900 Subject: [PATCH] update import paths and add __init__.py to make it testable --- deprecated/{mixnet-v1 => }/__init__.py | 0 deprecated/{mixnet-v1 => mixnet_v1}/README.md | 0 deprecated/mixnet_v1/__init__.py | 0 deprecated/{mixnet-v1 => mixnet_v1}/bls.py | 2 +- deprecated/{mixnet-v1 => mixnet_v1}/client.py | 8 ++++---- deprecated/{mixnet-v1 => mixnet_v1}/config.py | 4 ++-- deprecated/{mixnet-v1 => mixnet_v1}/fisheryates.py | 0 deprecated/{mixnet-v1 => mixnet_v1}/mixnet.py | 10 +++++++--- deprecated/{mixnet-v1 => mixnet_v1}/node.py | 4 ++-- deprecated/{mixnet-v1 => mixnet_v1}/packet.py | 2 +- deprecated/{mixnet-v1 => mixnet_v1}/poisson.py | 0 deprecated/{mixnet-v1 => mixnet_v1}/structure.png | Bin deprecated/{mixnet-v1 => mixnet_v1}/test_client.py | 8 ++++---- .../{mixnet-v1 => mixnet_v1}/test_fisheryates.py | 2 +- deprecated/{mixnet-v1 => mixnet_v1}/test_mixnet.py | 4 ++-- deprecated/{mixnet-v1 => mixnet_v1}/test_node.py | 8 ++++---- deprecated/{mixnet-v1 => mixnet_v1}/test_packet.py | 8 ++++---- deprecated/{mixnet-v1 => mixnet_v1}/test_utils.py | 10 +++++----- deprecated/{mixnet-v1 => mixnet_v1}/utils.py | 0 19 files changed, 37 insertions(+), 33 deletions(-) rename deprecated/{mixnet-v1 => }/__init__.py (100%) rename deprecated/{mixnet-v1 => mixnet_v1}/README.md (100%) create mode 100644 deprecated/mixnet_v1/__init__.py rename deprecated/{mixnet-v1 => mixnet_v1}/bls.py (82%) rename deprecated/{mixnet-v1 => mixnet_v1}/client.py (94%) rename deprecated/{mixnet-v1 => mixnet_v1}/config.py (96%) rename deprecated/{mixnet-v1 => mixnet_v1}/fisheryates.py (100%) rename deprecated/{mixnet-v1 => mixnet_v1}/mixnet.py (89%) rename deprecated/{mixnet-v1 => mixnet_v1}/node.py (96%) rename deprecated/{mixnet-v1 => mixnet_v1}/packet.py (98%) rename deprecated/{mixnet-v1 => mixnet_v1}/poisson.py (100%) rename deprecated/{mixnet-v1 => mixnet_v1}/structure.png (100%) rename deprecated/{mixnet-v1 => mixnet_v1}/test_client.py (86%) rename deprecated/{mixnet-v1 => mixnet_v1}/test_fisheryates.py (91%) rename deprecated/{mixnet-v1 => mixnet_v1}/test_mixnet.py (83%) rename deprecated/{mixnet-v1 => mixnet_v1}/test_node.py (94%) rename deprecated/{mixnet-v1 => mixnet_v1}/test_packet.py (92%) rename deprecated/{mixnet-v1 => mixnet_v1}/test_utils.py (88%) rename deprecated/{mixnet-v1 => mixnet_v1}/utils.py (100%) diff --git a/deprecated/mixnet-v1/__init__.py b/deprecated/__init__.py similarity index 100% rename from deprecated/mixnet-v1/__init__.py rename to deprecated/__init__.py diff --git a/deprecated/mixnet-v1/README.md b/deprecated/mixnet_v1/README.md similarity index 100% rename from deprecated/mixnet-v1/README.md rename to deprecated/mixnet_v1/README.md diff --git a/deprecated/mixnet_v1/__init__.py b/deprecated/mixnet_v1/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/deprecated/mixnet-v1/bls.py b/deprecated/mixnet_v1/bls.py similarity index 82% rename from deprecated/mixnet-v1/bls.py rename to deprecated/mixnet_v1/bls.py index a4278b0..44c79a3 100644 --- a/deprecated/mixnet-v1/bls.py +++ b/deprecated/mixnet_v1/bls.py @@ -2,7 +2,7 @@ from typing import TypeAlias import blspy -from mixnet.utils import random_bytes +from deprecated.mixnet_v1.utils import random_bytes BlsPrivateKey: TypeAlias = blspy.PrivateKey BlsPublicKey: TypeAlias = blspy.G1Element diff --git a/deprecated/mixnet-v1/client.py b/deprecated/mixnet_v1/client.py similarity index 94% rename from deprecated/mixnet-v1/client.py rename to deprecated/mixnet_v1/client.py index 8d21cf3..c954980 100644 --- a/deprecated/mixnet-v1/client.py +++ b/deprecated/mixnet_v1/client.py @@ -4,10 +4,10 @@ import asyncio from contextlib import suppress from typing import Self -from mixnet.config import MixClientConfig, MixnetTopology -from mixnet.node import PacketQueue -from mixnet.packet import PacketBuilder -from mixnet.poisson import poisson_interval_sec +from deprecated.mixnet_v1.config import MixClientConfig, MixnetTopology +from deprecated.mixnet_v1.node import PacketQueue +from deprecated.mixnet_v1.packet import PacketBuilder +from deprecated.mixnet_v1.poisson import poisson_interval_sec class MixClient: diff --git a/deprecated/mixnet-v1/config.py b/deprecated/mixnet_v1/config.py similarity index 96% rename from deprecated/mixnet-v1/config.py rename to deprecated/mixnet_v1/config.py index 5b1a2d1..642500e 100644 --- a/deprecated/mixnet-v1/config.py +++ b/deprecated/mixnet_v1/config.py @@ -10,8 +10,8 @@ from cryptography.hazmat.primitives.asymmetric.x25519 import ( ) from pysphinx.node import Node -from mixnet.bls import BlsPrivateKey, BlsPublicKey -from mixnet.fisheryates import FisherYates +from deprecated.mixnet_v1.bls import BlsPrivateKey, BlsPublicKey +from deprecated.mixnet_v1.fisheryates import FisherYates @dataclass diff --git a/deprecated/mixnet-v1/fisheryates.py b/deprecated/mixnet_v1/fisheryates.py similarity index 100% rename from deprecated/mixnet-v1/fisheryates.py rename to deprecated/mixnet_v1/fisheryates.py diff --git a/deprecated/mixnet-v1/mixnet.py b/deprecated/mixnet_v1/mixnet.py similarity index 89% rename from deprecated/mixnet-v1/mixnet.py rename to deprecated/mixnet_v1/mixnet.py index dedc9ef..1058823 100644 --- a/deprecated/mixnet-v1/mixnet.py +++ b/deprecated/mixnet_v1/mixnet.py @@ -4,9 +4,13 @@ import asyncio from contextlib import suppress from typing import Self, TypeAlias -from mixnet.client import MixClient -from mixnet.config import MixnetConfig, MixnetTopology, MixnetTopologyConfig -from mixnet.node import MixNode +from deprecated.mixnet_v1.client import MixClient +from deprecated.mixnet_v1.config import ( + MixnetConfig, + MixnetTopology, + MixnetTopologyConfig, +) +from deprecated.mixnet_v1.node import MixNode EntropyQueue: TypeAlias = "asyncio.Queue[bytes]" diff --git a/deprecated/mixnet-v1/node.py b/deprecated/mixnet_v1/node.py similarity index 96% rename from deprecated/mixnet-v1/node.py rename to deprecated/mixnet_v1/node.py index 8ab4b77..aa20a64 100644 --- a/deprecated/mixnet-v1/node.py +++ b/deprecated/mixnet_v1/node.py @@ -15,8 +15,8 @@ from pysphinx.sphinx import ( UnknownHeaderTypeError, ) -from mixnet.config import MixNodeConfig, NodeAddress -from mixnet.poisson import poisson_interval_sec +from deprecated.mixnet_v1.config import MixNodeConfig, NodeAddress +from deprecated.mixnet_v1.poisson import poisson_interval_sec PacketQueue: TypeAlias = "asyncio.Queue[Tuple[NodeAddress, SphinxPacket]]" PacketPayloadQueue: TypeAlias = ( diff --git a/deprecated/mixnet-v1/packet.py b/deprecated/mixnet_v1/packet.py similarity index 98% rename from deprecated/mixnet-v1/packet.py rename to deprecated/mixnet_v1/packet.py index 71fe687..6ecf262 100644 --- a/deprecated/mixnet-v1/packet.py +++ b/deprecated/mixnet_v1/packet.py @@ -9,7 +9,7 @@ from typing import Dict, List, Self, Tuple, TypeAlias from pysphinx.payload import Payload from pysphinx.sphinx import SphinxPacket -from mixnet.config import MixnetTopology, MixNodeInfo +from deprecated.mixnet_v1.config import MixnetTopology, MixNodeInfo class MessageFlag(Enum): diff --git a/deprecated/mixnet-v1/poisson.py b/deprecated/mixnet_v1/poisson.py similarity index 100% rename from deprecated/mixnet-v1/poisson.py rename to deprecated/mixnet_v1/poisson.py diff --git a/deprecated/mixnet-v1/structure.png b/deprecated/mixnet_v1/structure.png similarity index 100% rename from deprecated/mixnet-v1/structure.png rename to deprecated/mixnet_v1/structure.png diff --git a/deprecated/mixnet-v1/test_client.py b/deprecated/mixnet_v1/test_client.py similarity index 86% rename from deprecated/mixnet-v1/test_client.py rename to deprecated/mixnet_v1/test_client.py index 4327466..fff7b31 100644 --- a/deprecated/mixnet-v1/test_client.py +++ b/deprecated/mixnet_v1/test_client.py @@ -3,13 +3,13 @@ from unittest import IsolatedAsyncioTestCase import numpy -from mixnet.client import MixClient -from mixnet.poisson import poisson_mean_interval_sec -from mixnet.test_utils import ( +from deprecated.mixnet_v1.client import MixClient +from deprecated.mixnet_v1.poisson import poisson_mean_interval_sec +from deprecated.mixnet_v1.test_utils import ( init_mixnet_config, with_test_timeout, ) -from mixnet.utils import random_bytes +from deprecated.mixnet_v1.utils import random_bytes class TestMixClient(IsolatedAsyncioTestCase): diff --git a/deprecated/mixnet-v1/test_fisheryates.py b/deprecated/mixnet_v1/test_fisheryates.py similarity index 91% rename from deprecated/mixnet-v1/test_fisheryates.py rename to deprecated/mixnet_v1/test_fisheryates.py index a32554c..1d9a605 100644 --- a/deprecated/mixnet-v1/test_fisheryates.py +++ b/deprecated/mixnet_v1/test_fisheryates.py @@ -1,6 +1,6 @@ from unittest import TestCase -from mixnet.fisheryates import FisherYates +from deprecated.mixnet_v1.fisheryates import FisherYates class TestFisherYates(TestCase): diff --git a/deprecated/mixnet-v1/test_mixnet.py b/deprecated/mixnet_v1/test_mixnet.py similarity index 83% rename from deprecated/mixnet-v1/test_mixnet.py rename to deprecated/mixnet_v1/test_mixnet.py index 9a0e4cb..fde95bf 100644 --- a/deprecated/mixnet-v1/test_mixnet.py +++ b/deprecated/mixnet_v1/test_mixnet.py @@ -1,8 +1,8 @@ import asyncio from unittest import IsolatedAsyncioTestCase -from mixnet.mixnet import Mixnet -from mixnet.test_utils import init_mixnet_config +from deprecated.mixnet_v1.mixnet import Mixnet +from deprecated.mixnet_v1.test_utils import init_mixnet_config class TestMixnet(IsolatedAsyncioTestCase): diff --git a/deprecated/mixnet-v1/test_node.py b/deprecated/mixnet_v1/test_node.py similarity index 94% rename from deprecated/mixnet-v1/test_node.py rename to deprecated/mixnet_v1/test_node.py index 26ab0c7..a26c9b1 100644 --- a/deprecated/mixnet-v1/test_node.py +++ b/deprecated/mixnet_v1/test_node.py @@ -5,10 +5,10 @@ from unittest import IsolatedAsyncioTestCase import numpy from pysphinx.sphinx import SphinxPacket -from mixnet.node import MixNode, NodeAddress, PacketQueue -from mixnet.packet import PacketBuilder -from mixnet.poisson import poisson_interval_sec, poisson_mean_interval_sec -from mixnet.test_utils import ( +from deprecated.mixnet_v1.node import MixNode, NodeAddress, PacketQueue +from deprecated.mixnet_v1.packet import PacketBuilder +from deprecated.mixnet_v1.poisson import poisson_interval_sec, poisson_mean_interval_sec +from deprecated.mixnet_v1.test_utils import ( init_mixnet_config, with_test_timeout, ) diff --git a/deprecated/mixnet-v1/test_packet.py b/deprecated/mixnet_v1/test_packet.py similarity index 92% rename from deprecated/mixnet-v1/test_packet.py rename to deprecated/mixnet_v1/test_packet.py index d1d517a..64322df 100644 --- a/deprecated/mixnet-v1/test_packet.py +++ b/deprecated/mixnet_v1/test_packet.py @@ -3,15 +3,15 @@ from unittest import TestCase from pysphinx.sphinx import ProcessedFinalHopPacket, SphinxPacket -from mixnet.config import MixNodeInfo -from mixnet.packet import ( +from deprecated.mixnet_v1.config import MixNodeInfo +from deprecated.mixnet_v1.packet import ( Fragment, MessageFlag, MessageReconstructor, PacketBuilder, ) -from mixnet.test_utils import init_mixnet_config -from mixnet.utils import random_bytes +from deprecated.mixnet_v1.test_utils import init_mixnet_config +from deprecated.mixnet_v1.utils import random_bytes class TestPacket(TestCase): diff --git a/deprecated/mixnet-v1/test_utils.py b/deprecated/mixnet_v1/test_utils.py similarity index 88% rename from deprecated/mixnet-v1/test_utils.py rename to deprecated/mixnet_v1/test_utils.py index e3ba260..89426cc 100644 --- a/deprecated/mixnet-v1/test_utils.py +++ b/deprecated/mixnet_v1/test_utils.py @@ -2,17 +2,17 @@ import asyncio from cryptography.hazmat.primitives.asymmetric.x25519 import X25519PrivateKey -from mixnet.bls import generate_bls -from mixnet.config import ( +from deprecated.mixnet_v1.bls import generate_bls +from deprecated.mixnet_v1.config import ( MixClientConfig, - MixNodeConfig, MixnetConfig, - MixNodeInfo, MixnetTopology, MixnetTopologyConfig, MixnetTopologySize, + MixNodeConfig, + MixNodeInfo, ) -from mixnet.utils import random_bytes +from deprecated.mixnet_v1.utils import random_bytes def with_test_timeout(t): diff --git a/deprecated/mixnet-v1/utils.py b/deprecated/mixnet_v1/utils.py similarity index 100% rename from deprecated/mixnet-v1/utils.py rename to deprecated/mixnet_v1/utils.py