Some checks failed
Go Test Multi-Platform / Test (ubuntu-latest, amd64) (push) Successful in 1m34s
Go Test Multi-Platform / Test (ubuntu-latest, arm64) (push) Successful in 49s
Go Revive Lint / lint (push) Successful in 46s
Run Gosec / tests (push) Successful in 1m21s
Go Build Multi-Platform / build (amd64, windows) (push) Failing after 49s
Go Build Multi-Platform / build (amd64, freebsd) (push) Successful in 1m4s
Go Build Multi-Platform / build (arm64, darwin) (push) Successful in 58s
Go Build Multi-Platform / build (arm, linux) (push) Successful in 1m1s
Go Build Multi-Platform / build (arm64, windows) (push) Successful in 41s
Go Build Multi-Platform / build (arm64, freebsd) (push) Failing after 4m51s
Go Build Multi-Platform / build (arm, windows) (push) Failing after 4m53s
Go Build Multi-Platform / build (arm64, linux) (push) Failing after 4m49s
Go Build Multi-Platform / build (amd64, linux) (push) Failing after 4m57s
Go Build Multi-Platform / build (arm, freebsd) (push) Failing after 4m55s
Go Build Multi-Platform / build (amd64, darwin) (push) Failing after 4m59s
Go Build Multi-Platform / Create Release (push) Has been skipped
62 lines
1.4 KiB
Go
62 lines
1.4 KiB
Go
package main
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"git.quad4.io/Networks/Reticulum-Go/internal/config"
|
|
"git.quad4.io/Networks/Reticulum-Go/pkg/common"
|
|
)
|
|
|
|
func TestNewReticulum(t *testing.T) {
|
|
// Set up a temporary home directory for testing
|
|
tmpDir := t.TempDir()
|
|
originalHome := os.Getenv(common.STR_HOME)
|
|
os.Setenv(common.STR_HOME, tmpDir)
|
|
defer os.Setenv(common.STR_HOME, originalHome)
|
|
|
|
cfg := config.DefaultConfig()
|
|
// Disable interfaces for simple test
|
|
cfg.Interfaces = make(map[string]*common.InterfaceConfig)
|
|
|
|
r, err := NewReticulum(cfg)
|
|
if err != nil {
|
|
t.Fatalf("NewReticulum failed: %v", err)
|
|
}
|
|
if r == nil {
|
|
t.Fatal("NewReticulum returned nil")
|
|
}
|
|
|
|
if r.identity == nil {
|
|
t.Error("Reticulum identity should not be nil")
|
|
}
|
|
if r.destination == nil {
|
|
t.Error("Reticulum destination should not be nil")
|
|
}
|
|
|
|
// Verify directories were created
|
|
basePath := filepath.Join(tmpDir, ".reticulum-go")
|
|
if _, err := os.Stat(basePath); os.IsNotExist(err) {
|
|
t.Error("Base directory not created")
|
|
}
|
|
}
|
|
|
|
func TestNodeAppData(t *testing.T) {
|
|
tmpDir := t.TempDir()
|
|
os.Setenv(common.STR_HOME, tmpDir)
|
|
|
|
r := &Reticulum{
|
|
nodeEnabled: true,
|
|
maxTransferSize: common.NUM_500,
|
|
}
|
|
|
|
data := r.createNodeAppData()
|
|
if len(data) == common.ZERO {
|
|
t.Error("createNodeAppData returned empty data")
|
|
}
|
|
if data[0] != common.HEX_0x93 {
|
|
t.Errorf("Expected array header 0x93, got 0x%x", data[0])
|
|
}
|
|
}
|