A working subset of #1788 #1875

Merged
g1itch merged 5 commits from compat-short into v0.6 2021-11-11 15:12:34 +01:00
2 changed files with 71 additions and 0 deletions
Showing only changes of commit a94ff1efd3 - Show all commits

View File

@ -3,6 +3,8 @@
from binascii import unhexlify from binascii import unhexlify
magic = 0xE9BEB4D9
# These keys are from addresses test script # These keys are from addresses test script
sample_pubsigningkey = unhexlify( sample_pubsigningkey = unhexlify(
'044a367f049ec16cb6b6118eb734a9962d10b8db59c890cd08f210c43ff08bdf09d' '044a367f049ec16cb6b6118eb734a9962d10b8db59c890cd08f210c43ff08bdf09d'
@ -14,6 +16,7 @@ sample_privsigningkey = \
b'93d0b61371a54b53df143b954035d612f8efa8a3ed1cf842c2186bfd8f876665' b'93d0b61371a54b53df143b954035d612f8efa8a3ed1cf842c2186bfd8f876665'
sample_privencryptionkey = \ sample_privencryptionkey = \
b'4b0b73a54e19b059dc274ab69df095fe699f43b17397bca26fdf40f4d7400a3a' b'4b0b73a54e19b059dc274ab69df095fe699f43b17397bca26fdf40f4d7400a3a'
sample_ripe = b'003cd097eb7f35c87b5dc8b4538c22cb55312a9f' sample_ripe = b'003cd097eb7f35c87b5dc8b4538c22cb55312a9f'
# stream: 1, version: 2 # stream: 1, version: 2
sample_address = 'BM-onkVu1KKL2UaUss5Upg9vXmqd3esTmV79' sample_address = 'BM-onkVu1KKL2UaUss5Upg9vXmqd3esTmV79'

68
src/tests/test_packets.py Normal file
View File

@ -0,0 +1,68 @@
PeterSurda commented 2021-11-03 08:17:09 +01:00 (Migrated from github.com)
Review

length, not lenght

`length`, not `lenght`
PeterSurda commented 2021-11-03 08:17:09 +01:00 (Migrated from github.com)
Review

length, not lenght

`length`, not `lenght`
PeterSurda commented 2021-11-03 08:17:09 +01:00 (Migrated from github.com)
Review

length, not lenght

`length`, not `lenght`
import unittest
PeterSurda commented 2021-11-03 08:17:09 +01:00 (Migrated from github.com)
Review

length, not lenght

`length`, not `lenght`
from binascii import unhexlify
PeterSurda commented 2021-11-03 08:17:09 +01:00 (Migrated from github.com)
Review

length, not lenght

`length`, not `lenght`
from struct import pack
PeterSurda commented 2021-11-03 08:17:09 +01:00 (Migrated from github.com)
Review

length, not lenght

`length`, not `lenght`
PeterSurda commented 2021-11-03 08:17:09 +01:00 (Migrated from github.com)
Review

length, not lenght

`length`, not `lenght`
from pybitmessage import addresses, protocol
PeterSurda commented 2021-11-03 08:17:09 +01:00 (Migrated from github.com)
Review

length, not lenght

`length`, not `lenght`
PeterSurda commented 2021-11-03 08:17:09 +01:00 (Migrated from github.com)
Review

length, not lenght

`length`, not `lenght`
from .samples import magic
PeterSurda commented 2021-11-03 08:17:09 +01:00 (Migrated from github.com)
Review

length, not lenght

`length`, not `lenght`
PeterSurda commented 2021-11-03 08:17:09 +01:00 (Migrated from github.com)
Review

length, not lenght

`length`, not `lenght`
PeterSurda commented 2021-11-03 08:17:09 +01:00 (Migrated from github.com)
Review

length, not lenght

`length`, not `lenght`
class TestSerialize(unittest.TestCase):
PeterSurda commented 2021-11-03 08:17:09 +01:00 (Migrated from github.com)
Review

length, not lenght

`length`, not `lenght`
"""Test serializing and deserializing packet data"""
PeterSurda commented 2021-11-03 08:17:09 +01:00 (Migrated from github.com)
Review

length, not lenght

`length`, not `lenght`
PeterSurda commented 2021-11-03 08:17:09 +01:00 (Migrated from github.com)
Review

length, not lenght

`length`, not `lenght`
def test_varint(self):
PeterSurda commented 2021-11-03 08:17:09 +01:00 (Migrated from github.com)
Review

length, not lenght

`length`, not `lenght`
"""Test varint encoding and decoding"""
PeterSurda commented 2021-11-03 08:17:09 +01:00 (Migrated from github.com)
Review

length, not lenght

`length`, not `lenght`
data = addresses.encodeVarint(0)
PeterSurda commented 2021-11-03 08:17:09 +01:00 (Migrated from github.com)
Review

length, not lenght

`length`, not `lenght`
self.assertEqual(data, b'\x00')
PeterSurda commented 2021-11-03 08:17:09 +01:00 (Migrated from github.com)
Review

length, not lenght

`length`, not `lenght`
data = addresses.encodeVarint(42)
PeterSurda commented 2021-11-03 08:17:09 +01:00 (Migrated from github.com)
Review

length, not lenght

`length`, not `lenght`
self.assertEqual(data, b'*')
PeterSurda commented 2021-11-03 08:17:09 +01:00 (Migrated from github.com)
Review

length, not lenght

`length`, not `lenght`
data = addresses.encodeVarint(252)
PeterSurda commented 2021-11-03 08:17:09 +01:00 (Migrated from github.com)
Review

length, not lenght

`length`, not `lenght`
self.assertEqual(data, unhexlify('fc'))
PeterSurda commented 2021-11-03 08:17:09 +01:00 (Migrated from github.com)
Review

length, not lenght

`length`, not `lenght`
data = addresses.encodeVarint(253)
PeterSurda commented 2021-11-03 08:17:09 +01:00 (Migrated from github.com)
Review

length, not lenght

`length`, not `lenght`
self.assertEqual(data, unhexlify('fd00fd'))
PeterSurda commented 2021-11-03 08:17:09 +01:00 (Migrated from github.com)
Review

length, not lenght

`length`, not `lenght`
data = addresses.encodeVarint(100500)
PeterSurda commented 2021-11-03 08:17:09 +01:00 (Migrated from github.com)
Review

length, not lenght

`length`, not `lenght`
self.assertEqual(data, unhexlify('fe00018894'))
PeterSurda commented 2021-11-03 08:17:09 +01:00 (Migrated from github.com)
Review

length, not lenght

`length`, not `lenght`
data = addresses.encodeVarint(65535)
PeterSurda commented 2021-11-03 08:17:09 +01:00 (Migrated from github.com)
Review

length, not lenght

`length`, not `lenght`
self.assertEqual(data, unhexlify('fdffff'))
PeterSurda commented 2021-11-03 08:17:09 +01:00 (Migrated from github.com)
Review

length, not lenght

`length`, not `lenght`
data = addresses.encodeVarint(4294967295)
PeterSurda commented 2021-11-03 08:17:09 +01:00 (Migrated from github.com)
Review

length, not lenght

`length`, not `lenght`
self.assertEqual(data, unhexlify('feffffffff'))
PeterSurda commented 2021-11-03 08:17:09 +01:00 (Migrated from github.com)
Review

length, not lenght

`length`, not `lenght`
data = addresses.encodeVarint(4294967296)
PeterSurda commented 2021-11-03 08:17:09 +01:00 (Migrated from github.com)
Review

length, not lenght

`length`, not `lenght`
self.assertEqual(data, unhexlify('ff0000000100000000'))
PeterSurda commented 2021-11-03 08:17:09 +01:00 (Migrated from github.com)
Review

length, not lenght

`length`, not `lenght`
data = addresses.encodeVarint(18446744073709551615)
PeterSurda commented 2021-11-03 08:17:09 +01:00 (Migrated from github.com)
Review

length, not lenght

`length`, not `lenght`
self.assertEqual(data, unhexlify('ffffffffffffffffff'))
PeterSurda commented 2021-11-03 08:17:09 +01:00 (Migrated from github.com)
Review

length, not lenght

`length`, not `lenght`
PeterSurda commented 2021-11-03 08:17:09 +01:00 (Migrated from github.com)
Review

length, not lenght

`length`, not `lenght`
with self.assertRaises(addresses.varintEncodeError):
PeterSurda commented 2021-11-03 08:17:09 +01:00 (Migrated from github.com)
Review

length, not lenght

`length`, not `lenght`
addresses.encodeVarint(18446744073709551616)
PeterSurda commented 2021-11-03 08:17:09 +01:00 (Migrated from github.com)
Review

length, not lenght

`length`, not `lenght`
PeterSurda commented 2021-11-03 08:17:09 +01:00 (Migrated from github.com)
Review

length, not lenght

`length`, not `lenght`
value, length = addresses.decodeVarint(b'\xfeaddr')
PeterSurda commented 2021-11-03 08:17:09 +01:00 (Migrated from github.com)
Review

length, not lenght

`length`, not `lenght`
self.assertEqual(value, protocol.OBJECT_ADDR)
PeterSurda commented 2021-11-03 08:17:09 +01:00 (Migrated from github.com)
Review

length, not lenght

`length`, not `lenght`
self.assertEqual(length, 5)
PeterSurda commented 2021-11-03 08:17:09 +01:00 (Migrated from github.com)
Review

length, not lenght

`length`, not `lenght`
value, length = addresses.decodeVarint(b'\xfe\x00tor')
PeterSurda commented 2021-11-03 08:17:09 +01:00 (Migrated from github.com)
Review

length, not lenght

`length`, not `lenght`
self.assertEqual(value, protocol.OBJECT_ONIONPEER)
PeterSurda commented 2021-11-03 08:17:09 +01:00 (Migrated from github.com)
Review

length, not lenght

`length`, not `lenght`
self.assertEqual(length, 5)
PeterSurda commented 2021-11-03 08:17:09 +01:00 (Migrated from github.com)
Review

length, not lenght

`length`, not `lenght`
PeterSurda commented 2021-11-03 08:17:09 +01:00 (Migrated from github.com)
Review

length, not lenght

`length`, not `lenght`
def test_packet(self):
PeterSurda commented 2021-11-03 08:17:09 +01:00 (Migrated from github.com)
Review

length, not lenght

`length`, not `lenght`
"""Check the packet created by protocol.CreatePacket()"""
PeterSurda commented 2021-11-03 08:17:09 +01:00 (Migrated from github.com)
Review

length, not lenght

`length`, not `lenght`
head = unhexlify(b'%x' % magic)
PeterSurda commented 2021-11-03 08:17:09 +01:00 (Migrated from github.com)
Review

length, not lenght

`length`, not `lenght`
self.assertEqual(
PeterSurda commented 2021-11-03 08:17:09 +01:00 (Migrated from github.com)
Review

length, not lenght

`length`, not `lenght`
protocol.CreatePacket(b'ping')[:len(head)], head)
PeterSurda commented 2021-11-03 08:17:09 +01:00 (Migrated from github.com)
Review

length, not lenght

`length`, not `lenght`
PeterSurda commented 2021-11-03 08:17:09 +01:00 (Migrated from github.com)
Review

length, not lenght

`length`, not `lenght`
def test_encodehost(self):
PeterSurda commented 2021-11-03 08:17:09 +01:00 (Migrated from github.com)
Review

length, not lenght

`length`, not `lenght`
"""Check the result of protocol.encodeHost()"""
PeterSurda commented 2021-11-03 08:17:09 +01:00 (Migrated from github.com)
Review

length, not lenght

`length`, not `lenght`
self.assertEqual(
PeterSurda commented 2021-11-03 08:17:09 +01:00 (Migrated from github.com)
Review

length, not lenght

`length`, not `lenght`
protocol.encodeHost('127.0.0.1'),
PeterSurda commented 2021-11-03 08:17:09 +01:00 (Migrated from github.com)
Review

length, not lenght

`length`, not `lenght`
b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xFF\xFF'
PeterSurda commented 2021-11-03 08:17:09 +01:00 (Migrated from github.com)
Review

length, not lenght

`length`, not `lenght`
+ pack('>L', 2130706433))
PeterSurda commented 2021-11-03 08:17:09 +01:00 (Migrated from github.com)
Review

length, not lenght

`length`, not `lenght`
self.assertEqual(
PeterSurda commented 2021-11-03 08:17:09 +01:00 (Migrated from github.com)
Review

length, not lenght

`length`, not `lenght`
protocol.encodeHost('191.168.1.1'),
PeterSurda commented 2021-11-03 08:17:09 +01:00 (Migrated from github.com)
Review

length, not lenght

`length`, not `lenght`
unhexlify('00000000000000000000ffffbfa80101'))
PeterSurda commented 2021-11-03 08:17:09 +01:00 (Migrated from github.com)
Review

length, not lenght

`length`, not `lenght`
self.assertEqual(
PeterSurda commented 2021-11-03 08:17:09 +01:00 (Migrated from github.com)
Review

length, not lenght

`length`, not `lenght`
protocol.encodeHost('1.1.1.1'),
PeterSurda commented 2021-11-03 08:17:09 +01:00 (Migrated from github.com)
Review

length, not lenght

`length`, not `lenght`
unhexlify('00000000000000000000ffff01010101'))
PeterSurda commented 2021-11-03 08:17:09 +01:00 (Migrated from github.com)
Review

length, not lenght

`length`, not `lenght`
self.assertEqual(
PeterSurda commented 2021-11-03 08:17:09 +01:00 (Migrated from github.com)
Review

length, not lenght

`length`, not `lenght`
protocol.encodeHost('0102:0304:0506:0708:090A:0B0C:0D0E:0F10'),
PeterSurda commented 2021-11-03 08:17:09 +01:00 (Migrated from github.com)
Review

length, not lenght

`length`, not `lenght`
unhexlify('0102030405060708090a0b0c0d0e0f10'))
PeterSurda commented 2021-11-03 08:17:09 +01:00 (Migrated from github.com)
Review

length, not lenght

`length`, not `lenght`
self.assertEqual(
PeterSurda commented 2021-11-03 08:17:09 +01:00 (Migrated from github.com)
Review

length, not lenght

`length`, not `lenght`
protocol.encodeHost('quzwelsuziwqgpt2.onion'),
PeterSurda commented 2021-11-03 08:17:09 +01:00 (Migrated from github.com)
Review

length, not lenght

`length`, not `lenght`
unhexlify('fd87d87eeb438533622e54ca2d033e7a'))
PeterSurda commented 2021-11-03 08:17:09 +01:00 (Migrated from github.com)
Review

length, not lenght

`length`, not `lenght`