Browse Source

move x25519 tests to _comms module, more will be added..

main
John-Mark Gurney 3 years ago
parent
commit
a3d7add3e5
3 changed files with 20 additions and 18 deletions
  1. +1
    -1
      Makefile
  2. +0
    -17
      lora.py
  3. +19
    -0
      lora_comms.py

+ 1
- 1
Makefile View File

@@ -188,7 +188,7 @@ runbuild: $(SRCS)

.PHONY: runtests
runtests: Makefile lora_comms.py lora.py loraserv.py multicast.py $(LIBLORA_TEST) $(LIBLORA_TEST_SRCS)
ls $(.ALLSRC) | entr sh -c '(cd $(.CURDIR) && $(MAKE) $(.MAKEFLAGS) $(LIBLORA_TEST)) && ((PYTHONPATH="$(.CURDIR)" python3 -m coverage run -m unittest lora multicast loraserv && coverage report --omit=$(.CURDIR)/p/\* -m -i) 2>&1 | head -n 30)'
ls $(.ALLSRC) | entr sh -c '(cd $(.CURDIR) && $(MAKE) $(.MAKEFLAGS) $(LIBLORA_TEST)) && ((PYTHONPATH="$(.CURDIR)" python3 -m coverage run -m unittest lora multicast loraserv lora_comms && coverage report --omit=$(.CURDIR)/p/\* -m -i) 2>&1 | head -n 30)'

.if empty(IRR_KEY) && exists($(.CURDIR)/.irr_key)
IRR_KEY!= cat $(.CURDIR)/.irr_key


+ 0
- 17
lora.py View File

@@ -603,23 +603,6 @@ class TestSequencing(unittest.IsolatedAsyncioTestCase):
# that the order they ran in was correct
self.assertEqual(col, list(range(1, 7)))

class TestX25519(unittest.TestCase):
def test_basic(self):
aprivkey = lora_comms.x25519_genkey()
apubkey = lora_comms.x25519_base(aprivkey, 1)

bprivkey = lora_comms.x25519_genkey()
bpubkey = lora_comms.x25519_base(bprivkey, 1)

self.assertNotEqual(aprivkey, bprivkey)
self.assertNotEqual(apubkey, bpubkey)

ra = lora_comms.x25519_wrap(apubkey, aprivkey, bpubkey, 1)

rb = lora_comms.x25519_wrap(bpubkey, bprivkey, apubkey, 1)

self.assertEqual(ra, rb)

class TestLORANode(unittest.IsolatedAsyncioTestCase):
shared_domain = b'com.funkthat.lora.irrigation.shared.v0.0.1'



+ 19
- 0
lora_comms.py View File

@@ -23,6 +23,7 @@
#

import os
import unittest

from ctypes import Structure, POINTER, CFUNCTYPE, pointer, sizeof
from ctypes import c_uint8, c_uint16, c_ssize_t, c_size_t, c_uint64, c_int
@@ -161,3 +162,21 @@ def comms_process_wrap(state, input):
comms_process(state, inpkt, outbuf)

return outbuf._from()

class TestX25519(unittest.TestCase):
def test_basic(self):
aprivkey = x25519_genkey()
apubkey = x25519_base(aprivkey, 1)

bprivkey = x25519_genkey()
bpubkey = x25519_base(bprivkey, 1)

self.assertNotEqual(aprivkey, bprivkey)
self.assertNotEqual(apubkey, bpubkey)

ra = x25519_wrap(apubkey, aprivkey, bpubkey, 1)

rb = x25519_wrap(bpubkey, bprivkey, apubkey, 1)

self.assertEqual(ra, rb)


Loading…
Cancel
Save