Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix type error #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Fix type error #9

wants to merge 1 commit into from

Conversation

pbsds
Copy link

@pbsds pbsds commented Apr 18, 2024

fixes this issue on python3.12

___________________ HandshakesTest.test_xx_handshake_offline ___________________

self = <tests.test_handshakes_offline.HandshakesTest testMethod=test_xx_handshake_offline>

    def test_xx_handshake_offline(self):
        stream = DummySegmentedStream([
            base64.b64decode(
                b"GvoBCiCiMwovEL8pYkUdcxCz6w5lvzvyxgAgHiNm4LnOwO8KQxIwt+dvmTcTMcE12jCC"
                b"rbnLcFY+H2/QuKr4/h4BCHy0rDS9rKp63yqRfFX5vEPY0/UGGqMBCfYtpYzsdsU3cN0Bq4ui5Dm0MY/+Yur2cCFb"
                b"tLRgBa858hWFuCIuWKrkE89GrF0uo+wJsolq4miiqMOdXJfuZ2YBZ4paFS2mWjVmQSINRo8J3LzXncUDMeQBO/KkC"
                b"ARw5BTcVkj2gwI6FG+yB/qI8BUJIxxswJc6q+H+HWkNro+Xl6urn5aOwK7bgBSPNctncZGY72NlJByEQCB6Bra7U"
                b"ykzQA==")
        ])
        ephemeral = KeyPair.from_bytes(
            base64.b64decode(
                b"qLt+l8Jh9mUF/QciIRjd7Z0qKyhN//46Xawk5jdL4WF4tFaszfGgyodH3ErvqU5lV4GnOccdy9zj39GU6AAPVQ=="
            )
        )
        # initialize WANoiseProtocol 2.1
        wa_handshake = WAHandshake(2, 1)
        # this should do a XX handshake since we are not passing the remote static public key
>       wa_handshake.perform(self.CONFIG, stream, self.KEYPAIR, e=ephemeral)

tests/test_handshakes_offline.py:47: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
consonance/handshake.py:79: in perform
    client_payload = self._create_full_payload(client_config)
consonance/handshake.py:287: in _create_full_payload
    client_payload.session_id = random.randint(-max_int, max_int-1)
/nix/store/7yh2ax34jd7fgf17mjfd3c6niw1h2hsj-python3-3.12.2/lib/python3.12/random.py:336: in randint
    return self.randrange(a, b+1)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <random.Random object at 0x65cce0>, start = -2147483648.0
stop = 2147483648.0, step = 1

    def randrange(self, start, stop=None, step=_ONE):
        """Choose a random item from range(stop) or range(start, stop[, step]).
    
        Roughly equivalent to ``choice(range(start, stop, step))`` but
        supports arbitrarily large ranges and is optimized for common cases.
    
        """
    
        # This code is a bit messy to make it fast for the
        # common case while still doing adequate error checking.
>       istart = _index(start)
E       TypeError: 'float' object cannot be interpreted as an integer

@@ -282,7 +282,7 @@ def _create_full_payload(self, client_config):
client_payload.passive = client_config.passive
client_payload.push_name = client_config.pushname

max_int = (2**32) / 2
max_int = 2**31
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

equivalent version:

Suggested change
max_int = 2**31
max_int = 2**32 // 2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant