Commit 716ccb68 authored by mdj33's avatar mdj33 Committed by vipwzw

fix ut

parent 7847aa74
......@@ -85,7 +85,7 @@ func CheckCount(count int32) bool {
//CheckAmount 最小交易 1coin
func CheckAmount(amount, coinPrecision int64) bool {
if amount < coinPrecision || amount >= types.MaxCoin {
if amount < coinPrecision || amount >= types.MaxCoin*coinPrecision {
return false
}
return true
......
......@@ -41,8 +41,8 @@ func NewMainAccount(cfg *types.Chain33Config, paraTitle, paraExecName, paraSymbo
}
func assetDepositBalance(acc *account.DB, addr string, amount int64) (*types.Receipt, error) {
if err := acc.CheckAmount(amount); err != nil {
return nil, err
if !acc.CheckAmount(amount) {
return nil, types.ErrAmount
}
acc1 := acc.LoadAccount(addr)
copyacc := *acc1
......@@ -66,8 +66,8 @@ func assetDepositBalance(acc *account.DB, addr string, amount int64) (*types.Rec
}
func assetWithdrawBalance(acc *account.DB, addr string, amount int64) (*types.Receipt, error) {
if err := acc.CheckAmount(amount); err != nil {
return nil, err
if !acc.CheckAmount(amount) {
return nil, types.ErrAmount
}
acc1 := acc.LoadAccount(addr)
if acc1.Balance-amount < 0 {
......
......@@ -5,6 +5,7 @@
package executor
import (
"strings"
"testing"
apimock "github.com/33cn/chain33/client/mocks"
......@@ -39,7 +40,9 @@ func (s *suiteRelayLog) SetupSuite() {
}
s.db = new(mocks.KV)
s.log = newRelayLog(order)
cfg := types.NewChain33Config(strings.Replace(types.GetDefaultCfgstring(), "Title=\"local\"", "Title=\"chain33\"", 1))
s.log = newRelayLog(order, cfg)
}
func (s *suiteRelayLog) TestSave() {
......
......@@ -542,10 +542,16 @@ func tokenSell(cmd *cobra.Command, args []string) {
fmt.Fprintln(os.Stderr, errors.Wrapf(err, "FormatFloatDisplay2Value.fee"))
return
}
totalInt64 := int64(total * 1e8 / 1e6)
//缺省一手是0.01个coin,如果精度小于100,就是1
oneHand := int64(1)
if cfg.CoinPrecision > 1e2 {
oneHand = cfg.CoinPrecision / 1e2
}
totalInt64 := int64(total * float64(cfg.CoinPrecision) / float64(oneHand))
params := &pty.TradeSellTx{
TokenSymbol: symbol,
AmountPerBoardlot: 1e6,
AmountPerBoardlot: oneHand,
MinBoardlot: min,
PricePerBoardlot: priceInt64,
TotalBoardlot: totalInt64,
......@@ -710,10 +716,16 @@ func tokenBuyLimit(cmd *cobra.Command, args []string) {
fmt.Fprintln(os.Stderr, errors.Wrapf(err, "FormatFloatDisplay2Value.fee"))
return
}
totalInt64 := int64(total * 1e8 / 1e6)
//缺省一手是0.01个coin,如果精度小于100,就是1
oneHand := int64(1)
if cfg.CoinPrecision > 1e2 {
oneHand = cfg.CoinPrecision / 1e2
}
totalInt64 := int64(total * float64(cfg.CoinPrecision) / float64(oneHand))
params := &pty.TradeBuyLimitTx{
TokenSymbol: symbol,
AmountPerBoardlot: 1e6,
AmountPerBoardlot: oneHand,
MinBoardlot: min,
PricePerBoardlot: priceInt64,
TotalBoardlot: totalInt64,
......
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