Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Kirill Smelkov
neo
Commits
ec54f600
Commit
ec54f600
authored
Aug 24, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
fccafbfe
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
16 deletions
+25
-16
go/neo/client/cache_test.go
go/neo/client/cache_test.go
+25
-16
No files found.
go/neo/client/cache_test.go
View file @
ec54f600
...
@@ -20,6 +20,7 @@
...
@@ -20,6 +20,7 @@
package
client
package
client
import
(
import
(
"bytes"
"fmt"
"fmt"
"reflect"
"reflect"
"sort"
"sort"
...
@@ -95,6 +96,9 @@ func xideq(oid zodb.Oid, tid zodb.Tid) zodb.Xid {
...
@@ -95,6 +96,9 @@ func xideq(oid zodb.Oid, tid zodb.Tid) zodb.Xid {
}
}
func
TestCache
(
t
*
testing
.
T
)
{
func
TestCache
(
t
*
testing
.
T
)
{
// XXX hack; place=ok?
pretty
.
CompareConfig
.
PrintStringers
=
true
// XXX <100 <90 <80
// XXX <100 <90 <80
// q<110 -> a) 110 <= cache.before b) otherwise
// q<110 -> a) 110 <= cache.before b) otherwise
// q<85 -> a) inside 90.serial..90 b) outside
// q<85 -> a) inside 90.serial..90 b) outside
...
@@ -112,15 +116,27 @@ func TestCache(t *testing.T) {
...
@@ -112,15 +116,27 @@ func TestCache(t *testing.T) {
c
:=
NewCache
(
tstor
)
c
:=
NewCache
(
tstor
)
// XXX hack; place=ok?
checkLoad
:=
func
(
xid
zodb
.
Xid
,
data
[]
byte
,
serial
zodb
.
Tid
,
err
error
)
{
pretty
.
CompareConfig
.
PrintStringers
=
true
t
.
Helper
()
bad
:=
&
bytes
.
Buffer
{}
d
,
s
,
e
:=
c
.
Load
(
xid
)
if
!
reflect
.
DeepEqual
(
data
,
d
)
{
fmt
.
Fprintf
(
bad
,
"data:
\n
%s"
,
pretty
.
Compare
(
data
,
d
))
}
if
serial
!=
s
{
fmt
.
Fprintf
(
bad
,
"serial:
\n
%s"
,
pretty
.
Compare
(
serial
,
s
))
}
if
!
reflect
.
DeepEqual
(
err
,
e
)
{
fmt
.
Fprintf
(
bad
,
"err:
\n
%s"
,
pretty
.
Compare
(
err
,
e
))
}
if
bad
.
Len
()
!=
0
{
t
.
Fatalf
(
"load(%v):
\n
%s"
,
xid
,
bad
.
Bytes
())
}
}
// load <3 -> new rce entry
// load <3 -> new rce entry
// XXX vvv -> checkLoad()
checkLoad
(
xidlt
(
1
,
3
),
nil
,
0
,
&
zodb
.
ErrXidMissing
{
xidlt
(
1
,
3
)})
data
,
serial
,
err
:=
c
.
Load
(
xidlt
(
1
,
3
))
ok1
(
data
==
nil
)
ok1
(
serial
==
0
)
eq
(
err
,
&
zodb
.
ErrXidMissing
{
xidlt
(
1
,
3
)})
oce1
:=
c
.
entryMap
[
1
]
oce1
:=
c
.
entryMap
[
1
]
ok1
(
len
(
oce1
.
revv
)
==
1
)
ok1
(
len
(
oce1
.
revv
)
==
1
)
...
@@ -131,10 +147,7 @@ func TestCache(t *testing.T) {
...
@@ -131,10 +147,7 @@ func TestCache(t *testing.T) {
eq
(
rce1_b3
.
err
,
&
zodb
.
ErrXidMissing
{
xidlt
(
1
,
3
)})
eq
(
rce1_b3
.
err
,
&
zodb
.
ErrXidMissing
{
xidlt
(
1
,
3
)})
// load <4 -> <3 merged with <4
// load <4 -> <3 merged with <4
data
,
serial
,
err
=
c
.
Load
(
xidlt
(
1
,
4
))
checkLoad
(
xidlt
(
1
,
4
),
nil
,
0
,
&
zodb
.
ErrXidMissing
{
xidlt
(
1
,
4
)})
ok1
(
data
==
nil
)
ok1
(
serial
==
0
)
eq
(
err
,
&
zodb
.
ErrXidMissing
{
xidlt
(
1
,
4
)})
ok1
(
len
(
oce1
.
revv
)
==
1
)
ok1
(
len
(
oce1
.
revv
)
==
1
)
rce1_b4
:=
oce1
.
revv
[
0
]
rce1_b4
:=
oce1
.
revv
[
0
]
...
@@ -144,11 +157,7 @@ func TestCache(t *testing.T) {
...
@@ -144,11 +157,7 @@ func TestCache(t *testing.T) {
eq
(
rce1_b4
.
err
,
&
zodb
.
ErrXidMissing
{
xidlt
(
1
,
4
)})
eq
(
rce1_b4
.
err
,
&
zodb
.
ErrXidMissing
{
xidlt
(
1
,
4
)})
// load <2 -> <2 merged with <4
// load <2 -> <2 merged with <4
data
,
serial
,
err
=
c
.
Load
(
xidlt
(
1
,
2
))
checkLoad
(
xidlt
(
1
,
2
),
nil
,
0
,
&
zodb
.
ErrXidMissing
{
xidlt
(
1
,
2
)})
ok1
(
data
==
nil
)
ok1
(
serial
==
0
)
fmt
.
Println
(
err
)
eq
(
err
,
&
zodb
.
ErrXidMissing
{
xidlt
(
1
,
2
)})
ok1
(
len
(
oce1
.
revv
)
==
1
)
ok1
(
len
(
oce1
.
revv
)
==
1
)
ok1
(
oce1
.
revv
[
0
]
==
rce1_b4
)
ok1
(
oce1
.
revv
[
0
]
==
rce1_b4
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment