feat: 补齐虚拟机验收并去掉 Docker 弱网占位
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
package accept
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"git.asio.asia/nixevol/NixMsg/test/harness"
|
||||
)
|
||||
|
||||
func TestF21BareTCPLoginSendRecvAck(t *testing.T) {
|
||||
srv, err := harness.Start(harness.Options{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer func() { _ = srv.Stop() }()
|
||||
|
||||
ac := AdminLogin(t, srv)
|
||||
const password = "password1234"
|
||||
CreateEndpoint(t, ac, "tcpalice1", password)
|
||||
CreateEndpoint(t, ac, "tcpbob001", password)
|
||||
|
||||
alice := MQTTLoginTCP(t, srv.Addr, "tcpalice1", password)
|
||||
defer alice.Close()
|
||||
bob := MQTTLoginTCP(t, srv.Addr, "tcpbob001", password)
|
||||
defer bob.Close()
|
||||
|
||||
send := alice.Request(t, map[string]any{
|
||||
"v": 1, "type": "send", "rid": "tcp1", "id": "tcp-msg-1",
|
||||
"to": map[string]any{"kind": "endpoint", "id": "tcpbob001"},
|
||||
"body": map[string]any{"enc": "utf8", "data": "over-tcp"},
|
||||
"delay_ms": int64(0),
|
||||
})
|
||||
if !send.OK {
|
||||
t.Fatalf("send: %+v", send)
|
||||
}
|
||||
msg := bob.WaitType(t, "msg", 15*time.Second)
|
||||
if msg["id"] != "tcp-msg-1" {
|
||||
t.Fatalf("msg: %v", msg)
|
||||
}
|
||||
ack := bob.Request(t, map[string]any{
|
||||
"v": 1, "type": "ack", "rid": "tcp2", "from": "tcpalice1", "id": "tcp-msg-1",
|
||||
})
|
||||
if !ack.OK {
|
||||
t.Fatalf("ack: %+v", ack)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user