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
97f19751
Commit
97f19751
authored
Sep 04, 2019
by
linj
Committed by
vipwzw
Sep 05, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
兼容原来交易, 默认以coins 标价的
parent
70faa36c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
2 deletions
+21
-2
trade_test.go
plugin/dapp/trade/executor/trade_test.go
+19
-0
util.go
plugin/dapp/trade/executor/util.go
+2
-2
No files found.
plugin/dapp/trade/executor/trade_test.go
View file @
97f19751
...
...
@@ -7,6 +7,8 @@ package executor
import
(
"testing"
"github.com/stretchr/testify/assert"
"github.com/33cn/chain33/types"
pty
"github.com/33cn/plugin/plugin/dapp/trade/types"
)
...
...
@@ -112,3 +114,20 @@ func TestRevokeSaveDel(t *testing.T) {
kvDel
:=
genDeleteSellKv
(
&
sellorderRevoked
)
check
(
t
,
kv
,
kvDel
)
}
func
TestPriceCheck
(
t
*
testing
.
T
)
{
cases
:=
[]
struct
{
exec
string
symbol
string
result
bool
}{
{
"coins"
,
"bty"
,
true
},
{
""
,
"bty"
,
false
},
{
"coins"
,
""
,
false
},
{
"token"
,
"TEST"
,
true
},
}
for
_
,
c
:=
range
cases
{
assert
.
Equal
(
t
,
c
.
result
,
checkPrice
(
types
.
GetDappFork
(
pty
.
TradeX
,
pty
.
ForkTradePriceX
),
c
.
exec
,
c
.
symbol
))
}
}
plugin/dapp/trade/executor/util.go
View file @
97f19751
...
...
@@ -49,7 +49,7 @@ func checkAsset(height int64, exec, symbol string) bool {
func
checkPrice
(
height
int64
,
exec
,
symbol
string
)
bool
{
if
types
.
IsDappFork
(
height
,
pt
.
TradeX
,
pt
.
ForkTradePriceX
)
{
if
exec
==
""
||
symbol
==
""
{
if
exec
==
""
&&
symbol
!=
""
||
exec
!=
""
&&
symbol
==
""
{
return
false
}
}
else
{
...
...
@@ -84,7 +84,7 @@ func createAccountDB(height int64, db db.KV, exec, symbol string) (*account.DB,
func
createPriceDB
(
height
int64
,
db
db
.
KV
,
exec
,
symbol
string
)
(
*
account
.
DB
,
error
)
{
if
types
.
IsDappFork
(
height
,
pt
.
TradeX
,
pt
.
ForkTradePriceX
)
{
//
在fork 之前提的交易
//
为空默认使用 coins
if
exec
==
""
{
acc
:=
account
.
NewCoinsAccount
()
acc
.
SetDB
(
db
)
...
...
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