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

Unit tests for lib/packet/scion.py #204

Merged
merged 16 commits into from
Jun 30, 2015

Conversation

pratyakshs
Copy link
Contributor

(work in progress)
@kormat, this is ready for a review.

data = bytes([0b11110000, 0b00111111]) + bytes.fromhex('0304 05 06 07 08')
...
ntools.eq_(hdr.version, 0b1111)
ntools.eq_(hdr.src_addr_len, 0x000000)
ntools.eq_(hdr.dst_addr_len, 0x111111)
hdr._extension_hdrs = MagicMock(spect_set=['__bool__'])
hdr._extension_hdrs.__bool__.side_effects = [True, True, False]

  

return req

def pack(self):
self.payload = struct.pack("HH", self.reply_id, self.request_id)
self.payload = struct.pack("!HH", self.reply_id, self.request_id)
Copy link
Contributor

Choose a reason for hiding this comment

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

After seeing the sorts of changes needed for this, i would prefer it was in a separate PR

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here you go: #209

Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@kormat kormat mentioned this pull request Jun 26, 2015
@@ -1,4 +1,4 @@
# Copyright 2014 ETH Zurich
# Copyright 2015 ETH Zurich
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't know the exact legal rules here, but i would leave the year untouched.

Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@kormat
Copy link
Contributor

kormat commented Jun 29, 2015

Ok, finished this review pass, with mostly minor comments.

@pratyakshs
Copy link
Contributor Author

@kormat , I think this is complete, you can have a look.

@kormat kormat changed the title Unit tests for lib/packet/scion.py + minor edits in scion.py Unit tests for lib/packet/scion.py Jun 30, 2015
hdr.common_hdr.total_len = 200
path = MagicMock(spec_set=['pack'])
path.pack.return_value = b'packed_path'
hdr.set_path(path)
Copy link
Contributor

Choose a reason for hiding this comment

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

Need an assertion that pack.pack was called

Copy link
Contributor

Choose a reason for hiding this comment

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

👍

scion_common_hdr.return_value = common_hdr
scion_common_hdr.LEN = 2
scion_addr.side_effect = ['src_addr', 'dst_addr']
ntools.eq_(hdr._parse_common_hdr(data, 2), 2 + 2 + 3 + 5)
Copy link
Contributor

Choose a reason for hiding this comment

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

I would suggest changing the initial offset to 1, so it's easier to see where the result numbers come from.

Copy link
Contributor

Choose a reason for hiding this comment

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

👍

In TestSIONHeaderParseCommonHdr.test
@kormat
Copy link
Contributor

kormat commented Jun 30, 2015

LGTM, nice work :)

kormat added a commit that referenced this pull request Jun 30, 2015
Unit tests for lib/packet/scion.py
@kormat kormat merged commit af06563 into scionproto:master Jun 30, 2015
@pratyakshs pratyakshs deleted the unit_test_scion branch June 30, 2015 12:54
FR4NK-W pushed a commit to FR4NK-W/osourced-scion that referenced this pull request Feb 14, 2017
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.

None yet

2 participants