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
fe3b45fd
Commit
fe3b45fd
authored
Aug 20, 2019
by
harrylee
Committed by
vipwzw
Aug 23, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modify code for golanglinter
parent
cf334942
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
26 changed files
with
126 additions
and
270 deletions
+126
-270
Makefile
Makefile
+6
-4
README.md
README.md
+4
-3
para_test.go
plugin/consensus/para/para_test.go
+7
-36
raft_test.go
plugin/consensus/raft/raft_test.go
+1
-1
boardaction_test.go
plugin/dapp/autonomy/executor/boardaction_test.go
+1
-1
projectaction_test.go
plugin/dapp/autonomy/executor/projectaction_test.go
+3
-3
ruleaction_test.go
plugin/dapp/autonomy/executor/ruleaction_test.go
+1
-1
event_test.go
plugin/dapp/evm/executor/abi/event_test.go
+0
-6
type_test.go
plugin/dapp/evm/executor/abi/type_test.go
+0
-4
base_evm_test.go
plugin/dapp/evm/executor/tests/base_evm_test.go
+1
-1
hashlock_test.go
plugin/dapp/hashlock/executor/hashlock_test.go
+0
-0
hashlock_unit_test.go
plugin/dapp/hashlock/executor/hashlock_unit_test.go
+29
-9
exec_test.go
plugin/dapp/multisig/wallet/exec_test.go
+0
-23
paracross_test.go
plugin/dapp/paracross/executor/paracross_test.go
+4
-34
privacy_test.go
plugin/dapp/privacy/wallet/privacy_test.go
+1
-1
type.go
plugin/dapp/relay/cmd/relayd/relayd/type.go
+0
-18
rpc_test.go
plugin/dapp/relay/rpc/rpc_test.go
+0
-16
retrieve_test.go
plugin/dapp/retrieve/executor/retrieve_test.go
+0
-0
retrieve_unit_test.go
plugin/dapp/retrieve/executor/retrieve_unit_test.go
+17
-3
ticket_test.go
plugin/dapp/ticket/executor/ticket_test.go
+4
-4
token_new_test.go
plugin/dapp/token/executor/token_new_test.go
+10
-46
kvmvccdb_test.go
plugin/store/kvmvcc/kvmvccdb_test.go
+28
-38
kvmvcc_mavl_test.go
plugin/store/kvmvccmavl/kvmvcc_mavl_test.go
+2
-2
trie_test.go
plugin/store/mpt/db/trie_test.go
+1
-1
trie_test.go
plugin/store/mpt/db2/trie_test.go
+1
-1
mpt_test.go
plugin/store/mpt/mpt_test.go
+5
-14
No files found.
Makefile
View file @
fe3b45fd
...
@@ -4,13 +4,15 @@
...
@@ -4,13 +4,15 @@
# 2. make dep
# 2. make dep
# 3. make build
# 3. make build
# ...
# ...
export
GO111MODULE
=
on
export
GOPROXY
=
https://mirrors.aliyun.com/goproxy
CLI
:=
build/chain33-cli
CLI
:=
build/chain33-cli
SRC_CLI
:=
github.com/33cn/plugin/cli
SRC_CLI
:=
github.com/33cn/plugin/cli
APP
:=
build/chain33
APP
:=
build/chain33
CHAIN33
=
github.com/33cn/chain33
CHAIN33
=
github.com/33cn/chain33
CHAIN33_VERSION
=
$(
shell
nl
go.mod |grep
"github.com/33cn/chain33"
|awk
'{print $$3}'
)
CHAIN33_VERSION
=
$(
shell
nl
go.mod |grep
"github.com/33cn/chain33"
|awk
'{print $$3}'
)
CHAIN33_PATH
=
${
GOPATH
}
/pkg/mod/github.com/33cn/chain33@
${
CHAIN33_VERSION
}
CHAIN33_PATH
=
${
GOPATH
}
/pkg/mod/github.com/33cn/chain33@
${
CHAIN33_VERSION
}
BUILD_FLAGS
=
-ldflags
"-X
${
CHAIN33_PATH
}
/common/version.GitCommit=
`
git rev-parse
--short
=
8 HEAD
`
"
LDFLAGS
:=
-ldflags
"-w -s"
LDFLAGS
:=
-ldflags
"-w -s"
PKG_LIST_VET
:=
`
go list ./... |
grep
-v
"vendor"
|
grep
-v
plugin/dapp/evm/executor/vm/common/crypto/bn256
`
PKG_LIST_VET
:=
`
go list ./... |
grep
-v
"vendor"
|
grep
-v
plugin/dapp/evm/executor/vm/common/crypto/bn256
`
PKG_LIST
:=
`
go list ./... |
grep
-v
"vendor"
|
grep
-v
"chain33/test"
|
grep
-v
"mocks"
|
grep
-v
"pbft"
`
PKG_LIST
:=
`
go list ./... |
grep
-v
"vendor"
|
grep
-v
"chain33/test"
|
grep
-v
"mocks"
|
grep
-v
"pbft"
`
...
@@ -23,15 +25,15 @@ proj := "build"
...
@@ -23,15 +25,15 @@ proj := "build"
default
:
depends build
default
:
depends build
build
:
depends
build
:
depends
go build
-v
-i
-o
$(APP)
go build
$(BUILD_FLAGS)
-v
-i
-o
$(APP)
go build
-v
-i
-o
$(CLI)
$(SRC_CLI)
go build
$(BUILD_FLAGS)
-v
-i
-o
$(CLI)
$(SRC_CLI)
@
cp
chain33.toml
$(CHAIN33_PATH)
/build/system-test-rpc.sh build/
@
cp
chain33.toml
$(CHAIN33_PATH)
/build/system-test-rpc.sh build/
@
cp
chain33.para.toml build/ci/paracross/
@
cp
chain33.para.toml build/ci/paracross/
build_ci
:
depends
##
Build the binary file for CI
build_ci
:
depends
##
Build the binary file for CI
@
go build
-v
-i
-o
$(CLI)
$(SRC_CLI)
@
go build
-v
-i
-o
$(CLI)
$(SRC_CLI)
@
go build
-v
-o
$(APP)
@
go build
$(BUILD_FLAGS)
-v
-o
$(APP)
@
cp
chain33.toml
$(CHAIN33_PATH)
/build/system-test-rpc.sh build/
@
cp
chain33.toml
$(CHAIN33_PATH)
/build/system-test-rpc.sh build/
@
cp
chain33.para.toml build/ci/paracross/
@
cp
chain33.para.toml build/ci/paracross/
...
...
README.md
View file @
fe3b45fd
...
@@ -11,10 +11,11 @@ https://camo.githubusercontent.com/915b7be44ada53c290eb157634330494ebe3e30a/6874
...
@@ -11,10 +11,11 @@ https://camo.githubusercontent.com/915b7be44ada53c290eb157634330494ebe3e30a/6874
*
chain33地址: https://github.com/33cn/chain33
*
chain33地址: https://github.com/33cn/chain33
*
chain33官网: https://chain.33.cn
*
chain33官网: https://chain.33.cn
## 环境
### 环境
** 需要 安装golang1.12 or latest **
```
需要安装golang1.12 or latest
```
#### 支持make file的平台
#### 支持make file的平台
...
...
plugin/consensus/para/para_test.go
View file @
fe3b45fd
...
@@ -5,15 +5,14 @@
...
@@ -5,15 +5,14 @@
package
para
package
para
import
(
import
(
"github.com/stretchr/testify/assert"
//"github.com/stretchr/testify/mock"
"encoding/hex"
"encoding/hex"
"math/rand"
"github.com/stretchr/testify/assert"
"testing"
"testing"
"time"
apimocks
"github.com/33cn/chain33/client/mocks"
apimocks
"github.com/33cn/chain33/client/mocks"
"github.com/33cn/chain33/common/address"
"github.com/33cn/chain33/common/crypto"
"github.com/33cn/chain33/common/crypto"
"github.com/33cn/chain33/queue"
"github.com/33cn/chain33/queue"
qmocks
"github.com/33cn/chain33/queue/mocks"
qmocks
"github.com/33cn/chain33/queue/mocks"
...
@@ -26,7 +25,7 @@ import (
...
@@ -26,7 +25,7 @@ import (
)
)
var
(
var
(
Amount
=
int64
(
1
*
types
.
Coin
)
Amount
=
1
*
types
.
Coin
Title
=
string
(
"user.p.para."
)
Title
=
string
(
"user.p.para."
)
Title2
=
string
(
"user.p.test."
)
Title2
=
string
(
"user.p.test."
)
)
)
...
@@ -42,37 +41,9 @@ func TestFilterTxsForPara(t *testing.T) {
...
@@ -42,37 +41,9 @@ func TestFilterTxsForPara(t *testing.T) {
}
}
func
createCrossMainTx
(
to
string
)
(
*
types
.
Transaction
,
error
)
{
param
:=
types
.
CreateTx
{
To
:
string
(
to
),
Amount
:
Amount
,
Fee
:
0
,
Note
:
[]
byte
(
"test asset transfer"
),
IsWithdraw
:
false
,
IsToken
:
false
,
TokenSymbol
:
""
,
ExecName
:
pt
.
ParaX
,
}
transfer
:=
&
pt
.
ParacrossAction
{}
v
:=
&
pt
.
ParacrossAction_AssetTransfer
{
AssetTransfer
:
&
types
.
AssetsTransfer
{
Amount
:
param
.
Amount
,
Note
:
param
.
GetNote
(),
To
:
param
.
GetTo
()}}
transfer
.
Value
=
v
transfer
.
Ty
=
pt
.
ParacrossActionAssetTransfer
tx
:=
&
types
.
Transaction
{
Execer
:
[]
byte
(
param
.
GetExecName
()),
Payload
:
types
.
Encode
(
transfer
),
To
:
address
.
ExecAddress
(
param
.
GetExecName
()),
Fee
:
param
.
Fee
,
Nonce
:
rand
.
New
(
rand
.
NewSource
(
time
.
Now
()
.
UnixNano
()))
.
Int63
(),
}
return
tx
,
nil
}
func
createCrossParaTx
(
to
string
,
amount
int64
)
(
*
types
.
Transaction
,
error
)
{
func
createCrossParaTx
(
to
string
,
amount
int64
)
(
*
types
.
Transaction
,
error
)
{
param
:=
types
.
CreateTx
{
param
:=
types
.
CreateTx
{
To
:
string
(
to
)
,
To
:
to
,
Amount
:
amount
,
Amount
:
amount
,
Fee
:
0
,
Fee
:
0
,
Note
:
[]
byte
(
"test asset transfer"
),
Note
:
[]
byte
(
"test asset transfer"
),
...
@@ -88,7 +59,7 @@ func createCrossParaTx(to string, amount int64) (*types.Transaction, error) {
...
@@ -88,7 +59,7 @@ func createCrossParaTx(to string, amount int64) (*types.Transaction, error) {
func
createCrossParaTempTx
(
to
string
,
amount
int64
)
(
*
types
.
Transaction
,
error
)
{
func
createCrossParaTempTx
(
to
string
,
amount
int64
)
(
*
types
.
Transaction
,
error
)
{
param
:=
types
.
CreateTx
{
param
:=
types
.
CreateTx
{
To
:
string
(
to
)
,
To
:
to
,
Amount
:
amount
,
Amount
:
amount
,
Fee
:
0
,
Fee
:
0
,
Note
:
[]
byte
(
"test asset transfer"
),
Note
:
[]
byte
(
"test asset transfer"
),
...
...
plugin/consensus/raft/raft_test.go
View file @
fe3b45fd
...
@@ -160,7 +160,7 @@ func prepareTxList() *types.Transaction {
...
@@ -160,7 +160,7 @@ func prepareTxList() *types.Transaction {
func
getReplyList
(
n
int
)
(
txs
[]
*
types
.
Transaction
)
{
func
getReplyList
(
n
int
)
(
txs
[]
*
types
.
Transaction
)
{
for
i
:=
0
;
i
<
int
(
n
)
;
i
++
{
for
i
:=
0
;
i
<
n
;
i
++
{
txs
=
append
(
txs
,
prepareTxList
())
txs
=
append
(
txs
,
prepareTxList
())
}
}
return
txs
return
txs
...
...
plugin/dapp/autonomy/executor/boardaction_test.go
View file @
fe3b45fd
...
@@ -331,7 +331,7 @@ func voteProposalBoard(t *testing.T, env *ExecEnv, exec drivers.Driver, stateDB
...
@@ -331,7 +331,7 @@ func voteProposalBoard(t *testing.T, env *ExecEnv, exec drivers.Driver, stateDB
account
:=
accCoin
.
LoadExecAccount
(
AddrA
,
address
.
ExecAddress
(
auty
.
AutonomyX
))
account
:=
accCoin
.
LoadExecAccount
(
AddrA
,
address
.
ExecAddress
(
auty
.
AutonomyX
))
require
.
Equal
(
t
,
int64
(
0
),
account
.
Frozen
)
require
.
Equal
(
t
,
int64
(
0
),
account
.
Frozen
)
account
=
accCoin
.
LoadExecAccount
(
autonomyFundAddr
,
address
.
ExecAddress
(
auty
.
AutonomyX
))
account
=
accCoin
.
LoadExecAccount
(
autonomyFundAddr
,
address
.
ExecAddress
(
auty
.
AutonomyX
))
require
.
Equal
(
t
,
int64
(
proposalAmount
)
,
account
.
Balance
)
require
.
Equal
(
t
,
proposalAmount
,
account
.
Balance
)
// status
// status
value
,
err
:=
stateDB
.
Get
(
propBoardID
(
proposalID
))
value
,
err
:=
stateDB
.
Get
(
propBoardID
(
proposalID
))
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
...
...
plugin/dapp/autonomy/executor/projectaction_test.go
View file @
fe3b45fd
...
@@ -114,7 +114,7 @@ func TestPropProject(t *testing.T) {
...
@@ -114,7 +114,7 @@ func TestPropProject(t *testing.T) {
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
pbtx
,
err
=
signTx
(
pbtx
,
PrivKeyA
)
pbtx
,
err
=
signTx
(
pbtx
,
PrivKeyA
)
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
_
,
err
=
exec
.
Exec
(
pbtx
,
i
nt
(
i
)
)
_
,
err
=
exec
.
Exec
(
pbtx
,
i
)
require
.
Error
(
t
,
err
,
result
[
i
])
require
.
Error
(
t
,
err
,
result
[
i
])
}
}
...
@@ -388,7 +388,7 @@ func checkVoteProposalProjectResult(t *testing.T, stateDB dbm.KV, proposalID str
...
@@ -388,7 +388,7 @@ func checkVoteProposalProjectResult(t *testing.T, stateDB dbm.KV, proposalID str
account
:=
accCoin
.
LoadExecAccount
(
AddrA
,
address
.
ExecAddress
(
auty
.
AutonomyX
))
account
:=
accCoin
.
LoadExecAccount
(
AddrA
,
address
.
ExecAddress
(
auty
.
AutonomyX
))
require
.
Equal
(
t
,
int64
(
0
),
account
.
Frozen
)
require
.
Equal
(
t
,
int64
(
0
),
account
.
Frozen
)
account
=
accCoin
.
LoadExecAccount
(
autonomyFundAddr
,
address
.
ExecAddress
(
auty
.
AutonomyX
))
account
=
accCoin
.
LoadExecAccount
(
autonomyFundAddr
,
address
.
ExecAddress
(
auty
.
AutonomyX
))
require
.
Equal
(
t
,
int64
(
proposalAmount
)
,
account
.
Balance
)
require
.
Equal
(
t
,
proposalAmount
,
account
.
Balance
)
// status
// status
value
,
err
:=
stateDB
.
Get
(
propProjectID
(
proposalID
))
value
,
err
:=
stateDB
.
Get
(
propProjectID
(
proposalID
))
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
...
@@ -491,7 +491,7 @@ func checkPubVoteProposalProjectResult(t *testing.T, stateDB dbm.KV, proposalID
...
@@ -491,7 +491,7 @@ func checkPubVoteProposalProjectResult(t *testing.T, stateDB dbm.KV, proposalID
account
:=
accCoin
.
LoadExecAccount
(
AddrA
,
address
.
ExecAddress
(
auty
.
AutonomyX
))
account
:=
accCoin
.
LoadExecAccount
(
AddrA
,
address
.
ExecAddress
(
auty
.
AutonomyX
))
require
.
Equal
(
t
,
int64
(
0
),
account
.
Frozen
)
require
.
Equal
(
t
,
int64
(
0
),
account
.
Frozen
)
account
=
accCoin
.
LoadExecAccount
(
autonomyFundAddr
,
address
.
ExecAddress
(
auty
.
AutonomyX
))
account
=
accCoin
.
LoadExecAccount
(
autonomyFundAddr
,
address
.
ExecAddress
(
auty
.
AutonomyX
))
require
.
Equal
(
t
,
int64
(
proposalAmount
)
+
testProjectAmount
,
account
.
Balance
)
require
.
Equal
(
t
,
proposalAmount
+
testProjectAmount
,
account
.
Balance
)
// status
// status
value
,
err
:=
stateDB
.
Get
(
propProjectID
(
proposalID
))
value
,
err
:=
stateDB
.
Get
(
propProjectID
(
proposalID
))
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
...
...
plugin/dapp/autonomy/executor/ruleaction_test.go
View file @
fe3b45fd
...
@@ -272,7 +272,7 @@ func voteProposalRule(t *testing.T, env *ExecEnv, exec drivers.Driver, stateDB d
...
@@ -272,7 +272,7 @@ func voteProposalRule(t *testing.T, env *ExecEnv, exec drivers.Driver, stateDB d
account
:=
accCoin
.
LoadExecAccount
(
AddrA
,
address
.
ExecAddress
(
auty
.
AutonomyX
))
account
:=
accCoin
.
LoadExecAccount
(
AddrA
,
address
.
ExecAddress
(
auty
.
AutonomyX
))
require
.
Equal
(
t
,
int64
(
0
),
account
.
Frozen
)
require
.
Equal
(
t
,
int64
(
0
),
account
.
Frozen
)
account
=
accCoin
.
LoadExecAccount
(
autonomyFundAddr
,
address
.
ExecAddress
(
auty
.
AutonomyX
))
account
=
accCoin
.
LoadExecAccount
(
autonomyFundAddr
,
address
.
ExecAddress
(
auty
.
AutonomyX
))
require
.
Equal
(
t
,
int64
(
proposalAmount
)
,
account
.
Balance
)
require
.
Equal
(
t
,
proposalAmount
,
account
.
Balance
)
// status
// status
value
,
err
:=
stateDB
.
Get
(
propRuleID
(
proposalID
))
value
,
err
:=
stateDB
.
Get
(
propRuleID
(
proposalID
))
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
...
...
plugin/dapp/evm/executor/abi/event_test.go
View file @
fe3b45fd
...
@@ -326,12 +326,6 @@ Taken from
...
@@ -326,12 +326,6 @@ Taken from
https://github.com/ethereum/go-ethereum/pull/15568
https://github.com/ethereum/go-ethereum/pull/15568
*/
*/
type
testResult
struct
{
Values
[
2
]
*
big
.
Int
Value1
*
big
.
Int
Value2
*
big
.
Int
}
// TestEventUnpackIndexed verifies that indexed field will be skipped by event decoder.
// TestEventUnpackIndexed verifies that indexed field will be skipped by event decoder.
func
TestEventUnpackIndexed
(
t
*
testing
.
T
)
{
func
TestEventUnpackIndexed
(
t
*
testing
.
T
)
{
definition
:=
`[{"name": "test", "type": "event", "inputs": [{"indexed": true, "name":"value1", "type":"uint8"},{"indexed": false, "name":"value2", "type":"uint8"}]}]`
definition
:=
`[{"name": "test", "type": "event", "inputs": [{"indexed": true, "name":"value1", "type":"uint8"},{"indexed": false, "name":"value2", "type":"uint8"}]}]`
...
...
plugin/dapp/evm/executor/abi/type_test.go
View file @
fe3b45fd
...
@@ -24,10 +24,6 @@ import (
...
@@ -24,10 +24,6 @@ import (
"github.com/33cn/plugin/plugin/dapp/evm/executor/vm/common"
"github.com/33cn/plugin/plugin/dapp/evm/executor/vm/common"
)
)
// typeWithoutStringer is a alias for the Type type which simply doesn't implement
// the stringer interface to allow printing type details in the tests below.
type
typeWithoutStringer
Type
// Tests that all allowed types get recognized by the type parser.
// Tests that all allowed types get recognized by the type parser.
func
TestTypeRegexp
(
t
*
testing
.
T
)
{
func
TestTypeRegexp
(
t
*
testing
.
T
)
{
tests
:=
[]
struct
{
tests
:=
[]
struct
{
...
...
plugin/dapp/evm/executor/tests/base_evm_test.go
View file @
fe3b45fd
...
@@ -30,7 +30,7 @@ func TestCreateContract1(t *testing.T) {
...
@@ -30,7 +30,7 @@ func TestCreateContract1(t *testing.T) {
test
.
assertEqualsB
(
ret
,
execCode
)
test
.
assertEqualsB
(
ret
,
execCode
)
test
.
assertBigger
(
int
(
gasLimit
),
int
(
leftGas
))
test
.
assertBigger
(
int
(
gasLimit
),
int
(
leftGas
))
test
.
assertNotEqualsI
(
common
.
Address
(
addr
)
,
common
.
EmptyAddress
())
test
.
assertNotEqualsI
(
addr
,
common
.
EmptyAddress
())
// 检查返回数据是否正确
// 检查返回数据是否正确
test
.
assertEqualsV
(
statedb
.
GetLastSnapshot
()
.
GetID
(),
0
)
test
.
assertEqualsV
(
statedb
.
GetLastSnapshot
()
.
GetID
(),
0
)
...
...
plugin/dapp/hashlock/executor/hashlock_test.go
deleted
100755 → 0
View file @
cf334942
This diff is collapsed.
Click to expand it.
plugin/dapp/hashlock/executor/hashlock_unit_test.go
View file @
fe3b45fd
...
@@ -10,6 +10,8 @@ import (
...
@@ -10,6 +10,8 @@ import (
"fmt"
"fmt"
"testing"
"testing"
"math/rand"
"github.com/33cn/chain33/common"
"github.com/33cn/chain33/common"
"github.com/33cn/chain33/common/address"
"github.com/33cn/chain33/common/address"
"github.com/33cn/chain33/common/crypto"
"github.com/33cn/chain33/common/crypto"
...
@@ -19,13 +21,31 @@ import (
...
@@ -19,13 +21,31 @@ import (
pty
"github.com/33cn/plugin/plugin/dapp/hashlock/types"
pty
"github.com/33cn/plugin/plugin/dapp/hashlock/types"
)
)
var
toAddr
string
var
(
var
returnAddr
string
toAddr
string
var
toPriv
crypto
.
PrivKey
returnAddr
string
var
returnPriv
crypto
.
PrivKey
toPriv
crypto
.
PrivKey
returnPriv
crypto
.
PrivKey
testNormErr
error
hashlock
drivers
.
Driver
secret
[]
byte
addrexec
string
)
const
secretLen
=
32
var
testNormErr
error
func
genaddress
()
(
string
,
crypto
.
PrivKey
)
{
var
hashlock
drivers
.
Driver
cr
,
err
:=
crypto
.
New
(
types
.
GetSignName
(
""
,
types
.
SECP256K1
))
if
err
!=
nil
{
panic
(
err
)
}
privto
,
err
:=
cr
.
GenKey
()
if
err
!=
nil
{
panic
(
err
)
}
addrto
:=
address
.
PubKeyToAddress
(
privto
.
PubKey
()
.
Bytes
())
return
addrto
.
String
(),
privto
}
func
TestInit
(
t
*
testing
.
T
)
{
func
TestInit
(
t
*
testing
.
T
)
{
toAddr
,
toPriv
=
genaddress
()
toAddr
,
toPriv
=
genaddress
()
...
@@ -106,7 +126,7 @@ func ConstructLockTx() *types.Transaction {
...
@@ -106,7 +126,7 @@ func ConstructLockTx() *types.Transaction {
vlock
:=
&
pty
.
HashlockAction_Hlock
{
Hlock
:
&
pty
.
HashlockLock
{
Amount
:
lockAmount
,
Time
:
locktime
,
Hash
:
common
.
Sha256
(
secret
),
ToAddress
:
toAddr
,
ReturnAddress
:
returnAddr
}}
vlock
:=
&
pty
.
HashlockAction_Hlock
{
Hlock
:
&
pty
.
HashlockLock
{
Amount
:
lockAmount
,
Time
:
locktime
,
Hash
:
common
.
Sha256
(
secret
),
ToAddress
:
toAddr
,
ReturnAddress
:
returnAddr
}}
transfer
:=
&
pty
.
HashlockAction
{
Value
:
vlock
,
Ty
:
pty
.
HashlockActionLock
}
transfer
:=
&
pty
.
HashlockAction
{
Value
:
vlock
,
Ty
:
pty
.
HashlockActionLock
}
tx
:=
&
types
.
Transaction
{
Execer
:
[]
byte
(
"hashlock"
),
Payload
:
types
.
Encode
(
transfer
),
Fee
:
fee
,
To
:
toAddr
}
tx
:=
&
types
.
Transaction
{
Execer
:
[]
byte
(
"hashlock"
),
Payload
:
types
.
Encode
(
transfer
),
Fee
:
fee
,
To
:
toAddr
}
tx
.
Nonce
=
r
.
Int63
()
tx
.
Nonce
=
r
and
.
Int63
()
tx
.
Sign
(
types
.
SECP256K1
,
returnPriv
)
tx
.
Sign
(
types
.
SECP256K1
,
returnPriv
)
return
tx
return
tx
...
@@ -119,7 +139,7 @@ func ConstructUnlockTx() *types.Transaction {
...
@@ -119,7 +139,7 @@ func ConstructUnlockTx() *types.Transaction {
vunlock
:=
&
pty
.
HashlockAction_Hunlock
{
Hunlock
:
&
pty
.
HashlockUnlock
{
Secret
:
secret
}}
vunlock
:=
&
pty
.
HashlockAction_Hunlock
{
Hunlock
:
&
pty
.
HashlockUnlock
{
Secret
:
secret
}}
transfer
:=
&
pty
.
HashlockAction
{
Value
:
vunlock
,
Ty
:
pty
.
HashlockActionUnlock
}
transfer
:=
&
pty
.
HashlockAction
{
Value
:
vunlock
,
Ty
:
pty
.
HashlockActionUnlock
}
tx
:=
&
types
.
Transaction
{
Execer
:
[]
byte
(
"hashlock"
),
Payload
:
types
.
Encode
(
transfer
),
Fee
:
fee
,
To
:
toAddr
}
tx
:=
&
types
.
Transaction
{
Execer
:
[]
byte
(
"hashlock"
),
Payload
:
types
.
Encode
(
transfer
),
Fee
:
fee
,
To
:
toAddr
}
tx
.
Nonce
=
r
.
Int63
()
tx
.
Nonce
=
r
and
.
Int63
()
tx
.
Sign
(
types
.
SECP256K1
,
returnPriv
)
tx
.
Sign
(
types
.
SECP256K1
,
returnPriv
)
return
tx
return
tx
}
}
...
@@ -131,7 +151,7 @@ func ConstructSendTx() *types.Transaction {
...
@@ -131,7 +151,7 @@ func ConstructSendTx() *types.Transaction {
vsend
:=
&
pty
.
HashlockAction_Hsend
{
Hsend
:
&
pty
.
HashlockSend
{
Secret
:
secret
}}
vsend
:=
&
pty
.
HashlockAction_Hsend
{
Hsend
:
&
pty
.
HashlockSend
{
Secret
:
secret
}}
transfer
:=
&
pty
.
HashlockAction
{
Value
:
vsend
,
Ty
:
pty
.
HashlockActionSend
}
transfer
:=
&
pty
.
HashlockAction
{
Value
:
vsend
,
Ty
:
pty
.
HashlockActionSend
}
tx
:=
&
types
.
Transaction
{
Execer
:
[]
byte
(
"hashlock"
),
Payload
:
types
.
Encode
(
transfer
),
Fee
:
fee
,
To
:
toAddr
}
tx
:=
&
types
.
Transaction
{
Execer
:
[]
byte
(
"hashlock"
),
Payload
:
types
.
Encode
(
transfer
),
Fee
:
fee
,
To
:
toAddr
}
tx
.
Nonce
=
r
.
Int63
()
tx
.
Nonce
=
r
and
.
Int63
()
tx
.
Sign
(
types
.
SECP256K1
,
toPriv
)
tx
.
Sign
(
types
.
SECP256K1
,
toPriv
)
return
tx
return
tx
}
}
...
...
plugin/dapp/multisig/wallet/exec_test.go
View file @
fe3b45fd
...
@@ -9,8 +9,6 @@ import (
...
@@ -9,8 +9,6 @@ import (
"testing"
"testing"
"github.com/33cn/chain33/common"
"github.com/33cn/chain33/common"
// "github.com/33cn/chain33/common/address"
"github.com/33cn/chain33/common/crypto"
"github.com/33cn/chain33/rpc/jsonclient"
"github.com/33cn/chain33/rpc/jsonclient"
rpctypes
"github.com/33cn/chain33/rpc/types"
rpctypes
"github.com/33cn/chain33/rpc/types"
_
"github.com/33cn/chain33/system"
_
"github.com/33cn/chain33/system"
...
@@ -48,27 +46,6 @@ var TestPrivkeyHex = []string{
...
@@ -48,27 +46,6 @@ var TestPrivkeyHex = []string{
"0x5b8ca316cf073aa94f1056a9e3f6e0b9a9ec11ae45862d58c7a09640b4d55302"
,
"0x5b8ca316cf073aa94f1056a9e3f6e0b9a9ec11ae45862d58c7a09640b4d55302"
,
}
}
func
signTx
(
tx
*
types
.
Transaction
,
hexPrivKey
string
)
(
*
types
.
Transaction
,
error
)
{
signType
:=
types
.
SECP256K1
c
,
err
:=
crypto
.
New
(
types
.
GetSignName
(
mty
.
MultiSigX
,
signType
))
if
err
!=
nil
{
return
tx
,
err
}
bytes
,
err
:=
common
.
FromHex
(
hexPrivKey
[
:
])
if
err
!=
nil
{
return
tx
,
err
}
privKey
,
err
:=
c
.
PrivKeyFromBytes
(
bytes
)
if
err
!=
nil
{
return
tx
,
err
}
tx
.
Sign
(
int32
(
signType
),
privKey
)
return
tx
,
nil
}
func
getRPCClient
(
t
*
testing
.
T
,
mocker
*
testnode
.
Chain33Mock
)
*
jsonclient
.
JSONClient
{
func
getRPCClient
(
t
*
testing
.
T
,
mocker
*
testnode
.
Chain33Mock
)
*
jsonclient
.
JSONClient
{
jrpcClient
:=
mocker
.
GetJSONC
()
jrpcClient
:=
mocker
.
GetJSONC
()
assert
.
NotNil
(
t
,
jrpcClient
)
assert
.
NotNil
(
t
,
jrpcClient
)
...
...
plugin/dapp/paracross/executor/paracross_test.go
View file @
fe3b45fd
...
@@ -6,9 +6,7 @@ package executor
...
@@ -6,9 +6,7 @@ package executor
import
(
import
(
"bytes"
"bytes"
"math/rand"
"testing"
"testing"
"time"
apimock
"github.com/33cn/chain33/client/mocks"
apimock
"github.com/33cn/chain33/client/mocks"
"github.com/33cn/chain33/common"
"github.com/33cn/chain33/common"
...
@@ -289,7 +287,7 @@ func checkDoneReceipt(suite suite.Suite, receipt *types.Receipt, commitCnt int)
...
@@ -289,7 +287,7 @@ func checkDoneReceipt(suite suite.Suite, receipt *types.Receipt, commitCnt int)
assert
.
Nil
(
suite
.
T
(),
err
,
"decode title failed"
)
assert
.
Nil
(
suite
.
T
(),
err
,
"decode title failed"
)
suite
.
T
()
.
Log
(
"title"
,
titleStat
)
suite
.
T
()
.
Log
(
"title"
,
titleStat
)
assert
.
Equal
(
suite
.
T
(),
int32
(
pt
.
TyLogParacrossCommitDone
),
receipt
.
Logs
[
1
]
.
Ty
)
assert
.
Equal
(
suite
.
T
(),
int32
(
pt
.
TyLogParacrossCommitDone
),
receipt
.
Logs
[
1
]
.
Ty
)
assert
.
Equal
(
suite
.
T
(),
int64
(
TitleHeight
)
,
titleStat
.
Height
)
assert
.
Equal
(
suite
.
T
(),
TitleHeight
,
titleStat
.
Height
)
assert
.
Equal
(
suite
.
T
(),
Title
,
titleStat
.
Title
)
assert
.
Equal
(
suite
.
T
(),
Title
,
titleStat
.
Title
)
assert
.
Equal
(
suite
.
T
(),
CurBlock
,
titleStat
.
BlockHash
)
assert
.
Equal
(
suite
.
T
(),
CurBlock
,
titleStat
.
BlockHash
)
}
}
...
@@ -305,7 +303,7 @@ func checkRecordReceipt(suite *CommitTestSuite, receipt *types.Receipt, commitCn
...
@@ -305,7 +303,7 @@ func checkRecordReceipt(suite *CommitTestSuite, receipt *types.Receipt, commitCn
suite
.
T
()
.
Log
(
"record"
,
record
)
suite
.
T
()
.
Log
(
"record"
,
record
)
assert
.
Equal
(
suite
.
T
(),
int32
(
pt
.
TyLogParacrossCommitRecord
),
receipt
.
Logs
[
0
]
.
Ty
)
assert
.
Equal
(
suite
.
T
(),
int32
(
pt
.
TyLogParacrossCommitRecord
),
receipt
.
Logs
[
0
]
.
Ty
)
assert
.
Equal
(
suite
.
T
(),
Title
,
record
.
Status
.
Title
)
assert
.
Equal
(
suite
.
T
(),
Title
,
record
.
Status
.
Title
)
assert
.
Equal
(
suite
.
T
(),
int64
(
TitleHeight
)
,
record
.
Status
.
Height
)
assert
.
Equal
(
suite
.
T
(),
TitleHeight
,
record
.
Status
.
Height
)
assert
.
Equal
(
suite
.
T
(),
CurBlock
,
record
.
Status
.
BlockHash
)
assert
.
Equal
(
suite
.
T
(),
CurBlock
,
record
.
Status
.
BlockHash
)
}
}
...
@@ -528,8 +526,8 @@ func (s *VoteTestSuite) TestVoteTx() {
...
@@ -528,8 +526,8 @@ func (s *VoteTestSuite) TestVoteTx() {
if
bytes
.
Equal
(
key
,
kv
.
Key
)
{
if
bytes
.
Equal
(
key
,
kv
.
Key
)
{
var
rst
pt
.
ParacrossNodeStatus
var
rst
pt
.
ParacrossNodeStatus
types
.
Decode
(
kv
.
GetValue
(),
&
rst
)
types
.
Decode
(
kv
.
GetValue
(),
&
rst
)
s
.
Equal
([]
uint8
([]
byte
{
0x4d
})
,
rst
.
TxResult
)
s
.
Equal
([]
byte
{
0x4d
}
,
rst
.
TxResult
)
s
.
Equal
([]
uint8
([]
byte
{
0x25
})
,
rst
.
CrossTxResult
)
s
.
Equal
([]
byte
{
0x25
}
,
rst
.
CrossTxResult
)
s
.
Equal
(
7
,
len
(
rst
.
TxHashs
))
s
.
Equal
(
7
,
len
(
rst
.
TxHashs
))
s
.
Equal
(
6
,
len
(
rst
.
CrossTxHashs
))
s
.
Equal
(
6
,
len
(
rst
.
CrossTxHashs
))
break
break
...
@@ -653,34 +651,6 @@ func (s *VoteTestSuite) createVoteTx(status *pt.ParacrossNodeStatus, privFrom st
...
@@ -653,34 +651,6 @@ func (s *VoteTestSuite) createVoteTx(status *pt.ParacrossNodeStatus, privFrom st
return
tx
,
nil
return
tx
,
nil
}
}
func
createCrossMainTx
(
to
[]
byte
)
(
*
types
.
Transaction
,
error
)
{
param
:=
types
.
CreateTx
{
To
:
string
(
to
),
Amount
:
Amount
,
Fee
:
0
,
Note
:
[]
byte
(
"test asset transfer"
),
IsWithdraw
:
false
,
IsToken
:
false
,
TokenSymbol
:
""
,
ExecName
:
pt
.
ParaX
,
}
transfer
:=
&
pt
.
ParacrossAction
{}
v
:=
&
pt
.
ParacrossAction_AssetTransfer
{
AssetTransfer
:
&
types
.
AssetsTransfer
{
Amount
:
param
.
Amount
,
Note
:
param
.
GetNote
(),
To
:
param
.
GetTo
()}}
transfer
.
Value
=
v
transfer
.
Ty
=
pt
.
ParacrossActionAssetTransfer
tx
:=
&
types
.
Transaction
{
Execer
:
[]
byte
(
param
.
GetExecName
()),
Payload
:
types
.
Encode
(
transfer
),
To
:
address
.
ExecAddress
(
param
.
GetExecName
()),
Fee
:
param
.
Fee
,
Nonce
:
rand
.
New
(
rand
.
NewSource
(
time
.
Now
()
.
UnixNano
()))
.
Int63
(),
}
return
tx
,
nil
}
func
createCrossParaTx
(
s
suite
.
Suite
,
to
[]
byte
)
(
*
types
.
Transaction
,
error
)
{
func
createCrossParaTx
(
s
suite
.
Suite
,
to
[]
byte
)
(
*
types
.
Transaction
,
error
)
{
param
:=
types
.
CreateTx
{
param
:=
types
.
CreateTx
{
To
:
string
(
to
),
To
:
string
(
to
),
...
...
plugin/dapp/privacy/wallet/privacy_test.go
View file @
fe3b45fd
...
@@ -205,7 +205,7 @@ func (mock *PrivacyMock) createPublic2PrivacyTx(req *ty.ReqCreatePrivacyTx) *typ
...
@@ -205,7 +205,7 @@ func (mock *PrivacyMock) createPublic2PrivacyTx(req *ty.ReqCreatePrivacyTx) *typ
value
:=
&
ty
.
Public2Privacy
{
value
:=
&
ty
.
Public2Privacy
{
Tokenname
:
req
.
Tokenname
,
Tokenname
:
req
.
Tokenname
,
Amount
:
amount
,
Amount
:
amount
,
Note
:
string
(
req
.
GetNote
()
),
Note
:
req
.
GetNote
(
),
Output
:
privacyOutput
,
Output
:
privacyOutput
,
}
}
action
:=
&
ty
.
PrivacyAction
{
action
:=
&
ty
.
PrivacyAction
{
...
...
plugin/dapp/relay/cmd/relayd/relayd/type.go
View file @
fe3b45fd
...
@@ -22,24 +22,6 @@ type latestBlock struct {
...
@@ -22,24 +22,6 @@ type latestBlock struct {
TxIndexes
[]
uint64
`json:"txIndexes"`
TxIndexes
[]
uint64
`json:"txIndexes"`
}
}
type
header
struct
{
Hash
string
`json:"hash"`
Ver
uint64
`json:"ver"`
PrevBlock
string
`json:"prev_block"`
MerkleRoot
string
`json:"mrkl_root"`
Time
int64
`json:"time"`
Bits
int64
`json:"bits"`
Fee
float64
`json:"fee,omitempty"`
Nonce
int64
`json:"nonce"`
TxNum
uint64
`json:"n_tx"`
Size
uint64
`json:"size"`
BlockIndex
uint64
`json:"block_index"`
MainChain
bool
`json:"main_chain"`
Height
uint64
`json:"height"`
ReceivedTime
int64
`json:"received_time"`
RelayedBy
string
`json:"relayed_by"`
}
func
(
b
*
block
)
BtcHeader
()
*
ty
.
BtcHeader
{
func
(
b
*
block
)
BtcHeader
()
*
ty
.
BtcHeader
{
return
&
ty
.
BtcHeader
{
return
&
ty
.
BtcHeader
{
Hash
:
b
.
Hash
,
Hash
:
b
.
Hash
,
...
...
plugin/dapp/relay/rpc/rpc_test.go
View file @
fe3b45fd
...
@@ -3,19 +3,3 @@
...
@@ -3,19 +3,3 @@
// license that can be found in the LICENSE file.
// license that can be found in the LICENSE file.
package
rpc
package
rpc
import
(
"github.com/33cn/chain33/client/mocks"
rpctypes
"github.com/33cn/chain33/rpc/types"
)
func
newTestChannelClient
()
*
channelClient
{
api
:=
&
mocks
.
QueueProtocolAPI
{}
return
&
channelClient
{
ChannelClient
:
rpctypes
.
ChannelClient
{
QueueProtocolAPI
:
api
},
}
}
func
newTestJrpcClient
()
*
Jrpc
{
return
&
Jrpc
{
cli
:
newTestChannelClient
()}
}
plugin/dapp/retrieve/executor/retrieve_test.go
deleted
100755 → 0
View file @
cf334942
This diff is collapsed.
Click to expand it.
plugin/dapp/retrieve/executor/retrieve_unit_test.go
View file @
fe3b45fd
...
@@ -8,8 +8,10 @@ import (
...
@@ -8,8 +8,10 @@ import (
"bytes"
"bytes"
"errors"
"errors"
"fmt"
"fmt"
"math/rand"
"testing"
"testing"
"github.com/33cn/chain33/common/address"
"github.com/33cn/chain33/common/crypto"
"github.com/33cn/chain33/common/crypto"
"github.com/33cn/chain33/common/db"
"github.com/33cn/chain33/common/db"
"github.com/33cn/chain33/executor"
"github.com/33cn/chain33/executor"
...
@@ -28,6 +30,18 @@ var (
...
@@ -28,6 +30,18 @@ var (
retrieve
drivers
.
Driver
retrieve
drivers
.
Driver
)
)
func
genaddress
()
(
string
,
crypto
.
PrivKey
)
{
cr
,
err
:=
crypto
.
New
(
types
.
GetSignName
(
""
,
types
.
SECP256K1
))
if
err
!=
nil
{
panic
(
err
)
}
privto
,
err
:=
cr
.
GenKey
()
if
err
!=
nil
{
panic
(
err
)
}
addrto
:=
address
.
PubKeyToAddress
(
privto
.
PubKey
()
.
Bytes
())
return
addrto
.
String
(),
privto
}
func
init
()
{
func
init
()
{
backupAddr
,
backupPriv
=
genaddress
()
backupAddr
,
backupPriv
=
genaddress
()
defaultAddr
,
defaultPriv
=
genaddress
()
defaultAddr
,
defaultPriv
=
genaddress
()
...
@@ -251,7 +265,7 @@ func ConstructBackupTx() *types.Transaction {
...
@@ -251,7 +265,7 @@ func ConstructBackupTx() *types.Transaction {
//fmt.Println(vlock)
//fmt.Println(vlock)
transfer
:=
&
rt
.
RetrieveAction
{
Value
:
vbackup
,
Ty
:
rt
.
RetrieveActionBackup
}
transfer
:=
&
rt
.
RetrieveAction
{
Value
:
vbackup
,
Ty
:
rt
.
RetrieveActionBackup
}
tx
:=
&
types
.
Transaction
{
Execer
:
[]
byte
(
"retrieve"
),
Payload
:
types
.
Encode
(
transfer
),
Fee
:
fee
,
To
:
backupAddr
}
tx
:=
&
types
.
Transaction
{
Execer
:
[]
byte
(
"retrieve"
),
Payload
:
types
.
Encode
(
transfer
),
Fee
:
fee
,
To
:
backupAddr
}
tx
.
Nonce
=
r
.
Int63
()
tx
.
Nonce
=
r
and
.
Int63
()
tx
.
Sign
(
types
.
SECP256K1
,
defaultPriv
)
tx
.
Sign
(
types
.
SECP256K1
,
defaultPriv
)
return
tx
return
tx
}
}
...
@@ -261,7 +275,7 @@ func ConstructPrepareTx() *types.Transaction {
...
@@ -261,7 +275,7 @@ func ConstructPrepareTx() *types.Transaction {
vprepare
:=
&
rt
.
RetrieveAction_Prepare
{
Prepare
:
&
rt
.
PrepareRetrieve
{
BackupAddress
:
backupAddr
,
DefaultAddress
:
defaultAddr
}}
vprepare
:=
&
rt
.
RetrieveAction_Prepare
{
Prepare
:
&
rt
.
PrepareRetrieve
{
BackupAddress
:
backupAddr
,
DefaultAddress
:
defaultAddr
}}
transfer
:=
&
rt
.
RetrieveAction
{
Value
:
vprepare
,
Ty
:
rt
.
RetrieveActionPrepare
}
transfer
:=
&
rt
.
RetrieveAction
{
Value
:
vprepare
,
Ty
:
rt
.
RetrieveActionPrepare
}
tx
:=
&
types
.
Transaction
{
Execer
:
[]
byte
(
"retrieve"
),
Payload
:
types
.
Encode
(
transfer
),
Fee
:
fee
,
To
:
backupAddr
}
tx
:=
&
types
.
Transaction
{
Execer
:
[]
byte
(
"retrieve"
),
Payload
:
types
.
Encode
(
transfer
),
Fee
:
fee
,
To
:
backupAddr
}
tx
.
Nonce
=
r
.
Int63
()
tx
.
Nonce
=
r
and
.
Int63
()
tx
.
Sign
(
types
.
SECP256K1
,
backupPriv
)
tx
.
Sign
(
types
.
SECP256K1
,
backupPriv
)
//tx.Sign(types.SECP256K1, defaultPriv)
//tx.Sign(types.SECP256K1, defaultPriv)
return
tx
return
tx
...
@@ -273,7 +287,7 @@ func ConstructPerformTx() *types.Transaction {
...
@@ -273,7 +287,7 @@ func ConstructPerformTx() *types.Transaction {
vperform
:=
&
rt
.
RetrieveAction_Perform
{
Perform
:
&
rt
.
PerformRetrieve
{
BackupAddress
:
backupAddr
,
DefaultAddress
:
defaultAddr
}}
vperform
:=
&
rt
.
RetrieveAction_Perform
{
Perform
:
&
rt
.
PerformRetrieve
{
BackupAddress
:
backupAddr
,
DefaultAddress
:
defaultAddr
}}
transfer
:=
&
rt
.
RetrieveAction
{
Value
:
vperform
,
Ty
:
rt
.
RetrieveActionPerform
}
transfer
:=
&
rt
.
RetrieveAction
{
Value
:
vperform
,
Ty
:
rt
.
RetrieveActionPerform
}
tx
:=
&
types
.
Transaction
{
Execer
:
[]
byte
(
"retrieve"
),
Payload
:
types
.
Encode
(
transfer
),
Fee
:
fee
,
To
:
backupAddr
}
tx
:=
&
types
.
Transaction
{
Execer
:
[]
byte
(
"retrieve"
),
Payload
:
types
.
Encode
(
transfer
),
Fee
:
fee
,
To
:
backupAddr
}
tx
.
Nonce
=
r
.
Int63
()
tx
.
Nonce
=
r
and
.
Int63
()
tx
.
Sign
(
types
.
SECP256K1
,
backupPriv
)
tx
.
Sign
(
types
.
SECP256K1
,
backupPriv
)
return
tx
return
tx
...
...
plugin/dapp/ticket/executor/ticket_test.go
View file @
fe3b45fd
...
@@ -43,13 +43,13 @@ func TestTicketPrice(t *testing.T) {
...
@@ -43,13 +43,13 @@ func TestTicketPrice(t *testing.T) {
func
TestCheckFork
(
t
*
testing
.
T
)
{
func
TestCheckFork
(
t
*
testing
.
T
)
{
assert
.
Equal
(
t
,
int64
(
1
),
types
.
GetFork
(
"ForkChainParamV2"
))
assert
.
Equal
(
t
,
int64
(
1
),
types
.
GetFork
(
"ForkChainParamV2"
))
p1
:=
types
.
GetP
(
0
)
p1
:=
types
.
GetP
(
0
)
assert
.
Equal
(
t
,
int64
(
10000
*
types
.
Coin
)
,
p1
.
TicketPrice
)
assert
.
Equal
(
t
,
10000
*
types
.
Coin
,
p1
.
TicketPrice
)
p1
=
types
.
GetP
(
1
)
p1
=
types
.
GetP
(
1
)
assert
.
Equal
(
t
,
int64
(
3000
*
types
.
Coin
)
,
p1
.
TicketPrice
)
assert
.
Equal
(
t
,
3000
*
types
.
Coin
,
p1
.
TicketPrice
)
p1
=
types
.
GetP
(
2
)
p1
=
types
.
GetP
(
2
)
assert
.
Equal
(
t
,
int64
(
3000
*
types
.
Coin
)
,
p1
.
TicketPrice
)
assert
.
Equal
(
t
,
3000
*
types
.
Coin
,
p1
.
TicketPrice
)
p1
=
types
.
GetP
(
3
)
p1
=
types
.
GetP
(
3
)
assert
.
Equal
(
t
,
int64
(
3000
*
types
.
Coin
)
,
p1
.
TicketPrice
)
assert
.
Equal
(
t
,
3000
*
types
.
Coin
,
p1
.
TicketPrice
)
}
}
func
TestTicket
(
t
*
testing
.
T
)
{
func
TestTicket
(
t
*
testing
.
T
)
{
...
...
plugin/dapp/token/executor/token_new_test.go
View file @
fe3b45fd
...
@@ -16,7 +16,6 @@ import (
...
@@ -16,7 +16,6 @@ import (
"github.com/33cn/chain33/common"
"github.com/33cn/chain33/common"
"github.com/33cn/chain33/common/address"
"github.com/33cn/chain33/common/address"
"github.com/33cn/chain33/common/crypto"
"github.com/33cn/chain33/common/crypto"
cty
"github.com/33cn/chain33/system/dapp/coins/types"
"github.com/33cn/chain33/types"
"github.com/33cn/chain33/types"
pty
"github.com/33cn/plugin/plugin/dapp/token/types"
pty
"github.com/33cn/plugin/plugin/dapp/token/types"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/assert"
...
@@ -385,28 +384,6 @@ func TestQueryTokenLogs(t *testing.T) {
...
@@ -385,28 +384,6 @@ func TestQueryTokenLogs(t *testing.T) {
}
}
}
}
//***************************************************
//**************common actions for Test**************
//***************************************************
func
sendtoaddress
(
c
types
.
Chain33Client
,
priv
crypto
.
PrivKey
,
to
string
,
amount
int64
)
([]
byte
,
error
)
{
v
:=
&
cty
.
CoinsAction_Transfer
{
Transfer
:
&
types
.
AssetsTransfer
{
Amount
:
amount
}}
transfer
:=
&
cty
.
CoinsAction
{
Value
:
v
,
Ty
:
cty
.
CoinsActionTransfer
}
tx
:=
&
types
.
Transaction
{
Execer
:
[]
byte
(
"coins"
),
Payload
:
types
.
Encode
(
transfer
),
Fee
:
fee
,
To
:
to
}
tx
.
Nonce
=
r
.
Int63
()
tx
.
Sign
(
types
.
SECP256K1
,
priv
)
// Contact the server and print out its response.
reply
,
err
:=
c
.
SendTransaction
(
context
.
Background
(),
tx
)
if
err
!=
nil
{
fmt
.
Println
(
"err"
,
err
)
return
nil
,
err
}
if
!
reply
.
IsOk
{
fmt
.
Println
(
"err = "
,
reply
.
GetMsg
())
return
nil
,
errors
.
New
(
string
(
reply
.
GetMsg
()))
}
return
tx
.
Hash
(),
nil
}
func
waitTx
(
hash
[]
byte
)
bool
{
func
waitTx
(
hash
[]
byte
)
bool
{
i
:=
0
i
:=
0
for
{
for
{
...
@@ -428,19 +405,6 @@ func waitTx(hash []byte) bool {
...
@@ -428,19 +405,6 @@ func waitTx(hash []byte) bool {
}
}
}
}
func
genaddress
()
(
string
,
crypto
.
PrivKey
)
{
cr
,
err
:=
crypto
.
New
(
types
.
GetSignName
(
""
,
types
.
SECP256K1
))
if
err
!=
nil
{
panic
(
err
)
}
privto
,
err
:=
cr
.
GenKey
()
if
err
!=
nil
{
panic
(
err
)
}
addrto
:=
address
.
PubKeyToAddress
(
privto
.
PubKey
()
.
Bytes
())
return
addrto
.
String
(),
privto
}
func
getprivkey
(
key
string
)
crypto
.
PrivKey
{
func
getprivkey
(
key
string
)
crypto
.
PrivKey
{
cr
,
err
:=
crypto
.
New
(
types
.
GetSignName
(
""
,
types
.
SECP256K1
))
cr
,
err
:=
crypto
.
New
(
types
.
GetSignName
(
""
,
types
.
SECP256K1
))
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -469,19 +433,19 @@ func TestToken_validSymbolWithHeight(t *testing.T) {
...
@@ -469,19 +433,19 @@ func TestToken_validSymbolWithHeight(t *testing.T) {
height
int64
height
int64
expect
bool
expect
bool
}{
}{
{[]
byte
(
"x"
),
int64
(
forkBadTokenSymbol
-
1
)
,
false
},
{[]
byte
(
"x"
),
forkBadTokenSymbol
-
1
,
false
},
{[]
byte
(
"X林"
),
int64
(
forkBadTokenSymbol
-
1
)
,
true
},
{[]
byte
(
"X林"
),
forkBadTokenSymbol
-
1
,
true
},
{[]
byte
(
"x"
),
int64
(
forkBadTokenSymbol
)
,
false
},
{[]
byte
(
"x"
),
forkBadTokenSymbol
,
false
},
{[]
byte
(
"X林"
),
int64
(
forkBadTokenSymbol
)
,
false
},
{[]
byte
(
"X林"
),
forkBadTokenSymbol
,
false
},
{[]
byte
(
"x"
),
int64
(
forkTokenSymbolWithNumber
-
1
)
,
false
},
{[]
byte
(
"x"
),
forkTokenSymbolWithNumber
-
1
,
false
},
{[]
byte
(
"X林"
),
int64
(
forkTokenSymbolWithNumber
-
1
)
,
false
},
{[]
byte
(
"X林"
),
forkTokenSymbolWithNumber
-
1
,
false
},
{[]
byte
(
"X1"
),
int64
(
forkTokenSymbolWithNumber
-
1
)
,
false
},
{[]
byte
(
"X1"
),
forkTokenSymbolWithNumber
-
1
,
false
},
{[]
byte
(
"x"
),
int64
(
forkTokenSymbolWithNumber
)
,
false
},
{[]
byte
(
"x"
),
forkTokenSymbolWithNumber
,
false
},
{[]
byte
(
"X林"
),
int64
(
forkTokenSymbolWithNumber
)
,
false
},
{[]
byte
(
"X林"
),
forkTokenSymbolWithNumber
,
false
},
{[]
byte
(
"X1"
),
int64
(
forkTokenSymbolWithNumber
)
,
true
},
{[]
byte
(
"X1"
),
forkTokenSymbolWithNumber
,
true
},
}
}
for
_
,
c
:=
range
cases
{
for
_
,
c
:=
range
cases
{
...
...
plugin/store/kvmvcc/kvmvccdb_test.go
View file @
fe3b45fd
...
@@ -440,8 +440,8 @@ func BenchmarkGet(b *testing.B) {
...
@@ -440,8 +440,8 @@ func BenchmarkGet(b *testing.B) {
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
key
:=
GetRandomString
(
MaxKeylenth
)
key
:=
GetRandomString
(
MaxKeylenth
)
value
:=
fmt
.
Sprintf
(
"%s%d"
,
key
,
i
)
value
:=
fmt
.
Sprintf
(
"%s%d"
,
key
,
i
)
keys
=
append
(
keys
,
[]
byte
(
string
(
key
)
))
keys
=
append
(
keys
,
[]
byte
(
key
))
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
[]
byte
(
string
(
key
)),
Value
:
[]
byte
(
string
(
value
)
)})
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
[]
byte
(
key
),
Value
:
[]
byte
(
value
)})
if
i
%
10000
==
0
{
if
i
%
10000
==
0
{
datas
:=
&
types
.
StoreSet
{
StateHash
:
hash
,
KV
:
kv
,
Height
:
0
}
datas
:=
&
types
.
StoreSet
{
StateHash
:
hash
,
KV
:
kv
,
Height
:
0
}
hash
,
err
=
store
.
Set
(
datas
,
true
)
hash
,
err
=
store
.
Set
(
datas
,
true
)
...
@@ -487,8 +487,8 @@ func BenchmarkStoreGetKvs4N(b *testing.B) {
...
@@ -487,8 +487,8 @@ func BenchmarkStoreGetKvs4N(b *testing.B) {
for
i
:=
0
;
i
<
kvnum
;
i
++
{
for
i
:=
0
;
i
<
kvnum
;
i
++
{
key
=
GetRandomString
(
MaxKeylenth
)
key
=
GetRandomString
(
MaxKeylenth
)
value
=
fmt
.
Sprintf
(
"v%d"
,
i
)
value
=
fmt
.
Sprintf
(
"v%d"
,
i
)
keys
=
append
(
keys
,
[]
byte
(
string
(
key
)
))
keys
=
append
(
keys
,
[]
byte
(
key
))
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
[]
byte
(
string
(
key
)),
Value
:
[]
byte
(
string
(
value
)
)})
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
[]
byte
(
key
),
Value
:
[]
byte
(
value
)})
}
}
datas
:=
&
types
.
StoreSet
{
datas
:=
&
types
.
StoreSet
{
StateHash
:
drivers
.
EmptyRoot
[
:
],
StateHash
:
drivers
.
EmptyRoot
[
:
],
...
@@ -531,8 +531,8 @@ func BenchmarkStoreGetKvsForNN(b *testing.B) {
...
@@ -531,8 +531,8 @@ func BenchmarkStoreGetKvsForNN(b *testing.B) {
for
i
:=
0
;
i
<
30
;
i
++
{
for
i
:=
0
;
i
<
30
;
i
++
{
key
=
GetRandomString
(
MaxKeylenth
)
key
=
GetRandomString
(
MaxKeylenth
)
value
=
fmt
.
Sprintf
(
"v%d"
,
i
)
value
=
fmt
.
Sprintf
(
"v%d"
,
i
)
keys
=
append
(
keys
,
[]
byte
(
string
(
key
)
))
keys
=
append
(
keys
,
[]
byte
(
key
))
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
[]
byte
(
string
(
key
)),
Value
:
[]
byte
(
string
(
value
)
)})
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
[]
byte
(
key
),
Value
:
[]
byte
(
value
)})
}
}
datas
:=
&
types
.
StoreSet
{
datas
:=
&
types
.
StoreSet
{
StateHash
:
drivers
.
EmptyRoot
[
:
],
StateHash
:
drivers
.
EmptyRoot
[
:
],
...
@@ -591,8 +591,8 @@ func BenchmarkStoreGetKvsFor10000(b *testing.B) {
...
@@ -591,8 +591,8 @@ func BenchmarkStoreGetKvsFor10000(b *testing.B) {
for
i
:=
0
;
i
<
30
;
i
++
{
for
i
:=
0
;
i
<
30
;
i
++
{
key
=
GetRandomString
(
MaxKeylenth
)
key
=
GetRandomString
(
MaxKeylenth
)
value
=
fmt
.
Sprintf
(
"v%d"
,
i
)
value
=
fmt
.
Sprintf
(
"v%d"
,
i
)
keys
=
append
(
keys
,
[]
byte
(
string
(
key
)
))
keys
=
append
(
keys
,
[]
byte
(
key
))
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
[]
byte
(
string
(
key
)),
Value
:
[]
byte
(
string
(
value
)
)})
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
[]
byte
(
key
),
Value
:
[]
byte
(
value
)})
}
}
datas
:=
&
types
.
StoreSet
{
datas
:=
&
types
.
StoreSet
{
StateHash
:
drivers
.
EmptyRoot
[
:
],
StateHash
:
drivers
.
EmptyRoot
[
:
],
...
@@ -654,8 +654,8 @@ func BenchmarkGetIter(b *testing.B) {
...
@@ -654,8 +654,8 @@ func BenchmarkGetIter(b *testing.B) {
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
key
:=
GetRandomString
(
MaxKeylenth
)
key
:=
GetRandomString
(
MaxKeylenth
)
value
:=
fmt
.
Sprintf
(
"%s%d"
,
key
,
i
)
value
:=
fmt
.
Sprintf
(
"%s%d"
,
key
,
i
)
keys
=
append
(
keys
,
[]
byte
(
string
(
key
)
))
keys
=
append
(
keys
,
[]
byte
(
key
))
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
[]
byte
(
string
(
key
)),
Value
:
[]
byte
(
string
(
value
)
)})
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
[]
byte
(
key
),
Value
:
[]
byte
(
value
)})
if
i
%
10000
==
0
{
if
i
%
10000
==
0
{
datas
:=
&
types
.
StoreSet
{
StateHash
:
hash
,
KV
:
kv
,
Height
:
0
}
datas
:=
&
types
.
StoreSet
{
StateHash
:
hash
,
KV
:
kv
,
Height
:
0
}
hash
,
err
=
store
.
Set
(
datas
,
true
)
hash
,
err
=
store
.
Set
(
datas
,
true
)
...
@@ -699,8 +699,8 @@ func BenchmarkSet(b *testing.B) {
...
@@ -699,8 +699,8 @@ func BenchmarkSet(b *testing.B) {
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
key
:=
GetRandomString
(
MaxKeylenth
)
key
:=
GetRandomString
(
MaxKeylenth
)
value
:=
fmt
.
Sprintf
(
"%s%d"
,
key
,
i
)
value
:=
fmt
.
Sprintf
(
"%s%d"
,
key
,
i
)
keys
=
append
(
keys
,
[]
byte
(
string
(
key
)
))
keys
=
append
(
keys
,
[]
byte
(
key
))
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
[]
byte
(
string
(
key
)),
Value
:
[]
byte
(
string
(
value
)
)})
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
[]
byte
(
key
),
Value
:
[]
byte
(
value
)})
if
i
%
10000
==
0
{
if
i
%
10000
==
0
{
datas
:=
&
types
.
StoreSet
{
StateHash
:
hash
,
KV
:
kv
,
Height
:
0
}
datas
:=
&
types
.
StoreSet
{
StateHash
:
hash
,
KV
:
kv
,
Height
:
0
}
hash
,
err
=
store
.
Set
(
datas
,
true
)
hash
,
err
=
store
.
Set
(
datas
,
true
)
...
@@ -736,8 +736,8 @@ func BenchmarkStoreSet(b *testing.B) {
...
@@ -736,8 +736,8 @@ func BenchmarkStoreSet(b *testing.B) {
for
i
:=
0
;
i
<
30
;
i
++
{
for
i
:=
0
;
i
<
30
;
i
++
{
key
=
GetRandomString
(
MaxKeylenth
)
key
=
GetRandomString
(
MaxKeylenth
)
value
=
fmt
.
Sprintf
(
"v%d"
,
i
)
value
=
fmt
.
Sprintf
(
"v%d"
,
i
)
keys
=
append
(
keys
,
[]
byte
(
string
(
key
)
))
keys
=
append
(
keys
,
[]
byte
(
key
))
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
[]
byte
(
string
(
key
)),
Value
:
[]
byte
(
string
(
value
)
)})
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
[]
byte
(
key
),
Value
:
[]
byte
(
value
)})
}
}
datas
:=
&
types
.
StoreSet
{
datas
:=
&
types
.
StoreSet
{
StateHash
:
drivers
.
EmptyRoot
[
:
],
StateHash
:
drivers
.
EmptyRoot
[
:
],
...
@@ -771,8 +771,8 @@ func BenchmarkSetIter(b *testing.B) {
...
@@ -771,8 +771,8 @@ func BenchmarkSetIter(b *testing.B) {
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
key
:=
GetRandomString
(
MaxKeylenth
)
key
:=
GetRandomString
(
MaxKeylenth
)
value
:=
fmt
.
Sprintf
(
"%s%d"
,
key
,
i
)
value
:=
fmt
.
Sprintf
(
"%s%d"
,
key
,
i
)
keys
=
append
(
keys
,
[]
byte
(
string
(
key
)
))
keys
=
append
(
keys
,
[]
byte
(
key
))
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
[]
byte
(
string
(
key
)),
Value
:
[]
byte
(
string
(
value
)
)})
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
[]
byte
(
key
),
Value
:
[]
byte
(
value
)})
if
i
%
10000
==
0
{
if
i
%
10000
==
0
{
datas
:=
&
types
.
StoreSet
{
StateHash
:
hash
,
KV
:
kv
,
Height
:
0
}
datas
:=
&
types
.
StoreSet
{
StateHash
:
hash
,
KV
:
kv
,
Height
:
0
}
hash
,
err
=
store
.
Set
(
datas
,
true
)
hash
,
err
=
store
.
Set
(
datas
,
true
)
...
@@ -790,16 +790,6 @@ func BenchmarkSetIter(b *testing.B) {
...
@@ -790,16 +790,6 @@ func BenchmarkSetIter(b *testing.B) {
fmt
.
Println
(
"kvmvcc BenchmarkSet cost time is"
,
end
.
Sub
(
start
),
"num is"
,
b
.
N
)
fmt
.
Println
(
"kvmvcc BenchmarkSet cost time is"
,
end
.
Sub
(
start
),
"num is"
,
b
.
N
)
}
}
func
isDirExists
(
path
string
)
bool
{
fi
,
err
:=
os
.
Stat
(
path
)
if
err
!=
nil
{
return
os
.
IsExist
(
err
)
}
return
fi
.
IsDir
()
}
//一次设定多对kv,测试一次的时间/多少对kv,来算平均一对kv的耗时。
//一次设定多对kv,测试一次的时间/多少对kv,来算平均一对kv的耗时。
func
BenchmarkMemSet
(
b
*
testing
.
B
)
{
func
BenchmarkMemSet
(
b
*
testing
.
B
)
{
dir
,
err
:=
ioutil
.
TempDir
(
""
,
"example"
)
dir
,
err
:=
ioutil
.
TempDir
(
""
,
"example"
)
...
@@ -818,8 +808,8 @@ func BenchmarkMemSet(b *testing.B) {
...
@@ -818,8 +808,8 @@ func BenchmarkMemSet(b *testing.B) {
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
key
=
GetRandomString
(
MaxKeylenth
)
key
=
GetRandomString
(
MaxKeylenth
)
value
=
fmt
.
Sprintf
(
"v%d"
,
i
)
value
=
fmt
.
Sprintf
(
"v%d"
,
i
)
keys
=
append
(
keys
,
[]
byte
(
string
(
key
)
))
keys
=
append
(
keys
,
[]
byte
(
key
))
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
[]
byte
(
string
(
key
)),
Value
:
[]
byte
(
string
(
value
)
)})
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
[]
byte
(
key
),
Value
:
[]
byte
(
value
)})
}
}
datas
:=
&
types
.
StoreSet
{
datas
:=
&
types
.
StoreSet
{
StateHash
:
drivers
.
EmptyRoot
[
:
],
StateHash
:
drivers
.
EmptyRoot
[
:
],
...
@@ -852,8 +842,8 @@ func BenchmarkStoreMemSet(b *testing.B) {
...
@@ -852,8 +842,8 @@ func BenchmarkStoreMemSet(b *testing.B) {
for
i
:=
0
;
i
<
30
;
i
++
{
for
i
:=
0
;
i
<
30
;
i
++
{
key
=
GetRandomString
(
MaxKeylenth
)
key
=
GetRandomString
(
MaxKeylenth
)
value
=
fmt
.
Sprintf
(
"v%d"
,
i
)
value
=
fmt
.
Sprintf
(
"v%d"
,
i
)
keys
=
append
(
keys
,
[]
byte
(
string
(
key
)
))
keys
=
append
(
keys
,
[]
byte
(
key
))
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
[]
byte
(
string
(
key
)),
Value
:
[]
byte
(
string
(
value
)
)})
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
[]
byte
(
key
),
Value
:
[]
byte
(
value
)})
}
}
datas
:=
&
types
.
StoreSet
{
datas
:=
&
types
.
StoreSet
{
StateHash
:
drivers
.
EmptyRoot
[
:
],
StateHash
:
drivers
.
EmptyRoot
[
:
],
...
@@ -890,8 +880,8 @@ func BenchmarkCommit(b *testing.B) {
...
@@ -890,8 +880,8 @@ func BenchmarkCommit(b *testing.B) {
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
key
=
GetRandomString
(
MaxKeylenth
)
key
=
GetRandomString
(
MaxKeylenth
)
value
=
fmt
.
Sprintf
(
"v%d"
,
i
)
value
=
fmt
.
Sprintf
(
"v%d"
,
i
)
keys
=
append
(
keys
,
[]
byte
(
string
(
key
)
))
keys
=
append
(
keys
,
[]
byte
(
key
))
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
[]
byte
(
string
(
key
)),
Value
:
[]
byte
(
string
(
value
)
)})
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
[]
byte
(
key
),
Value
:
[]
byte
(
value
)})
}
}
datas
:=
&
types
.
StoreSet
{
datas
:=
&
types
.
StoreSet
{
StateHash
:
drivers
.
EmptyRoot
[
:
],
StateHash
:
drivers
.
EmptyRoot
[
:
],
...
@@ -931,8 +921,8 @@ func BenchmarkStoreCommit(b *testing.B) {
...
@@ -931,8 +921,8 @@ func BenchmarkStoreCommit(b *testing.B) {
for
i
:=
0
;
i
<
30
;
i
++
{
for
i
:=
0
;
i
<
30
;
i
++
{
key
=
GetRandomString
(
MaxKeylenth
)
key
=
GetRandomString
(
MaxKeylenth
)
value
=
fmt
.
Sprintf
(
"v%d"
,
i
)
value
=
fmt
.
Sprintf
(
"v%d"
,
i
)
keys
=
append
(
keys
,
[]
byte
(
string
(
key
)
))
keys
=
append
(
keys
,
[]
byte
(
key
))
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
[]
byte
(
string
(
key
)),
Value
:
[]
byte
(
string
(
value
)
)})
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
[]
byte
(
key
),
Value
:
[]
byte
(
value
)})
}
}
datas
:=
&
types
.
StoreSet
{
datas
:=
&
types
.
StoreSet
{
StateHash
:
drivers
.
EmptyRoot
[
:
],
StateHash
:
drivers
.
EmptyRoot
[
:
],
...
@@ -975,8 +965,8 @@ func BenchmarkIterMemSet(b *testing.B) {
...
@@ -975,8 +965,8 @@ func BenchmarkIterMemSet(b *testing.B) {
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
key
=
GetRandomString
(
MaxKeylenth
)
key
=
GetRandomString
(
MaxKeylenth
)
value
=
fmt
.
Sprintf
(
"v%d"
,
i
)
value
=
fmt
.
Sprintf
(
"v%d"
,
i
)
keys
=
append
(
keys
,
[]
byte
(
string
(
key
)
))
keys
=
append
(
keys
,
[]
byte
(
key
))
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
[]
byte
(
string
(
key
)),
Value
:
[]
byte
(
string
(
value
)
)})
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
[]
byte
(
key
),
Value
:
[]
byte
(
value
)})
}
}
datas
:=
&
types
.
StoreSet
{
datas
:=
&
types
.
StoreSet
{
StateHash
:
drivers
.
EmptyRoot
[
:
],
StateHash
:
drivers
.
EmptyRoot
[
:
],
...
@@ -1008,8 +998,8 @@ func BenchmarkIterCommit(b *testing.B) {
...
@@ -1008,8 +998,8 @@ func BenchmarkIterCommit(b *testing.B) {
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
key
=
GetRandomString
(
MaxKeylenth
)
key
=
GetRandomString
(
MaxKeylenth
)
value
=
fmt
.
Sprintf
(
"v%d"
,
i
)
value
=
fmt
.
Sprintf
(
"v%d"
,
i
)
keys
=
append
(
keys
,
[]
byte
(
string
(
key
)
))
keys
=
append
(
keys
,
[]
byte
(
key
))
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
[]
byte
(
string
(
key
)),
Value
:
[]
byte
(
string
(
value
)
)})
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
[]
byte
(
key
),
Value
:
[]
byte
(
value
)})
}
}
datas
:=
&
types
.
StoreSet
{
datas
:=
&
types
.
StoreSet
{
StateHash
:
drivers
.
EmptyRoot
[
:
],
StateHash
:
drivers
.
EmptyRoot
[
:
],
...
...
plugin/store/kvmvccmavl/kvmvcc_mavl_test.go
View file @
fe3b45fd
...
@@ -1386,8 +1386,8 @@ func benchmarkStoreCommit(b *testing.B, isResetForkHeight bool) {
...
@@ -1386,8 +1386,8 @@ func benchmarkStoreCommit(b *testing.B, isResetForkHeight bool) {
for
i
:=
0
;
i
<
30
;
i
++
{
for
i
:=
0
;
i
<
30
;
i
++
{
key
=
GetRandomString
(
MaxKeylenth
)
key
=
GetRandomString
(
MaxKeylenth
)
value
=
fmt
.
Sprintf
(
"v%d"
,
i
)
value
=
fmt
.
Sprintf
(
"v%d"
,
i
)
keys
=
append
(
keys
,
[]
byte
(
string
(
key
)
))
keys
=
append
(
keys
,
[]
byte
(
key
))
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
[]
byte
(
string
(
key
)),
Value
:
[]
byte
(
string
(
value
)
)})
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
[]
byte
(
key
),
Value
:
[]
byte
(
value
)})
}
}
datas
:=
&
types
.
StoreSet
{
datas
:=
&
types
.
StoreSet
{
StateHash
:
drivers
.
EmptyRoot
[
:
],
StateHash
:
drivers
.
EmptyRoot
[
:
],
...
...
plugin/store/mpt/db/trie_test.go
View file @
fe3b45fd
...
@@ -71,7 +71,7 @@ func TestEmptyTrie(t *testing.T) {
...
@@ -71,7 +71,7 @@ func TestEmptyTrie(t *testing.T) {
var
trie
Trie
var
trie
Trie
res
:=
trie
.
Hash
()
res
:=
trie
.
Hash
()
exp
:=
emptyRoot
exp
:=
emptyRoot
if
res
!=
common
.
Hash
(
exp
)
{
if
res
!=
exp
{
t
.
Errorf
(
"expected %x got %x"
,
exp
,
res
)
t
.
Errorf
(
"expected %x got %x"
,
exp
,
res
)
}
}
}
}
...
...
plugin/store/mpt/db2/trie_test.go
View file @
fe3b45fd
...
@@ -69,7 +69,7 @@ func TestEmptyTrie(t *testing.T) {
...
@@ -69,7 +69,7 @@ func TestEmptyTrie(t *testing.T) {
var
trie
Trie
var
trie
Trie
res
:=
trie
.
Hash
()
res
:=
trie
.
Hash
()
exp
:=
emptyRoot
exp
:=
emptyRoot
if
res
!=
common
.
Hash
(
exp
)
{
if
res
!=
exp
{
t
.
Errorf
(
"expected %x got %x"
,
exp
,
res
)
t
.
Errorf
(
"expected %x got %x"
,
exp
,
res
)
}
}
}
}
...
...
plugin/store/mpt/mpt_test.go
View file @
fe3b45fd
...
@@ -168,15 +168,6 @@ func TestKvdbRollback(t *testing.T) {
...
@@ -168,15 +168,6 @@ func TestKvdbRollback(t *testing.T) {
assert
.
Nil
(
t
,
notExistHash
)
assert
.
Nil
(
t
,
notExistHash
)
}
}
var
checkKVResult
[]
*
types
.
KeyValue
func
checkKV
(
k
,
v
[]
byte
)
bool
{
checkKVResult
=
append
(
checkKVResult
,
&
types
.
KeyValue
{
Key
:
k
,
Value
:
v
})
//mlog.Debug("checkKV", "key", string(k), "value", string(v))
return
false
}
func
GetRandomString
(
length
int
)
string
{
func
GetRandomString
(
length
int
)
string
{
return
common
.
GetRandPrintString
(
20
,
length
)
return
common
.
GetRandPrintString
(
20
,
length
)
}
}
...
@@ -197,8 +188,8 @@ func BenchmarkGet(b *testing.B) {
...
@@ -197,8 +188,8 @@ func BenchmarkGet(b *testing.B) {
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
key
:=
GetRandomString
(
MaxKeylenth
)
key
:=
GetRandomString
(
MaxKeylenth
)
value
:=
fmt
.
Sprintf
(
"%s%d"
,
key
,
i
)
value
:=
fmt
.
Sprintf
(
"%s%d"
,
key
,
i
)
keys
=
append
(
keys
,
[]
byte
(
string
(
key
)
))
keys
=
append
(
keys
,
[]
byte
(
key
))
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
[]
byte
(
string
(
key
)),
Value
:
[]
byte
(
string
(
value
)
)})
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
[]
byte
(
key
),
Value
:
[]
byte
(
value
)})
if
i
%
10000
==
0
{
if
i
%
10000
==
0
{
datas
:=
&
types
.
StoreSet
{
StateHash
:
hash
,
KV
:
kv
,
Height
:
0
}
datas
:=
&
types
.
StoreSet
{
StateHash
:
hash
,
KV
:
kv
,
Height
:
0
}
hash
,
err
=
store
.
Set
(
datas
,
true
)
hash
,
err
=
store
.
Set
(
datas
,
true
)
...
@@ -239,8 +230,8 @@ func BenchmarkSet(b *testing.B) {
...
@@ -239,8 +230,8 @@ func BenchmarkSet(b *testing.B) {
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
key
:=
GetRandomString
(
MaxKeylenth
)
key
:=
GetRandomString
(
MaxKeylenth
)
value
:=
fmt
.
Sprintf
(
"%s%d"
,
key
,
i
)
value
:=
fmt
.
Sprintf
(
"%s%d"
,
key
,
i
)
keys
=
append
(
keys
,
[]
byte
(
string
(
key
)
))
keys
=
append
(
keys
,
[]
byte
(
key
))
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
[]
byte
(
string
(
key
)),
Value
:
[]
byte
(
string
(
value
)
)})
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
[]
byte
(
key
),
Value
:
[]
byte
(
value
)})
if
i
%
10000
==
0
{
if
i
%
10000
==
0
{
datas
:=
&
types
.
StoreSet
{
StateHash
:
hash
,
KV
:
kv
,
Height
:
0
}
datas
:=
&
types
.
StoreSet
{
StateHash
:
hash
,
KV
:
kv
,
Height
:
0
}
hash
,
err
=
store
.
Set
(
datas
,
true
)
hash
,
err
=
store
.
Set
(
datas
,
true
)
...
@@ -274,7 +265,7 @@ func BenchmarkMemSet(b *testing.B) {
...
@@ -274,7 +265,7 @@ func BenchmarkMemSet(b *testing.B) {
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
key
=
GetRandomString
(
MaxKeylenth
)
key
=
GetRandomString
(
MaxKeylenth
)
value
=
fmt
.
Sprintf
(
"v%d"
,
i
)
value
=
fmt
.
Sprintf
(
"v%d"
,
i
)
keys
=
append
(
keys
,
[]
byte
(
string
(
key
)
))
keys
=
append
(
keys
,
[]
byte
(
key
))
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
[]
byte
(
string
(
key
)),
Value
:
[]
byte
(
string
(
value
))})
kv
=
append
(
kv
,
&
types
.
KeyValue
{
Key
:
[]
byte
(
string
(
key
)),
Value
:
[]
byte
(
string
(
value
))})
}
}
datas
:=
&
types
.
StoreSet
{
datas
:=
&
types
.
StoreSet
{
...
...
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