| @@ -690,37 +690,28 @@ class TestLORANode(unittest.IsolatedAsyncioTestCase): | |||||
| async def runner(self): | async def runner(self): | ||||
| for expectlen in [ 24, 17, 9, 9, 9, 9 ]: | for expectlen in [ 24, 17, 9, 9, 9, 9 ]: | ||||
| # get message | # get message | ||||
| gb = await self.get() | |||||
| r = make_pktbuf(gb) | |||||
| outbytes = bytearray(64) | |||||
| outbuf = make_pktbuf(outbytes) | |||||
| inmsg = await self.get() | |||||
| # process the test message | # process the test message | ||||
| lora_comms.comms_process(commstate, r, | |||||
| outbuf) | |||||
| out = lora_comms.comms_process_wrap( | |||||
| commstate, inmsg) | |||||
| # make sure the reply matches length | # make sure the reply matches length | ||||
| _self.assertEqual(expectlen, | |||||
| outbuf.pktlen) | |||||
| _self.assertEqual(expectlen, len(out)) | |||||
| # save what was originally replied | # save what was originally replied | ||||
| origmsg = outbuf._from() | |||||
| origmsg = out | |||||
| # pretend that the reply didn't make it | # pretend that the reply didn't make it | ||||
| r = make_pktbuf(gb) | |||||
| outbuf = make_pktbuf(outbytes) | |||||
| lora_comms.comms_process(commstate, r, | |||||
| outbuf) | |||||
| out = lora_comms.comms_process_wrap( | |||||
| commstate, inmsg) | |||||
| # make sure that the reply matches | # make sure that the reply matches | ||||
| # the previous | # the previous | ||||
| _self.assertEqual(origmsg, | |||||
| outbuf._from()) | |||||
| _self.assertEqual(origmsg, out) | |||||
| # pass the reply back | # pass the reply back | ||||
| await self.put(outbytes[:outbuf.pktlen]) | |||||
| await self.put(out) | |||||
| # Generate shared key | # Generate shared key | ||||
| shared_key = os.urandom(32) | shared_key = os.urandom(32) | ||||
| @@ -801,19 +792,14 @@ class TestLORANode(unittest.IsolatedAsyncioTestCase): | |||||
| class FlipMsg(object): | class FlipMsg(object): | ||||
| async def flipmsg(self): | async def flipmsg(self): | ||||
| # get message | # get message | ||||
| gb = await self.get() | |||||
| r = make_pktbuf(gb) | |||||
| outbytes = bytearray(64) | |||||
| outbuf = make_pktbuf(outbytes) | |||||
| inmsg = await self.get() | |||||
| # process the test message | # process the test message | ||||
| lora_comms.comms_process(commstate, r, | |||||
| outbuf) | |||||
| out = lora_comms.comms_process_wrap( | |||||
| commstate, inmsg) | |||||
| # pass the reply back | # pass the reply back | ||||
| pkt = outbytes[:outbuf.pktlen] | |||||
| await self.put(pkt) | |||||
| await self.put(out) | |||||
| # this class always passes messages, this is | # this class always passes messages, this is | ||||
| # used for the first session. | # used for the first session. | ||||
| @@ -824,17 +810,14 @@ class TestLORANode(unittest.IsolatedAsyncioTestCase): | |||||
| async with seq.sync(0): | async with seq.sync(0): | ||||
| # create bogus message | # create bogus message | ||||
| r = make_pktbuf(b'0'*24) | |||||
| outbytes = bytearray(64) | |||||
| outbuf = make_pktbuf(outbytes) | |||||
| inmsg = b'0'*24 | |||||
| # process the bogus message | # process the bogus message | ||||
| lora_comms.comms_process(commstate, r, | |||||
| outbuf) | |||||
| out = lora_comms.comms_process_wrap( | |||||
| commstate, inmsg) | |||||
| # make sure there was not a response | # make sure there was not a response | ||||
| _self.assertEqual(outbuf.pktlen, 0) | |||||
| _self.assertFalse(out) | |||||
| await self.flipmsg() | await self.flipmsg() | ||||