mirror of
https://github.com/Quad4-Software/Reticulum-Go
synced 2026-08-29 23:48:44 -04:00
42 lines
1.3 KiB
Zig
42 lines
1.3 KiB
Zig
// SPDX-License-Identifier: Apache-2.0
|
|
// Copyright (c) 2024-2026 Quad4.io
|
|
|
|
const std = @import("std");
|
|
const rns = @import("rns");
|
|
const testing = std.testing;
|
|
const helpers = @import("helpers.zig");
|
|
|
|
test "destination create announce hash" {
|
|
const port = try helpers.freeUdpPort();
|
|
|
|
var tmp = testing.tmpDir(.{});
|
|
defer tmp.cleanup();
|
|
try helpers.writeUdpPeerConfig(tmp.dir, port, port);
|
|
|
|
const cfg = try helpers.configPath(tmp, testing.allocator);
|
|
defer testing.allocator.free(cfg);
|
|
|
|
const node = try rns.nodeCreate(cfg);
|
|
defer rns.nodeDestroy(node) catch {};
|
|
|
|
const id = try rns.identityGenerate();
|
|
defer rns.identityDestroy(id) catch {};
|
|
|
|
try rns.nodeSetIdentity(node, id);
|
|
try rns.nodeStart(node);
|
|
defer rns.nodeStop(node) catch {};
|
|
|
|
const dest = try rns.destinationCreate(node, @enumFromInt(0), "zig-rns", &.{"chat"}, true);
|
|
defer rns.destinationDestroy(dest) catch {};
|
|
|
|
try rns.destinationAnnounce(dest, "hello");
|
|
|
|
const hash = try rns.destinationHash(dest);
|
|
try testing.expectEqual(@as(usize, rns.hash_len), hash.len);
|
|
|
|
var entries: [8]rns.PathEntry = undefined;
|
|
_ = rns.pathTable(node, &entries, -1) catch |err| switch (err) {
|
|
error.NotFound => {},
|
|
else => return err,
|
|
};
|
|
}
|