fix: scope server pins by port (fumi-core rev 1468f3c)

This commit is contained in:
randogoth 2026-09-30 08:52:57 +03:00
parent 996e879509
commit 7d2a147fec
16 changed files with 109 additions and 79 deletions

View file

@ -11,6 +11,7 @@ import "package:flutter_test/flutter_test.dart";
import "package:smol_mail/native/client.dart";
import "package:smol_mail/native/ffi.dart";
import "package:smol_mail/smol/address.dart";
const spikeServerKey = "wukbhdiwboarbg4pujxstbqi3caveunrruaopbwxr226ga3xv5ga";
const spikeServer = "127.0.0.1";
@ -39,7 +40,9 @@ void main() async {
expect(await client.accountAddress(), isNull);
// A pinned but dead host fails by code, never by prose: Unreachable (7).
await client.pinServer("127.0.0.1", spikeServerKey);
// The pin is scoped to the dead port itself — a default-port pin would
// not cover it, and the register would fail NotPinned instead.
await client.pinServer("127.0.0.1", spikeServerKey, 19629);
client.setMaster(Uint8List.fromList(List.filled(32, 9)));
try {
await client.register("nobody@127.0.0.1:19629");
@ -63,7 +66,7 @@ void main() async {
final mine = FumiNative("${dir.path}/mine.db");
await mine.open();
mine.setMaster(master);
await mine.pinServer("example.org", spikeServerKey);
await mine.pinServer("example.org", spikeServerKey, defaultPort);
await mine.importContact(
"smol://alice@example.org/ayb6y3mwr3cfkcmcaqbn3cgfi6xsrsoqkalykw5s7oqmwqcpnmsq");
@ -76,7 +79,7 @@ void main() async {
as Map<String, dynamic>;
expect(summary["contactsAdded"], 1);
expect(summary["pinsAdded"], 1);
expect(await restored.serverPin("example.org"), spikeServerKey);
expect(await restored.serverPin("example.org", defaultPort), spikeServerKey);
await mine.close();
await restored.close();
@ -98,14 +101,14 @@ void main() async {
final alice = FumiNative("${dir.path}/alice.db");
await alice.open();
alice.setMaster(aliceMaster);
await alice.pinServer(spikeServer, spikeServerKey);
await alice.pinServer(spikeServer, spikeServerKey, spikePort);
await alice.register("a$run@$spikeServer:$spikePort");
expect(await alice.accountAddress(), "a$run@$spikeServer:$spikePort");
final bob = FumiNative("${dir.path}/bob.db");
await bob.open();
bob.setMaster(bobMaster);
await bob.pinServer(spikeServer, spikeServerKey);
await bob.pinServer(spikeServer, spikeServerKey, spikePort);
await bob.register("b$run@$spikeServer:$spikePort");
final sent = await alice.send("b$run@$spikeServer:$spikePort",
@ -147,7 +150,7 @@ void main() async {
final alice = FumiNative("${dir.path}/alice.db");
await alice.open();
alice.setMaster(aliceMaster);
await alice.pinServer(spikeServer, spikeServerKey);
await alice.pinServer(spikeServer, spikeServerKey, spikePort);
await alice.register("a$run@$spikeServer:$spikePort");
final bob = FumiNative("${dir.path}/bob.db");
@ -156,7 +159,7 @@ void main() async {
// The onboarding screen zeroes its own master reference on dispose;
// whatever holds the master after that must not share that buffer.
bobMaster.fillRange(0, 32, 0);
await bob.pinServer(spikeServer, spikeServerKey);
await bob.pinServer(spikeServer, spikeServerKey, spikePort);
await bob.register("b$run@$spikeServer:$spikePort");
await alice.send("b$run@$spikeServer:$spikePort",