feat: refactor core+network+protocol: use platform abstractions,
transport vtable
This commit is contained in:
@@ -3,6 +3,7 @@ const std = @import("std");
|
||||
const protocol = @import("protocol.zig");
|
||||
const message = @import("message.zig");
|
||||
const crypto = @import("crypto.zig");
|
||||
const platform_time = @import("platform").time;
|
||||
|
||||
/// Helper to read little-endian integers from buffer slices
|
||||
fn readLittle(comptime T: type, buf: []const u8) T {
|
||||
@@ -702,7 +703,7 @@ pub const MessageSerializer = struct {
|
||||
.id = id,
|
||||
.source = self.local_peer_id,
|
||||
.dest = self.peer_id,
|
||||
.timestamp = std.time.timestamp(),
|
||||
.timestamp = platform_time.timestamp(),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1930,7 +1931,7 @@ test "key exchange messages are not encrypted" {
|
||||
const signature = [_]u8{0xAA} ** 64;
|
||||
const identity_key = [_]u8{0xBB} ** 32;
|
||||
const session_nonce = [_]u8{0xCC} ** 32;
|
||||
const timestamp = std.time.timestamp();
|
||||
const timestamp = platform_time.timestamp();
|
||||
const key_exchange = message.KeyExchangeInit.init(public_key, signature, identity_key, session_nonce, timestamp);
|
||||
const msg = message.Message{ .key_exchange_init = key_exchange };
|
||||
|
||||
@@ -2334,7 +2335,7 @@ test "key exchange response serialization roundtrip" {
|
||||
const signature = [_]u8{0x22} ** 64;
|
||||
const identity_key = [_]u8{0x33} ** 32;
|
||||
const initiator_nonce = [_]u8{0x44} ** 32;
|
||||
const timestamp = std.time.timestamp();
|
||||
const timestamp = platform_time.timestamp();
|
||||
const key_resp = message.KeyExchangeResponse.init(public_key, signature, identity_key, timestamp, initiator_nonce);
|
||||
const msg = message.Message{ .key_exchange_response = key_resp };
|
||||
|
||||
|
||||
Reference in New Issue
Block a user