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
f5b13fa1
Commit
f5b13fa1
authored
Apr 19, 2019
by
mdj33
Committed by
33cn
Apr 22, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix ut
parent
827cec52
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
66 deletions
+44
-66
para_test.go
plugin/consensus/para/para_test.go
+7
-61
paracross_test.go
plugin/dapp/paracross/executor/paracross_test.go
+37
-5
No files found.
plugin/consensus/para/para_test.go
View file @
f5b13fa1
...
...
@@ -28,23 +28,6 @@ var (
func
TestFilterTxsForPara
(
t
*
testing
.
T
)
{
types
.
Init
(
Title
,
nil
)
//only main txs
tx0
,
_
:=
createMainTx
(
"ticket"
,
"to"
)
//only main txs group
tx1
,
_
:=
createMainTx
(
"ticket"
,
"to"
)
tx2
,
_
:=
createMainTx
(
"token"
,
"to"
)
tx12
:=
[]
*
types
.
Transaction
{
tx1
,
tx2
}
txGroup12
,
err
:=
createTxsGroup
(
tx12
)
assert
.
Nil
(
t
,
err
)
//para cross tx group succ
tx3
,
_
:=
createCrossMainTx
(
"toA"
)
tx4
,
err
:=
createCrossParaTx
(
"toB"
,
4
)
assert
.
Nil
(
t
,
err
)
tx34
:=
[]
*
types
.
Transaction
{
tx3
,
tx4
}
txGroup34
,
err
:=
createTxsGroup
(
tx34
)
assert
.
Nil
(
t
,
err
)
//all para tx group
tx5
,
err
:=
createCrossParaTx
(
"toB"
,
5
)
assert
.
Nil
(
t
,
err
)
...
...
@@ -55,17 +38,13 @@ func TestFilterTxsForPara(t *testing.T) {
assert
.
Nil
(
t
,
err
)
//para cross tx group fail
tx7
,
_
:=
createCross
MainTx
(
"toA"
)
tx7
,
_
:=
createCross
ParaTx
(
"toA"
,
1
)
tx8
,
err
:=
createCrossParaTx
(
"toB"
,
8
)
assert
.
Nil
(
t
,
err
)
tx78
:=
[]
*
types
.
Transaction
{
tx7
,
tx8
}
txGroup78
,
err
:=
createTxsGroup
(
tx78
)
assert
.
Nil
(
t
,
err
)
tx9
,
_
:=
createMainTx
(
"relay"
,
"to"
)
//single para tx
txA
,
err
:=
createCrossParaTx
(
"toB"
,
10
)
assert
.
Nil
(
t
,
err
)
//all para tx group
txB
,
err
:=
createCrossParaTx
(
"toB"
,
11
)
...
...
@@ -80,12 +59,9 @@ func TestFilterTxsForPara(t *testing.T) {
txD
,
err
:=
createCrossParaTempTx
(
"toB"
,
10
)
assert
.
Nil
(
t
,
err
)
txs
:=
[]
*
types
.
Transaction
{
tx0
}
txs
=
append
(
txs
,
txGroup12
...
)
txs
=
append
(
txs
,
txGroup34
...
)
txs
:=
[]
*
types
.
Transaction
{}
txs
=
append
(
txs
,
txGroup56
...
)
txs
=
append
(
txs
,
txGroup78
...
)
txs
=
append
(
txs
,
tx9
,
txA
)
txs
=
append
(
txs
,
txGroupBC
...
)
txs
=
append
(
txs
,
txD
)
...
...
@@ -93,11 +69,7 @@ func TestFilterTxsForPara(t *testing.T) {
// t.Log("tx exec name", "i", i, "name", string(tx.Execer))
//}
recpt0
:=
&
types
.
ReceiptData
{
Ty
:
types
.
ExecOk
}
recpt1
:=
&
types
.
ReceiptData
{
Ty
:
types
.
ExecOk
}
recpt2
:=
&
types
.
ReceiptData
{
Ty
:
types
.
ExecOk
}
recpt3
:=
&
types
.
ReceiptData
{
Ty
:
types
.
ExecOk
}
recpt4
:=
&
types
.
ReceiptData
{
Ty
:
types
.
ExecOk
}
recpt5
:=
&
types
.
ReceiptData
{
Ty
:
types
.
ExecPack
}
recpt6
:=
&
types
.
ReceiptData
{
Ty
:
types
.
ExecPack
}
...
...
@@ -106,13 +78,11 @@ func TestFilterTxsForPara(t *testing.T) {
recpt7
:=
&
types
.
ReceiptData
{
Ty
:
types
.
ExecPack
,
Logs
:
logs
}
recpt8
:=
&
types
.
ReceiptData
{
Ty
:
types
.
ExecPack
}
recpt9
:=
&
types
.
ReceiptData
{
Ty
:
types
.
ExecOk
}
recptA
:=
&
types
.
ReceiptData
{
Ty
:
types
.
ExecPack
}
recptB
:=
&
types
.
ReceiptData
{
Ty
:
types
.
ExecPack
}
recptC
:=
&
types
.
ReceiptData
{
Ty
:
types
.
ExecPack
}
recptD
:=
&
types
.
ReceiptData
{
Ty
:
types
.
ExecPack
}
receipts
:=
[]
*
types
.
ReceiptData
{
recpt0
,
recpt1
,
recpt2
,
recpt3
,
recpt4
,
recpt5
,
recpt6
,
recpt7
,
recpt8
,
recpt9
,
recptA
,
recptB
,
recptC
,
recptD
}
receipts
:=
[]
*
types
.
ReceiptData
{
recpt5
,
recpt6
,
recpt7
,
recpt8
,
recptB
,
recptC
,
recptD
}
block
:=
&
types
.
Block
{
Txs
:
txs
}
detail
:=
&
types
.
BlockDetail
{
...
...
@@ -122,37 +92,13 @@ func TestFilterTxsForPara(t *testing.T) {
para
:=
&
client
{}
rst
:=
para
.
FilterTxsForPara
(
detail
)
filterTxs
:=
[]
*
types
.
Transaction
{
tx3
,
tx4
,
tx5
,
tx6
,
txA
,
txB
,
txC
}
filterTxs
:=
[]
*
types
.
Transaction
{
tx5
,
tx6
,
tx7
,
tx8
,
txB
,
txC
}
assert
.
Equal
(
t
,
filterTxs
,
rst
)
}
func
createMainTx
(
exec
string
,
to
string
)
(
*
types
.
Transaction
,
error
)
{
param
:=
types
.
CreateTx
{
To
:
to
,
Amount
:
Amount
,
Fee
:
0
,
Note
:
[]
byte
(
"test"
),
TokenSymbol
:
""
,
ExecName
:
exec
,
}
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
createCrossMainTx
(
to
string
)
(
*
types
.
Transaction
,
error
)
{
param
:=
types
.
CreateTx
{
To
:
string
(
to
),
...
...
plugin/dapp/paracross/executor/paracross_test.go
View file @
f5b13fa1
...
...
@@ -391,7 +391,7 @@ func (s *VoteTestSuite) TestVoteTx() {
s
.
Nil
(
err
)
tx2
,
err
:=
createAssetTransferTx
(
s
.
Suite
,
PrivKeyB
,
nil
)
s
.
Nil
(
err
)
tx3
,
err
:=
create
CrossMainTx
([]
byte
(
"toA"
)
)
tx3
,
err
:=
create
ParaNormalTx
(
s
.
Suite
,
PrivKeyB
,
nil
)
s
.
Nil
(
err
)
tx4
,
err
:=
createCrossParaTx
(
s
.
Suite
,
[]
byte
(
"toB"
))
s
.
Nil
(
err
)
...
...
@@ -439,10 +439,10 @@ func (s *VoteTestSuite) TestVoteTx() {
if
bytes
.
Equal
(
key
,
kv
.
Key
)
{
var
rst
pt
.
ParacrossNodeStatus
types
.
Decode
(
kv
.
GetValue
(),
&
rst
)
s
.
Equal
([]
uint8
([]
byte
{
0x
25
}),
rst
.
TxResult
)
s
.
Equal
([]
uint8
([]
byte
{
0x
4d
}),
rst
.
CrossTxResult
)
s
.
Equal
(
6
,
len
(
rst
.
TxHashs
))
s
.
Equal
(
7
,
len
(
rst
.
CrossTxHashs
))
s
.
Equal
([]
uint8
([]
byte
{
0x
4d
}),
rst
.
TxResult
)
s
.
Equal
([]
uint8
([]
byte
{
0x
25
}),
rst
.
CrossTxResult
)
s
.
Equal
(
7
,
len
(
rst
.
TxHashs
))
s
.
Equal
(
6
,
len
(
rst
.
CrossTxHashs
))
break
}
}
...
...
@@ -537,3 +537,34 @@ func createTxsGroup(s suite.Suite, txs []*types.Transaction) ([]*types.Transacti
func
TestVoteSuite
(
t
*
testing
.
T
)
{
suite
.
Run
(
t
,
new
(
VoteTestSuite
))
}
func
createParaNormalTx
(
s
suite
.
Suite
,
privFrom
string
,
to
[]
byte
)
(
*
types
.
Transaction
,
error
)
{
param
:=
types
.
CreateTx
{
To
:
string
(
to
),
Amount
:
Amount
,
Fee
:
0
,
Note
:
[]
byte
(
"token"
),
IsWithdraw
:
false
,
IsToken
:
false
,
TokenSymbol
:
""
,
ExecName
:
Title
+
"token"
,
}
tx
:=
&
types
.
Transaction
{
Execer
:
[]
byte
(
param
.
GetExecName
()),
Payload
:
[]
byte
{},
To
:
address
.
ExecAddress
(
param
.
GetExecName
()),
Fee
:
param
.
Fee
,
}
tx
,
err
:=
types
.
FormatTx
(
param
.
GetExecName
(),
tx
)
if
err
!=
nil
{
return
nil
,
err
}
tx
,
err
=
signTx
(
s
,
tx
,
privFrom
)
assert
.
Nil
(
s
.
T
(),
err
,
"sign asset transfer failed"
)
if
err
!=
nil
{
return
nil
,
err
}
return
tx
,
nil
}
\ No newline at end of file
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