Skip to content

Commit

Permalink
change multiaddr version
Browse files Browse the repository at this point in the history
  • Loading branch information
dvmazur committed Nov 4, 2024
1 parent 227d628 commit e61e597
Show file tree
Hide file tree
Showing 15 changed files with 21 additions and 458 deletions.
1 change: 1 addition & 0 deletions hivemind/p2p/multiaddr/codecs/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import importlib

Check failure on line 1 in hivemind/p2p/multiaddr/codecs/__init__.py

View workflow job for this annotation

GitHub Actions / isort

Imports are incorrectly sorted and/or formatted.


# These are special sizes
LENGTH_PREFIXED_VAR_SIZE = -1

Expand Down
1 change: 1 addition & 0 deletions hivemind/p2p/multiaddr/codecs/cid.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from . import LENGTH_PREFIXED_VAR_SIZE


SIZE = LENGTH_PREFIXED_VAR_SIZE
IS_PATH = False

Expand Down
1 change: 1 addition & 0 deletions hivemind/p2p/multiaddr/codecs/domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from . import LENGTH_PREFIXED_VAR_SIZE


SIZE = LENGTH_PREFIXED_VAR_SIZE
IS_PATH = False

Expand Down
1 change: 1 addition & 0 deletions hivemind/p2p/multiaddr/codecs/fspath.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from . import LENGTH_PREFIXED_VAR_SIZE


SIZE = LENGTH_PREFIXED_VAR_SIZE
IS_PATH = True

Expand Down
1 change: 1 addition & 0 deletions hivemind/p2p/multiaddr/codecs/ip4.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import netaddr

Check failure on line 1 in hivemind/p2p/multiaddr/codecs/ip4.py

View workflow job for this annotation

GitHub Actions / isort

Imports are incorrectly sorted and/or formatted.


SIZE = 32
IS_PATH = False

Expand Down
1 change: 1 addition & 0 deletions hivemind/p2p/multiaddr/codecs/ip6.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import netaddr

Check failure on line 1 in hivemind/p2p/multiaddr/codecs/ip6.py

View workflow job for this annotation

GitHub Actions / isort

Imports are incorrectly sorted and/or formatted.


SIZE = 128
IS_PATH = False

Expand Down
1 change: 1 addition & 0 deletions hivemind/p2p/multiaddr/codecs/onion.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import base64
import struct


SIZE = 96
IS_PATH = False

Expand Down
1 change: 1 addition & 0 deletions hivemind/p2p/multiaddr/codecs/onion3.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import base64

Check failure on line 1 in hivemind/p2p/multiaddr/codecs/onion3.py

View workflow job for this annotation

GitHub Actions / isort

Imports are incorrectly sorted and/or formatted.
import struct


SIZE = 296
IS_PATH = False

Expand Down
1 change: 1 addition & 0 deletions hivemind/p2p/multiaddr/codecs/uint16be.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import struct

Check failure on line 1 in hivemind/p2p/multiaddr/codecs/uint16be.py

View workflow job for this annotation

GitHub Actions / isort

Imports are incorrectly sorted and/or formatted.


SIZE = 16
IS_PATH = False

Expand Down
1 change: 1 addition & 0 deletions hivemind/p2p/multiaddr/codecs/utf8.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from . import LENGTH_PREFIXED_VAR_SIZE


SIZE = LENGTH_PREFIXED_VAR_SIZE
IS_PATH = False

Expand Down
6 changes: 5 additions & 1 deletion hivemind/p2p/multiaddr/multiaddr.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
import varint

from . import exceptions, protocols
from .transforms import bytes_iter, bytes_to_string, string_to_bytes

from .transforms import bytes_iter
from .transforms import string_to_bytes
from .transforms import bytes_to_string


__all__ = ("Multiaddr",)

Expand Down
9 changes: 6 additions & 3 deletions hivemind/p2p/multiaddr/transforms.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import io

Check failure on line 1 in hivemind/p2p/multiaddr/transforms.py

View workflow job for this annotation

GitHub Actions / isort

Imports are incorrectly sorted and/or formatted.

import varint

from . import exceptions
from .codecs import LENGTH_PREFIXED_VAR_SIZE, codec_by_name
from .protocols import protocol_with_code, protocol_with_name

from .codecs import LENGTH_PREFIXED_VAR_SIZE
from .codecs import codec_by_name

from .protocols import protocol_with_code
from .protocols import protocol_with_name


def string_to_bytes(string):
Expand Down
21 changes: 0 additions & 21 deletions tests/test_multiaddr.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,6 @@
"/sctp",
"/udp/65536",
"/tcp/65536",
"/onion/9imaq4ygg2iegci7:80",
"/onion/aaimaq4ygg2iegci7:80",
"/onion/timaq4ygg2iegci7:0",
"/onion/timaq4ygg2iegci7:-1",
"/onion/timaq4ygg2iegci7",
"/onion/timaq4ygg2iegci@:666",
"/onion3/9ww6ybal4bd7szmgncyruucpgfkqahzddi37ktceo3ah7ngmcopnpyyd:80",
"/onion3/vww6ybal4bd7szmgncyruucpgfkqahzddi37ktceo3ah7ngmcopnpyyd7:80",
"/onion3/vww6ybal4bd7szmgncyruucpgfkqahzddi37ktceo3ah7ngmcopnpyyd:0",
"/onion3/vww6ybal4bd7szmgncyruucpgfkqahzddi37ktceo3ah7ngmcopnpyyd:a",
"/onion3/vww6ybal4bd7szmgncyruucpgfkqahzddi37ktceo3ah7ngmcopnpyyd:-1",
"/onion3/vww6ybal4bd7szmgncyruucpgfkqahzddi37ktceo3ah7ngmcopnpyyd",
"/onion3/vww6ybal4bd7szmgncyruucpgfkqahzddi37ktceo3ah7ngmcopnpyy@:666",
"/udp/1234/sctp",
"/udp/1234/udt/1234",
"/udp/1234/utp/1234",
Expand Down Expand Up @@ -82,10 +69,6 @@ def test_invalid(addr_str):
"/ip6zone/x/ip6/fe80::1",
"/ip6zone/x%y/ip6/fe80::1",
"/ip6zone/x%y/ip6/::",
"/onion/timaq4ygg2iegci7:1234",
"/onion/timaq4ygg2iegci7:80/http",
"/onion3/vww6ybal4bd7szmgncyruucpgfkqahzddi37ktceo3ah7ngmcopnpyyd:1234",
"/onion3/vww6ybal4bd7szmgncyruucpgfkqahzddi37ktceo3ah7ngmcopnpyyd:80/http",
"/udp/0",
"/tcp/0",
"/sctp/0",
Expand All @@ -110,8 +93,6 @@ def test_invalid(addr_str):
"/ip4/1.2.3.4/tcp/80/unix/a/b/c/d/e/f",
"/ip4/127.0.0.1/p2p/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSupNKC" "/tcp/1234/unix/stdio",
"/ip4/127.0.0.1/tcp/9090/http/p2p-webrtc-direct",
"/dns/example.com",
"/dns4/موقع.وزارة-الاتصالات.مصر",
],
) # nopep8
def test_valid(addr_str):
Expand Down Expand Up @@ -183,7 +164,6 @@ def test_invalid_protocols_with_string(proto_string):
("/ip4/1.2.3.4", -1, ("/ip4/1.2.3.4",)),
("/ip4/0.0.0.0", 0, ("/ip4/0.0.0.0",)),
("/ip6/::1", 1, ("/ip6/::1",)),
("/onion/timaq4ygg2iegci7:80/http", 0, ("/onion/timaq4ygg2iegci7:80/http",)),
(
"/ip4/127.0.0.1/p2p/bafzbeigvf25ytwc3akrijfecaotc74udrhcxzh2cx3we5qqnw5vgrei4bm/tcp/1234",
1,
Expand All @@ -202,7 +182,6 @@ def test_split(proto_string, maxsplit, expected):
(("/ip4/1.2.3.4",), "/ip4/1.2.3.4"),
((b"\x04\x00\x00\x00\x00",), "/ip4/0.0.0.0"),
(("/ip6/::1",), "/ip6/::1"),
(("/onion/timaq4ygg2iegci7:80/http",), "/onion/timaq4ygg2iegci7:80/http"),
(
(
b"\x04\x7F\x00\x00\x01",
Expand Down
182 changes: 0 additions & 182 deletions tests/test_protocols.py

This file was deleted.

Loading

0 comments on commit e61e597

Please sign in to comment.