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
b6105c0a
Commit
b6105c0a
authored
Oct 16, 2019
by
liuyuhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modify evm and paracross
parent
8150a333
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
56 additions
and
21 deletions
+56
-21
evm_test.go
plugin/dapp/evm/commands/evm_test.go
+5
-1
util_test.go
plugin/dapp/evm/executor/tests/util_test.go
+2
-1
assettransfer_test.go
plugin/dapp/paracross/executor/assettransfer_test.go
+18
-2
assetwithdraw_test.go
plugin/dapp/paracross/executor/assetwithdraw_test.go
+7
-0
paracross_test.go
plugin/dapp/paracross/executor/paracross_test.go
+2
-2
para_test.go
plugin/dapp/paracross/testnode/para_test.go
+10
-1
jrpc_channel_test.go
plugin/dapp/ticket/rpc/jrpc_channel_test.go
+3
-8
rpc_real_test.go
plugin/dapp/ticket/rpc/rpc_real_test.go
+8
-0
rpc_test.go
plugin/dapp/ticket/rpc/rpc_test.go
+1
-6
No files found.
plugin/dapp/evm/commands/evm_test.go
View file @
b6105c0a
...
...
@@ -10,16 +10,19 @@ import (
"github.com/stretchr/testify/assert"
// 因为测试程序在外层,而合约类型的初始化在里面,所以需要显示引用,否则不会加载合约插件
_
"github.com/33cn/plugin/plugin/dapp/evm/executor"
evm
"github.com/33cn/plugin/plugin/dapp/evm/executor"
evmtypes
"github.com/33cn/plugin/plugin/dapp/evm/types"
// 需要显示引用系统插件,以加载系统内置合约
"github.com/33cn/chain33/client/mocks"
_
"github.com/33cn/chain33/system"
"github.com/stretchr/testify/mock"
)
// TestQueryDebug 测试命令行调用rpc接口
func
TestQueryDebug
(
t
*
testing
.
T
)
{
var
cfg
=
types
.
NewChain33Config
(
types
.
GetDefaultCfgstring
())
evm
.
Init
(
evmtypes
.
ExecutorName
,
cfg
,
nil
)
var
debugReq
=
evmtypes
.
EvmDebugReq
{
Optype
:
1
}
js
,
err
:=
types
.
PBToJSON
(
&
debugReq
)
assert
.
Nil
(
t
,
err
)
...
...
@@ -35,6 +38,7 @@ func TestQueryDebug(t *testing.T) {
// 这里对需要mock的方法打桩,Close是必须的,其它方法根据需要
mockapi
.
On
(
"Close"
)
.
Return
()
mockapi
.
On
(
"Query"
,
"evm"
,
"EvmDebug"
,
&
debugReq
)
.
Return
(
&
mockResp
,
nil
)
mockapi
.
On
(
"GetConfig"
,
mock
.
Anything
)
.
Return
(
cfg
,
nil
)
mock33
:=
testnode
.
New
(
""
,
mockapi
)
defer
mock33
.
Close
()
...
...
plugin/dapp/evm/executor/tests/util_test.go
View file @
b6105c0a
...
...
@@ -22,9 +22,10 @@ import (
evmtypes
"github.com/33cn/plugin/plugin/dapp/evm/types"
"github.com/33cn/chain33/queue"
"github.com/33cn/chain33/client"
"strings"
)
var
chainTestCfg
=
types
.
NewChain33Config
(
types
.
GetDefaultCfgstring
(
))
var
chainTestCfg
=
types
.
NewChain33Config
(
strings
.
Replace
(
types
.
GetDefaultCfgstring
(),
"Title=
\"
local
\"
"
,
"Title=
\"
chain33
\"
"
,
1
))
func
init
()
{
evm
.
Init
(
evmtypes
.
ExecutorName
,
chainTestCfg
,
nil
)
...
...
plugin/dapp/paracross/executor/assettransfer_test.go
View file @
b6105c0a
...
...
@@ -18,6 +18,8 @@ import (
dbmock
"github.com/33cn/chain33/common/db/mocks"
"github.com/33cn/chain33/types"
pt
"github.com/33cn/plugin/plugin/dapp/paracross/types"
"strings"
"github.com/33cn/plugin/plugin/dapp/paracross/testnode"
"github.com/stretchr/testify/mock"
)
...
...
@@ -55,10 +57,10 @@ func (suite *AssetTransferTestSuite) SetupTest() {
// memdb 不支持KVDB接口, 等测试完Exec , 再扩展 memdb
//suite.localDB, _ = dbm.NewGoMemDB("local", "local", 1024)
suite
.
localDB
=
new
(
dbmock
.
KVDB
)
suite
.
api
=
new
(
apimock
.
QueueProtocolAPI
)
suite
.
api
.
On
(
"GetConfig"
,
mock
.
Anything
)
.
Return
(
chain33TestCfg
,
nil
)
suite
.
exec
=
newParacross
()
.
(
*
Paracross
)
suite
.
api
=
new
(
apimock
.
QueueProtocolAPI
)
suite
.
api
.
On
(
"GetConfig"
,
mock
.
Anything
)
.
Return
(
chain33TestCfg
,
nil
)
suite
.
exec
.
SetAPI
(
suite
.
api
)
suite
.
exec
.
SetLocalDB
(
suite
.
localDB
)
suite
.
exec
.
SetStateDB
(
suite
.
stateDB
)
...
...
@@ -101,6 +103,10 @@ func (suite *AssetTransferTestSuite) SetupTest() {
func
(
suite
*
AssetTransferTestSuite
)
TestExecTransferNobalance
()
{
//types.Init("test", nil)
suite
.
api
=
new
(
apimock
.
QueueProtocolAPI
)
suite
.
api
.
On
(
"GetConfig"
,
mock
.
Anything
)
.
Return
(
chain33TestMainCfg
,
nil
)
suite
.
exec
.
SetAPI
(
suite
.
api
)
toB
:=
Nodes
[
1
]
tx
,
err
:=
createAssetTransferTx
(
suite
.
Suite
,
PrivKeyD
,
toB
)
if
err
!=
nil
{
...
...
@@ -117,6 +123,10 @@ func (suite *AssetTransferTestSuite) TestExecTransferNobalance() {
func
(
suite
*
AssetTransferTestSuite
)
TestExecTransfer
()
{
//types.Init("test", nil)
suite
.
api
=
new
(
apimock
.
QueueProtocolAPI
)
suite
.
api
.
On
(
"GetConfig"
,
mock
.
Anything
)
.
Return
(
chain33TestMainCfg
,
nil
)
suite
.
exec
.
SetAPI
(
suite
.
api
)
toB
:=
Nodes
[
1
]
total
:=
1000
*
types
.
Coin
...
...
@@ -163,6 +173,7 @@ func (suite *AssetTransferTestSuite) TestExecTransfer() {
}
func
(
suite
*
AssetTransferTestSuite
)
TestExecTransferInPara
()
{
chain33TestCfg
=
types
.
NewChain33Config
(
strings
.
Replace
(
testnode
.
DefaultConfig
,
"Title=
\"
user.p.guodun.
\"
"
,
"Title=
\"
user.p.test.
\"
"
,
1
))
//para_init(Title)
toB
:=
Nodes
[
1
]
...
...
@@ -222,6 +233,10 @@ const TestSymbol = "TEST"
func
(
suite
*
AssetTransferTestSuite
)
TestExecTransferToken
()
{
//types.Init("test", nil)
suite
.
api
=
new
(
apimock
.
QueueProtocolAPI
)
suite
.
api
.
On
(
"GetConfig"
,
mock
.
Anything
)
.
Return
(
chain33TestMainCfg
,
nil
)
suite
.
exec
.
SetAPI
(
suite
.
api
)
toB
:=
Nodes
[
1
]
total
:=
1000
*
types
.
Coin
...
...
@@ -267,6 +282,7 @@ func (suite *AssetTransferTestSuite) TestExecTransferToken() {
}
func
(
suite
*
AssetTransferTestSuite
)
TestExecTransferTokenInPara
()
{
chain33TestCfg
=
types
.
NewChain33Config
(
strings
.
Replace
(
testnode
.
DefaultConfig
,
"Title=
\"
user.p.guodun.
\"
"
,
"Title=
\"
user.p.test.
\"
"
,
1
))
// para_init(Title)
toB
:=
Nodes
[
1
]
...
...
plugin/dapp/paracross/executor/assetwithdraw_test.go
View file @
b6105c0a
...
...
@@ -92,6 +92,9 @@ func (suite *AssetWithdrawTestSuite) SetupTest() {
// 主链先不执行
func
(
suite
*
AssetWithdrawTestSuite
)
TestExecAssetWithdrawOnMainChain
()
{
//types.Init("test", nil)
suite
.
api
=
new
(
apimock
.
QueueProtocolAPI
)
suite
.
api
.
On
(
"GetConfig"
,
mock
.
Anything
)
.
Return
(
chain33TestMainCfg
,
nil
)
suite
.
exec
.
SetAPI
(
suite
.
api
)
tx
,
err
:=
createAssetWithdrawTx
(
suite
.
Suite
,
PrivKeyA
,
Nodes
[
1
])
if
err
!=
nil
{
suite
.
T
()
.
Error
(
"createAssetWithdrawTx"
,
"err"
,
err
)
...
...
@@ -147,6 +150,10 @@ func (suite *AssetWithdrawTestSuite) TestExecAssetWithdrawOnParaChain() {
// 主链在平行链执行成功后执行
func
(
suite
*
AssetWithdrawTestSuite
)
TestExecAssetWithdrawAfterPara
()
{
// types.Init("test", nil)
suite
.
api
=
new
(
apimock
.
QueueProtocolAPI
)
suite
.
api
.
On
(
"GetConfig"
,
mock
.
Anything
)
.
Return
(
chain33TestMainCfg
,
nil
)
suite
.
exec
.
SetAPI
(
suite
.
api
)
// make coins for transfer
acc
:=
account
.
NewCoinsAccount
(
chain33TestCfg
)
acc
.
SetDB
(
suite
.
stateDB
)
...
...
plugin/dapp/paracross/executor/paracross_test.go
View file @
b6105c0a
...
...
@@ -21,8 +21,8 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"
"github.com/stretchr/testify/mock"
"github.com/33cn/plugin/plugin/dapp/paracross/testnode"
"strings"
"github.com/33cn/plugin/plugin/dapp/paracross/testnode"
)
// 构造一个4个节点的平行链数据, 进行测试
...
...
@@ -56,7 +56,7 @@ var (
MainBlockHeightForTransfer
=
int64
(
9
)
tempTitle
=
""
chain33TestCfg
=
types
.
NewChain33Config
(
strings
.
Replace
(
testnode
.
DefaultConfig
,
"Title=
\"
user.p.guodun.
\"
"
,
"Title=
\"
user.p.test.
\"
"
,
1
))
//chain33TestCfg = types.NewChain33Config(testnode.DefaultConfig
)
chain33TestMainCfg
=
types
.
NewChain33Config
(
strings
.
Replace
(
types
.
GetDefaultCfgstring
(),
"Title=
\"
local
\"
"
,
"Title=
\"
test
\"
"
,
1
)
)
)
type
CommitTestSuite
struct
{
...
...
plugin/dapp/paracross/testnode/para_test.go
View file @
b6105c0a
...
...
@@ -7,10 +7,19 @@ import (
_
"github.com/33cn/chain33/system"
_
"github.com/33cn/plugin/plugin"
"github.com/33cn/chain33/util/testnode"
"github.com/33cn/chain33/types"
"strings"
)
func
TestParaNode
(
t
*
testing
.
T
)
{
para
:=
NewParaNode
(
nil
,
nil
)
cfg
:=
types
.
NewChain33Config
(
strings
.
Replace
(
types
.
GetDefaultCfgstring
(),
"Title=
\"
local
\"
"
,
"Title=
\"
chain33
\"
"
,
1
))
cfg
.
GetModuleConfig
()
.
Consensus
.
Name
=
"ticket"
main
:=
testnode
.
NewWithConfig
(
cfg
,
nil
)
main
.
Listen
()
para
:=
NewParaNode
(
main
,
nil
)
paraCfg
:=
para
.
Para
.
GetAPI
()
.
GetConfig
()
defer
para
.
Close
()
//通过rpc 发生信息
...
...
plugin/dapp/ticket/rpc/jrpc_channel_test.go
View file @
b6105c0a
...
...
@@ -17,18 +17,13 @@ import (
"github.com/stretchr/testify/assert"
)
var
mocker
*
testnode
.
Chain33Mock
func
TestMain
(
m
*
testing
.
M
)
{
func
TestJRPCChannel
(
t
*
testing
.
T
)
{
cfg
:=
types
.
NewChain33Config
(
types
.
GetDefaultCfgstring
())
cfg
.
GetModuleConfig
()
.
Consensus
.
Name
=
"ticket"
mocker
=
testnode
.
NewWithConfig
(
cfg
,
nil
)
mocker
:
=
testnode
.
NewWithConfig
(
cfg
,
nil
)
mocker
.
Listen
()
m
.
Run
()
mocker
.
Close
()
}
defer
mocker
.
Close
()
func
TestJRPCChannel
(
t
*
testing
.
T
)
{
jrpcClient
:=
mocker
.
GetJSONC
()
testCases
:=
[]
struct
{
...
...
plugin/dapp/ticket/rpc/rpc_real_test.go
View file @
b6105c0a
...
...
@@ -13,10 +13,18 @@ import (
_
"github.com/33cn/plugin/plugin"
ty
"github.com/33cn/plugin/plugin/dapp/ticket/types"
"github.com/stretchr/testify/assert"
"github.com/33cn/chain33/types"
"github.com/33cn/chain33/util/testnode"
)
func
TestNewTicket
(
t
*
testing
.
T
)
{
//选票(可以用hotwallet 关闭选票)
cfg
:=
types
.
NewChain33Config
(
types
.
GetDefaultCfgstring
())
cfg
.
GetModuleConfig
()
.
Consensus
.
Name
=
"ticket"
mocker
:=
testnode
.
NewWithConfig
(
cfg
,
nil
)
mocker
.
Listen
()
defer
mocker
.
Close
()
in
:=
&
ty
.
TicketClose
{
MinerAddress
:
mocker
.
GetHotAddress
()}
var
res
rpctypes
.
ReplyHashes
err
:=
mocker
.
GetJSONC
()
.
Call
(
"ticket.CloseTickets"
,
in
,
&
res
)
...
...
plugin/dapp/ticket/rpc/rpc_test.go
View file @
b6105c0a
...
...
@@ -116,8 +116,7 @@ func newJrpc(api client.QueueProtocolAPI) *Jrpc {
}
func
TestChannelClient_BindMiner
(
t
*
testing
.
T
)
{
cfg
:=
types
.
NewChain33Config
(
types
.
GetDefaultCfgstring
())
cfg
.
SetTitleOnlyForTest
(
"test"
)
cfg
:=
types
.
NewChain33Config
(
cfgstring
)
api
:=
new
(
mocks
.
QueueProtocolAPI
)
api
.
On
(
"GetConfig"
,
mock
.
Anything
)
.
Return
(
cfg
,
nil
)
client
:=
newGrpc
(
api
)
...
...
@@ -131,10 +130,6 @@ func TestChannelClient_BindMiner(t *testing.T) {
storevalue
.
Values
=
append
(
storevalue
.
Values
,
accv
)
api
.
On
(
"StoreGet"
,
mock
.
Anything
)
.
Return
(
storevalue
,
nil
)
.
Twice
()
//cfg, _ := types.InitCfgString(cfgstring)
//types.Init("test", cfg)
//var addrs = make([]string, 1)
//addrs = append(addrs, "1Jn2qu84Z1SUUosWjySggBS9pKWdAP3tZt")
var
in
=
&
ty
.
ReqBindMiner
{
...
...
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