2025-08-26 21:05:36 -06:00
|
|
|
#include <unity.h>
|
2023-10-07 01:03:15 -06:00
|
|
|
|
|
|
|
|
#include "Reticulum.h"
|
|
|
|
|
#include "Bytes.h"
|
|
|
|
|
|
2026-03-06 16:43:04 -07:00
|
|
|
void test_reticulum_reference() {
|
2024-07-03 11:30:01 -06:00
|
|
|
HEAD("Running testReference...", RNS::LOG_TRACE);
|
2023-10-07 01:03:15 -06:00
|
|
|
|
|
|
|
|
RNS::Reticulum reticulum_default;
|
2025-08-26 21:05:36 -06:00
|
|
|
TEST_ASSERT_TRUE(reticulum_default);
|
2023-10-07 01:03:15 -06:00
|
|
|
|
2023-11-19 11:36:09 -07:00
|
|
|
RNS::Reticulum reticulum_none({RNS::Type::NONE});
|
2025-08-26 21:05:36 -06:00
|
|
|
TEST_ASSERT_FALSE(reticulum_none);
|
2023-10-07 01:03:15 -06:00
|
|
|
|
|
|
|
|
RNS::Reticulum reticulum_default_copy(reticulum_default);
|
2025-08-26 21:05:36 -06:00
|
|
|
TEST_ASSERT_TRUE(reticulum_default_copy);
|
2023-10-07 01:03:15 -06:00
|
|
|
|
|
|
|
|
RNS::Reticulum reticulum_none_copy(reticulum_none);
|
2025-08-26 21:05:36 -06:00
|
|
|
TEST_ASSERT_FALSE(reticulum_none_copy);
|
2023-10-07 01:03:15 -06:00
|
|
|
|
2023-11-26 18:10:46 -07:00
|
|
|
/*
|
2024-07-03 11:30:01 -06:00
|
|
|
RNS::loglevel(RNS::LOG_TRACE);
|
2023-11-26 18:10:46 -07:00
|
|
|
TestInterface testinterface;
|
|
|
|
|
|
|
|
|
|
std::set<std::reference_wrapper<RNS::Interface>, std::less<RNS::Interface>> interfaces;
|
|
|
|
|
interfaces.insert(testinterface);
|
|
|
|
|
for (auto iter = interfaces.begin(); iter != interfaces.end(); ++iter) {
|
|
|
|
|
RNS::Interface& interface = (*iter);
|
2026-03-01 10:59:33 -07:00
|
|
|
TRACEF("Found interface: %s", interface.toString().c_str());
|
2023-11-26 18:10:46 -07:00
|
|
|
RNS::Bytes data;
|
2023-12-03 16:43:53 -07:00
|
|
|
const_cast<RNS::Interface&>(interface).on_outgoing(data);
|
2023-11-26 18:10:46 -07:00
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
*/
|
|
|
|
|
/*
|
2024-07-03 11:30:01 -06:00
|
|
|
RNS::loglevel(RNS::LOG_TRACE);
|
2023-11-26 18:10:46 -07:00
|
|
|
TestInterface testinterface;
|
|
|
|
|
|
|
|
|
|
std::set<std::reference_wrapper<RNS::Interface>, std::less<RNS::Interface>> interfaces;
|
|
|
|
|
interfaces.insert(testinterface);
|
|
|
|
|
for (auto& interface : interfaces) {
|
2026-03-01 10:59:33 -07:00
|
|
|
TRACEF("Found interface: %s", interface.toString().c_str());
|
2023-11-26 18:10:46 -07:00
|
|
|
RNS::Bytes data;
|
2023-12-03 16:43:53 -07:00
|
|
|
const_cast<RNS::Interface&>(interface).on_outgoing(data);
|
2023-11-26 18:10:46 -07:00
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
*/
|
|
|
|
|
/*
|
2024-07-03 11:30:01 -06:00
|
|
|
RNS::loglevel(RNS::LOG_TRACE);
|
2023-11-26 18:10:46 -07:00
|
|
|
TestInterface testinterface;
|
|
|
|
|
|
|
|
|
|
std::list<std::reference_wrapper<RNS::Interface>> interfaces;
|
|
|
|
|
interfaces.push_back(testinterface);
|
|
|
|
|
for (auto iter = interfaces.begin(); iter != interfaces.end(); ++iter) {
|
|
|
|
|
RNS::Interface& interface = (*iter);
|
2026-03-01 10:59:33 -07:00
|
|
|
TRACEF("Found interface: %s", interface.toString().c_str());
|
2023-11-26 18:10:46 -07:00
|
|
|
RNS::Bytes data;
|
2023-12-03 16:43:53 -07:00
|
|
|
const_cast<RNS::Interface&>(interface).on_outgoing(data);
|
2023-11-26 18:10:46 -07:00
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
*/
|
|
|
|
|
/*
|
2024-07-03 11:30:01 -06:00
|
|
|
RNS::loglevel(RNS::LOG_TRACE);
|
2023-11-26 18:10:46 -07:00
|
|
|
TestInterface testinterface;
|
|
|
|
|
|
|
|
|
|
std::list<std::reference_wrapper<RNS::Interface>> interfaces;
|
|
|
|
|
interfaces.push_back(testinterface);
|
|
|
|
|
//for (auto& interface : interfaces) {
|
|
|
|
|
for (RNS::Interface& interface : interfaces) {
|
2026-03-01 10:59:33 -07:00
|
|
|
TRACEF("Found interface: %s", interface.toString().c_str());
|
2023-11-26 18:10:46 -07:00
|
|
|
RNS::Bytes data;
|
2023-12-03 16:43:53 -07:00
|
|
|
const_cast<RNS::Interface&>(interface).on_outgoing(data);
|
2023-11-26 18:10:46 -07:00
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
*/
|
|
|
|
|
/*
|
|
|
|
|
std::list<std::reference_wrapper<RNS::Interface>> interfaces;
|
|
|
|
|
{
|
2024-07-03 11:30:01 -06:00
|
|
|
RNS::loglevel(RNS::LOG_TRACE);
|
2023-11-26 18:10:46 -07:00
|
|
|
TestInterface testinterface;
|
|
|
|
|
interfaces.push_back(testinterface);
|
|
|
|
|
for (auto iter = interfaces.begin(); iter != interfaces.end(); ++iter) {
|
|
|
|
|
RNS::Interface& interface = (*iter);
|
2026-03-01 10:59:33 -07:00
|
|
|
TRACEF("1 Found interface: %s", interface.toString().c_str());
|
2023-11-26 18:10:46 -07:00
|
|
|
RNS::Bytes data;
|
2023-12-03 16:43:53 -07:00
|
|
|
const_cast<RNS::Interface&>(interface).on_outgoing(data);
|
2023-11-26 18:10:46 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for (auto iter = interfaces.begin(); iter != interfaces.end(); ++iter) {
|
|
|
|
|
RNS::Interface& interface = (*iter);
|
2026-03-01 10:59:33 -07:00
|
|
|
TRACEF("2 Found interface: %s", interface.toString().c_str());
|
2023-11-26 18:10:46 -07:00
|
|
|
RNS::Bytes data;
|
2023-12-03 16:43:53 -07:00
|
|
|
const_cast<RNS::Interface&>(interface).on_outgoing(data);
|
2023-11-26 18:10:46 -07:00
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
*/
|
|
|
|
|
/*
|
2024-07-03 11:30:01 -06:00
|
|
|
HEAD("Testing map...", RNS::LOG_TRACE);
|
2023-11-26 18:10:46 -07:00
|
|
|
{
|
|
|
|
|
std::map<RNS::Bytes, RNS::Destination&> destinations;
|
|
|
|
|
destinations.insert({destination.hash(), destination});
|
|
|
|
|
//for (RNS::Destination& destination : destinations) {
|
|
|
|
|
for (auto& [hash, destination] : destinations) {
|
2026-03-01 10:59:33 -07:00
|
|
|
TRACEF("Iterated destination: %s", destination.toString().c_str());
|
2023-11-26 18:10:46 -07:00
|
|
|
}
|
|
|
|
|
RNS::Bytes hash = destination.hash();
|
|
|
|
|
auto iter = destinations.find(hash);
|
|
|
|
|
if (iter != destinations.end()) {
|
|
|
|
|
RNS::Destination& destination = (*iter).second;
|
2026-03-01 10:59:33 -07:00
|
|
|
TRACEF("Found destination: %s", destination.toString().c_str());
|
2023-11-26 18:10:46 -07:00
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
|
2023-10-07 01:03:15 -06:00
|
|
|
}
|
|
|
|
|
|
2026-03-06 16:43:04 -07:00
|
|
|
void test_destination_entry_reference() {
|
|
|
|
|
HEAD("Running testReference...", RNS::LOG_TRACE);
|
|
|
|
|
|
|
|
|
|
RNS::Transport::DestinationEntry destination_entry;
|
|
|
|
|
TEST_ASSERT_FALSE(destination_entry);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2025-08-26 21:05:36 -06:00
|
|
|
|
|
|
|
|
void setUp(void) {
|
|
|
|
|
// set stuff up here before each test
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void tearDown(void) {
|
|
|
|
|
// clean stuff up here after each test
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int runUnityTests(void) {
|
2023-10-07 01:03:15 -06:00
|
|
|
UNITY_BEGIN();
|
2026-03-06 16:43:04 -07:00
|
|
|
RUN_TEST(test_reticulum_reference);
|
|
|
|
|
RUN_TEST(test_destination_entry_reference);
|
2023-10-07 01:03:15 -06:00
|
|
|
return UNITY_END();
|
|
|
|
|
}
|
2025-08-26 21:05:36 -06:00
|
|
|
|
|
|
|
|
// For native dev-platform or for some embedded frameworks
|
|
|
|
|
int main(void) {
|
|
|
|
|
return runUnityTests();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#ifdef ARDUINO
|
|
|
|
|
// For Arduino framework
|
|
|
|
|
void setup() {
|
|
|
|
|
// Wait ~2 seconds before the Unity test runner
|
|
|
|
|
// establishes connection with a board Serial interface
|
|
|
|
|
delay(2000);
|
|
|
|
|
|
|
|
|
|
runUnityTests();
|
|
|
|
|
}
|
|
|
|
|
void loop() {}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
// For ESP-IDF framework
|
|
|
|
|
void app_main() {
|
|
|
|
|
runUnityTests();
|
|
|
|
|
}
|