@pumpkin-plugins/port-mapping API / testing/fake-network / FakeNetwork
Class: FakeNetwork
Defined in: tools/port-mapping/src/testing/fake-network.ts:94
A network in memory for tests: a clock you move by hand and routers (FakeIgd) that answer on it. Datagrams reach every router; connections reach the router whose address and HTTP port match.
Implements
Constructors
Constructor
new FakeNetwork(
routers?):FakeNetwork
Defined in: tools/port-mapping/src/testing/fake-network.ts:103
Creates a network with the given routers.
Parameters
routers?
FakeIgd[] = []
Returns
FakeNetwork
Properties
autoAdvanceMs
autoAdvanceMs:
number=0
Defined in: tools/port-mapping/src/testing/fake-network.ts:106
How far the clock moves each time it is read, for code that waits on it in a loop.
local
local:
Ipv4|undefined
Defined in: tools/port-mapping/src/testing/fake-network.ts:97
This machine's address. Undefined means no route.
Accessors
leaks
Get Signature
get leaks():
number
Defined in: tools/port-mapping/src/testing/fake-network.ts:146
Sockets and connections that were opened and never closed.
Returns
number
Methods
dial()
dial(
to):Dial
Defined in: tools/port-mapping/src/testing/fake-network.ts:129
Starts a TCP connection.
Parameters
to
Returns
Implementation of
localAddress()
localAddress():
Ipv4|undefined
Defined in: tools/port-mapping/src/testing/fake-network.ts:119
The address this machine uses to reach toward, or the internet when that is omitted.
Returns
Ipv4 | undefined
The address, or undefined when there is no route.
Implementation of
now()
now():
number
Defined in: tools/port-mapping/src/testing/fake-network.ts:108
The current time in milliseconds.
Returns
number
Implementation of
openDatagram()
openDatagram():
DatagramSocket
Defined in: tools/port-mapping/src/testing/fake-network.ts:123
Opens a UDP socket bound to any free port.
Returns
Implementation of
pause()
pause(
ms):void
Defined in: tools/port-mapping/src/testing/fake-network.ts:115
Moves the clock on by ms, as if the caller had blocked that long.
Parameters
ms
number
Returns
void