Created
March 15, 2016 04:31
-
-
Save parsonsmatt/c5833574c123da217bc4 to your computer and use it in GitHub Desktop.
mmm property checking
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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