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
f303a848
Commit
f303a848
authored
Sep 24, 2020
by
QM
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add unit test
parent
f803e5ec
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
51 additions
and
7 deletions
+51
-7
parablssign_test.go
plugin/consensus/para/parablssign_test.go
+4
-1
test-rpc.sh
plugin/dapp/paracross/cmd/test/test-rpc.sh
+0
-1
paracross_test.go
plugin/dapp/paracross/executor/paracross_test.go
+44
-5
supervisionaccount_test.go
plugin/dapp/paracross/executor/supervisionaccount_test.go
+3
-0
No files found.
plugin/consensus/para/parablssign_test.go
View file @
f303a848
...
...
@@ -34,7 +34,6 @@ func TestIntegrateCommits(t *testing.T) {
assert
.
Equal
(
t
,
len
(
pool
[
0
]
.
Signs
),
2
)
assert
.
Equal
(
t
,
pool
[
0
]
.
Addrs
[
0
],
"aa"
)
assert
.
Equal
(
t
,
pool
[
0
]
.
Addrs
[
1
],
"bb"
)
}
func
TestBlsSignMain
(
t
*
testing
.
T
)
{
...
...
@@ -97,6 +96,10 @@ func testBlsSign(t *testing.T, cryptCli crypto.Crypto) {
err
=
client
.
verifyBlsSign
(
KS
,
commit
)
assert
.
Equal
(
t
,
err
,
nil
)
client
.
typeNode
=
pt
.
ParaCommitNode
err
=
client
.
verifyBlsSign
(
KS
,
commit
)
assert
.
NotEmpty
(
t
,
err
)
}
func
testVerifyBlsSign
(
t
*
testing
.
T
,
cryptCli
crypto
.
Crypto
)
{
...
...
plugin/dapp/paracross/cmd/test/test-rpc.sh
View file @
f303a848
...
...
@@ -585,7 +585,6 @@ function apply_coins() {
para_exec_addr
=
$(
curl
-ksd
'{"method":"Chain33.ConvertExectoAddr","params":[{"execname":"user.p.para.paracross"}]}'
${
para_ip
}
| jq
-r
".result"
)
chain33_SendToAddress
"
$addr1q9
"
"
${
para_exec_addr
}
"
900000000
"
${
para_ip
}
"
chain33_QueryExecBalance
"
${
addr1q9
}
"
"user.p.para.paracross"
"
$para_ip
"
}
function
run_testcases
()
{
...
...
plugin/dapp/paracross/executor/paracross_test.go
View file @
f303a848
...
...
@@ -46,6 +46,13 @@ var (
[]
byte
(
"1MCftFynyvG2F4ED5mdHYgziDxx6vDrScs"
),
}
PrivKeyE
=
"0x3a35610ba6e1e72d7878f4c819e6a6768668cb5481f423ef04b6a11e0e16e44f"
// 15HmJz2abkExxgcmSRt2Q5D4hZg6zJUD1h
PrivKeyF
=
"0xaffa90b6a897c798e63890312b2ec9fb5a3c156dac290479ccb67c25c78e9413"
// 1JQjqDChawMYfG3yyxByrhJ467HorPVfFZ
SupervisionNodes
=
[][]
byte
{
[]
byte
(
"15HmJz2abkExxgcmSRt2Q5D4hZg6zJUD1h"
),
[]
byte
(
"1JQjqDChawMYfG3yyxByrhJ467HorPVfFZ"
),
}
chain33TestCfg
=
types
.
NewChain33Config
(
testnode
.
DefaultConfig
)
chain33TestMainCfg
=
types
.
NewChain33Config
(
strings
.
Replace
(
types
.
GetDefaultCfgstring
(),
"Title=
\"
local
\"
"
,
"Title=
\"
test
\"
"
,
1
))
)
...
...
@@ -76,6 +83,28 @@ func makeNodeInfo(key, addr string, cnt int) *types.ConfigItem {
return
&
item
}
func
makeSupervisionNodeInfo
(
suite
*
CommitTestSuite
)
{
SupervisionNodeKey
:=
calcParaSupervisionNodeGroupAddrsKey
(
Title
)
var
item
types
.
ConfigItem
item
.
Key
=
Title
item
.
Addr
=
Title
item
.
Ty
=
mty
.
ConfigItemArrayConfig
emptyValue
:=
&
types
.
ArrayConfig
{
Value
:
make
([]
string
,
0
)}
arr
:=
types
.
ConfigItem_Arr
{
Arr
:
emptyValue
}
item
.
Value
=
&
arr
for
_
,
n
:=
range
SupervisionNodes
{
item
.
GetArr
()
.
Value
=
append
(
item
.
GetArr
()
.
Value
,
string
(
n
))
}
_
=
suite
.
stateDB
.
Set
(
SupervisionNodeKey
,
types
.
Encode
(
&
item
))
value
,
err
:=
suite
.
stateDB
.
Get
(
SupervisionNodeKey
)
if
err
!=
nil
{
suite
.
T
()
.
Error
(
"get setup title failed"
,
err
)
return
}
assert
.
Equal
(
suite
.
T
(),
value
,
types
.
Encode
(
&
item
))
}
func
init
()
{
log
.
SetFileLog
(
nil
)
log
.
SetLogLevel
(
"debug"
)
...
...
@@ -116,6 +145,8 @@ func (suite *CommitTestSuite) SetupSuite() {
}
assert
.
Equal
(
suite
.
T
(),
value
,
types
.
Encode
(
nodeValue
))
makeSupervisionNodeInfo
(
suite
)
stageKey
:=
calcParaSelfConsStagesKey
()
stage
:=
&
pt
.
SelfConsensStage
{
StartHeight
:
0
,
Enable
:
pt
.
ParaConfigYes
}
stages
:=
&
pt
.
SelfConsensStages
{
Items
:
[]
*
pt
.
SelfConsensStage
{
stage
}}
...
...
@@ -246,7 +277,7 @@ func commitOnceImpl(suite suite.Suite, exec *Paracross, privkeyStr string) (rece
return
}
func
checkCommitReceipt
(
suite
*
CommitTestSuite
,
receipt
*
types
.
Receipt
,
commitCnt
int
)
{
func
checkCommitReceipt
(
suite
*
CommitTestSuite
,
receipt
*
types
.
Receipt
,
commitCnt
int
,
commitSupervisionCnt
int
)
{
assert
.
Equal
(
suite
.
T
(),
receipt
.
Ty
,
int32
(
types
.
ExecOk
))
assert
.
Len
(
suite
.
T
(),
receipt
.
KV
,
1
)
assert
.
Len
(
suite
.
T
(),
receipt
.
Logs
,
1
)
...
...
@@ -264,6 +295,7 @@ func checkCommitReceipt(suite *CommitTestSuite, receipt *types.Receipt, commitCn
assert
.
Equal
(
suite
.
T
(),
int32
(
pt
.
ParacrossStatusCommiting
),
titleHeight
.
Status
)
assert
.
Equal
(
suite
.
T
(),
Title
,
titleHeight
.
Title
)
assert
.
Equal
(
suite
.
T
(),
commitCnt
,
len
(
titleHeight
.
Details
.
Addrs
))
assert
.
Equal
(
suite
.
T
(),
commitSupervisionCnt
,
len
(
titleHeight
.
SupervisionDetails
.
Addrs
))
}
func
checkDoneReceipt
(
suite
suite
.
Suite
,
receipt
*
types
.
Receipt
,
commitCnt
int
)
{
...
...
@@ -318,16 +350,22 @@ func checkRecordReceipt(suite *CommitTestSuite, receipt *types.Receipt, commitCn
func
(
suite
*
CommitTestSuite
)
TestExec
()
{
receipt
:=
commitOnce
(
suite
,
PrivKeyA
)
checkCommitReceipt
(
suite
,
receipt
,
1
)
checkCommitReceipt
(
suite
,
receipt
,
1
,
0
)
receipt
=
commitOnce
(
suite
,
PrivKeyA
)
checkCommitReceipt
(
suite
,
receipt
,
1
)
checkCommitReceipt
(
suite
,
receipt
,
1
,
0
)
receipt
=
commitOnce
(
suite
,
PrivKeyB
)
checkCommitReceipt
(
suite
,
receipt
,
2
)
checkCommitReceipt
(
suite
,
receipt
,
2
,
0
)
receipt
=
commitOnce
(
suite
,
PrivKeyA
)
checkCommitReceipt
(
suite
,
receipt
,
2
)
checkCommitReceipt
(
suite
,
receipt
,
2
,
0
)
receipt
=
commitOnce
(
suite
,
PrivKeyE
)
checkCommitReceipt
(
suite
,
receipt
,
2
,
1
)
receipt
=
commitOnce
(
suite
,
PrivKeyF
)
checkCommitReceipt
(
suite
,
receipt
,
2
,
2
)
receipt
=
commitOnce
(
suite
,
PrivKeyC
)
checkDoneReceipt
(
suite
.
Suite
,
receipt
,
3
)
...
...
@@ -337,6 +375,7 @@ func (suite *CommitTestSuite) TestExec() {
receipt
=
commitOnce
(
suite
,
PrivKeyD
)
checkRecordReceipt
(
suite
,
receipt
,
4
)
}
func
TestCommitSuite
(
t
*
testing
.
T
)
{
...
...
plugin/dapp/paracross/executor/supervisionaccount_test.go
View file @
f303a848
...
...
@@ -25,6 +25,7 @@ func (suite *NodeManageTestSuite) testSupervisionExec() {
}
func
(
suite
*
NodeManageTestSuite
)
testSupervisionNodeConfigQuit
()
{
// Apply
config
:=
&
pt
.
ParaNodeAddrConfig
{
Title
:
chain33TestCfg
.
GetTitle
(),
Op
:
pt
.
ParacrossSupervisionNodeApply
,
...
...
@@ -40,6 +41,7 @@ func (suite *NodeManageTestSuite) testSupervisionNodeConfigQuit() {
err
=
types
.
Decode
(
receipt
.
Logs
[
0
]
.
Log
,
&
g
)
suite
.
Nil
(
err
)
// Quit
config
=
&
pt
.
ParaNodeAddrConfig
{
Title
:
chain33TestCfg
.
GetTitle
(),
Op
:
pt
.
ParacrossSupervisionNodeQuit
,
...
...
@@ -49,6 +51,7 @@ func (suite *NodeManageTestSuite) testSupervisionNodeConfigQuit() {
suite
.
Nil
(
err
)
receipt
=
nodeCommit
(
suite
,
PrivKey14K
,
tx
)
assert
.
Equal
(
suite
.
T
(),
receipt
.
Ty
,
int32
(
types
.
ExecOk
))
}
func
(
suite
*
NodeManageTestSuite
)
testSupervisionNodeConfigApprove
()
{
...
...
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