Skip to content

Instantly share code, notes, and snippets.

@parsonsmatt parsonsmatt/
Created Mar 15, 2016

What would you like to do?
mmm property checking
def decode(data):
Accepts a byte array and converts it into an Ack packet if possible. If the
decoding fails, then this method raises DecodeError. The following doc test
randomly samples legal values for the acknowledgment number and window size and
asserts that for all those values, Ack.decode(p.encode()) == p
>>> from random import *
>>> ack_nos = [randrange(int(1e6)) for i in range(1,10)]
>>> win_sizes = [randrange(int(1e3)) for i in range(1,10)]
>>> ps = [Ack(x, y) for x in ack_nos for y in win_sizes]
>>> [p for p in ps if Ack.decode(p.encode()) != p]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.