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
37bac459
Commit
37bac459
authored
Apr 29, 2019
by
kingwang
Committed by
vipwzw
Apr 29, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix para test
parent
7667a9dc
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
57 additions
and
11 deletions
+57
-11
cfg.go
plugin/dapp/paracross/testnode/cfg.go
+5
-1
paranode.go
plugin/dapp/paracross/testnode/paranode.go
+1
-1
base.go
plugin/mempool/para/base.go
+2
-9
para_test.go
plugin/mempool/para/para_test.go
+49
-0
No files found.
plugin/dapp/paracross/testnode/cfg.go
View file @
37bac459
package
testnode
package
testnode
var
paraconfig
=
`
//default config for testnode
var
DefaultConfig
=
`
Title="user.p.guodun."
Title="user.p.guodun."
# TestNet=true
# TestNet=true
...
@@ -71,6 +72,9 @@ poolCacheSize=10240
...
@@ -71,6 +72,9 @@ poolCacheSize=10240
minTxFee=100000
minTxFee=100000
maxTxNumPerAccount=10000
maxTxNumPerAccount=10000
[mempool.sub.para]
poolCacheSize=102400
[consensus]
[consensus]
name="para"
name="para"
genesisBlockTime=1514533394
genesisBlockTime=1514533394
...
...
plugin/dapp/paracross/testnode/paranode.go
View file @
37bac459
...
@@ -23,7 +23,7 @@ func NewParaNode(main *testnode.Chain33Mock, para *testnode.Chain33Mock) *ParaNo
...
@@ -23,7 +23,7 @@ func NewParaNode(main *testnode.Chain33Mock, para *testnode.Chain33Mock) *ParaNo
main
.
Listen
()
main
.
Listen
()
}
}
if
para
==
nil
{
if
para
==
nil
{
cfg
,
sub
:=
types
.
InitCfgString
(
parac
onfig
)
cfg
,
sub
:=
types
.
InitCfgString
(
DefaultC
onfig
)
testnode
.
ModifyParaClient
(
sub
,
main
.
GetCfg
()
.
RPC
.
GrpcBindAddr
)
testnode
.
ModifyParaClient
(
sub
,
main
.
GetCfg
()
.
RPC
.
GrpcBindAddr
)
para
=
testnode
.
NewWithConfig
(
cfg
,
sub
,
nil
)
para
=
testnode
.
NewWithConfig
(
cfg
,
sub
,
nil
)
para
.
Listen
()
para
.
Listen
()
...
...
plugin/mempool/para/base.go
View file @
37bac459
...
@@ -46,7 +46,6 @@ func NewMempool(cfg *types.Mempool) *Mempool {
...
@@ -46,7 +46,6 @@ func NewMempool(cfg *types.Mempool) *Mempool {
func
(
mem
*
Mempool
)
SetQueueClient
(
client
queue
.
Client
)
{
func
(
mem
*
Mempool
)
SetQueueClient
(
client
queue
.
Client
)
{
mem
.
client
=
client
mem
.
client
=
client
mem
.
client
.
Sub
(
mem
.
key
)
mem
.
client
.
Sub
(
mem
.
key
)
mem
.
wg
.
Add
(
1
)
mem
.
wg
.
Add
(
1
)
go
func
()
{
go
func
()
{
for
msg
:=
range
client
.
Recv
()
{
for
msg
:=
range
client
.
Recv
()
{
...
@@ -69,8 +68,7 @@ func (mem *Mempool) SetQueueClient(client queue.Client) {
...
@@ -69,8 +68,7 @@ func (mem *Mempool) SetQueueClient(client queue.Client) {
}
}
}
}
default
:
default
:
msg
.
Reply
(
client
.
NewMessage
(
mem
.
key
,
types
.
EventReply
,
&
types
.
Reply
{
IsOk
:
false
,
msg
.
Reply
(
client
.
NewMessage
(
mem
.
key
,
types
.
EventReply
,
types
.
ErrActionNotSupport
))
Msg
:
[]
byte
(
fmt
.
Sprintf
(
"para %v doesn't handle message %v"
,
mem
.
key
,
msg
.
Ty
))}))
}
}
}
}
}()
}()
...
@@ -81,10 +79,9 @@ func (mem *Mempool) Wait() {}
...
@@ -81,10 +79,9 @@ func (mem *Mempool) Wait() {}
// Close method
// Close method
func
(
mem
*
Mempool
)
Close
()
{
func
(
mem
*
Mempool
)
Close
()
{
if
mem
.
isClose
(
)
{
if
!
atomic
.
CompareAndSwapInt32
(
&
mem
.
isclose
,
0
,
1
)
{
return
return
}
}
atomic
.
StoreInt32
(
&
mem
.
isclose
,
1
)
if
mem
.
client
!=
nil
{
if
mem
.
client
!=
nil
{
mem
.
client
.
Close
()
mem
.
client
.
Close
()
}
}
...
@@ -93,7 +90,3 @@ func (mem *Mempool) Close() {
...
@@ -93,7 +90,3 @@ func (mem *Mempool) Close() {
mem
.
wg
.
Wait
()
mem
.
wg
.
Wait
()
mlog
.
Info
(
"para mempool module closed"
)
mlog
.
Info
(
"para mempool module closed"
)
}
}
func
(
mem
*
Mempool
)
isClose
()
bool
{
return
atomic
.
LoadInt32
(
&
mem
.
isclose
)
==
1
}
plugin/mempool/para/para_test.go
0 → 100644
View file @
37bac459
package
para_test
import
(
"testing"
"github.com/33cn/chain33/types"
"github.com/33cn/chain33/util"
"github.com/33cn/chain33/util/testnode"
paratest
"github.com/33cn/plugin/plugin/dapp/paracross/testnode"
"github.com/33cn/plugin/plugin/mempool/para"
"github.com/stretchr/testify/assert"
_
"github.com/33cn/chain33/system"
_
"github.com/33cn/plugin/plugin"
)
func
TestClose
(
t
*
testing
.
T
)
{
mem
:=
para
.
NewMempool
(
nil
)
n
:=
1000
done
:=
make
(
chan
struct
{},
n
)
for
i
:=
0
;
i
<
n
;
i
++
{
go
func
()
{
mem
.
Close
()
done
<-
struct
{}{}
}()
}
for
i
:=
0
;
i
<
n
;
i
++
{
<-
done
}
}
func
TestParaNodeMempool
(
t
*
testing
.
T
)
{
main
:=
testnode
.
New
(
""
,
nil
)
main
.
Listen
()
cfg
,
sub
:=
types
.
InitCfgString
(
paratest
.
DefaultConfig
)
testnode
.
ModifyParaClient
(
sub
,
main
.
GetCfg
()
.
RPC
.
GrpcBindAddr
)
cfg
.
Mempool
.
Name
=
"para"
para
:=
testnode
.
NewWithConfig
(
cfg
,
sub
,
nil
)
para
.
Listen
()
mockpara
:=
paratest
.
NewParaNode
(
main
,
para
)
tx
:=
util
.
CreateTxWithExecer
(
mockpara
.
Para
.
GetGenesisKey
(),
"user.p.guodun.none"
)
hash
:=
mockpara
.
Para
.
SendTx
(
tx
)
assert
.
Equal
(
t
,
tx
.
Hash
(),
hash
)
_
,
err
:=
mockpara
.
Para
.
GetAPI
()
.
GetMempool
()
assert
.
Equal
(
t
,
err
,
types
.
ErrActionNotSupport
)
t
.
Log
(
err
)
}
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