@@ -188,7 +188,7 @@ runbuild: $(SRCS) | |||||
.PHONY: runtests | .PHONY: runtests | ||||
runtests: Makefile lora_comms.py lora.py loraserv.py multicast.py $(LIBLORA_TEST) $(LIBLORA_TEST_SRCS) | 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) | .if empty(IRR_KEY) && exists($(.CURDIR)/.irr_key) | ||||
IRR_KEY!= cat $(.CURDIR)/.irr_key | IRR_KEY!= cat $(.CURDIR)/.irr_key | ||||
@@ -603,23 +603,6 @@ class TestSequencing(unittest.IsolatedAsyncioTestCase): | |||||
# that the order they ran in was correct | # that the order they ran in was correct | ||||
self.assertEqual(col, list(range(1, 7))) | 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): | class TestLORANode(unittest.IsolatedAsyncioTestCase): | ||||
shared_domain = b'com.funkthat.lora.irrigation.shared.v0.0.1' | shared_domain = b'com.funkthat.lora.irrigation.shared.v0.0.1' | ||||
@@ -23,6 +23,7 @@ | |||||
# | # | ||||
import os | import os | ||||
import unittest | |||||
from ctypes import Structure, POINTER, CFUNCTYPE, pointer, sizeof | 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 | 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) | comms_process(state, inpkt, outbuf) | ||||
return outbuf._from() | 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) | |||||