-
Notifications
You must be signed in to change notification settings - Fork 0
/
lib_test.go
46 lines (39 loc) · 1.47 KB
/
lib_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
package negentropy
import (
"fmt"
"log"
"testing"
)
func TestIfItRuns(t *testing.T) {
na := NewNegentropy(50_000)
na.Storage.Insert(0, [ID_SIZE]byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0})
na.Storage.Insert(1, [ID_SIZE]byte{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0})
na.Storage.Insert(3, [ID_SIZE]byte{3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0})
na.Storage.Seal()
nb := NewNegentropy(50_000)
nb.Storage.Insert(0, [ID_SIZE]byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0})
nb.Storage.Insert(1, [ID_SIZE]byte{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0})
nb.Storage.Insert(2, [ID_SIZE]byte{2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0})
nb.Storage.Insert(3, [ID_SIZE]byte{3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0})
nb.Storage.Seal()
msg1, err := na.Initiate()
if err != nil {
log.Fatal(err)
return
}
msg2, have, want, err := nb.Reconcile(msg1)
if err != nil {
log.Fatal(err)
return
}
fmt.Println("have", have)
fmt.Println("want", want)
msg3, have, want, err := na.Reconcile(msg2)
if err != nil {
log.Fatal(err)
return
}
fmt.Println("have", have)
fmt.Println("want", want)
fmt.Println(msg3)
}