-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompress_test.go
100 lines (86 loc) · 4.39 KB
/
compress_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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
package rpc25519
import (
//"bytes"
//cryrand "crypto/rand"
"fmt"
//"net"
"testing"
//"time"
cv "github.com/glycerine/goconvey/convey"
)
var _ = fmt.Printf
func Test030_compress_inverses(t *testing.T) {
cv.Convey("compress.go pressor and decomp should be inverses", t, func() {
p := newPressor(1000)
d := newDecomp(1000)
orig := testData0 // append([]byte("hello rpc25519 world!"), make([]byte, 300)...)
bytesMsg := append([]byte{}, orig...)
//for _, magic7 := range []byte{1} {
for _, magic7 := range []magic7b{0, 1, 2, 3, 4, 5, 6} {
nm, err := decodeMagic7(magic7)
_ = nm
panicOn(err)
msg1, err := p.handleCompress(magic7, bytesMsg)
panicOn(err)
//vv("%v compressed from %v -> %v bytes", nm, len(orig), len(msg1))
//vv("compressed msg1 = '%v'", string(msg1))
// s2 compressed from 288 -> 271 bytes
msg2, err := d.handleDecompress(magic7, msg1)
panicOn(err)
//vv("msg2 = '%v'", string(msg2))
if string(msg2) != string(orig) {
panic("compress output did not decompress to the same")
}
}
})
}
var testData0 = []byte{
0x82, 0xad, 0x48, 0x44, 0x52, 0x5f, 0x7a, 0x69, 0x64, 0x30, 0x30, 0x5f,
0x72, 0x63, 0x74, 0x88, 0xb1, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64,
0x5f, 0x7a, 0x69, 0x64, 0x30, 0x30, 0x5f, 0x74, 0x69, 0x6d, 0xc7, 0xc,
0x5, 0x0, 0x0, 0x0, 0x0, 0x67, 0x81, 0x95, 0x6a, 0xc, 0x60, 0xa7,
0xc8, 0xae, 0x46, 0x72, 0x6f, 0x6d, 0x5f, 0x7a, 0x69, 0x64, 0x30, 0x31,
0x5f, 0x73, 0x74, 0x72, 0xb5, 0x75, 0x64, 0x70, 0x3a, 0x2f, 0x2f, 0x31,
0x32, 0x37, 0x2e, 0x30, 0x2e, 0x30, 0x2e, 0x31, 0x3a, 0x36, 0x34, 0x39,
0x39, 0x32, 0xac, 0x54, 0x6f, 0x5f, 0x7a, 0x69, 0x64, 0x30, 0x32, 0x5f,
0x73, 0x74, 0x72, 0xb5, 0x75, 0x64, 0x70, 0x3a, 0x2f, 0x2f, 0x31, 0x32,
0x37, 0x2e, 0x30, 0x2e, 0x30, 0x2e, 0x31, 0x3a, 0x36, 0x34, 0x39, 0x39,
0x32, 0xaf, 0x53, 0x65, 0x71, 0x6e, 0x6f, 0x5f, 0x7a, 0x69, 0x64, 0x30,
0x34, 0x5f, 0x75, 0x36, 0x34, 0x2, 0xad, 0x54, 0x79, 0x70, 0x5f, 0x7a,
0x69, 0x64, 0x30, 0x35, 0x5f, 0x72, 0x63, 0x74, 0x1, 0xb0, 0x43, 0x61,
0x6c, 0x6c, 0x49, 0x44, 0x5f, 0x7a, 0x69, 0x64, 0x30, 0x36, 0x5f, 0x73,
0x74, 0x72, 0xbc, 0x37, 0x50, 0x72, 0x4a, 0x68, 0x73, 0x38, 0x49, 0x33,
0x31, 0x30, 0x32, 0x76, 0x78, 0x7a, 0x66, 0x43, 0x49, 0x78, 0x59, 0x34,
0x32, 0x49, 0x41, 0x59, 0x32, 0x77, 0x3d, 0xb0, 0x53, 0x65, 0x72, 0x69,
0x61, 0x6c, 0x5f, 0x7a, 0x69, 0x64, 0x30, 0x37, 0x5f, 0x69, 0x36, 0x34,
0x1, 0xb5, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4e, 0x61, 0x6d,
0x65, 0x5f, 0x7a, 0x69, 0x64, 0x31, 0x31, 0x5f, 0x73, 0x74, 0x72, 0xaa,
0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x45, 0x63, 0x68, 0x6f, 0xb1, 0x4a,
0x6f, 0x62, 0x53, 0x65, 0x72, 0x7a, 0x5f, 0x7a, 0x69, 0x64, 0x30, 0x31,
0x5f, 0x62, 0x69, 0x6e, 0xc4, 0x12, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x20,
0x66, 0x72, 0x6f, 0x6d, 0x20, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x21}
var testData_S2_compressed = []byte{
0xff, 0x6, 0x0, 0x0, 0x53, 0x32, 0x73, 0x54, 0x77, 0x4f, 0x0, 0x1,
0x1, 0x0, 0xd1, 0x91, 0x15, 0xa3, 0xa0, 0x2, 0x5c, 0x82, 0xad, 0x48,
0x44, 0x52, 0x5f, 0x7a, 0x69, 0x64, 0x30, 0x30, 0x5f, 0x72, 0x63, 0x74,
0x88, 0xb1, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0xd, 0x13, 0x58,
0x74, 0x69, 0x6d, 0xc7, 0xc, 0x5, 0x0, 0x0, 0x0, 0x0, 0x67, 0x81,
0x95, 0x6a, 0xc, 0x60, 0xa7, 0xc8, 0xae, 0x46, 0x72, 0x6f, 0x6d, 0x5,
0x1e, 0x8c, 0x31, 0x5f, 0x73, 0x74, 0x72, 0xb5, 0x75, 0x64, 0x70, 0x3a,
0x2f, 0x2f, 0x31, 0x32, 0x37, 0x2e, 0x30, 0x2e, 0x30, 0x2e, 0x31, 0x3a,
0x36, 0x34, 0x39, 0x39, 0x32, 0xac, 0x54, 0x6f, 0x5f, 0x7a, 0x69, 0x64,
0x30, 0x32, 0x66, 0x23, 0x0, 0x10, 0xaf, 0x53, 0x65, 0x71, 0x6e, 0x9,
0x26, 0x24, 0x34, 0x5f, 0x75, 0x36, 0x34, 0x2, 0xad, 0x54, 0x79, 0x70,
0x5, 0x58, 0x0, 0x35, 0x1, 0x89, 0x1c, 0x1, 0xb0, 0x43, 0x61, 0x6c,
0x6c, 0x49, 0x44, 0x5, 0x12, 0x0, 0x36, 0x1, 0x6a, 0xf0, 0x40, 0xbc,
0x37, 0x50, 0x72, 0x4a, 0x68, 0x73, 0x38, 0x49, 0x33, 0x31, 0x30, 0x32,
0x76, 0x78, 0x7a, 0x66, 0x43, 0x49, 0x78, 0x59, 0x34, 0x32, 0x49, 0x41,
0x59, 0x32, 0x77, 0x3d, 0xb0, 0x53, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x5f,
0x7a, 0x69, 0x64, 0x30, 0x37, 0x5f, 0x69, 0x36, 0x34, 0x1, 0xb5, 0x53,
0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x5f, 0x7a,
0x69, 0x64, 0x31, 0x31, 0x1, 0x45, 0x48, 0xaa, 0x63, 0x75, 0x73, 0x74,
0x6f, 0x6d, 0x45, 0x63, 0x68, 0x6f, 0xb1, 0x4a, 0x6f, 0x62, 0x53, 0x65,
0x72, 0x7a, 0x1, 0x1d, 0x64, 0x30, 0x31, 0x5f, 0x62, 0x69, 0x6e, 0xc4,
0x12, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x20, 0x66, 0x72, 0x6f, 0x6d, 0x20,
0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x21,
}