diff --git a/pkg/autoconfig/src/router.ts b/pkg/autoconfig/src/router.ts index 36039f5f..88afe636 100644 --- a/pkg/autoconfig/src/router.ts +++ b/pkg/autoconfig/src/router.ts @@ -1,4 +1,4 @@ -import { Endpoint } from "@ndn/endpoint"; +import { consume, type ConsumerOptions } from "@ndn/endpoint"; import { type Forwarder, type FwFace, TapFace } from "@ndn/fw"; import { Interest, Name, type NameLike } from "@ndn/packet"; import type { H3Transport } from "@ndn/quic-transport"; @@ -121,15 +121,15 @@ async function testConnection( const tapFace = TapFace.create(face); tapFace.addRoute("/"); const abort = new AbortController(); + const cOpts: ConsumerOptions = { fw: tapFace.fw, signal: abort.signal }; try { - const endpoint = new Endpoint({ fw: tapFace.fw, signal: abort.signal }); await Promise.any(tc.map((pkt) => { if (typeof pkt === "string" && pkt.endsWith("/*")) { pkt = new Name(pkt.slice(0, -2)).append(Math.trunc(Math.random() * 1e8).toString().padStart(8, "0")); } const interest = pkt instanceof Interest ? pkt : new Interest(pkt, Interest.CanBePrefix, Interest.Lifetime(testConnectionTimeout)); - return endpoint.consume(interest); + return consume(interest, cOpts); })); } finally { abort.abort(); diff --git a/pkg/autoconfig/tests/network.t.ts b/pkg/autoconfig/tests/network.t.ts index 7d4ee7cb..517b7145 100644 --- a/pkg/autoconfig/tests/network.t.ts +++ b/pkg/autoconfig/tests/network.t.ts @@ -1,4 +1,4 @@ -import { Endpoint } from "@ndn/endpoint"; +import { produce } from "@ndn/endpoint"; import { Forwarder, type FwFace } from "@ndn/fw"; import { UdpServer, UdpServerForwarder } from "@ndn/node-transport/test-fixture/udp-server"; import { Data, Name } from "@ndn/packet"; @@ -17,10 +17,10 @@ afterEach(() => { async function addServerWithDelayProducer(delayDuration: number): Promise { const server = await UdpServer.create(UdpServerForwarder); - const producer = new Endpoint({ fw: server.fw }).produce("/localhop/test-connection", async (interest) => { + const producer = produce("/localhop/test-connection", async (interest) => { await delay(delayDuration); return new Data(interest.name); - }); + }, { fw: server.fw }); closers.push(server, producer); return server.hostport; }