wip: testing and cleanup
This commit is contained in:
parent
8dbccaa3e6
commit
d78d704a45
@ -10,7 +10,6 @@ import (
|
|||||||
type controlMsg[T any] struct {
|
type controlMsg[T any] struct {
|
||||||
SrcIP byte
|
SrcIP byte
|
||||||
SrcAddr netip.AddrPort
|
SrcAddr netip.AddrPort
|
||||||
// TODO: RecvdAt int64 // Unixmilli.
|
|
||||||
Packet T
|
Packet T
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,15 +33,6 @@ func TestPeerState_OnPeerUpdate_publicLocalIsServer(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
func TestPeerState_OnPeerUpdate_serverDirect(t *testing.T) {
|
|
||||||
h := NewPeerStateTestHarness()
|
|
||||||
h.ConfigServer_Public(t)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestPeerState_OnPeerUpdate_serverRelayed(t *testing.T) {
|
|
||||||
h := NewPeerStateTestHarness()
|
|
||||||
h.ConfigServer_Relayed(t)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestPeerState_OnPeerUpdate_clientDirect(t *testing.T) {
|
func TestPeerState_OnPeerUpdate_clientDirect(t *testing.T) {
|
||||||
h := NewPeerStateTestHarness()
|
h := NewPeerStateTestHarness()
|
||||||
|
32
peer/state-server_test.go
Normal file
32
peer/state-server_test.go
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
package peer
|
||||||
|
|
||||||
|
import "testing"
|
||||||
|
|
||||||
|
func TestStateServer_peerUpdate(t *testing.T) {
|
||||||
|
h := NewPeerStateTestHarness()
|
||||||
|
h.ConfigServer_Public(t)
|
||||||
|
h.PeerUpdate(nil)
|
||||||
|
assertType[*stateDisconnected](t, h.State)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestStateServer_onInit(t *testing.T) {
|
||||||
|
h := NewPeerStateTestHarness()
|
||||||
|
h.ConfigServer_Public(t)
|
||||||
|
|
||||||
|
msg := controlMsg[packetInit]{
|
||||||
|
SrcIP: 3,
|
||||||
|
SrcAddr: addrPort4(1, 2, 3, 4, 1000),
|
||||||
|
Packet: packetInit{
|
||||||
|
TraceID: newTraceID(),
|
||||||
|
Direct: true,
|
||||||
|
Version: 4,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
h.OnInit(msg)
|
||||||
|
assertEqual(t, len(h.Sent), 1)
|
||||||
|
assertEqual(t, h.Sent[0].Peer.DirectAddr, msg.SrcAddr)
|
||||||
|
resp := assertType[packetInit](t, h.Sent[0].Packet)
|
||||||
|
assertEqual(t, msg.Packet.TraceID, resp.TraceID)
|
||||||
|
assertEqual(t, resp.Version, version)
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user