Commit 960e0451 authored by jiangpeng's avatar jiangpeng Committed by vipwzw

import autotest

parent ebfb1739
...@@ -10,8 +10,8 @@ SRC_CLI := github.com/33cn/plugin/cli ...@@ -10,8 +10,8 @@ SRC_CLI := github.com/33cn/plugin/cli
APP := build/chain33 APP := build/chain33
CHAIN33=github.com/33cn/chain33 CHAIN33=github.com/33cn/chain33
CHAIN33_PATH=vendor/${CHAIN33} CHAIN33_PATH=vendor/${CHAIN33}
AUTO_TEST := build/tools/autotest/autotest AUTOTEST := build/autotest/autotest
SRC_AUTO_TEST := ${CHAIN33}/cmd/autotest SRC_AUTOTEST_PLUGIN := ${CHAIN33_PATH}/cmd/autotest/pluginversion
LDFLAGS := -ldflags "-w -s" LDFLAGS := -ldflags "-w -s"
PKG_LIST := `go list ./... | grep -v "vendor" | grep -v "chain33/test" | grep -v "mocks" | grep -v "pbft"` PKG_LIST := `go list ./... | grep -v "vendor" | grep -v "chain33/test" | grep -v "mocks" | grep -v "pbft"`
PKG_LIST_Q := `go list ./... | grep -v "vendor" | grep -v "chain33/test" | grep -v "mocks" | grep -v "blockchain" | grep -v "pbft"` PKG_LIST_Q := `go list ./... | grep -v "vendor" | grep -v "chain33/test" | grep -v "mocks" | grep -v "blockchain" | grep -v "pbft"`
...@@ -39,7 +39,8 @@ para: ...@@ -39,7 +39,8 @@ para:
autotest:## build autotest binary autotest:## build autotest binary
@go build -v -i -o $(AUTO_TEST) $(SRC_AUTO_TEST) @cp -r $(CHAIN33_PATH)/build/autotest build/
@go build -v -i -o $(AUTOTEST) $(SRC_AUTOTEST_PLUGIN)
@cp cmd/autotest/*.toml build/tools/autotest/ @cp cmd/autotest/*.toml build/tools/autotest/
@if [ -n "$(dapp)" ]; then \ @if [ -n "$(dapp)" ]; then \
cd build/tools/autotest && bash ./local-autotest.sh $(dapp) && cd ../../../; \ cd build/tools/autotest && bash ./local-autotest.sh $(dapp) && cd ../../../; \
......
// 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 autotest
import (
. "github.com/33cn/chain33/cmd/autotest/types"
"strconv"
)
//pub2priv case
type CreateUtxosCase struct {
BaseCase
From string `toml:"from"`
To string `toml:"to"`
Amount string `toml:"amount"`
}
type CreateUtxosPack struct {
BaseCasePack
}
func (testCase *CreateUtxosCase) SendCommand(packID string) (PackFunc, error) {
return DefaultSend(testCase, &CreateUtxosPack{}, packID)
}
func (pack *CreateUtxosPack) GetCheckHandlerMap() interface{} {
funcMap := make(CheckHandlerMapDiscard, 2)
funcMap["balance"] = pack.checkBalance
funcMap["utxo"] = pack.checkUtxo
return funcMap
}
func (pack *CreateUtxosPack) checkBalance(txInfo map[string]interface{}) bool {
interCase := pack.TCase.(*CreateUtxosCase)
feeStr := txInfo["tx"].(map[string]interface{})["fee"].(string)
logArr := txInfo["receipt"].(map[string]interface{})["logs"].([]interface{})
logFee := logArr[0].(map[string]interface{})["log"].(map[string]interface{})
logSend := logArr[1].(map[string]interface{})["log"].(map[string]interface{})
fee, _ := strconv.ParseFloat(feeStr, 64)
amount, _ := strconv.ParseFloat(interCase.Amount, 64)
pack.FLog.Info("PrivCreateutxosDetail", "TestID", pack.PackID,
"Fee", feeStr, "Amount", interCase.Amount, "FromAddr", interCase.From,
"FromPrev", logSend["prev"].(map[string]interface{})["balance"].(string),
"FromCurr", logSend["current"].(map[string]interface{})["balance"].(string))
return CheckBalanceDeltaWithAddr(logFee, interCase.From, -fee) &&
CheckBalanceDeltaWithAddr(logSend, interCase.From, -amount)
}
func (pack *CreateUtxosPack) checkUtxo(txInfo map[string]interface{}) bool {
interCase := pack.TCase.(*CreateUtxosCase)
logArr := txInfo["receipt"].(map[string]interface{})["logs"].([]interface{})
outputLog := logArr[2].(map[string]interface{})["log"].(map[string]interface{})
amount, _ := strconv.ParseFloat(interCase.Amount, 64)
//get available utxo with addr
availUtxo, err := CalcUtxoAvailAmount(interCase.To, pack.TxHash)
totalOutput := CalcTxUtxoAmount(outputLog, "keyoutput")
availCheck := IsBalanceEqualFloat(availUtxo, amount)
pack.FLog.Info("PrivCreateutxosDetail", "TestID", pack.PackID,
"TransferAmount", interCase.Amount, "UtxoOutput", totalOutput,
"ToAddr", interCase.To, "UtxoAvailable", availUtxo, "CalcAvailErr", err)
return availCheck && IsBalanceEqualFloat(totalOutput, amount)
}
// 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 autotest
import (
. "github.com/33cn/chain33/cmd/autotest/types"
"strconv"
)
//pub2priv case
type PrivToPrivCase struct {
BaseCase
From string `toml:"from"`
To string `toml:"to"`
Amount string `toml:"amount"`
}
type PrivToPrivPack struct {
BaseCasePack
}
func (testCase *PrivToPrivCase) SendCommand(packID string) (PackFunc, error) {
return DefaultSend(testCase, &PrivToPrivPack{}, packID)
}
func (pack *PrivToPrivPack) GetCheckHandlerMap() interface{} {
funcMap := make(CheckHandlerMapDiscard, 2)
funcMap["utxo"] = pack.checkUtxo
return funcMap
}
func (pack *PrivToPrivPack) checkUtxo(txInfo map[string]interface{}) bool {
interCase := pack.TCase.(*PrivToPrivCase)
logArr := txInfo["receipt"].(map[string]interface{})["logs"].([]interface{})
inputLog := logArr[1].(map[string]interface{})["log"].(map[string]interface{})
outputLog := logArr[2].(map[string]interface{})["log"].(map[string]interface{})
amount, _ := strconv.ParseFloat(interCase.Amount, 64)
fee, _ := strconv.ParseFloat(txInfo["tx"].(map[string]interface{})["fee"].(string), 64)
utxoInput := CalcTxUtxoAmount(inputLog, "keyinput")
utxoOutput := CalcTxUtxoAmount(outputLog, "keyoutput")
fromAvail, err1 := CalcUtxoAvailAmount(interCase.From, pack.TxHash)
fromSpend, err2 := CalcUtxoSpendAmount(interCase.From, pack.TxHash)
toAvail, err3 := CalcUtxoAvailAmount(interCase.To, pack.TxHash)
utxoCheck := IsBalanceEqualFloat(fromAvail, utxoInput-amount-fee) &&
IsBalanceEqualFloat(toAvail, amount) &&
IsBalanceEqualFloat(fromSpend, utxoInput)
pack.FLog.Info("Private2PrivateUtxoDetail", "TestID", pack.PackID,
"FromAddr", interCase.From, "ToAddr", interCase.To, "Fee", fee,
"TransferAmount", interCase.Amount, "UtxoInput", utxoInput, "UtxoOutput", utxoOutput,
"FromAvailable", fromAvail, "FromSpend", fromSpend, "ToAvailable", toAvail,
"CalcFromAvailErr", err1, "CalcFromSpendErr", err2, "CalcToAvailErr", err3)
return IsBalanceEqualFloat(fee, utxoInput-utxoOutput) && utxoCheck
}
// 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 autotest
import (
. "github.com/33cn/chain33/cmd/autotest/types"
"strconv"
)
//pub2priv case
type PrivToPubCase struct {
BaseCase
From string `toml:"from"`
To string `toml:"to"`
Amount string `toml:"amount"`
}
type PrivToPubPack struct {
BaseCasePack
}
func (testCase *PrivToPubCase) SendCommand(packID string) (PackFunc, error) {
return DefaultSend(testCase, &PrivToPubPack{}, packID)
}
func (pack *PrivToPubPack) GetCheckHandlerMap() interface{} {
funcMap := make(CheckHandlerMapDiscard, 2)
funcMap["balance"] = pack.checkBalance
funcMap["utxo"] = pack.checkUtxo
return funcMap
}
func (pack *PrivToPubPack) checkBalance(txInfo map[string]interface{}) bool {
interCase := pack.TCase.(*PrivToPubCase)
feeStr := txInfo["tx"].(map[string]interface{})["fee"].(string)
from := txInfo["fromaddr"].(string) //privacy contract addr
logArr := txInfo["receipt"].(map[string]interface{})["logs"].([]interface{})
logFee := logArr[0].(map[string]interface{})["log"].(map[string]interface{})
logPub := logArr[1].(map[string]interface{})["log"].(map[string]interface{})
fee, _ := strconv.ParseFloat(feeStr, 64)
amount, _ := strconv.ParseFloat(interCase.Amount, 64)
pack.FLog.Info("Private2PubDetails", "TestID", pack.PackID,
"Fee", feeStr, "Amount", interCase.Amount,
"FromAddr", interCase.From, "ToAddr", interCase.To,
"ToPrev", logPub["prev"].(map[string]interface{})["balance"].(string),
"ToCurr", logPub["current"].(map[string]interface{})["balance"].(string))
return CheckBalanceDeltaWithAddr(logFee, from, -fee) &&
CheckBalanceDeltaWithAddr(logPub, interCase.To, amount)
}
func (pack *PrivToPubPack) checkUtxo(txInfo map[string]interface{}) bool {
interCase := pack.TCase.(*PrivToPubCase)
logArr := txInfo["receipt"].(map[string]interface{})["logs"].([]interface{})
inputLog := logArr[2].(map[string]interface{})["log"].(map[string]interface{})
outputLog := logArr[3].(map[string]interface{})["log"].(map[string]interface{})
amount, _ := strconv.ParseFloat(interCase.Amount, 64)
fee, _ := strconv.ParseFloat(txInfo["tx"].(map[string]interface{})["fee"].(string), 64)
utxoInput := CalcTxUtxoAmount(inputLog, "keyinput")
utxoOutput := CalcTxUtxoAmount(outputLog, "keyoutput")
//get available utxo with addr
availUtxo, err1 := CalcUtxoAvailAmount(interCase.From, pack.TxHash)
//get spend utxo with addr
spendUtxo, err2 := CalcUtxoSpendAmount(interCase.From, pack.TxHash)
utxoCheck := IsBalanceEqualFloat(availUtxo, utxoOutput) && IsBalanceEqualFloat(spendUtxo, utxoInput)
pack.FLog.Info("Private2PubUtxoDetail", "TestID", pack.PackID, "Fee", fee,
"TransferAmount", interCase.Amount, "UtxoInput", utxoInput, "UtxoOutput", utxoOutput,
"FromAddr", interCase.From, "UtxoAvailable", availUtxo, "UtxoSpend", spendUtxo,
"CalcAvailErr", err1, "CalcSpendErr", err2)
return IsBalanceEqualFloat(amount, utxoInput-utxoOutput-fee) && utxoCheck
}
// 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 autotest
import (
. "github.com/33cn/chain33/cmd/autotest/types"
. "github.com/33cn/chain33/system/dapp/coins/autotest"
. "github.com/33cn/plugin/plugin/dapp/token/autotest"
"reflect"
)
type privacyAutoTest struct {
SimpleCaseArr []SimpleCase `toml:"SimpleCase,omitempty"`
TokenPreCreateCaseArr []TokenPreCreateCase `toml:"TokenPreCreateCase,omitempty"`
TokenFinishCreateCaseArr []TokenFinishCreateCase `toml:"TokenFinishCreateCase,omitempty"`
TransferCaseArr []TransferCase `toml:"TransferCase,omitempty"`
PubToPrivCaseArr []PubToPrivCase `toml:"PubToPrivCase,omitempty"`
PrivToPrivCaseArr []PrivToPrivCase `toml:"PrivToPrivCase,omitempty"`
PrivToPubCaseArr []PrivToPubCase `toml:"PrivToPubCase,omitempty"`
CreateUtxosCaseArr []CreateUtxosCase `toml:"CreateUtxosCase,omitempty"`
}
func init() {
RegisterAutoTest(privacyAutoTest{})
}
func (config privacyAutoTest) GetName() string {
return "privacy"
}
func (config privacyAutoTest) GetTestConfigType() reflect.Type {
return reflect.TypeOf(config)
}
[[SimpleCase]]
id = "enablePrivacy"
command = "privacy enable -a all"
dep = ["import1", "import2", "import3"]
#import privacy test addr, 1D9xKRnLvV2zMtSxSx33ow1GF4pcbLcNRt
[[SimpleCase]]
id = "import1"
command = "account import_key -k 0x88b2fb90411935872f0501dd13345aba19b5fac9b00eb0dddd7df977d4d5477e -l privacy_test1"
#import privacy test addr,17UZr5eJVxDRW1gs7rausQwaSUPtvcpxGT
[[SimpleCase]]
id = "import2"
command = "account import_key -k 0xa0c6f46de8d275ce21e935afa5363e9b8a087fe604e05f7a9eef1258dc781c3a -l privacy_test2"
#import privacy test addr, 12HKLEn6g4FH39yUbHh4EVJWcFo5CXg22d
[[SimpleCase]]
id = "import3"
command = "account import_key -k 0x9d4f8ab11361be596468b265cb66946c87873d4a119713fd0c3d8302eae0a8e4 -l privacy_test3"
#prepare for privacy
[[TransferCase]]
id = "trans1"
command = "send bty transfer -a 999 -t 1FeyE6VDZ4FYgpK1n2okWMDAtPkwBuooQd -k 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
from = "12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
to = "1FeyE6VDZ4FYgpK1n2okWMDAtPkwBuooQd"
amount = "999"
checkItem = ["balance"]
dep = ["transForFee1", "transForFee2", "transForFee3"]
[[TransferCase]]
id = "transForFee1"
command = "send bty transfer -a 100 -t 1D9xKRnLvV2zMtSxSx33ow1GF4pcbLcNRt -k 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
from = "12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
to = "1D9xKRnLvV2zMtSxSx33ow1GF4pcbLcNRt"
amount = "100"
checkItem = ["balance"]
dep = ["enablePrivacy"]
[[TransferCase]]
id = "transForFee2"
command = "send bty transfer -a 100 -t 17UZr5eJVxDRW1gs7rausQwaSUPtvcpxGT -k 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
from = "12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
to = "17UZr5eJVxDRW1gs7rausQwaSUPtvcpxGT"
amount = "100"
checkItem = ["balance"]
dep = ["enablePrivacy"]
[[TransferCase]]
id = "transForFee3"
command = "send bty transfer -a 100 -t 12HKLEn6g4FH39yUbHh4EVJWcFo5CXg22d -k 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
from = "12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
to = "12HKLEn6g4FH39yUbHh4EVJWcFo5CXg22d"
amount = "100"
checkItem = ["balance"]
dep = ["enablePrivacy"]
#pub2priv
[[PubToPrivCase]]
id = "pub2priv1"
command = "privacy pub2priv -a 99 -f 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv -p d736dcff89c2e588d1fc3d44ba956af4d15d0a01eb1aedaf58fcbc2bdd09591fec9fd83ea6eee18c5a0fd8f1d167b1f8b020d8a6203be49f0bf3f410473fc534"
from = "12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
to = "17UZr5eJVxDRW1gs7rausQwaSUPtvcpxGT"
amount = "99"
checkItem = ["balance", "utxo"]
dep = ["trans1"]
[[PubToPrivCase]]
id = "pub2priv2"
command = "privacy pub2priv -a 99 -f 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv -p d45063357ab3454cfb7ee87db8f9ca2772d11bd82d4f681ce00ae44fe5929e8fd964867dae1b19b265b7f68d4ad965cfd4a0aaf71580344adf9fce28cfebadab"
from = "12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
to = "1D9xKRnLvV2zMtSxSx33ow1GF4pcbLcNRt"
amount = "99"
checkItem = ["balance", "utxo"]
dep = ["trans1"]
[[PubToPrivCase]]
id = "pub2priv3"
command = "privacy pub2priv -a 199 -f 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv -p dda1ae3184c1f4faca5b4e4be3dfea1c5026338764aca1d2c3e8e3c0b0001f4f4d5eb1761cd27dcbf36e2559c66173bc0d46ecc4feb72dee9e60896a696a5a06"
from = "12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
to = "12HKLEn6g4FH39yUbHh4EVJWcFo5CXg22d"
amount = "199"
checkItem = ["balance", "utxo"]
dep = ["trans1"]
#failpub2priv
[[PubToPrivCase]]
id = "failpub2priv1"
command = "privacy pub2priv -a 1000 -f 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv -p d736dcff89c2e588d1fc3d44ba956af4d15d0a01eb1aedaf58fcbc2bdd09591fec9fd83ea6eee18c5a0fd8f1d167b1f8b020d8a6203be49f0bf3f410473fc534"
from = "12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
to = "17UZr5eJVxDRW1gs7rausQwaSUPtvcpxGT"
amount = "1000"
checkItem = ["balance", "utxo"]
dep = ["trans1"]
fail = true
[[PubToPrivCase]]
id = "failpub2priv2"
command = "privacy pub2priv -a 603 -f 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv -p d45063357ab3454cfb7ee87db8f9ca2772d11bd82d4f681ce00ae44fe5929e8fd964867dae1b19b265b7f68d4ad965cfd4a0aaf71580344adf9fce28cfebadab"
from = "12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
to = "1D9xKRnLvV2zMtSxSx33ow1GF4pcbLcNRt"
amount = "603"
checkItem = ["balance", "utxo"]
dep = ["pub2priv3"]
fail = true
#priv2priv
[[PrivToPrivCase]]
id = "priv2priv1"
command = "privacy priv2priv -a 39 -f 17UZr5eJVxDRW1gs7rausQwaSUPtvcpxGT -p 0a9d212b2505aefaa8da370319088bbccfac097b007f52ed71d8133456c8185823c8eac43c5e937953d7b6c8e68b0db1f4f03df4946a29f524875118960a35fb"
from = "17UZr5eJVxDRW1gs7rausQwaSUPtvcpxGT"
to = "12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
amount = "39"
checkItem = ["utxo"]
dep = ["pub2priv1"]
[[PrivToPrivCase]]
id = "priv2priv2"
command = "privacy priv2priv -a 49 -f 1D9xKRnLvV2zMtSxSx33ow1GF4pcbLcNRt -p 0a9d212b2505aefaa8da370319088bbccfac097b007f52ed71d8133456c8185823c8eac43c5e937953d7b6c8e68b0db1f4f03df4946a29f524875118960a35fb"
from = "1D9xKRnLvV2zMtSxSx33ow1GF4pcbLcNRt"
to = "12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
amount = "49"
checkItem = ["utxo"]
dep = ["pub2priv2"]
[[PrivToPrivCase]]
id = "priv2priv3"
command = "privacy priv2priv -a 69 -f 12HKLEn6g4FH39yUbHh4EVJWcFo5CXg22d -p 0a9d212b2505aefaa8da370319088bbccfac097b007f52ed71d8133456c8185823c8eac43c5e937953d7b6c8e68b0db1f4f03df4946a29f524875118960a35fb"
from = "12HKLEn6g4FH39yUbHh4EVJWcFo5CXg22d"
to = "12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
amount = "69"
checkItem = ["utxo"]
dep = ["pub2priv3"]
#failpriv2priv
[[PrivToPrivCase]]
id = "failpriv2priv1"
command = "privacy priv2priv -a 100 -f 17UZr5eJVxDRW1gs7rausQwaSUPtvcpxGT -p 0a9d212b2505aefaa8da370319088bbccfac097b007f52ed71d8133456c8185823c8eac43c5e937953d7b6c8e68b0db1f4f03df4946a29f524875118960a35fb"
from = "17UZr5eJVxDRW1gs7rausQwaSUPtvcpxGT"
to = "12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
amount = "100"
checkItem = ["utxo"]
dep = ["pub2priv1"]
fail = true
[[PrivToPrivCase]]
id = "failpriv2priv2"
command = "privacy priv2priv -a 51 -f 1D9xKRnLvV2zMtSxSx33ow1GF4pcbLcNRt -p 0a9d212b2505aefaa8da370319088bbccfac097b007f52ed71d8133456c8185823c8eac43c5e937953d7b6c8e68b0db1f4f03df4946a29f524875118960a35fb"
from = "1D9xKRnLvV2zMtSxSx33ow1GF4pcbLcNRt"
to = "12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
amount = "51"
checkItem = ["utxo"]
dep = ["priv2priv2"]
fail = true
#priv2pub
[[PrivToPubCase]]
id = "priv2pub1"
command = "privacy priv2pub -a 48 -f 17UZr5eJVxDRW1gs7rausQwaSUPtvcpxGT -t 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
from = "17UZr5eJVxDRW1gs7rausQwaSUPtvcpxGT"
to = "12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
amount = "48"
checkItem = ["balance", "utxo"]
dep = ["priv2priv1"]
[[PrivToPubCase]]
id = "priv2pub2"
command = "privacy priv2pub -a 48 -f 1D9xKRnLvV2zMtSxSx33ow1GF4pcbLcNRt -t 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
from = "1D9xKRnLvV2zMtSxSx33ow1GF4pcbLcNRt"
to = "12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
amount = "48"
checkItem = ["balance", "utxo"]
dep = ["priv2priv2"]
[[PrivToPubCase]]
id = "priv2pub3"
command = "privacy priv2pub -a 69 -f 12HKLEn6g4FH39yUbHh4EVJWcFo5CXg22d -t 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
from = "12HKLEn6g4FH39yUbHh4EVJWcFo5CXg22d"
to = "12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
amount = "69"
checkItem = ["balance", "utxo"]
dep = ["priv2priv3"]
#failpriv2pub
[[PrivToPubCase]]
id = "failpriv2pub1"
command = "privacy priv2pub -a 100 -f 17UZr5eJVxDRW1gs7rausQwaSUPtvcpxGT -t 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
from = "17UZr5eJVxDRW1gs7rausQwaSUPtvcpxGT"
to = "12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
amount = "100"
checkItem = ["balance", "utxo"]
dep = ["priv2priv1"]
fail = true
[[PrivToPubCase]]
id = "failpriv2pub2"
command = "privacy priv2pub -a 3 -f 1D9xKRnLvV2zMtSxSx33ow1GF4pcbLcNRt -t 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
from = "1D9xKRnLvV2zMtSxSx33ow1GF4pcbLcNRt"
to = "12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
amount = "3"
checkItem = ["balance", "utxo"]
dep = ["priv2pub2"]
fail = true
#createutxosCase
[[CreateutxosCase]]
id = "privCreateutxos"
command = "privacy createutxos -a 20 -f 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv -p 0a9d212b2505aefaa8da370319088bbccfac097b007f52ed71d8133456c8185823c8eac43c5e937953d7b6c8e68b0db1f4f03df4946a29f524875118960a35fb"
from = "12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
to = "12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
amount = "20"
checkItem = ["balance", "utxo"]
dep = ["trans1"]
#failcreateutxosCase
[[CreateutxosCase]]
id = "failprivCreateutxos"
command = "privacy createutxos -a 1000 -f 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv -p 0a9d212b2505aefaa8da370319088bbccfac097b007f52ed71d8133456c8185823c8eac43c5e937953d7b6c8e68b0db1f4f03df4946a29f524875118960a35fb"
from = "12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
to = "12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
amount = "1000"
checkItem = ["balance", "utxo"]
dep = ["trans1"]
fail = true
\ No newline at end of file
// 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 autotest
import (
. "github.com/33cn/chain33/cmd/autotest/types"
"strconv"
)
//pub2priv case
type PubToPrivCase struct {
BaseCase
From string `toml:"from"`
To string `toml:"to"`
Amount string `toml:"amount"`
}
type PubToPrivPack struct {
BaseCasePack
}
func (testCase *PubToPrivCase) SendCommand(packID string) (PackFunc, error) {
return DefaultSend(testCase, &PubToPrivPack{}, packID)
}
func (pack *PubToPrivPack) GetCheckHandlerMap() interface{} {
funcMap := make(CheckHandlerMapDiscard, 2)
funcMap["balance"] = pack.checkBalance
funcMap["utxo"] = pack.checkUtxo
return funcMap
}
func (pack *PubToPrivPack) checkBalance(txInfo map[string]interface{}) bool {
interCase := pack.TCase.(*PubToPrivCase)
feeStr := txInfo["tx"].(map[string]interface{})["fee"].(string)
logArr := txInfo["receipt"].(map[string]interface{})["logs"].([]interface{})
logFee := logArr[0].(map[string]interface{})["log"].(map[string]interface{})
logSend := logArr[1].(map[string]interface{})["log"].(map[string]interface{})
fee, _ := strconv.ParseFloat(feeStr, 64)
amount, _ := strconv.ParseFloat(interCase.Amount, 64)
pack.FLog.Info("Pub2PrivateDetails", "TestID", pack.PackID,
"Fee", feeStr, "Amount", interCase.Amount, "FromAddr", interCase.From,
"FromPrev", logSend["prev"].(map[string]interface{})["balance"].(string),
"FromCurr", logSend["current"].(map[string]interface{})["balance"].(string))
return CheckBalanceDeltaWithAddr(logFee, interCase.From, -fee) &&
CheckBalanceDeltaWithAddr(logSend, interCase.From, -amount)
}
func (pack *PubToPrivPack) checkUtxo(txInfo map[string]interface{}) bool {
interCase := pack.TCase.(*PubToPrivCase)
logArr := txInfo["receipt"].(map[string]interface{})["logs"].([]interface{})
outputLog := logArr[2].(map[string]interface{})["log"].(map[string]interface{})
amount, _ := strconv.ParseFloat(interCase.Amount, 64)
//get available utxo with addr
availUtxo, err := CalcUtxoAvailAmount(interCase.To, pack.TxHash)
totalOutput := CalcTxUtxoAmount(outputLog, "keyoutput")
availCheck := IsBalanceEqualFloat(availUtxo, amount)
pack.FLog.Info("Pub2PrivateUtxoDetail", "TestID", pack.PackID,
"TransferAmount", interCase.Amount, "UtxoOutput", totalOutput,
"ToAddr", interCase.To, "UtxoAvailable", availUtxo, "CalcAvailErr", err)
return availCheck && IsBalanceEqualFloat(totalOutput, amount)
}
...@@ -6,6 +6,7 @@ package privacy ...@@ -6,6 +6,7 @@ package privacy
import ( import (
"github.com/33cn/chain33/pluginmgr" "github.com/33cn/chain33/pluginmgr"
_ "github.com/33cn/plugin/plugin/dapp/privacy/autotest"
"github.com/33cn/plugin/plugin/dapp/privacy/commands" "github.com/33cn/plugin/plugin/dapp/privacy/commands"
_ "github.com/33cn/plugin/plugin/dapp/privacy/crypto" _ "github.com/33cn/plugin/plugin/dapp/privacy/crypto"
"github.com/33cn/plugin/plugin/dapp/privacy/executor" "github.com/33cn/plugin/plugin/dapp/privacy/executor"
......
// 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 autotest
import (
. "github.com/33cn/chain33/cmd/autotest/types"
. "github.com/33cn/chain33/system/dapp/coins/autotest"
"reflect"
)
type tokenAutoTest struct {
SimpleCaseArr []SimpleCase `toml:"SimpleCase,omitempty"`
TokenPreCreateCaseArr []TokenPreCreateCase `toml:"TokenPreCreateCase,omitempty"`
TokenFinishCreateCaseArr []TokenFinishCreateCase `toml:"TokenFinishCreateCase,omitempty"`
TransferCaseArr []TransferCase `toml:"TransferCase,omitempty"`
WithdrawCaseArr []WithdrawCase `toml:"WithdrawCase,omitempty"`
TokenRevokeCaseArr []TokenRevokeCase `toml:"TokenRevokeCase,omitempty"`
}
func init() {
RegisterAutoTest(tokenAutoTest{})
}
func (config tokenAutoTest) GetName() string {
return "token"
}
func (config tokenAutoTest) GetTestConfigType() reflect.Type {
return reflect.TypeOf(config)
}
#import token test addr, 12cjnN5D4DPdBQSwh6vjwJbtsW4EJALTMv
[[SimpleCase]]
id = "import1"
command = "account import_key -k 0xc21d38be90493512a5c2417d565269a8b23ce8152010e404ff4f75efead8183a -l token_test"
[[TokenPreCreateCase]]
id = "tokenPre"
command = "send token precreate -f 0.01 -i testToken -n testToken -s TC -a 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv -t 100000 -p 1 -k 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
dep = ["transForPrecreate", "import1"]
[[TokenPreCreateCase]]
id = "tokenPre2"
command = "send token precreate -f 0.01 -i testToken -n testToken -s TCC -a 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv -t 100000 -p 1 -k 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
dep = ["transForPrecreate"]
[[TokenFinishCreateCase]]
id = "tokenFinish"
command = "send token finish -a 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv -f 0.01 -s TC -k 0xc34b5d9d44ac7b754806f761d3d4d2c4fe5214f6b074c19f069c4f5c2a29c8cc"
dep = ["tokenPre"]
#send to token for precreate
[[TransferCase]]
id = "transForPrecreate"
command = "send bty transfer -a 10 -t 12hpJBHybh1mSyCijQ2MQJPk7z7kZ7jnQa -k 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
from = "12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
to = "12hpJBHybh1mSyCijQ2MQJPk7z7kZ7jnQa"
amount = "10"
checkItem = ["balance"]
[[TransferCase]]
id = "transForFee"
command = "send bty transfer -a 10 -t 12cjnN5D4DPdBQSwh6vjwJbtsW4EJALTMv -k 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
from = "12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
to = "12cjnN5D4DPdBQSwh6vjwJbtsW4EJALTMv"
amount = "10"
checkItem = ["balance"]
[[TransferCase]]
id = "tokenTrans1"
command = "send token transfer -a 10 -s TC -t 12cjnN5D4DPdBQSwh6vjwJbtsW4EJALTMv -k 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
from = "12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
to = "12cjnN5D4DPdBQSwh6vjwJbtsW4EJALTMv"
amount = "10"
checkItem = ["balance"]
repeat = 10
dep = ["tokenFinish"]
[[TransferCase]]
id = "tokenTrans2"
command = "send token transfer -a 1 -s TC -t 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv -k 12cjnN5D4DPdBQSwh6vjwJbtsW4EJALTMv"
from = "12cjnN5D4DPdBQSwh6vjwJbtsW4EJALTMv"
to = "12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
amount = "1"
checkItem = ["balance"]
dep = ["tokenTrans1", "transForFee"]
[[TransferCase]]
id = "failTokenTrans"
command = "send token transfer -a 100 -s TC -t 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv -k 12cjnN5D4DPdBQSwh6vjwJbtsW4EJALTMv"
from = "12cjnN5D4DPdBQSwh6vjwJbtsW4EJALTMv"
to = "12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
amount = "100"
checkItem = ["balance"]
dep = ["tokenTrans2"]
fail = true
#diposit to trade
[[TransferCase]]
id = "tokenDiposit1"
command = "send token transfer -a 5 -s TC -t 1BXvgjmBw1aBgmGn1hjfGyRkmN3krWpFP4 -k 12cjnN5D4DPdBQSwh6vjwJbtsW4EJALTMv"
from = "12cjnN5D4DPdBQSwh6vjwJbtsW4EJALTMv"
to = "1BXvgjmBw1aBgmGn1hjfGyRkmN3krWpFP4"
amount = "5"
checkItem = ["balance"]
dep = ["tokenTrans1"]
[[WithdrawCase]]
id = "tokenWithdraw"
command = "send token withdraw -a 1 -s TC -e trade -k 12cjnN5D4DPdBQSwh6vjwJbtsW4EJALTMv"
addr = "12cjnN5D4DPdBQSwh6vjwJbtsW4EJALTMv"
amount = "1"
checkItem = ["balance"]
dep = ["tokenDiposit1"]
repeat = 4
[[WithdrawCase]]
id = "failTokenWithDraw"
command = "send token withdraw -a 5 -s TC -e trade -k 12cjnN5D4DPdBQSwh6vjwJbtsW4EJALTMv"
addr = "12cjnN5D4DPdBQSwh6vjwJbtsW4EJALTMv"
amount = "5"
checkItem = ["balance"]
dep = ["tokenWithdraw"]
fail = true
#--liugui 2018.9.19--
[[TokenRevokeCase]]
id = "tokenRevoke"
command = "send token revoke -f 0.01 -s TCC -a 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv -k 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
dep = ["tokenPre2"]
\ No newline at end of file
// 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 autotest
import (
. "github.com/33cn/chain33/cmd/autotest/types"
)
type TokenPreCreateCase struct {
BaseCase
//From string `toml:"from"`
//Amount string `toml:"amount"`
}
type TokenPreCreatePack struct {
BaseCasePack
}
type TokenFinishCreateCase struct {
BaseCase
//From string `toml:"from"`
//Amount string `toml:"amount"`
}
type TokenFinishCreatePack struct {
BaseCasePack
}
type TokenRevokeCase struct {
BaseCase
}
type TokenRevokePack struct {
BaseCasePack
}
func (testCase *TokenPreCreateCase) SendCommand(packID string) (PackFunc, error) {
return DefaultSend(testCase, &TokenPreCreatePack{}, packID)
}
func (testCase *TokenRevokeCase) SendCommand(packID string) (PackFunc, error) {
return DefaultSend(testCase, &TokenRevokePack{}, packID)
}
func (testCase *TokenFinishCreateCase) SendCommand(packID string) (PackFunc, error) {
return DefaultSend(testCase, &TokenFinishCreatePack{}, packID)
}
...@@ -6,6 +6,7 @@ package token ...@@ -6,6 +6,7 @@ package token
import ( import (
"github.com/33cn/chain33/pluginmgr" "github.com/33cn/chain33/pluginmgr"
_ "github.com/33cn/plugin/plugin/dapp/token/autotest"
"github.com/33cn/plugin/plugin/dapp/token/commands" "github.com/33cn/plugin/plugin/dapp/token/commands"
"github.com/33cn/plugin/plugin/dapp/token/executor" "github.com/33cn/plugin/plugin/dapp/token/executor"
"github.com/33cn/plugin/plugin/dapp/token/rpc" "github.com/33cn/plugin/plugin/dapp/token/rpc"
......
// 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 autotest
import (
"errors"
"fmt"
. "github.com/33cn/chain33/cmd/autotest/types"
"strconv"
)
type BuyCase struct {
BaseCase
From string `toml:"from"`
To string `toml:"to"`
TokenAmount string `toml:"tokenAmount"`
BtyAmount string `toml:"btyAmount"`
}
type BuyPack struct {
BaseCasePack
}
type DependBuyCase struct {
BuyCase
SellID string `toml:"sellID,omitempty"`
}
type DependBuyPack struct {
BuyPack
}
func (testCase *DependBuyCase) SendCommand(packID string) (PackFunc, error) {
if len(testCase.SellID) == 0 {
return nil, errors.New("depend sell case failed, Can't buy without sell id")
}
testCase.Command = fmt.Sprintf("%s -s %s", testCase.Command, testCase.SellID)
return DefaultSend(&testCase.BuyCase, &BuyPack{}, packID)
}
func (testCase *DependBuyCase) SetDependData(depData interface{}) {
if orderInfo, ok := depData.(*SellOrderInfo); ok && orderInfo != nil {
testCase.SellID = orderInfo.sellID
}
}
func (pack *BuyPack) GetCheckHandlerMap() interface{} {
funcMap := make(CheckHandlerMapDiscard, 2)
funcMap["frozen"] = pack.checkFrozen
funcMap["balance"] = pack.checkBalance
return funcMap
}
func (pack *BuyPack) checkBalance(txInfo map[string]interface{}) bool {
/*fromAddr := txInfo["tx"].(map[string]interface{})["from"].(string)
toAddr := txInfo["tx"].(map[string]interface{})["to"].(string)*/
feeStr := txInfo["tx"].(map[string]interface{})["fee"].(string)
logArr := txInfo["receipt"].(map[string]interface{})["logs"].([]interface{})
interCase := pack.TCase.(*BuyCase)
logFee := logArr[0].(map[string]interface{})["log"].(map[string]interface{})
logBuyBty := logArr[1].(map[string]interface{})["log"].(map[string]interface{})
logSellBty := logArr[2].(map[string]interface{})["log"].(map[string]interface{})
logBuyToken := logArr[4].(map[string]interface{})["log"].(map[string]interface{})
fee, _ := strconv.ParseFloat(feeStr, 64)
tokenAmount, _ := strconv.ParseFloat(interCase.TokenAmount, 64)
btyAmount, _ := strconv.ParseFloat(interCase.BtyAmount, 64)
pack.FLog.Info("BuyBalanceDetails", "ID", pack.PackID,
"Fee", feeStr, "TokenAmount", interCase.TokenAmount, "BtyAmount", interCase.BtyAmount,
"SellerBtyPrev", logSellBty["prev"].(map[string]interface{})["balance"].(string),
"SellerBtyCurr", logSellBty["current"].(map[string]interface{})["balance"].(string),
"BuyerBtyPrev", logBuyBty["prev"].(map[string]interface{})["balance"].(string),
"BuyerBtyCurr", logBuyBty["current"].(map[string]interface{})["balance"].(string),
"BuyerTokenPrev", logBuyToken["prev"].(map[string]interface{})["balance"].(string),
"BuyerTokenCurr", logBuyToken["current"].(map[string]interface{})["balance"].(string))
return CheckBalanceDeltaWithAddr(logFee, interCase.From, -fee) &&
CheckBalanceDeltaWithAddr(logBuyBty, interCase.From, -btyAmount) &&
CheckBalanceDeltaWithAddr(logSellBty, interCase.To, btyAmount) &&
CheckBalanceDeltaWithAddr(logBuyToken, interCase.From, tokenAmount)
}
func (pack *BuyPack) checkFrozen(txInfo map[string]interface{}) bool {
logArr := txInfo["receipt"].(map[string]interface{})["logs"].([]interface{})
interCase := pack.TCase.(*BuyCase)
logSellToken := logArr[3].(map[string]interface{})["log"].(map[string]interface{})
tokenAmount, _ := strconv.ParseFloat(interCase.TokenAmount, 64)
pack.FLog.Info("BuyFrozenDetails", "ID", pack.PackID,
"BuyTokenAmount", interCase.TokenAmount,
"SellerTokenPrev", logSellToken["prev"].(map[string]interface{})["frozen"].(string),
"SellerTokenCurr", logSellToken["current"].(map[string]interface{})["frozen"].(string))
return CheckFrozenDeltaWithAddr(logSellToken, interCase.To, -tokenAmount)
}
// 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 autotest
import (
. "github.com/33cn/chain33/cmd/autotest/types"
"strconv"
)
type SellCase struct {
BaseCase
From string `toml:"from"`
Amount string `toml:"amount"`
}
type SellPack struct {
BaseCasePack
orderInfo *SellOrderInfo
}
type SellOrderInfo struct {
sellID string
}
func (testCase *SellCase) SendCommand(packID string) (PackFunc, error) {
return DefaultSend(testCase, &SellPack{}, packID)
}
func (pack *SellPack) GetCheckHandlerMap() interface{} {
funcMap := make(CheckHandlerMapDiscard, 2)
funcMap["frozen"] = pack.checkFrozen
funcMap["balance"] = pack.checkBalance
return funcMap
}
func (pack *SellPack) GetDependData() interface{} {
return pack.orderInfo
}
func (pack *SellPack) checkBalance(txInfo map[string]interface{}) bool {
/*fromAddr := txInfo["tx"].(map[string]interface{})["from"].(string)
toAddr := txInfo["tx"].(map[string]interface{})["to"].(string)*/
feeStr := txInfo["tx"].(map[string]interface{})["fee"].(string)
logArr := txInfo["receipt"].(map[string]interface{})["logs"].([]interface{})
interCase := pack.TCase.(*SellCase)
logFee := logArr[0].(map[string]interface{})["log"].(map[string]interface{})
logSend := logArr[1].(map[string]interface{})["log"].(map[string]interface{})
fee, _ := strconv.ParseFloat(feeStr, 64)
amount, _ := strconv.ParseFloat(interCase.Amount, 64)
pack.FLog.Info("SellBalanceDetails", "TestID", pack.PackID,
"Fee", feeStr, "SellAmount", interCase.Amount,
"SellerBalancePrev", logSend["prev"].(map[string]interface{})["balance"].(string),
"SellerBalanceCurr", logSend["current"].(map[string]interface{})["balance"].(string))
//save sell order info
sellOrderInfo := logArr[2].(map[string]interface{})["log"].(map[string]interface{})["base"].(map[string]interface{})
pack.orderInfo = &SellOrderInfo{}
pack.orderInfo.sellID = sellOrderInfo["sellID"].(string)
return CheckBalanceDeltaWithAddr(logFee, interCase.From, -fee) &&
CheckBalanceDeltaWithAddr(logSend, interCase.From, -amount)
}
func (pack *SellPack) checkFrozen(txInfo map[string]interface{}) bool {
logArr := txInfo["receipt"].(map[string]interface{})["logs"].([]interface{})
interCase := pack.TCase.(*SellCase)
logSend := logArr[1].(map[string]interface{})["log"].(map[string]interface{})
amount, _ := strconv.ParseFloat(interCase.Amount, 64)
pack.FLog.Info("SellFrozenDetails", "TestID", pack.PackID,
"SellAmount", interCase.Amount,
"SellerFrozenPrev", logSend["prev"].(map[string]interface{})["frozen"].(string),
"SellerFrozenCurr", logSend["current"].(map[string]interface{})["frozen"].(string))
return CheckFrozenDeltaWithAddr(logSend, interCase.From, amount)
}
// 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 autotest
import (
. "github.com/33cn/chain33/cmd/autotest/types"
. "github.com/33cn/chain33/system/dapp/coins/autotest"
. "github.com/33cn/plugin/plugin/dapp/token/autotest"
"reflect"
)
type tradeAutoTest struct {
SimpleCaseArr []SimpleCase `toml:"SimpleCase,omitempty"`
TokenPreCreateCaseArr []TokenPreCreateCase `toml:"TokenPreCreateCase,omitempty"`
TokenFinishCreateCaseArr []TokenFinishCreateCase `toml:"TokenFinishCreateCase,omitempty"`
TransferCaseArr []TransferCase `toml:"TransferCase,omitempty"`
SellCaseArr []SellCase `toml:"SellCase,omitempty"`
DependBuyCaseArr []DependBuyCase `toml:"DependBuyCase,omitempty"`
}
func init() {
RegisterAutoTest(tradeAutoTest{})
}
func (config tradeAutoTest) GetName() string {
return "trade"
}
func (config tradeAutoTest) GetTestConfigType() reflect.Type {
return reflect.TypeOf(config)
}
#import trade test addr, 1Luh4AziYyaC5zP3hUXtXFZS873xAxm6rH
[[SimpleCase]]
id = "import1"
command = "account import_key -k 0xfdf2bbff853ecff2e7b86b2a8b45726c6538ca7d1403dc94e50131ef379bdca0 -l trade_test"
[[TokenPreCreateCase]]
id = "tokenPre"
command = "send token precreate -f 0.01 -i testToken -n testToken -s TS -a 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv -t 100000 -p 1 -k 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
dep = ["transForPrecreate", "import1"]
[[TokenFinishCreateCase]]
id = "tokenFinish"
command = "send token finish -a 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv -f 0.01 -s TS -k 0xc34b5d9d44ac7b754806f761d3d4d2c4fe5214f6b074c19f069c4f5c2a29c8cc"
dep = ["tokenPre"]
#send to token for precreate
[[TransferCase]]
id = "transForPrecreate"
command = "send bty transfer -a 10 -t 12hpJBHybh1mSyCijQ2MQJPk7z7kZ7jnQa -k 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
from = "12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
to = "12hpJBHybh1mSyCijQ2MQJPk7z7kZ7jnQa"
amount = "10"
checkItem = ["balance"]
[[TransferCase]]
id = "transForFee"
command = "send bty transfer -a 100 -t 1Luh4AziYyaC5zP3hUXtXFZS873xAxm6rH -k 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
from = "12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
to = "1Luh4AziYyaC5zP3hUXtXFZS873xAxm6rH"
amount = "100"
checkItem = ["balance"]
dep = ["import1"]
#prepare bty for trade sell and buy
[[TransferCase]]
id = "btyToTrade"
command = "send bty transfer -a 7 -t 1BXvgjmBw1aBgmGn1hjfGyRkmN3krWpFP4 -k 1Luh4AziYyaC5zP3hUXtXFZS873xAxm6rH"
from = "1Luh4AziYyaC5zP3hUXtXFZS873xAxm6rH"
to = "1BXvgjmBw1aBgmGn1hjfGyRkmN3krWpFP4"
amount = "7"
checkItem = ["balance"]
dep = ["transForFee"]
[[TransferCase]]
id = "tokenToTrade"
command = "send token transfer -a 50 -s TS -t 1BXvgjmBw1aBgmGn1hjfGyRkmN3krWpFP4 -k 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
from = "12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
to = "1BXvgjmBw1aBgmGn1hjfGyRkmN3krWpFP4"
amount = "50"
checkItem = ["balance"]
dep = ["tokenFinish", "btyToTrade"]
#token sell case
[[SellCase]]
id = "tokenSell1"
command = "send trade sell -f 0.01 -m 100 -p 0.01 -t 10 -s TS -k 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
from = "12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
amount = "10"
checkItem = ["balance", "frozen"]
dep = ["tokenToTrade"]
[[SellCase]]
id = "tokenSell2"
command = "send trade sell -f 0.01 -m 100 -p 0.01 -t 1 -s TS -k 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
from = "12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
amount = "1"
checkItem = ["balance", "frozen"]
dep = ["tokenToTrade"]
[[SellCase]]
id = "tokenSell3"
command = "send trade sell -f 0.01 -m 100 -p 0.01 -t 10 -s TS -k 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
from = "12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
amount = "10"
checkItem = ["balance", "frozen"]
dep = ["tokenToTrade"]
#no balance
[[SellCase]]
id = "failSell"
command = "send trade sell -f 0.01 -m 100 -p 0.01 -t 100 -s TS -k 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
from = "12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
amount = "100"
checkItem = ["balance", "frozen"]
fail = true
#因trade购买需要指定sellID, DependBuyCase自动获取由dep指定SellCase的sellID
[[DependBuyCase]]
id = "tokenBuy"
command = "send trade buy -c 100 -f 0.01 -k 1Luh4AziYyaC5zP3hUXtXFZS873xAxm6rH"
from = "1Luh4AziYyaC5zP3hUXtXFZS873xAxm6rH"
to = "12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
btyAmount = "1"
tokenAmount = "1"
checkItem = ["balance", "frozen"]
dep = ["tokenSell1"]
repeat = 5
#不满足最少份数
[[DependBuyCase]]
id = "failBuy1"
command = "send trade buy -c 90 -f 0.01 -k 1Luh4AziYyaC5zP3hUXtXFZS873xAxm6rH"
from = "1Luh4AziYyaC5zP3hUXtXFZS873xAxm6rH"
to = "12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
btyAmount = "0.9"
tokenAmount = "0.9"
checkItem = ["balance", "frozen"]
dep = ["tokenSell1"]
fail = true
#剩余正在sell的不够
[[DependBuyCase]]
id = "failBuy2"
command = "send trade buy -c 200 -f 0.01 -k 1Luh4AziYyaC5zP3hUXtXFZS873xAxm6rH"
from = "1Luh4AziYyaC5zP3hUXtXFZS873xAxm6rH"
to = "12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
btyAmount = "2"
tokenAmount = "2"
checkItem = ["balance", "frozen"]
dep = ["tokenSell2"]
fail = true
#bty余额不足
[[DependBuyCase]]
id = "failBuy3"
command = "send trade buy -c 800 -f 0.01 -k 1Luh4AziYyaC5zP3hUXtXFZS873xAxm6rH"
from = "1Luh4AziYyaC5zP3hUXtXFZS873xAxm6rH"
to = "12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
btyAmount = "8"
tokenAmount = "8"
checkItem = ["balance", "frozen"]
dep = ["tokenSell3"]
fail = true
...@@ -6,6 +6,7 @@ package trade ...@@ -6,6 +6,7 @@ package trade
import ( import (
"github.com/33cn/chain33/pluginmgr" "github.com/33cn/chain33/pluginmgr"
_ "github.com/33cn/plugin/plugin/dapp/trade/autotest"
"github.com/33cn/plugin/plugin/dapp/trade/commands" "github.com/33cn/plugin/plugin/dapp/trade/commands"
"github.com/33cn/plugin/plugin/dapp/trade/executor" "github.com/33cn/plugin/plugin/dapp/trade/executor"
"github.com/33cn/plugin/plugin/dapp/trade/rpc" "github.com/33cn/plugin/plugin/dapp/trade/rpc"
......
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