Commit cb9afd65 authored by Boris Pilka's avatar Boris Pilka

Merge branch 'master' of git.ifne.eu:space-public/pyDTN


Former-commit-id: 42d6c7c7
parents b31e8b02 b9721a77
from common import *
class TestCommon(object):
DTN_TIME = 606658292
UNIX_TIME = 1553343092
def test_time_conversion(self):
assert unix2dtn(self.UNIX_TIME) == self.DTN_TIME
assert dtn2unix(self.DTN_TIME) == self.UNIX_TIME
DATA = 1023
ENCODED_DATA = b'\x87\x7f'
def test_encode(self):
assert sdnv_encode(self.DATA) == self.ENCODED_DATA
DATA_READ = [ 0x12, 0x11, 0x10, 0x09];
def test_read(self):
assert sdnv_read(self.DATA_READ,2) == (16, 3)
SERIAL_RESPONSE =b'\x9f\x89\x07\x00\x01\x82\x01etest2\x82\x01dtest\x82\x01\x00\x82\x1a$(\xde\xf4\x00\x19\x01,B%r\x87\t\x01\x00\x02\x04\x82\x18\x1e\x00D]}\xd8u\x87\x08\x02\x00\x02\x01\x00D\x98\x9d\x838\x87\x01\x00\x00\x02\x02aHDF\xa27\x80\xff'
SERIAL_TCPCL_RESPONSE = b'\x13M\x9f\x89\x07\x00\x01\x82\x01etest2\x82\x01dtest\x82\x01\x00\x82\x1a$(\xde\xf4\x00\x19\x01,B%r\x87\t\x01\x00\x02\x04\x82\x18\x1e\x00D]}\xd8u\x87\x08\x02\x00\x02\x01\x00D\x98\x9d\x838\x87\x01\x00\x00\x02\x02aHDF\xa27\x80\xff'
def test_serialize(self):
bundle = serialize_bundle(
"dtn:test",
"dtn:test2",
"H",
NULL_EID,
self.UNIX_TIME
)
assert bundle == self.SERIAL_RESPONSE
result = serialize_tcpcl_single_bundle_segment(bundle)
assert result == self.SERIAL_TCPCL_RESPONSE
START_OFFSET = 4572
END_OFFSET = 12512
CONTACT = (606671843, 606679783, 500)
SERIAL_UPCN_CONFIG_RESPONSE = b'1(dtn:pyDTN-2.dtn):(172.25.0.12:2002)::[{606671843,606679783,500}];'
def test_serialize_config(self):
result = serialize_upcn_config_message(
"dtn:pyDTN-2.dtn",
"172.25.0.12:2002",
contacts=[
self.CONTACT,
],
)
assert result == self.SERIAL_UPCN_CONFIG_RESPONSE
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment