-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhdr_test.go
63 lines (48 loc) · 1.42 KB
/
hdr_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package rpc25519
import (
"testing"
cv "github.com/glycerine/goconvey/convey"
)
func Test010_HDR_generation(t *testing.T) {
cv.Convey("A HDR should look nice in both String() and JSON() output", t, func() {
from := "client"
to := "server"
subject := "myRPC_call_name()"
//isRPC := true
//isLeg2 := false
// call:
hdr := NewHDR(from, to, subject, CallRPC, 0)
shdr := hdr.String()
jhdr := hdr.JSON()
vv("shdr = '%v'", shdr)
vv("jhdr = '%v'", string(jhdr))
// response:
hdr2 := NewHDR(to, from, subject, CallRPC, 0)
shdr2 := hdr2.String()
jhdr2 := hdr2.JSON()
vv("shdr2 = '%v'", shdr2)
vv("jhdr2 = '%v'", string(jhdr2))
//friendly := hdr2.OpaqueURLFriendly()
//vv("friendly = '%v'", friendly)
//hdr2back, err := HDRFromOpaqueURLFriendly(friendly)
//panicOn(err)
//vv("hdr2back = '%v'", hdr2back)
//vv("hdr2 = '%v'", hdr2)
//cv.So(hdr2back.Equal(hdr2), cv.ShouldBeTrue)
//vv("back from friendly: '%v'", hdr2back.String())
//vv("pretty: '%v'", hdr2back.Pretty())
// json serz
by1 := hdr.Bytes()
un1 := Unbytes(by1)
cv.So(un1.Equal(hdr), cv.ShouldBeTrue)
// greenpack serz
cfg := &Config{}
pair := &rwPair{}
w := newWorkspace("hdr_test", 4096, true, cfg, pair, nil) // max possible message len, to pre-allocate memory.
green, err := hdr.AsGreenpack(w.buf)
panicOn(err)
hdr3, err := HDRFromGreenpack(green)
panicOn(err)
cv.So(hdr3.Equal(hdr), cv.ShouldBeTrue)
})
}