Commit 97f19751 authored by linj's avatar linj Committed by vipwzw

兼容原来交易, 默认以coins 标价的

parent 70faa36c
......@@ -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))
}
}
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment