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
556c6d21
Commit
556c6d21
authored
Jan 13, 2019
by
vipwzw
Committed by
33cn
Jan 14, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix test
parent
9fad87f0
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
15 additions
and
54 deletions
+15
-54
jsvm_test.go
plugin/dapp/js/executor/jsvm_test.go
+1
-1
lotteryblock.go
plugin/dapp/lottery/executor/lotteryblock.go
+0
-21
lotterydb.go
plugin/dapp/lottery/executor/lotterydb.go
+5
-28
exec_test.go
plugin/dapp/unfreeze/executor/exec_test.go
+4
-4
driver.go
vendor/github.com/33cn/chain33/system/dapp/driver.go
+5
-0
No files found.
plugin/dapp/js/executor/jsvm_test.go
View file @
556c6d21
...
...
@@ -26,7 +26,7 @@ func init() {
func
initExec
(
ldb
db
.
DB
,
kvdb
db
.
KVDB
,
code
string
,
t
assert
.
TestingT
)
*
js
{
e
:=
newjs
()
.
(
*
js
)
e
.
SetEnv
(
1
,
time
.
Now
()
.
Unix
(),
1
,
nil
,
nil
)
e
.
SetEnv
(
1
,
time
.
Now
()
.
Unix
(),
1
)
mockapi
:=
&
mocks
.
QueueProtocolAPI
{}
mockapi
.
On
(
"Query"
,
"ticket"
,
"RandNumHash"
,
mock
.
Anything
)
.
Return
(
&
types
.
ReplyHash
{
Hash
:
[]
byte
(
"hello"
)},
nil
)
e
.
SetAPI
(
mockapi
)
...
...
plugin/dapp/lottery/executor/lotteryblock.go
deleted
100755 → 0
View file @
9fad87f0
// Copyright Fuzamei Corp. 2018 All Rights Reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package
executor
import
(
"github.com/33cn/chain33/types"
)
const
retryNum
=
10
// GetMainHeightByTxHash get Block height
func
(
action
*
Action
)
GetMainHeightByTxHash
(
txHash
[]
byte
)
(
int64
,
error
)
{
param
:=
&
types
.
ReqHash
{
Hash
:
txHash
}
txDetail
,
err
:=
action
.
lottery
.
GetExecutorAPI
()
.
QueryTx
(
param
)
if
err
!=
nil
{
return
-
1
,
err
}
return
txDetail
.
GetHeight
(),
nil
}
plugin/dapp/lottery/executor/lotterydb.go
View file @
556c6d21
...
...
@@ -261,12 +261,7 @@ func (action *Action) LotteryCreate(create *pty.LotteryCreate) (*types.Receipt,
lott
.
BuyAmount
=
0
llog
.
Debug
(
"LotteryCreate"
,
"OpRewardRatio"
,
lott
.
OpRewardRatio
,
"DevRewardRatio"
,
lott
.
DevRewardRatio
)
if
types
.
IsPara
()
{
mainHeight
,
err
:=
action
.
GetMainHeightByTxHash
(
action
.
txhash
)
if
mainHeight
<
0
{
llog
.
Error
(
"LotteryCreate"
,
"mainHeight"
,
mainHeight
)
return
nil
,
err
}
lott
.
CreateOnMain
=
mainHeight
lott
.
CreateOnMain
=
action
.
lottery
.
GetMainHeight
()
}
llog
.
Debug
(
"LotteryCreate created"
,
"lotteryID"
,
lotteryID
)
...
...
@@ -316,22 +311,13 @@ func (action *Action) LotteryBuy(buy *pty.LotteryBuy) (*types.Receipt, error) {
lott
.
Status
=
pty
.
LotteryPurchase
lott
.
Round
++
if
types
.
IsPara
()
{
mainHeight
,
err
:=
action
.
GetMainHeightByTxHash
(
action
.
txhash
)
if
mainHeight
<
0
{
llog
.
Error
(
"LotteryBuy"
,
"mainHeight"
,
mainHeight
)
return
nil
,
err
}
lott
.
LastTransToPurStateOnMain
=
mainHeight
lott
.
LastTransToPurStateOnMain
=
action
.
lottery
.
GetMainHeight
()
}
}
if
lott
.
Status
==
pty
.
LotteryPurchase
{
if
types
.
IsPara
()
{
mainHeight
,
err
:=
action
.
GetMainHeightByTxHash
(
action
.
txhash
)
if
mainHeight
<
0
{
llog
.
Error
(
"LotteryBuy"
,
"mainHeight"
,
mainHeight
)
return
nil
,
err
}
mainHeight
:=
action
.
lottery
.
GetMainHeight
()
if
mainHeight
-
lott
.
LastTransToPurStateOnMain
>
lott
.
GetPurBlockNum
()
{
llog
.
Error
(
"LotteryBuy"
,
"action.height"
,
action
.
height
,
"mainHeight"
,
mainHeight
,
"LastTransToPurStateOnMain"
,
lott
.
LastTransToPurStateOnMain
)
return
nil
,
pty
.
ErrLotteryStatus
...
...
@@ -437,11 +423,7 @@ func (action *Action) LotteryDraw(draw *pty.LotteryDraw) (*types.Receipt, error)
}
if
types
.
IsPara
()
{
mainHeight
,
err
:=
action
.
GetMainHeightByTxHash
(
action
.
txhash
)
if
mainHeight
<
0
{
llog
.
Error
(
"LotteryBuy"
,
"mainHeight"
,
mainHeight
)
return
nil
,
err
}
mainHeight
:=
action
.
lottery
.
GetMainHeight
()
if
mainHeight
-
lott
.
GetLastTransToPurStateOnMain
()
<
lott
.
GetDrawBlockNum
()
{
llog
.
Error
(
"LotteryDraw"
,
"action.height"
,
action
.
height
,
"mainHeight"
,
mainHeight
,
"GetLastTransToPurStateOnMain"
,
lott
.
GetLastTransToPurState
())
return
nil
,
pty
.
ErrLotteryStatus
...
...
@@ -711,12 +693,7 @@ func (action *Action) checkDraw(lott *LotteryDB) (*types.Receipt, *pty.LotteryUp
action
.
recordMissing
(
lott
)
if
types
.
IsPara
()
{
mainHeight
,
err
:=
action
.
GetMainHeightByTxHash
(
action
.
txhash
)
if
mainHeight
<
0
{
llog
.
Error
(
"LotteryDraw"
,
"mainHeight"
,
mainHeight
)
return
nil
,
nil
,
nil
,
err
}
lott
.
LastTransToDrawStateOnMain
=
mainHeight
lott
.
LastTransToDrawStateOnMain
=
action
.
lottery
.
GetHeight
()
}
return
&
types
.
Receipt
{
Ty
:
types
.
ExecOk
,
KV
:
kv
,
Logs
:
logs
},
&
updateInfo
,
&
gainInfos
,
nil
}
...
...
plugin/dapp/unfreeze/executor/exec_test.go
View file @
556c6d21
...
...
@@ -90,7 +90,7 @@ func TestUnfreeze(t *testing.T) {
}
exec
:=
newUnfreeze
()
exec
.
SetStateDB
(
stateDB
)
exec
.
SetEnv
(
env
.
blockHeight
,
env
.
blockTime
,
env
.
difficulty
,
nil
,
nil
)
exec
.
SetEnv
(
env
.
blockHeight
,
env
.
blockTime
,
env
.
difficulty
)
receipt
,
err
:=
exec
.
Exec
(
createTx
,
int
(
1
))
assert
.
Nil
(
t
,
err
)
assert
.
NotNil
(
t
,
receipt
)
...
...
@@ -117,7 +117,7 @@ func TestUnfreeze(t *testing.T) {
t
.
Error
(
"RPC_UnfreezeWithdrawTx sign"
,
"err"
,
err
)
}
blockTime
:=
int64
(
10
)
exec
.
SetEnv
(
env
.
blockHeight
+
1
,
env
.
blockTime
+
blockTime
,
env
.
difficulty
,
nil
,
nil
)
exec
.
SetEnv
(
env
.
blockHeight
+
1
,
env
.
blockTime
+
blockTime
,
env
.
difficulty
)
receipt
,
err
=
exec
.
Exec
(
withdrawTx
,
1
)
assert
.
Nil
(
t
,
err
)
assert
.
NotNil
(
t
,
receipt
)
...
...
@@ -151,7 +151,7 @@ func TestUnfreeze(t *testing.T) {
t
.
Error
(
"RPC_UnfreezeWithdrawTx sign"
,
"err"
,
err
)
}
blockTime
:=
int64
(
10
)
exec
.
SetEnv
(
env
.
blockHeight
+
1
,
env
.
blockTime
+
blockTime
,
env
.
difficulty
,
nil
,
nil
)
exec
.
SetEnv
(
env
.
blockHeight
+
1
,
env
.
blockTime
+
blockTime
,
env
.
difficulty
)
receipt
,
err
=
exec
.
Exec
(
withdrawTx
,
1
)
assert
.
Equal
(
t
,
pty
.
ErrNoPrivilege
,
err
)
assert
.
Nil
(
t
,
receipt
)
...
...
@@ -214,7 +214,7 @@ func TestUnfreeze(t *testing.T) {
t
.
Error
(
"RPC_UnfreezeWithdrawTx sign"
,
"err"
,
err
)
}
blockTime
:=
int64
(
10
)
exec
.
SetEnv
(
env
.
blockHeight
+
1
,
env
.
blockTime
+
blockTime
+
blockTime
,
env
.
difficulty
,
nil
,
nil
)
exec
.
SetEnv
(
env
.
blockHeight
+
1
,
env
.
blockTime
+
blockTime
+
blockTime
,
env
.
difficulty
)
receipt
,
err
=
exec
.
Exec
(
withdrawTx
,
1
)
assert
.
Equal
(
t
,
pty
.
ErrUnfreezeEmptied
,
err
)
assert
.
Nil
(
t
,
receipt
)
...
...
vendor/github.com/33cn/chain33/system/dapp/driver.go
View file @
556c6d21
...
...
@@ -398,6 +398,11 @@ func (d *DriverBase) GetHeight() int64 {
return
d
.
height
}
// GetMainHeight return height
func
(
d
*
DriverBase
)
GetMainHeight
()
int64
{
return
d
.
mainHeight
}
// GetBlockTime return block time
func
(
d
*
DriverBase
)
GetBlockTime
()
int64
{
return
d
.
blocktime
...
...
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