Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 12 additions & 15 deletions udp/server_libcoap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,19 @@
import (
"bytes"
"errors"
"fmt"

Check failure on line 6 in udp/server_libcoap_test.go

View workflow job for this annotation

GitHub Actions / lint

File is not properly formatted (gci)
"math/rand"
"os/exec"
"strconv"
"sync"
"testing"

"github.com/plgd-dev/go-coap/v3/message"
"github.com/plgd-dev/go-coap/v3/message/codes"
"github.com/plgd-dev/go-coap/v3/mux"
coapNet "github.com/plgd-dev/go-coap/v3/net"
"github.com/plgd-dev/go-coap/v3/options"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"math/rand"
"os/exec"
"strconv"
"sync"
"testing"
)

func TestConnGetBlockwise(t *testing.T) {
Expand Down Expand Up @@ -76,7 +75,7 @@

err = m.Handle("/big", mux.HandlerFunc(func(w mux.ResponseWriter, r *mux.Message) {
assert.Equal(t, codes.GET, r.Code())
errS := w.SetResponse(codes.Content, message.AppOctets, bytes.NewReader([]byte(bigPayload10KiB)))
errS := w.SetResponse(codes.Content, message.AppOctets, bytes.NewReader(bigPayload10KiB))
require.NoError(t, errS)
require.NotEmpty(t, w.Conn())
require.Equal(t, message.Confirmable, r.Type())
Expand All @@ -92,7 +91,6 @@
errS := s.Serve(l)
assert.NoError(t, errS)
}()

cc, err := Dial(l.LocalAddr().String())
require.NoError(t, err)
defer func() {
Expand Down Expand Up @@ -233,7 +231,7 @@
wantCode: codes.Content,
wantErr: false,
useToken: true,
wantPayload: []byte(bigPayload10KiB),
wantPayload: bigPayload10KiB,
},
{
name: "block-post-without-token",
Expand All @@ -243,7 +241,7 @@
wantCode: codes.Content,
wantErr: false,
useToken: false,
wantPayload: []byte(bigPayload10KiB),
wantPayload: bigPayload10KiB,
},
}

Expand All @@ -267,7 +265,7 @@
err = m.Handle("/big", mux.HandlerFunc(func(w mux.ResponseWriter, r *mux.Message) {
assert.Equal(t, codes.POST, r.Code())
received, err2 := r.ReadBody()
errS := w.SetResponse(codes.Content, message.TextPlain, bytes.NewReader([]byte(bigPayload10KiB)))
errS := w.SetResponse(codes.Content, message.TextPlain, bytes.NewReader(bigPayload10KiB))
require.NoError(t, err2)
assert.Equal(t, bigPayload10KiB, received)
require.NoError(t, errS)
Expand Down Expand Up @@ -322,8 +320,7 @@
var args []string
args = append(args, "-m", method)
if token {
rand.Uint64()
args = append(args, "-T", strconv.FormatUint(rand.Uint64(), 10))
args = append(args, "-T", strconv.FormatUint(uint64(rand.Uint32()), 16))
}
if payload {
args = append(args, "-b", "1024")
Expand All @@ -347,7 +344,7 @@
return out.Bytes(), nil
}

const bigPayload10KiB = `89075337635954647102216077828334038179638965680796041208684221958292459041499210220101176726750119361506928946801115768179724
var bigPayload10KiB = []byte(`89075337635954647102216077828334038179638965680796041208684221958292459041499210220101176726750119361506928946801115768179724
42244632672758898527798766326186965189573496725417576843236332384515325066967967084729236662659424427203830789178855960389888
59671607161000645588293584669984665020199777828148967747970527020608102921980556435899241646582421992569038754973449362160805
31239955776017464552148435666505635723861800404618684226812752076597749931057757306056294943547000781262839809899923354086591
Expand Down Expand Up @@ -428,4 +425,4 @@
91655282321189488943674583928812971734718557687261267540861951330156857260194972959320584575281425950364513866555614168110966
87585502488315874658362449099439868192063303681917995993161431685969345689815394695246096186072665320424126902383281639806078
13897268972795607841085430069511881664533488909312510299548807790607510574162189448464719710343594178873230685172521870698370
6337814198009624212201025856162445`
6337814198009624212201025856162445`)
Loading