Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
plugin
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
link33
plugin
Commits
a6ca512b
Commit
a6ca512b
authored
Feb 15, 2019
by
kingwang
Committed by
33cn
Feb 22, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix test bug
parent
6afcd5b4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
72 deletions
+7
-72
hashlock_unit_test.go
plugin/dapp/hashlock/executor/hashlock_unit_test.go
+3
-34
retrieve_unit_test.go
plugin/dapp/retrieve/executor/retrieve_unit_test.go
+4
-38
No files found.
plugin/dapp/hashlock/executor/hashlock_unit_test.go
View file @
a6ca512b
...
...
@@ -14,9 +14,9 @@ import (
"github.com/33cn/chain33/common"
"github.com/33cn/chain33/common/address"
"github.com/33cn/chain33/common/crypto"
"github.com/33cn/chain33/common/db"
drivers
"github.com/33cn/chain33/system/dapp"
"github.com/33cn/chain33/types"
"github.com/33cn/chain33/util"
pty
"github.com/33cn/plugin/plugin/dapp/hashlock/types"
)
...
...
@@ -93,7 +93,8 @@ func TestExecHashsend(t *testing.T) {
func
constructHashlockInstance
()
drivers
.
Driver
{
h
:=
newHashlock
()
h
.
SetStateDB
(
NewTestDB
())
_
,
_
,
kvdb
:=
util
.
CreateTestDB
()
h
.
SetStateDB
(
kvdb
)
return
h
}
...
...
@@ -150,35 +151,3 @@ func CompareRetrieveExecResult(rec1 *types.Receipt, err1 error, rec2 *types.Rece
}
return
true
}
type
TestDB
struct
{
cache
map
[
string
][]
byte
db
.
TransactionDB
}
func
NewTestDB
()
*
TestDB
{
return
&
TestDB
{
cache
:
make
(
map
[
string
][]
byte
)}
}
func
(
e
*
TestDB
)
Get
(
key
[]
byte
)
(
value
[]
byte
,
err
error
)
{
if
value
,
ok
:=
e
.
cache
[
string
(
key
)];
ok
{
//elog.Error("getkey", "key", string(key), "value", string(value))
return
value
,
nil
}
return
nil
,
types
.
ErrNotFound
}
func
(
e
*
TestDB
)
Set
(
key
[]
byte
,
value
[]
byte
)
error
{
//elog.Error("setkey", "key", string(key), "value", string(value))
e
.
cache
[
string
(
key
)]
=
value
return
nil
}
func
(
e
*
TestDB
)
BatchGet
(
keys
[][]
byte
)
(
values
[][]
byte
,
err
error
)
{
return
nil
,
types
.
ErrNotFound
}
//从数据库中查询数据列表,set 中的cache 更新不会影响这个list
func
(
e
*
TestDB
)
List
(
prefix
,
key
[]
byte
,
count
,
direction
int32
)
([][]
byte
,
error
)
{
return
nil
,
types
.
ErrNotFound
}
plugin/dapp/retrieve/executor/retrieve_unit_test.go
View file @
a6ca512b
...
...
@@ -15,6 +15,7 @@ import (
"github.com/33cn/chain33/executor"
drivers
"github.com/33cn/chain33/system/dapp"
"github.com/33cn/chain33/types"
"github.com/33cn/chain33/util"
rt
"github.com/33cn/plugin/plugin/dapp/retrieve/types"
)
...
...
@@ -235,8 +236,9 @@ func TestExecDelLocalBackup(t *testing.T) {
func
constructRetrieveInstance
()
drivers
.
Driver
{
r
:=
newRetrieve
()
r
.
SetStateDB
(
NewTestDB
())
r
.
SetLocalDB
(
NewTestLDB
())
_
,
_
,
kvdb
:=
util
.
CreateTestDB
()
r
.
SetStateDB
(
kvdb
)
r
.
SetLocalDB
(
kvdb
)
return
r
}
...
...
@@ -328,39 +330,3 @@ func CompareRetrieveExecResult(rec1 *types.Receipt, err1 error, rec2 *types.Rece
}
return
true
}
type
TestLDB
struct
{
db
.
TransactionDB
cache
map
[
string
][]
byte
}
func
NewTestLDB
()
*
TestLDB
{
return
&
TestLDB
{
cache
:
make
(
map
[
string
][]
byte
)}
}
func
(
e
*
TestLDB
)
Get
(
key
[]
byte
)
(
value
[]
byte
,
err
error
)
{
if
value
,
ok
:=
e
.
cache
[
string
(
key
)];
ok
{
//elog.Error("getkey", "key", string(key), "value", string(value))
return
value
,
nil
}
return
nil
,
types
.
ErrNotFound
}
func
(
e
*
TestLDB
)
Set
(
key
[]
byte
,
value
[]
byte
)
error
{
//elog.Error("setkey", "key", string(key), "value", string(value))
e
.
cache
[
string
(
key
)]
=
value
return
nil
}
func
(
e
*
TestLDB
)
BatchGet
(
keys
[][]
byte
)
(
values
[][]
byte
,
err
error
)
{
return
nil
,
types
.
ErrNotFound
}
//从数据库中查询数据列表,set 中的cache 更新不会影响这个list
func
(
e
*
TestLDB
)
List
(
prefix
,
key
[]
byte
,
count
,
direction
int32
)
([][]
byte
,
error
)
{
return
nil
,
types
.
ErrNotFound
}
func
(
e
*
TestLDB
)
PrefixCount
(
prefix
[]
byte
)
int64
{
return
0
}
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