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
bd5de82f
Commit
bd5de82f
authored
Jan 19, 2020
by
linj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加单元测试
parent
ed8add83
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
0 deletions
+46
-0
upgrade_test.go
plugin/dapp/trade/executor/upgrade_test.go
+46
-0
No files found.
plugin/dapp/trade/executor/upgrade_test.go
View file @
bd5de82f
package
executor
import
(
"bytes"
"testing"
dbm
"github.com/33cn/chain33/common/db"
"github.com/33cn/chain33/types"
"github.com/33cn/chain33/util"
"github.com/stretchr/testify/assert"
)
...
...
@@ -73,3 +75,47 @@ func Test_Upgrade(t *testing.T) {
func
callUpgradeLocalDBV2
(
localdb
dbm
.
KVDB
)
error
{
return
UpgradeLocalDBV2
(
localdb
,
"bty"
)
}
// 测试更新后是否删除完全, asset 设置
func
Test_UpgradeOrderAsset
(
t
*
testing
.
T
)
{
dir
,
db
,
localdb
:=
util
.
CreateTestDB
()
defer
util
.
CloseTestDB
(
dir
,
db
)
assert
.
NotNil
(
t
,
localdb
)
tabV1
:=
NewOrderTable
(
localdb
)
tabV1
.
Add
(
order3
)
kvs
,
err
:=
tabV1
.
Save
()
assert
.
Nil
(
t
,
err
)
for
_
,
kv
:=
range
kvs
{
localdb
.
Set
(
kv
.
Key
,
kv
.
Value
)
}
err
=
callUpgradeLocalDBV2
(
localdb
)
assert
.
Nil
(
t
,
err
)
v1
,
err
:=
localdb
.
List
([]
byte
(
"LODB-trade-order"
),
nil
,
0
,
dbm
.
ListASC
|
dbm
.
ListWithKey
)
assert
.
Nil
(
t
,
err
)
assert
.
NotNil
(
t
,
v1
)
primaryKey
:=
"000000000000300001"
prefix
:=
"LODB-trade-order_v2"
for
_
,
v
:=
range
v1
{
var
kv
types
.
KeyValue
err
:=
types
.
Decode
(
v
,
&
kv
)
assert
.
Nil
(
t
,
err
)
// 前缀都是v2, 删除完成测试
if
!
bytes
.
Equal
([]
byte
(
"LODB-trade-order_v2-d-000000000000300001"
),
kv
.
Key
)
{
assert
.
Equal
(
t
,
[]
byte
(
primaryKey
),
kv
.
Value
)
assert
.
True
(
t
,
bytes
.
HasPrefix
(
kv
.
Key
,
[]
byte
(
prefix
)))
}
}
// assert 前缀测试
v
,
err
:=
localdb
.
Get
([]
byte
(
"LODB-trade-order_v2-m-asset-coins.bty_token.CCNY-000000000000300001"
))
assert
.
Nil
(
t
,
err
)
assert
.
Equal
(
t
,
primaryKey
,
string
(
v
))
// just print log
//assert.NotNil(t, nil)
}
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