-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhasq_simple_test.go
More file actions
41 lines (37 loc) · 850 Bytes
/
hasq_simple_test.go
File metadata and controls
41 lines (37 loc) · 850 Bytes
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
package hashq_mod
import (
"os"
"testing"
)
func TestMemoryHashSequence_Add(t *testing.T) {
sequence := NewMemoryHashSequence()
tok := NewToken("DATA")
sequence.Add(tok.Next())
sequence.Add(tok.Next())
sequence.Add(tok.Next())
if sequence.Length() != 3 {
t.Fatal("Sequence not have three elements")
}
}
func TestServer_Create(t *testing.T) {
address := "127.0.0.1:59090"
sc := NewSimpleClient(address)
defer sc.Close()
c := NewClient()
tokenHash := c.NewToken("SIMPLE_TOKEN")
hash := c.AddHash(tokenHash)
verified := sc.CreateHash(hash)
if !verified {
t.Error("Error create first hash")
}
hash = c.AddHash(tokenHash)
verified = sc.CreateHash(hash)
if !verified {
t.Error("Error create second hash")
}
}
func TestMain(m *testing.M) {
store := NewStore()
go StartService("127.0.0.1:59090", &store)
os.Exit(m.Run())
}