update statuscode
All checks were successful
Build and Publish / BuildAndDeployAmd64 (push) Successful in 27s
Build and Publish / BuildAndDeploy (push) Successful in 2m20s

This commit is contained in:
matst80
2024-11-13 22:14:04 +01:00
parent 2539a05b71
commit 9e87351681
2 changed files with 10 additions and 3 deletions

View File

@@ -44,9 +44,9 @@ func MakeFrameWithPayload(msg FrameType, statusCode StatusCode, payload []byte)
return FrameWithPayload{ return FrameWithPayload{
Frame: Frame{ Frame: Frame{
Type: msg, Type: msg,
StatusCode: 0, StatusCode: statusCode,
Length: len, Length: len,
Checksum: MakeChecksum(msg, 0, len), Checksum: MakeChecksum(msg, statusCode, len),
}, },
Payload: payload, Payload: payload,
} }

View File

@@ -9,8 +9,11 @@ func TestGenericConnection(t *testing.T) {
t.Errorf("Error listening: %v\n", err) t.Errorf("Error listening: %v\n", err)
} }
datta := []byte("Hello, world!") datta := []byte("Hello, world!")
listener.AddHandler(Ping, func(input *FrameWithPayload, resultChan chan<- FrameWithPayload) error {
resultChan <- MakeFrameWithPayload(Pong, 200, nil)
return nil
})
listener.AddHandler(1, func(input *FrameWithPayload, resultChan chan<- FrameWithPayload) error { listener.AddHandler(1, func(input *FrameWithPayload, resultChan chan<- FrameWithPayload) error {
resultChan <- MakeFrameWithPayload(2, 200, datta) resultChan <- MakeFrameWithPayload(2, 200, datta)
return nil return nil
}) })
@@ -21,6 +24,10 @@ func TestGenericConnection(t *testing.T) {
if r.Type != 2 { if r.Type != 2 {
t.Errorf("Expected type 2, got %d\n", r.Type) t.Errorf("Expected type 2, got %d\n", r.Type)
} }
response, err := conn.Call(Ping, nil)
if err != nil || response.StatusCode != 200 || response.Type != Pong {
t.Errorf("Error connecting to remote %v\n", response)
}
i := 100 i := 100
results := make(chan FrameWithPayload, i) results := make(chan FrameWithPayload, i)
for i > 0 { for i > 0 {