Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neoppod
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Levin Zimmermann
neoppod
Commits
7ab9fe97
Commit
7ab9fe97
authored
Aug 24, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
2d2242a9
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
5 deletions
+21
-5
go/neo/client/cache_test.go
go/neo/client/cache_test.go
+21
-5
No files found.
go/neo/client/cache_test.go
View file @
7ab9fe97
...
@@ -21,6 +21,7 @@ package client
...
@@ -21,6 +21,7 @@ package client
import
(
import
(
"bytes"
"bytes"
"errors"
"fmt"
"fmt"
"reflect"
"reflect"
"sort"
"sort"
...
@@ -42,9 +43,10 @@ type tStorage struct {
...
@@ -42,9 +43,10 @@ type tStorage struct {
type
tOidData
struct
{
type
tOidData
struct
{
serial
zodb
.
Tid
serial
zodb
.
Tid
data
[]
byte
data
[]
byte
err
error
// e.g. io error
}
}
func
(
s
*
tStorage
)
Load
(
xid
zodb
.
Xid
)
(
data
[]
byte
,
serial
zodb
.
Tid
,
err
error
)
{
func
(
s
tor
*
tStorage
)
Load
(
xid
zodb
.
Xid
)
(
data
[]
byte
,
serial
zodb
.
Tid
,
err
error
)
{
fmt
.
Printf
(
"> load(%v)
\n
"
,
xid
)
fmt
.
Printf
(
"> load(%v)
\n
"
,
xid
)
defer
func
()
{
fmt
.
Printf
(
"< %v, %v, %v
\n
"
,
data
,
serial
,
err
)
}()
defer
func
()
{
fmt
.
Printf
(
"< %v, %v, %v
\n
"
,
data
,
serial
,
err
)
}()
tid
:=
xid
.
Tid
tid
:=
xid
.
Tid
...
@@ -52,7 +54,7 @@ func (s *tStorage) Load(xid zodb.Xid) (data []byte, serial zodb.Tid, err error)
...
@@ -52,7 +54,7 @@ func (s *tStorage) Load(xid zodb.Xid) (data []byte, serial zodb.Tid, err error)
tid
++
// XXX overflow
tid
++
// XXX overflow
}
}
datav
:=
s
.
dataMap
[
xid
.
Oid
]
datav
:=
s
tor
.
dataMap
[
xid
.
Oid
]
if
datav
==
nil
{
if
datav
==
nil
{
return
nil
,
0
,
&
zodb
.
ErrOidMissing
{
xid
.
Oid
}
return
nil
,
0
,
&
zodb
.
ErrOidMissing
{
xid
.
Oid
}
}
}
...
@@ -75,14 +77,21 @@ func (s *tStorage) Load(xid zodb.Xid) (data []byte, serial zodb.Tid, err error)
...
@@ -75,14 +77,21 @@ func (s *tStorage) Load(xid zodb.Xid) (data []byte, serial zodb.Tid, err error)
return
nil
,
0
,
&
zodb
.
ErrXidMissing
{
xid
}
return
nil
,
0
,
&
zodb
.
ErrXidMissing
{
xid
}
}
}
return
datav
[
i
]
.
data
,
datav
[
i
]
.
serial
,
nil
s
,
e
:=
datav
[
i
]
.
serial
,
datav
[
i
]
.
err
if
e
!=
nil
{
s
=
0
// obey protocol of returning 0 with error
}
return
datav
[
i
]
.
data
,
s
,
e
}
}
var
ioerr
=
errors
.
New
(
"input/output error"
)
var
tstor
=
&
tStorage
{
var
tstor
=
&
tStorage
{
dataMap
:
map
[
zodb
.
Oid
][]
tOidData
{
dataMap
:
map
[
zodb
.
Oid
][]
tOidData
{
1
:
{
1
:
{
{
4
,
[]
byte
(
"hello"
)},
{
4
,
[]
byte
(
"hello"
),
nil
},
{
8
,
[]
byte
(
"world"
)},
{
7
,
nil
,
ioerr
},
{
12
,
[]
byte
(
"world"
),
nil
},
},
},
},
},
}
}
...
@@ -204,6 +213,13 @@ func TestCache(t *testing.T) {
...
@@ -204,6 +213,13 @@ func TestCache(t *testing.T) {
ok1
(
rce1_b7
!=
rce1_b6
)
ok1
(
rce1_b7
!=
rce1_b6
)
checkRCE
(
rce1_b7
,
7
,
4
,
hello
,
nil
)
checkRCE
(
rce1_b7
,
7
,
4
,
hello
,
nil
)
checkOCE
(
1
,
rce1_b4
,
rce1_b7
)
checkOCE
(
1
,
rce1_b4
,
rce1_b7
)
// load <8 -> ioerr | new rce
checkLoad
(
xidlt
(
1
,
8
),
nil
,
0
,
ioerr
)
ok1
(
len
(
oce1
.
revv
)
==
3
)
rce1_b8
:=
oce1
.
revv
[
2
]
checkRCE
(
rce1_b8
,
8
,
0
,
nil
,
ioerr
)
checkOCE
(
1
,
rce1_b4
,
rce1_b7
,
rce1_b8
)
}
}
type
Checker
struct
{
type
Checker
struct
{
...
...
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