This repository has been archived by the owner on Sep 15, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 143
/
action_update_test.go
53 lines (44 loc) · 1.7 KB
/
action_update_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
package holochain
import (
peer "github.com/libp2p/go-libp2p-peer"
. "github.com/smartystreets/goconvey/convey"
"testing"
)
func TestSysValidateMod(t *testing.T) {
d, _, h := PrepareTestChain("test")
defer CleanupTestChain(h, d)
hash := commit(h, "evenNumbers", "2")
_, def, _ := h.GetEntryDef("evenNumbers")
/* This is actually bogus because it assumes we have the entry type in our chain but
might be in a different chain.
Convey("it should check that entry types match on mod", t, func() {
a := NewModAction("oddNumbers", &GobEntry{}, hash)
err := a.SysValidation(h, def, nil, []peer.ID{h.nodeID})
So(err, ShouldEqual, ErrEntryTypeMismatch)
})
*/
Convey("it should check that entry isn't linking ", t, func() {
a := NewModAction("rating", &GobEntry{}, hash)
_, ratingsDef, _ := h.GetEntryDef("rating")
err := a.SysValidation(h, ratingsDef, nil, []peer.ID{h.nodeID})
So(err, ShouldEqual, ErrModInvalidForLinks)
})
Convey("it should check that entry validates", t, func() {
a := NewModAction("evenNumbers", nil, hash)
err := a.SysValidation(h, def, nil, []peer.ID{h.nodeID})
So(err, ShouldEqual, ErrNilEntryInvalid)
})
Convey("it should check that header isn't missing", t, func() {
a := NewModAction("evenNumbers", &GobEntry{}, hash)
err := a.SysValidation(h, def, nil, []peer.ID{h.nodeID})
So(err, ShouldBeError)
So(err, ShouldEqual, ErrModMissingHeader)
})
Convey("it should check that replaces is doesn't make a loop", t, func() {
a := NewModAction("evenNumbers", &GobEntry{}, hash)
a.header = &Header{EntryLink: hash}
err := a.SysValidation(h, def, nil, []peer.ID{h.nodeID})
So(err, ShouldBeError)
So(err, ShouldEqual, ErrModReplacesHashNotDifferent)
})
}