Commit 4b05a8c7 authored by 张振华's avatar 张振华

update

parents 5b17e84a 53a3f129
......@@ -90,13 +90,13 @@ ineffassign:
@golangci-lint run --no-config --issues-exit-code=1 --deadline=2m --disable-all --enable=ineffassign -n ${PKG_LIST_INEFFASSIGN}
race: ## Run data race detector
@go test -race -short $(PKG_LIST)
@go test -parallel=8 -race -short $(PKG_LIST)
test: ## Run unittests
@go test -race $(PKG_LIST)
@go test -parallel=8 -race $(PKG_LIST)
testq: ## Run unittests
@go test $(PKG_LIST)
@go test -parallel=8 $(PKG_LIST)
fmt: fmt_proto fmt_shell ## go fmt
@go fmt ./...
......
......@@ -37,9 +37,9 @@ chain33_BlockWait() {
break
fi
count=$((count + 1))
sleep 1
sleep 0.1
done
echo "wait new block $count s, cur height=$expect,old=$cur_height"
echo "wait new block $count/10 s, cur height=$expect,old=$cur_height"
}
chain33_QueryTx() {
......
......@@ -10,9 +10,7 @@ function dapp_test_rpc() {
if [ -d dapptest ]; then
cp $DAPP_TEST_COMMON dapptest/
cd dapptest || return
dir=$(find . -maxdepth 1 -type d ! -name dapptest ! -name evm ! -name game ! -name guess ! -name hashlock ! -name ticket ! -name lottery ! -name pokerbull ! -name retrieve ! -name token ! -name trade ! -name . | sed 's/^\.\///' | sort)
dir=$(find . -maxdepth 1 -type d ! -name dapptest ! -name ticket ! -name . | sed 's/^\.\///' | sort)
echo "dapps list: $dir"
for app in $dir; do
echo "=========== # $app rpc test ============="
......@@ -20,8 +18,8 @@ function dapp_test_rpc() {
echo "=========== # $app rpc end ============="
done
##ticket用例最后执行
./ticket/"${RPC_TESTFILE}" "$ip"
fi
echo "============ # dapp rpc test end ============="
}
#dapp_test_rpc $1
......@@ -80,6 +80,7 @@ function base_init() {
sed -i $sedfix 's/^powLimitBits=.*/powLimitBits="0x1f2fffff"/g' chain33.toml
sed -i $sedfix 's/^targetTimePerBlock=.*/targetTimePerBlock=1/g' chain33.toml
sed -i $sedfix 's/^targetTimespan=.*/targetTimespan=10000000/g' chain33.toml
# p2p
sed -i $sedfix 's/^seeds=.*/seeds=["chain33:13802","chain32:13802","chain31:13802"]/g' chain33.toml
......@@ -131,13 +132,13 @@ function start() {
${CLI} net info
${CLI} net peer_info
local count=100
local count=1000
while [ $count -gt 0 ]; do
peersCount=$(${CLI} net peer_info | jq '.[] | length')
if [ "${peersCount}" -ge 2 ]; then
break
fi
sleep 5
sleep 1
((count--))
echo "peers error: peersCount=${peersCount}"
done
......@@ -212,10 +213,10 @@ function miner() {
sleep 1
echo "=========== # close auto mining ============="
result=$(${1} wallet auto_mine -f 0 | jq ".isok")
if [ "${result}" = "false" ]; then
exit 1
fi
#result=$(${1} wallet auto_mine -f 0 | jq ".isok")
#if [ "${result}" = "false" ]; then
# exit 1
#fi
}
function block_wait() {
......@@ -232,9 +233,9 @@ function block_wait() {
break
fi
count=$((count + 1))
sleep 1
sleep 0.1
done
echo "wait new block $count s, cur height=$expect,old=$cur_height"
echo "wait new block $count/10 s, cur height=$expect,old=$cur_height"
}
function block_wait2height() {
......@@ -257,9 +258,9 @@ function block_wait2height() {
break
fi
count=$((count + 1))
sleep 1
sleep 0.1
done
echo "wait new block $count s, cur_height=$new_height,expect=$expect"
echo "wait new block $count/10 s, cur_height=$new_height,expect=$expect"
}
function check_docker_status() {
......
......@@ -12,7 +12,7 @@ mkdir -p "$COVERAGE_DIR"
# Create a coverage file for each package
for package in ${PKG_LIST}; do
go test -covermode=count -coverprofile "${COVERAGE_DIR}/${package##*/}.cov" "$package"
go test -parallel=8 -covermode=count -coverprofile "${COVERAGE_DIR}/${package##*/}.cov" "$package"
done
# Merge the coverage profile files
......
......@@ -108,7 +108,7 @@ futureBlockTime = 16
ticketFrozenTime = 5 #5s only for test
ticketWithdrawTime = 10 #10s only for test
ticketMinerWaitTime = 2 #2s only for test
targetTimespan = 2304
targetTimespan=2304
targetTimePerBlock=16
[mver.consensus.ticket.ForkChainParamV1]
......@@ -116,14 +116,14 @@ futureBlockTime = 15
ticketFrozenTime = 43200
ticketWithdrawTime = 172800
ticketMinerWaitTime = 7200
targetTimespan = 2160
targetTimePerBlock = 15
targetTimespan=2160
targetTimePerBlock=15
[mver.consensus.ticket.ForkChainParamV2]
coinReward = 5
coinDevFund = 3
targetTimespan = 720
targetTimePerBlock = 5
targetTimespan=720
targetTimePerBlock=5
ticketPrice = 3000
......
......@@ -3,7 +3,7 @@ module github.com/33cn/plugin
go 1.12
require (
github.com/33cn/chain33 v0.0.0-20190916043245-c5f98f6a92f5
github.com/33cn/chain33 v0.0.0-20190925060849-e4f820a6390e
github.com/BurntSushi/toml v0.3.1
github.com/NebulousLabs/Sia v1.3.7
github.com/btcsuite/btcd v0.0.0-20181013004428-67e573d211ac
......
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
github.com/33cn/chain33 v0.0.0-20190916043245-c5f98f6a92f5 h1:Nr0twQPrU5o8JE7jjXlaUNS8qQpREQxLi9IAYSAGAIc=
github.com/33cn/chain33 v0.0.0-20190916043245-c5f98f6a92f5/go.mod h1:4I8n+Zyf3t0UKM5jjpqJY627Tub62oXkLsdzIv4r6rQ=
github.com/33cn/chain33 v0.0.0-20190925060849-e4f820a6390e h1:Wb1JboAH5FMilArO9dyrmwgKPTn3V6Qz34ZSRn+K11s=
github.com/33cn/chain33 v0.0.0-20190925060849-e4f820a6390e/go.mod h1:4I8n+Zyf3t0UKM5jjpqJY627Tub62oXkLsdzIv4r6rQ=
github.com/AndreasBriese/bbloom v0.0.0-20180913140656-343706a395b7 h1:PqzgE6kAMi81xWQA2QIVxjWkFHptGgC547vchpUbtFo=
github.com/AndreasBriese/bbloom v0.0.0-20180913140656-343706a395b7/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8=
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
......
......@@ -200,13 +200,6 @@ func DposPerf() {
fmt.Println("Verify CB failed.")
}
//fmt.Println("=======start GetCBInfoByCircle!=======")
//first time, not hit
//dposClient.csState.GetCBInfoByCircle(task.Cycle)
//time.Sleep(1 * time.Second)
//second time, hit cache
//dposClient.csState.GetCBInfoByCircle(task.Cycle)
fmt.Println("=======start VoteVerify!=======")
vote := generateVote(dposClient.csState)
if nil == vote {
......@@ -430,7 +423,6 @@ func createConn2() error {
return err
}
c = types.NewChain33Client(conn)
//r = rand.New(rand.NewSource(types.Now().UnixNano()))
return nil
}
......@@ -509,7 +501,6 @@ func NormPut() {
// SendCBTx method
func verifyCB(cs *ConsensusState, info *dty.DposCBInfo) bool {
//info.Pubkey = strings.ToUpper(hex.EncodeToString(cs.privValidator.GetPubKey().Bytes()))
canonical := dty.CanonicalOnceCBInfo{
Cycle: info.Cycle,
StopHeight: info.StopHeight,
......
#!/usr/bin/env bash
# shellcheck disable=SC2128
# shellcheck source=/dev/null
source ../dapp-test-common.sh
MAIN_HTTP=""
CASE_ERR=""
evm_createContract_unsignedTx="0a0365766d129407228405608060405234801561001057600080fd5b50610264806100206000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c8063b8e010de1461003b578063cc80f6f314610045575b600080fd5b6100436100c2565b005b61004d610109565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561008757818101518382015260200161006f565b50505050905090810190601f1680156100b45780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b60408051808201909152600d8082527f5468697320697320746573742e000000000000000000000000000000000000006020909201918252610106916000916101a0565b50565b60008054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156101955780601f1061016a57610100808354040283529160200191610195565b820191906000526020600020905b81548152906001019060200180831161017857829003601f168201915b505050505090505b90565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106101e157805160ff191683800117855561020e565b8280016001018555821561020e579182015b8281111561020e5782518255916020019190600101906101f3565b5061021a92915061021e565b5090565b61019d91905b8082111561021a576000815560010161022456fea165627a7a72305820fec5dd5ca2cb47523ba08c04749bc5c14c435afee039f3047c2b7ea2faca737800293a8a025b7b22636f6e7374616e74223a66616c73652c22696e70757473223a5b5d2c226e616d65223a22736574222c226f757470757473223a5b5d2c2270617961626c65223a66616c73652c2273746174654d75746162696c697479223a226e6f6e70617961626c65222c2274797065223a2266756e6374696f6e227d2c7b22636f6e7374616e74223a747275652c22696e70757473223a5b5d2c226e616d65223a2273686f77222c226f757470757473223a5b7b226e616d65223a22222c2274797065223a22737472696e67227d5d2c2270617961626c65223a66616c73652c2273746174654d75746162696c697479223a2276696577222c2274797065223a2266756e6374696f6e227d5d20c0c7ee04309aedc4bcfba5beca5f3a223139746a5335316b6a7772436f535153313355336f7765376759424c6653666f466d"
evm_createContract_para_unsignedTx="0a0f757365722e702e706172612e65766d129407228405608060405234801561001057600080fd5b50610264806100206000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c8063b8e010de1461003b578063cc80f6f314610045575b600080fd5b6100436100c2565b005b61004d610109565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561008757818101518382015260200161006f565b50505050905090810190601f1680156100b45780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b60408051808201909152600d8082527f5468697320697320746573742e000000000000000000000000000000000000006020909201918252610106916000916101a0565b50565b60008054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156101955780601f1061016a57610100808354040283529160200191610195565b820191906000526020600020905b81548152906001019060200180831161017857829003601f168201915b505050505090505b90565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106101e157805160ff191683800117855561020e565b8280016001018555821561020e579182015b8281111561020e5782518255916020019190600101906101f3565b5061021a92915061021e565b5090565b61019d91905b8082111561021a576000815560010161022456fea165627a7a7230582080ff1004de2195e6c08d0d0a65484b3d393c99c280e305cb383dbc89343cdd6a00293a8a025b7b22636f6e7374616e74223a66616c73652c22696e70757473223a5b5d2c226e616d65223a22736574222c226f757470757473223a5b5d2c2270617961626c65223a66616c73652c2273746174654d75746162696c697479223a226e6f6e70617961626c65222c2274797065223a2266756e6374696f6e227d2c7b22636f6e7374616e74223a747275652c22696e70757473223a5b5d2c226e616d65223a2273686f77222c226f757470757473223a5b7b226e616d65223a22222c2274797065223a22737472696e67227d5d2c2270617961626c65223a66616c73652c2273746174654d75746162696c697479223a2276696577222c2274797065223a2266756e6374696f6e227d5d20c0c7ee0430e1c7facdc1f199956c3a2231483969326a67464a594e5167573350695468694337796b7a5663653570764b7478"
evm_creatorAddr="14KEKbYtKKQm4wMthSK9J4La4nAiidGozt"
evm_creatorAddr="1PTXh2EZ8aRUzpuoDRASV19K86Kx3qQiPt"
evm_creatorAddr_key="0x4947ce3c4b845cfed59be2edf47320546116a3ff3af5715a7df094d116039b89"
evm_contractAddr=""
evm_addr=""
txHash=""
#color
RED='\033[1;31m'
......@@ -24,75 +29,21 @@ function echo_rst() {
fi
}
function chain33_ImportPrivkey() {
local pri=$2
local acc=$3
local req='"method":"Chain33.ImportPrivkey", "params":[{"privkey":"'"$pri"'", "label":"admin"}]'
echo "#request: $req"
resp=$(curl -ksd "{$req}" "$1")
echo "#response: $resp"
ok=$(jq '(.error|not) and (.result.label=="admin") and (.result.acc.addr == "'"$acc"'")' <<<"$resp")
[ "$ok" == true ]
echo_rst "$FUNCNAME" "$?"
}
function Chain33_SendToAddress() {
local from="$1"
local to="$2"
local amount=$3
local req='"method":"Chain33.SendToAddress", "params":[{"from":"'"$from"'","to":"'"$to"'", "amount":'"$amount"', "note":"test\n"}]'
# echo "#request: $req"
resp=$(curl -ksd "{$req}" "${MAIN_HTTP}")
# echo "#response: $resp"
ok=$(jq '(.error|not) and (.result.hash|length==66)' <<<"$resp")
[ "$ok" == true ]
echo_rst "$FUNCNAME" "$?"
hash=$(jq '(.result.hash)' <<<"$resp")
echo "hash=$hash"
# query_tx "$hash"
}
function chain33_unlock() {
ok=$(curl -k -s --data-binary '{"jsonrpc":"2.0","id":2,"method":"Chain33.UnLock","params":[{"passwd":"1314fuzamei","timeout":0}]}' -H 'content-type:text/plain;' ${MAIN_HTTP} | jq -r ".result.isOK")
[ "$ok" == true ]
rst=$?
echo_rst "$FUNCNAME" "$rst"
}
function block_wait() {
local req='"method":"Chain33.GetLastHeader","params":[]'
cur_height=$(curl -ksd "{$req}" ${MAIN_HTTP} | jq ".result.height")
expect=$((cur_height + ${1}))
local count=0
while true; do
new_height=$(curl -ksd "{$req}" ${MAIN_HTTP} | jq ".result.height")
if [ "${new_height}" -ge "${expect}" ]; then
break
fi
count=$((count + 1))
sleep 1
done
echo "wait new block $count s, cur height=$expect,old=$cur_height"
}
function evm_createContract() {
validator=$1
expectRes=$2
if [ "$ispara" == "true" ]; then
paraName="user.p.para."
signRawTx "${evm_createContract_para_unsignedTx}" "${evm_creatorAddr}"
chain33_SignRawTx "${evm_createContract_para_unsignedTx}" "${evm_creatorAddr_key}" "$MAIN_HTTP"
else
signRawTx "${evm_createContract_unsignedTx}" "${evm_creatorAddr}"
chain33_SignRawTx "${evm_createContract_unsignedTx}" "${evm_creatorAddr_key}" "$MAIN_HTTP"
fi
echo_rst "CreateContract signRawTx" "$?"
sendSignedTx
echo_rst "CreateContract sendSignedTx" "$?"
txHash=$RAW_TX_HASH
queryTransaction "${validator}" "${expectRes}"
block_wait 2
echo "CreateContract queryExecRes end"
queryTransaction "${validator}" "${expectRes}"
echo_rst "CreateContract queryExecRes" "$?"
chain33_BlockWait 1 "$MAIN_HTTP"
}
function evm_addressCheck() {
......@@ -121,20 +72,12 @@ function evm_callContract() {
return
fi
signRawTx "${unsignedTx}" "${evm_creatorAddr}"
rst=$?
echo_rst "CallContract signRawTx" "$rst"
if [ ${rst} == 1 ]; then
return
fi
sendSignedTx
echo_rst "CallContract sendSignedTx" "$?"
block_wait 2
chain33_SignRawTx "${unsignedTx}" "${evm_creatorAddr_key}" "$MAIN_HTTP"
txHash=$RAW_TX_HASH
queryTransaction "${validator}" "${expectRes}"
echo_rst "CallContract queryExecRes" "$?"
echo "CallContract queryExecRes end"
chain33_BlockWait 1 "$MAIN_HTTP"
}
function evm_abiGet() {
......@@ -158,16 +101,12 @@ function evm_transfer() {
return
fi
signRawTx "${unsignedTx}" "${evm_creatorAddr}"
echo_rst "evm transfer signRawTx" "$?"
sendSignedTx
echo_rst "evm transfer sendSignedTx" "$?"
block_wait 2
chain33_SignRawTx "${unsignedTx}" "${evm_creatorAddr_key}" "$MAIN_HTTP"
txHash=$RAW_TX_HASH
queryTransaction "${validator}" "${expectRes}"
echo_rst "evm transfer queryExecRes" "$?"
echo "evm transfer queryExecRes end"
chain33_BlockWait 2 "$MAIN_HTTP"
}
function evm_getBalance() {
......@@ -194,35 +133,12 @@ function evm_withDraw() {
return
fi
signRawTx "${unsignedTx}" "${evm_creatorAddr}"
echo_rst "evm withdraw signRawTx" "$?"
sendSignedTx
echo_rst "evm withdraw sendSignedTx" "$?"
block_wait 2
chain33_SignRawTx "${unsignedTx}" "${evm_creatorAddr_key}" "$MAIN_HTTP"
txHash=$RAW_TX_HASH
queryTransaction "${validator}" "${expectRes}"
echo_rst "evm withdraw queryExecRes" "$?"
}
function signRawTx() {
unsignedTx=$1
addr=$2
signedTx=$(curl -s --data-binary '{"jsonrpc":"2.0","id":2,"method":"Chain33.SignRawTx","params":[{"addr":"'"${addr}"'","txHex":"'"${unsignedTx}"'","expire":"120s"}]}' -H 'content-type:text/plain;' ${MAIN_HTTP} | jq -r ".result")
if [ "$signedTx" == "null" ]; then
return 1
else
return 0
fi
}
echo "evm withdraw queryExecRes end"
function sendSignedTx() {
txHash=$(curl -s --data-binary '{"jsonrpc":"2.0","id":2,"method":"Chain33.SendTransaction","params":[{"token":"","data":"'"${signedTx}"'"}]}' -H 'content-type:text/plain;' ${MAIN_HTTP} | jq -r ".result")
if [ "$txHash" == "null" ]; then
return 1
else
return 0
fi
chain33_BlockWait 1 "$MAIN_HTTP"
}
# 查询交易的执行结果
......@@ -230,7 +146,7 @@ function sendSignedTx() {
function queryTransaction() {
validators=$1
expectRes=$2
echo "txhash=${txHash}"
echo "txHash=${txHash}"
res=$(curl -s --data-binary '{"jsonrpc":"2.0","id":2,"method":"Chain33.QueryTransaction","params":[{"hash":"'"${txHash}"'"}]}' -H 'content-type:text/plain;' ${MAIN_HTTP})
......@@ -267,18 +183,43 @@ function queryTransaction() {
function init() {
ispara=$(echo '"'"${MAIN_HTTP}"'"' | jq '.|contains("8901")')
echo "ipara=$ispara"
from="14KEKbYtKKQm4wMthSK9J4La4nAiidGozt"
local main_ip=${MAIN_HTTP//8901/8801}
#main chain import pri key
#1PTXh2EZ8aRUzpuoDRASV19K86Kx3qQiPt
chain33_ImportPrivkey "0x4947ce3c4b845cfed59be2edf47320546116a3ff3af5715a7df094d116039b89" "1PTXh2EZ8aRUzpuoDRASV19K86Kx3qQiPt" "evm" "${main_ip}"
local from="1PTXh2EZ8aRUzpuoDRASV19K86Kx3qQiPt"
if [ "$ispara" == false ]; then
chain33_applyCoins "$from" 12000000000 "${main_ip}"
chain33_QueryBalance "${from}" "$main_ip"
else
# tx fee
chain33_applyCoins "$from" 1000000000 "${main_ip}"
chain33_QueryBalance "${from}" "$main_ip"
local para_ip="${MAIN_HTTP}"
#para chain import pri key
chain33_ImportPrivkey "0x4947ce3c4b845cfed59be2edf47320546116a3ff3af5715a7df094d116039b89" "1PTXh2EZ8aRUzpuoDRASV19K86Kx3qQiPt" "evm" "$para_ip"
chain33_applyCoins "$from" 12000000000 "${para_ip}"
chain33_QueryBalance "${from}" "$para_ip"
fi
chain33_BlockWait 2 "$MAIN_HTTP"
local evm_addr=""
if [ "$ispara" == "true" ]; then
evm_addr=$(curl -ksd '{"method":"Chain33.ConvertExectoAddr","params":[{"execname":"user.p.para.evm"}]}' ${MAIN_HTTP} | jq -r ".result")
Chain33_SendToAddress "$from" "$evm_addr" 10000000000
chain33_SendToAddress "$from" "$evm_addr" 10000000000 "$MAIN_HTTP"
else
evm_addr=$(curl -ksd '{"method":"Chain33.ConvertExectoAddr","params":[{"execname":"evm"}]}' ${MAIN_HTTP} | jq -r ".result")
fi
echo "evm=$evm_addr"
Chain33_SendToAddress "$from" "$evm_addr" 10000000000
block_wait 2
chain33_SendToAddress "$from" "$evm_addr" 10000000000 "$MAIN_HTTP"
chain33_BlockWait 2 "$MAIN_HTTP"
}
function run_test() {
local ip=$1
......@@ -317,4 +258,4 @@ function main() {
fi
}
main "$1"
chain33_debug_function main "$1"
......@@ -3,17 +3,14 @@
set -e
set -o pipefail
# shellcheck source=/dev/null
source ../dapp-test-common.sh
MAIN_HTTP=""
GAME_ID=""
PASSWD="ABCD"
HASH_VALUE=$(echo -n "ABCD1" | sha256sum | awk '{print $1}')
ACCOUNT_A="1PUiGcbsccfxW3zuvHXZBJfznziph5miAo"
PRIVA_A="56942AD84CCF4788ED6DACBC005A1D0C4F91B63BCF0C99A02BE03C8DEAE71138"
ACCOUNT_B="1EDnnePAZN48aC2hiTDzhkczfF39g1pZZX"
PRIVA_B="2116459C0EC8ED01AA0EEAE35CAC5C96F94473F7816F114873291217303F6989"
EXECTOR=""
# shellcheck source=/dev/null
......@@ -142,9 +139,44 @@ function init() {
fi
echo "gameAddr=${game_addr}"
chain33_SendToAddress "${ACCOUNT_B}" "$game_addr" 5000000000 "${MAIN_HTTP}"
local main_ip=${MAIN_HTTP//8901/8801}
#main chain import pri key
#16Z3haNPQd9wrnFDw19rtpbgnN2xynNT9f
chain33_ImportPrivkey "0xfa21dc33a6144c546537580d28d894355d1e9af7292be175808b0f5737c30849" "16Z3haNPQd9wrnFDw19rtpbgnN2xynNT9f" "game1" "${main_ip}"
#16GXRfd9xj3XYMDti4y4ht7uzwoh55gZEc
chain33_ImportPrivkey "0x213286d352b01fd740b6eaeb78a4fd316d743dd51d2f12c6789977430a41e0c7" "16GXRfd9xj3XYMDti4y4ht7uzwoh55gZEc" "game2" "$main_ip"
local ACCOUNT_A="16Z3haNPQd9wrnFDw19rtpbgnN2xynNT9f"
local ACCOUNT_B="16GXRfd9xj3XYMDti4y4ht7uzwoh55gZEc"
if [ "$ispara" == false ]; then
chain33_applyCoins "$ACCOUNT_A" 12000000000 "${main_ip}"
chain33_QueryBalance "${ACCOUNT_A}" "$main_ip"
chain33_applyCoins "$ACCOUNT_B" 12000000000 "${main_ip}"
chain33_QueryBalance "${ACCOUNT_B}" "$main_ip"
else
# tx fee
chain33_applyCoins "$ACCOUNT_A" 1000000000 "${main_ip}"
chain33_QueryBalance "${ACCOUNT_A}" "$main_ip"
chain33_applyCoins "$ACCOUNT_B" 1000000000 "${main_ip}"
chain33_QueryBalance "${ACCOUNT_B}" "$main_ip"
local para_ip="${MAIN_HTTP}"
#para chain import pri key
chain33_ImportPrivkey "0xfa21dc33a6144c546537580d28d894355d1e9af7292be175808b0f5737c30849" "16Z3haNPQd9wrnFDw19rtpbgnN2xynNT9f" "game1" "$para_ip"
chain33_ImportPrivkey "0x213286d352b01fd740b6eaeb78a4fd316d743dd51d2f12c6789977430a41e0c7" "16GXRfd9xj3XYMDti4y4ht7uzwoh55gZEc" "game2" "$para_ip"
chain33_applyCoins "$ACCOUNT_A" 12000000000 "${para_ip}"
chain33_QueryBalance "${ACCOUNT_A}" "$para_ip"
chain33_applyCoins "$ACCOUNT_B" 12000000000 "${para_ip}"
chain33_QueryBalance "${ACCOUNT_B}" "$para_ip"
fi
chain33_SendToAddress "${ACCOUNT_B}" "$game_addr" 5000000000 "${MAIN_HTTP}"
chain33_QueryExecBalance "${ACCOUNT_B}" "game" "$MAIN_HTTP"
chain33_SendToAddress "${ACCOUNT_A}" "$game_addr" 5000000000 "${MAIN_HTTP}"
chain33_QueryExecBalance "${ACCOUNT_A}" "game" "$MAIN_HTTP"
chain33_BlockWait 1 "$MAIN_HTTP"
}
......@@ -197,4 +229,4 @@ function main() {
fi
}
main "$1"
chain33_debug_function main "$1"
......@@ -11,8 +11,8 @@ source ../dapp-test-common.sh
MAIN_HTTP=""
CASE_ERR=""
guess_admin_addr=12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
guess_user1_addr=1PUiGcbsccfxW3zuvHXZBJfznziph5miAo
guess_user2_addr=1EDnnePAZN48aC2hiTDzhkczfF39g1pZZX
guess_user1_addr=1NrfEBfdFJUUqgbw5ZbHXhdew6NNQumYhM
guess_user2_addr=17tRkBrccmFiVcLPXgEceRxDzJ2WaDZumN
guess_addr=""
guess_exec=""
......@@ -134,14 +134,46 @@ init() {
guess_addr=$(curl -ksd '{"method":"Chain33.ConvertExectoAddr","params":[{"execname":"guess"}]}' ${MAIN_HTTP} | jq -r ".result")
guess_exec="guess"
fi
echo "guess_addr=$guess_addr"
local from="1PUiGcbsccfxW3zuvHXZBJfznziph5miAo"
chain33_SendToAddress "$from" "$guess_addr" 10000000000 ${MAIN_HTTP}
local main_ip=${MAIN_HTTP//8901/8801}
#main chain import pri key
#1NrfEBfdFJUUqgbw5ZbHXhdew6NNQumYhM
chain33_ImportPrivkey "0xc889d2958843fc96d4bd3f578173137d37230e580d65e9074545c61e7e9c1932" "1NrfEBfdFJUUqgbw5ZbHXhdew6NNQumYhM" "guess1" "${main_ip}"
#17tRkBrccmFiVcLPXgEceRxDzJ2WaDZumN
chain33_ImportPrivkey "0xf10c79470dc74c229c4ee73b05d14c58322b771a6c749d27824f6a59bb6c2d73" "17tRkBrccmFiVcLPXgEceRxDzJ2WaDZumN" "guess2" "$main_ip"
local guess1="1NrfEBfdFJUUqgbw5ZbHXhdew6NNQumYhM"
local guess2="17tRkBrccmFiVcLPXgEceRxDzJ2WaDZumN"
if [ "$ispara" == false ]; then
chain33_applyCoins "$guess1" 12000000000 "${main_ip}"
chain33_QueryBalance "${guess1}" "$main_ip"
chain33_applyCoins "$guess2" 12000000000 "${main_ip}"
chain33_QueryBalance "${guess2}" "$main_ip"
else
# tx fee
chain33_applyCoins "$guess1" 1000000000 "${main_ip}"
chain33_QueryBalance "${guess1}" "$main_ip"
chain33_applyCoins "$guess2" 1000000000 "${main_ip}"
chain33_QueryBalance "${guess2}" "$main_ip"
local para_ip="${MAIN_HTTP}"
#para chain import pri key
chain33_ImportPrivkey "0xc889d2958843fc96d4bd3f578173137d37230e580d65e9074545c61e7e9c1932" "1NrfEBfdFJUUqgbw5ZbHXhdew6NNQumYhM" "guess1" "$para_ip"
chain33_ImportPrivkey "0xf10c79470dc74c229c4ee73b05d14c58322b771a6c749d27824f6a59bb6c2d73" "17tRkBrccmFiVcLPXgEceRxDzJ2WaDZumN" "guess2" "$para_ip"
chain33_applyCoins "$guess1" 12000000000 "${para_ip}"
chain33_QueryBalance "${guess1}" "$para_ip"
chain33_applyCoins "$guess2" 12000000000 "${para_ip}"
chain33_QueryBalance "${guess2}" "$para_ip"
fi
from="1EDnnePAZN48aC2hiTDzhkczfF39g1pZZX"
chain33_SendToAddress "$from" "$guess_addr" 10000000000 ${MAIN_HTTP}
chain33_SendToAddress "$guess1" "$guess_addr" 10000000000 ${MAIN_HTTP}
chain33_QueryExecBalance "${guess1}" "guess" "$MAIN_HTTP"
chain33_SendToAddress "$guess2" "$guess_addr" 10000000000 ${MAIN_HTTP}
chain33_QueryExecBalance "${guess2}" "guess" "$MAIN_HTTP"
chain33_BlockWait 1 "${MAIN_HTTP}"
}
......@@ -149,8 +181,8 @@ init() {
function run_test() {
#导入地址私钥
chain33_ImportPrivkey "56942AD84CCF4788ED6DACBC005A1D0C4F91B63BCF0C99A02BE03C8DEAE71138" "1PUiGcbsccfxW3zuvHXZBJfznziph5miAo" "user1" "$MAIN_HTTP"
chain33_ImportPrivkey "2116459C0EC8ED01AA0EEAE35CAC5C96F94473F7816F114873291217303F6989" "1EDnnePAZN48aC2hiTDzhkczfF39g1pZZX" "user2" "$MAIN_HTTP"
chain33_ImportPrivkey "0xc889d2958843fc96d4bd3f578173137d37230e580d65e9074545c61e7e9c1932" "1NrfEBfdFJUUqgbw5ZbHXhdew6NNQumYhM" "user1" "$MAIN_HTTP"
chain33_ImportPrivkey "0xf10c79470dc74c229c4ee73b05d14c58322b771a6c749d27824f6a59bb6c2d73" "17tRkBrccmFiVcLPXgEceRxDzJ2WaDZumN" "user2" "$MAIN_HTTP"
chain33_ImportPrivkey "4257D8692EF7FE13C68B65D6A52F03933DB2FA5CE8FAF210B5B8B80C721CED01" "12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv" "admin" "$MAIN_HTTP"
chain33_QueryBalance "${guess_admin_addr}" "$MAIN_HTTP"
......@@ -167,13 +199,13 @@ function run_test() {
guess_QueryGameByID "$eventId" 11
#用户1下注
guess_game_bet "56942AD84CCF4788ED6DACBC005A1D0C4F91B63BCF0C99A02BE03C8DEAE71138" "A"
guess_game_bet "0xc889d2958843fc96d4bd3f578173137d37230e580d65e9074545c61e7e9c1932" "A"
#查询游戏状态
guess_QueryGameByID "$eventId" 12
#用户2下注
guess_game_bet "2116459C0EC8ED01AA0EEAE35CAC5C96F94473F7816F114873291217303F6989" "B"
guess_game_bet "0xf10c79470dc74c229c4ee73b05d14c58322b771a6c749d27824f6a59bb6c2d73" "B"
#查询游戏状态
guess_QueryGameByID "$eventId" 12
......@@ -233,13 +265,13 @@ function run_test() {
guess_QueryGameByID "$eventId" 11
#用户1下注
guess_game_bet "56942AD84CCF4788ED6DACBC005A1D0C4F91B63BCF0C99A02BE03C8DEAE71138" "A"
guess_game_bet "0xc889d2958843fc96d4bd3f578173137d37230e580d65e9074545c61e7e9c1932" "A"
#查询游戏状态
guess_QueryGameByID "$eventId" 12
#用户2下注
guess_game_bet "2116459C0EC8ED01AA0EEAE35CAC5C96F94473F7816F114873291217303F6989" "B"
guess_game_bet "0xf10c79470dc74c229c4ee73b05d14c58322b771a6c749d27824f6a59bb6c2d73" "B"
#查询游戏状态
guess_QueryGameByID "$eventId" 12
......@@ -258,13 +290,13 @@ function run_test() {
guess_QueryGameByID "$eventId" 11
#用户1下注
guess_game_bet "56942AD84CCF4788ED6DACBC005A1D0C4F91B63BCF0C99A02BE03C8DEAE71138" "A"
guess_game_bet "0xc889d2958843fc96d4bd3f578173137d37230e580d65e9074545c61e7e9c1932" "A"
#查询游戏状态
guess_QueryGameByID "$eventId" 12
#用户2下注
guess_game_bet "2116459C0EC8ED01AA0EEAE35CAC5C96F94473F7816F114873291217303F6989" "B"
guess_game_bet "0xf10c79470dc74c229c4ee73b05d14c58322b771a6c749d27824f6a59bb6c2d73" "B"
#查询游戏状态
guess_QueryGameByID "$eventId" 12
......@@ -304,4 +336,4 @@ function main() {
echo "=========== # guess rpc test end============="
}
main "$1"
chain33_debug_function main "$1"
......@@ -5,8 +5,8 @@ set -o pipefail
MAIN_HTTP=""
addr_A=1PUiGcbsccfxW3zuvHXZBJfznziph5miAo
addr_B=1EDnnePAZN48aC2hiTDzhkczfF39g1pZZX
addr_A=19vpbRuz2XtKopQS2ruiVuVZeRdLd5n4t3
addr_B=1FcofeCgU1KYbB8dSa7cV2wjAF2RpMuUQD
# shellcheck source=/dev/null
source ../dapp-test-common.sh
......@@ -24,7 +24,7 @@ hashlock_lock() {
[ "$ok" == true ]
echo_rst "$FUNCNAME" "$?"
chain33_SignRawTx "$tx" "56942AD84CCF4788ED6DACBC005A1D0C4F91B63BCF0C99A02BE03C8DEAE71138" ${MAIN_HTTP}
chain33_SignRawTx "$tx" "0x1089b7f980fc467f029b7ae301249b36e3b582c911b1af1a24616c83b3563dcb" ${MAIN_HTTP}
#echo "txHash ${txhash}"
echo "========== # hashlock lock tx end =========="
......@@ -44,7 +44,7 @@ hashlock_send() {
[ "$ok" == true ]
echo_rst "$FUNCNAME" "$?"
chain33_SignRawTx "$tx" "2116459C0EC8ED01AA0EEAE35CAC5C96F94473F7816F114873291217303F6989" ${MAIN_HTTP}
chain33_SignRawTx "$tx" "0xb76a398c3901dfe5c7335525da88fda4df24c11ad11af4332f00c0953cc2910f" ${MAIN_HTTP}
#echo "txHash ${txhash}"
echo "========== # hashlock send tx end =========="
......@@ -63,7 +63,7 @@ hashlock_unlock() {
[ "$ok" == true ]
echo_rst "$FUNCNAME" "$?"
chain33_SignRawTx "$tx" "56942AD84CCF4788ED6DACBC005A1D0C4F91B63BCF0C99A02BE03C8DEAE71138" ${MAIN_HTTP}
chain33_SignRawTx "$tx" "0x1089b7f980fc467f029b7ae301249b36e3b582c911b1af1a24616c83b3563dcb" ${MAIN_HTTP}
#echo "txHash ${txhash}"
echo "========== # hashlock unlock tx end =========="
......@@ -79,11 +79,45 @@ init() {
hashlock_addr=$(curl -ksd '{"method":"Chain33.ConvertExectoAddr","params":[{"execname":"hashlock"}]}' ${MAIN_HTTP} | jq -r ".result")
fi
local from="1PUiGcbsccfxW3zuvHXZBJfznziph5miAo"
chain33_SendToAddress "$from" "$hashlock_addr" 10000000000 ${MAIN_HTTP}
local main_ip=${MAIN_HTTP//8901/8801}
#main chain import pri key
#19vpbRuz2XtKopQS2ruiVuVZeRdLd5n4t3
chain33_ImportPrivkey "0x1089b7f980fc467f029b7ae301249b36e3b582c911b1af1a24616c83b3563dcb" "19vpbRuz2XtKopQS2ruiVuVZeRdLd5n4t3" "hashlock1" "${main_ip}"
#1FcofeCgU1KYbB8dSa7cV2wjAF2RpMuUQD
chain33_ImportPrivkey "0xb76a398c3901dfe5c7335525da88fda4df24c11ad11af4332f00c0953cc2910f" "1FcofeCgU1KYbB8dSa7cV2wjAF2RpMuUQD" "hashlock2" "$main_ip"
local hashlock1="19vpbRuz2XtKopQS2ruiVuVZeRdLd5n4t3"
local hashlock2="1FcofeCgU1KYbB8dSa7cV2wjAF2RpMuUQD"
if [ "$ispara" == false ]; then
chain33_applyCoins "$hashlock1" 12000000000 "${main_ip}"
chain33_QueryBalance "${hashlock1}" "$main_ip"
chain33_applyCoins "$hashlock2" 12000000000 "${main_ip}"
chain33_QueryBalance "${hashlock2}" "$main_ip"
else
# tx fee
chain33_applyCoins "$hashlock1" 1000000000 "${main_ip}"
chain33_QueryBalance "${hashlock1}" "$main_ip"
chain33_applyCoins "$hashlock2" 1000000000 "${main_ip}"
chain33_QueryBalance "${hashlock2}" "$main_ip"
local para_ip="${MAIN_HTTP}"
#para chain import pri key
chain33_ImportPrivkey "0x1089b7f980fc467f029b7ae301249b36e3b582c911b1af1a24616c83b3563dcb" "19vpbRuz2XtKopQS2ruiVuVZeRdLd5n4t3" "hashlock1" "$para_ip"
chain33_ImportPrivkey "0xb76a398c3901dfe5c7335525da88fda4df24c11ad11af4332f00c0953cc2910f" "1FcofeCgU1KYbB8dSa7cV2wjAF2RpMuUQD" "hashlock2" "$para_ip"
chain33_applyCoins "$hashlock1" 12000000000 "${para_ip}"
chain33_QueryBalance "${hashlock1}" "$para_ip"
chain33_applyCoins "$hashlock2" 12000000000 "${para_ip}"
chain33_QueryBalance "${hashlock2}" "$para_ip"
fi
chain33_SendToAddress "$hashlock1" "$hashlock_addr" 10000000000 ${MAIN_HTTP}
chain33_QueryExecBalance "${hashlock1}" "hashlock" "$MAIN_HTTP"
chain33_SendToAddress "$hashlock2" "$hashlock_addr" 10000000000 ${MAIN_HTTP}
chain33_QueryExecBalance "${hashlock2}" "hashlock" "$MAIN_HTTP"
from="1EDnnePAZN48aC2hiTDzhkczfF39g1pZZX"
chain33_SendToAddress "$from" "$hashlock_addr" 10000000000 ${MAIN_HTTP}
chain33_BlockWait 1 "${MAIN_HTTP}"
}
......@@ -99,7 +133,7 @@ function run_test() {
hashlock_lock "aef"
chain33_QueryBalance "$addr_A" "${MAIN_HTTP}"
sleep 75
sleep 5
hashlock_unlock "aef"
chain33_BlockWait 1 ${MAIN_HTTP}
chain33_QueryBalance "$addr_A" "${MAIN_HTTP}"
......@@ -121,4 +155,4 @@ function main() {
fi
}
main "$1"
chain33_debug_function main "$1"
......@@ -18,8 +18,8 @@ gID=""
lottExecAddr=""
luckyNumber=""
purNum=30
drawNum=40
purNum=200
drawNum=220
opRatio=5
devRatio=5
......@@ -35,12 +35,45 @@ init() {
chain33_SignRawTx "${lottery_addCreator_unsignedTx}" "${lottery_creator_priv}" ${MAIN_HTTP}
fi
echo "lottExecAddr=$lottExecAddr"
local main_ip=${MAIN_HTTP//8901/8801}
#main chain import pri key
#1FLh9wBS2rat1mUS4G95hRpJt6yHYy5nHF
chain33_ImportPrivkey "0x8223b757a5d0f91b12e7af3b9666ca33be47fe63e1502987b0537089aaf90bc1" "1FLh9wBS2rat1mUS4G95hRpJt6yHYy5nHF" "lottery1" "${main_ip}"
#1UWE6NfXPR7eNAjYgT4HMERp7cMMi486E
chain33_ImportPrivkey "0xbfccb96690e0a1f89748b321f85b03e14bda0cb3d5d19f255ff0b9b0ffb624b3" "1UWE6NfXPR7eNAjYgT4HMERp7cMMi486E" "lottery2" "$main_ip"
local ACCOUNT_A="1FLh9wBS2rat1mUS4G95hRpJt6yHYy5nHF"
local ACCOUNT_B="1UWE6NfXPR7eNAjYgT4HMERp7cMMi486E"
if [ "$ispara" == false ]; then
chain33_applyCoins "$ACCOUNT_A" 12000000000 "${main_ip}"
chain33_QueryBalance "${ACCOUNT_A}" "$main_ip"
chain33_applyCoins "$ACCOUNT_B" 12000000000 "${main_ip}"
chain33_QueryBalance "${ACCOUNT_B}" "$main_ip"
else
# tx fee
chain33_applyCoins "$ACCOUNT_A" 1000000000 "${main_ip}"
chain33_QueryBalance "${ACCOUNT_A}" "$main_ip"
chain33_applyCoins "$ACCOUNT_B" 1000000000 "${main_ip}"
chain33_QueryBalance "${ACCOUNT_B}" "$main_ip"
local para_ip="${MAIN_HTTP}"
#para chain import pri key
chain33_ImportPrivkey "0x8223b757a5d0f91b12e7af3b9666ca33be47fe63e1502987b0537089aaf90bc1" "1FLh9wBS2rat1mUS4G95hRpJt6yHYy5nHF" "lottery1" "$para_ip"
chain33_ImportPrivkey "0xbfccb96690e0a1f89748b321f85b03e14bda0cb3d5d19f255ff0b9b0ffb624b3" "1UWE6NfXPR7eNAjYgT4HMERp7cMMi486E" "lottery2" "$para_ip"
chain33_applyCoins "$ACCOUNT_A" 12000000000 "${para_ip}"
chain33_QueryBalance "${ACCOUNT_A}" "$para_ip"
chain33_applyCoins "$ACCOUNT_B" 12000000000 "${para_ip}"
chain33_QueryBalance "${ACCOUNT_B}" "$para_ip"
fi
}
lottery_LotteryCreate() {
#创建交易
priv=$1
set -x
resp=$(curl -ksd '{"method":"Chain33.CreateTransaction","params":[{"execer":"lottery","actionName":"LotteryCreate",
"payload":{"purBlockNum":'"$purNum"',"drawBlockNum":'"$drawNum"', "opRewardRatio":'"$opRatio"',"devRewardRatio":'"$devRatio"',"fee":1000000}}]}' -H 'content-type:text/plain;' ${MAIN_HTTP})
ok=$(echo "${resp}" | jq -r ".error")
......@@ -50,7 +83,6 @@ lottery_LotteryCreate() {
#发送交易
rawTx=$(echo "${resp}" | jq -r ".result")
chain33_SignRawTx "${rawTx}" "${priv}" ${MAIN_HTTP}
set +x
gID="${RAW_TX_HASH}"
echo "gameID $gID"
......@@ -62,7 +94,6 @@ lottery_LotteryBuy() {
amount=$2
number=$3
way=$4
set -x
resp=$(curl -ksd '{"method":"Chain33.CreateTransaction","params":[{"execer":"lottery","actionName":"LotteryBuy",
"payload":{"lotteryId":"'"$gID"'","amount":'"$amount"',"number":'"$number"',"way":'"$way"',"fee":1000000}}]}' -H 'content-type:text/plain;' ${MAIN_HTTP})
ok=$(echo "${resp}" | jq -r ".error")
......@@ -72,13 +103,11 @@ lottery_LotteryBuy() {
#发送交易
rawTx=$(echo "${resp}" | jq -r ".result")
chain33_SignRawTx "${rawTx}" "${priv}" ${MAIN_HTTP}
set +x
}
lottery_LotteryDraw() {
#创建交易
priv=$1
set -x
resp=$(curl -ksd '{"method":"Chain33.CreateTransaction","params":[{"execer":"lottery","actionName":"LotteryDraw",
"payload":{"lotteryId":"'"$gID"'","fee":1000000}}]}' -H 'content-type:text/plain;' ${MAIN_HTTP})
ok=$(echo "${resp}" | jq -r ".error")
......@@ -88,13 +117,11 @@ lottery_LotteryDraw() {
#发送交易
rawTx=$(echo "${resp}" | jq -r ".result")
chain33_SignRawTx "${rawTx}" "${priv}" ${MAIN_HTTP}
set +x
}
lottery_LotteryClose() {
#创建交易
priv=$1
set -x
resp=$(curl -ksd '{"method":"Chain33.CreateTransaction","params":[{"execer":"lottery","actionName":"LotteryClose",
"payload":{"lotteryId":"'"$gID"'","fee":1000000}}]}' -H 'content-type:text/plain;' ${MAIN_HTTP})
ok=$(echo "${resp}" | jq -r ".error")
......@@ -104,7 +131,6 @@ lottery_LotteryClose() {
#发送交易
rawTx=$(echo "${resp}" | jq -r ".result")
chain33_SignRawTx "${rawTx}" "${priv}" ${MAIN_HTTP}
set +x
}
lottery_GetLotteryNormalInfo() {
......@@ -112,10 +138,8 @@ lottery_GetLotteryNormalInfo() {
addr=$2
execer="lottery"
funcName="GetLotteryNormalInfo"
set -x
resp=$(curl -ksd '{"method":"Chain33.Query","params":[{"execer":"'"$execer"'","funcName":"'"$funcName"'","payload":{"lotteryId":"'"$gameID"'"}}]}' -H 'content-type:text/plain;' ${MAIN_HTTP})
ok=$(jq '(.error|not) and (.result.purBlockNum == "'"$purNum"'") and (.result.drawBlockNum == "'"$drawNum"'") and (.result.createAddr == "'"$addr"'") and (.result.opRewardRatio == "'"$opRatio"'") and (.result.devRewardRatio == "'"$devRatio"'") and (.result | [has("createHeight"), true] | unique | length == 1)' <<<"$resp")
set +x
[[ $ok == true ]]
rst=$?
echo_rst "$FUNCNAME" "$rst"
......@@ -127,10 +151,8 @@ lottery_GetLotteryCurrentInfo() {
amount=$3
execer="lottery"
funcName="GetLotteryCurrentInfo"
set -x
resp=$(curl -ksd '{"method":"Chain33.Query","params":[{"execer":"'"$execer"'","funcName":"'"$funcName"'","payload":{"lotteryId":"'"$gameID"'"}}]}' -H 'content-type:text/plain;' ${MAIN_HTTP})
ok=$(jq '(.error|not) and (.result.status == '"$status"') and (.result.buyAmount == "'"$amount"'") and (.result | [has("lastTransToPurState", "lastTransToDrawState", "totalPurchasedTxNum", "round", "luckyNumber", "lastTransToPurStateOnMain", "lastTransToDrawStateOnMain", "purBlockNum", "drawBlockNum", "missingRecords", "totalAddrNum"), true] | unique | length == 1)' <<<"$resp")
set +x
[[ $ok == true ]]
rst=$?
echo_rst "$FUNCNAME" "$rst"
......@@ -146,10 +168,8 @@ lottery_GetLotteryPurchaseAddr() {
count=$2
execer="lottery"
funcName="GetLotteryPurchaseAddr"
set -x
resp=$(curl -ksd '{"method":"Chain33.Query","params":[{"execer":"'"$execer"'","funcName":"'"$funcName"'","payload":{"lotteryId":"'"$gameID"'"}}]}' -H 'content-type:text/plain;' ${MAIN_HTTP})
ok=$(jq '(.error|not) and (.result.address | length == '"$count"')' <<<"$resp")
set +x
[[ $ok == true ]]
rst=$?
echo_rst "$FUNCNAME" "$rst"
......@@ -161,10 +181,8 @@ lottery_GetLotteryHistoryLuckyNumber() {
lucky=$3
execer="lottery"
funcName="GetLotteryHistoryLuckyNumber"
set -x
resp=$(curl -ksd '{"method":"Chain33.Query","params":[{"execer":"'"$execer"'","funcName":"'"$funcName"'","payload":{"lotteryId":"'"$gameID"'"}}]}' -H 'content-type:text/plain;' ${MAIN_HTTP})
ok=$(jq '(.error|not) and (.result.records | length == '"$count"') and (.result.records[0].number == "'"$lucky"'")' <<<"$resp")
set +x
[[ $ok == true ]]
rst=$?
echo_rst "$FUNCNAME" "$rst"
......@@ -176,10 +194,8 @@ lottery_GetLotteryRoundLuckyNumber() {
lucky=$3
execer="lottery"
funcName="GetLotteryRoundLuckyNumber"
set -x
resp=$(curl -ksd '{"method":"Chain33.Query","params":[{"execer":"'"$execer"'","funcName":"'"$funcName"'","payload":{"lotteryId":"'"$gameID"'", "round":['"$round"']}}]}' -H 'content-type:text/plain;' ${MAIN_HTTP})
ok=$(jq '(.error|not) and (.result.records | length == 1) and (.result.records[0].number == "'"$lucky"'")' <<<"$resp")
set +x
[[ $ok == true ]]
rst=$?
echo_rst "$FUNCNAME" "$rst"
......@@ -192,10 +208,8 @@ lottery_GetLotteryHistoryBuyInfo() {
number=$4
execer="lottery"
funcName="GetLotteryHistoryBuyInfo"
set -x
resp=$(curl -ksd '{"method":"Chain33.Query","params":[{"execer":"'"$execer"'","funcName":"'"$funcName"'","payload":{"lotteryId":"'"$gameID"'", "addr":"'"$addr"'"}}]}' -H 'content-type:text/plain;' ${MAIN_HTTP})
ok=$(jq '(.error|not) and (.result.records | length == '"$count"') and (.result.records[0].number == "'"$number"'")' <<<"$resp")
set +x
[[ $ok == true ]]
rst=$?
echo_rst "$FUNCNAME" "$rst"
......@@ -209,10 +223,8 @@ lottery_GetLotteryBuyRoundInfo() {
number=$5
execer="lottery"
funcName="GetLotteryBuyRoundInfo"
set -x
resp=$(curl -ksd '{"method":"Chain33.Query","params":[{"execer":"'"$execer"'","funcName":"'"$funcName"'","payload":{"lotteryId":"'"$gameID"'", "addr":"'"$addr"'", "round":'"$round"'}}]}' -H 'content-type:text/plain;' ${MAIN_HTTP})
ok=$(jq '(.error|not) and (.result.records | length == '"$count"') and (.result.records[0].number == "'"$number"'")' <<<"$resp")
set +x
[[ $ok == true ]]
rst=$?
echo_rst "$FUNCNAME" "$rst"
......@@ -225,10 +237,8 @@ lottery_GetLotteryHistoryGainInfo() {
amount=$4
execer="lottery"
funcName="GetLotteryHistoryGainInfo"
set -x
resp=$(curl -ksd '{"method":"Chain33.Query","params":[{"execer":"'"$execer"'","funcName":"'"$funcName"'","payload":{"lotteryId":"'"$gameID"'", "addr":"'"$addr"'"}}]}' -H 'content-type:text/plain;' ${MAIN_HTTP})
ok=$(jq '(.error|not) and (.result.records | length == '"$count"') and (.result.records[0].addr == "'"$addr"'") and (.result.records[0].buyAmount == "'"$amount"'")' <<<"$resp")
set +x
[[ $ok == true ]]
rst=$?
echo_rst "$FUNCNAME" "$rst"
......@@ -241,10 +251,8 @@ lottery_GetLotteryRoundGainInfo() {
amount=$4
execer="lottery"
funcName="GetLotteryRoundGainInfo"
set -x
resp=$(curl -ksd '{"method":"Chain33.Query","params":[{"execer":"'"$execer"'","funcName":"'"$funcName"'","payload":{"lotteryId":"'"$gameID"'", "addr":"'"$addr"'", "round":'"$round"'}}]}' -H 'content-type:text/plain;' ${MAIN_HTTP})
ok=$(jq '(.error|not) and (.result.addr == "'"$addr"'") and (.result.round == "'"$round"'") and (.result.buyAmount == "'"$amount"'") and (.result | [has("fundAmount"), true] | unique | length == 1)' <<<"$resp")
set +x
[[ $ok == true ]]
rst=$?
echo_rst "$FUNCNAME" "$rst"
......@@ -252,16 +260,14 @@ lottery_GetLotteryRoundGainInfo() {
function run_testcases() {
#账户地址
gameAddr1="1PUiGcbsccfxW3zuvHXZBJfznziph5miAo"
gamePriv1="0x56942AD84CCF4788ED6DACBC005A1D0C4F91B63BCF0C99A02BE03C8DEAE71138"
gameAddr2="1EDnnePAZN48aC2hiTDzhkczfF39g1pZZX"
gamePriv2="0x2116459C0EC8ED01AA0EEAE35CAC5C96F94473F7816F114873291217303F6989"
gameAddr1="1FLh9wBS2rat1mUS4G95hRpJt6yHYy5nHF"
gamePriv1="0x8223b757a5d0f91b12e7af3b9666ca33be47fe63e1502987b0537089aaf90bc1"
gameAddr2="1UWE6NfXPR7eNAjYgT4HMERp7cMMi486E"
gamePriv2="0xbfccb96690e0a1f89748b321f85b03e14bda0cb3d5d19f255ff0b9b0ffb624b3"
set -x
#给游戏合约中转帐
chain33_SendToAddress "${gameAddr1}" "${lottExecAddr}" 500000000 "${MAIN_HTTP}"
chain33_SendToAddress "${gameAddr2}" "${lottExecAddr}" 500000000 "${MAIN_HTTP}"
set +x
#创建游戏
lottery_LotteryCreate "${lottery_creator_priv}"
......@@ -322,4 +328,4 @@ function main() {
echo "=========== # lottery rpc test end============="
}
main "$1"
chain33_debug_function main "$1"
......@@ -17,24 +17,6 @@ paracross_GetBlock2MainInfo() {
echo_rst "$FUNCNAME" "$rst"
}
chain33_lock() {
local ok
ok=$(curl -ksd '{"method":"Chain33.Lock","params":[]}' ${UNIT_HTTP} | jq -r ".result.isOK")
[ "$ok" == true ]
local rst=$?
echo_rst "$FUNCNAME" "$rst"
}
chain33_unlock() {
local ok
ok=$(curl -ksd '{"method":"Chain33.UnLock","params":[{"passwd":"1314fuzamei","timeout":0}]}' ${UNIT_HTTP} | jq -r ".result.isOK")
[ "$ok" == true ]
local rst=$?
echo_rst "$FUNCNAME" "$rst"
}
function paracross_SignAndSend() {
local signedTx
local sendedTx
......@@ -54,8 +36,9 @@ function paracross_QueryParaBalance() {
ip_http=${UNIT_HTTP%:*}
para_http="$ip_http:8901"
local exec=$2
req='{"method":"Chain33.GetBalance", "params":[{"addresses" : ["'"$1"'"], "execer" : "paracross","asset_exec":"paracross","asset_symbol":"coins.bty"}]}'
req='{"method":"Chain33.GetBalance", "params":[{"addresses" : ["'"$1"'"], "execer" : "'"${exec}"'","asset_exec":"paracross","asset_symbol":"coins.bty"}]}'
resp=$(curl -ksd "$req" "${para_http}")
balance=$(jq -r '.result[0].balance' <<<"$resp")
echo "$balance"
......@@ -130,7 +113,7 @@ function paracross_Transfer_Withdraw_Inner() {
#paracross_SignAndSend $fee "$privkey" "$tx_hash"
#1. 查询资产转移前余额状态
para_balance_before=$(paracross_QueryParaBalance "$from_addr")
para_balance_before=$(paracross_QueryParaBalance "$from_addr" "paracross")
echo "para before transferring:$para_balance_before"
main_balance_before=$(paracross_QueryMainBalance "$from_addr")
echo "main before transferring:$main_balance_before"
......@@ -144,7 +127,7 @@ function paracross_Transfer_Withdraw_Inner() {
#4 查询转移后余额状态
local times=100
while true; do
para_balance_after=$(paracross_QueryParaBalance "$from_addr")
para_balance_after=$(paracross_QueryParaBalance "$from_addr" "paracross")
echo "para after transferring:$para_balance_after"
main_balance_after=$(paracross_QueryMainBalance "$from_addr")
echo "main after transferring:$main_balance_after"
......@@ -175,7 +158,7 @@ function paracross_Transfer_Withdraw_Inner() {
#6 查询取钱后余额状态
local times=100
while true; do
para_balance_withdraw_after=$(paracross_QueryParaBalance "$from_addr")
para_balance_withdraw_after=$(paracross_QueryParaBalance "$from_addr" "paracross")
echo "para after withdrawing :$para_balance_withdraw_after"
main_balance_withdraw_after=$(paracross_QueryMainBalance "$from_addr")
echo "main after withdrawing :$main_balance_withdraw_after"
......@@ -306,9 +289,76 @@ function paracross_ListNodeStatus() {
echo_rst "$FUNCNAME" "$rst"
}
function paracross_testTxGroup() {
local para_ip=$1
ispara=$(echo '"'"${para_ip}"'"' | jq '.|contains("8901")')
echo "ipara=$ispara"
local paracross_addr=""
local main_ip=${para_ip//8901/8801}
paracross_addr=$(curl -ksd '{"method":"Chain33.ConvertExectoAddr","params":[{"execname":"paracross"}]}' "${main_ip}" | jq -r ".result")
echo "paracross_addr=$paracross_addr"
#main chain import pri key
local test_addr="1MAuE8QSbbech3bVKK2JPJJxYxNtT95oSU"
local test_prikey="0x24d1fad138be98eebee31440f144aa38c404533f40862995282162bc538e91c8"
#execer
local paracross_execer_name="user.p.para.paracross"
local trade_exec_name="user.p.para.trade"
local trade_exec_addr="12bihjzbaYWjcpDiiy9SuAWeqNksQdiN13"
local amount_trade=100000000
local amount_transfer=800000000
chain33_ImportPrivkey "${test_prikey}" "${test_addr}" "paracross-transfer6" "${main_ip}"
# tx fee + transfer 10 coins
chain33_applyCoins "${test_addr}" 1000000000 "${main_ip}"
chain33_QueryBalance "${test_addr}" "$main_ip"
#deposit 8 coins to paracross
chain33_SendToAddress "${test_addr}" "$paracross_addr" "$amount_transfer" "${main_ip}"
chain33_QueryExecBalance "${test_addr}" "paracross" "${main_ip}"
# 资产从主链转移到平行链
tx_hash_asset=$(curl -ksd '{"method":"Chain33.CreateTransaction","params":[{"execer":"'"${paracross_execer_name}"'","actionName":"ParacrossAssetTransfer","payload":{"execName":"'"${paracross_execer_name}"'","to":"'"$test_addr"'","amount":'${amount_transfer}'}}]}' "${para_ip}" | jq -r ".result")
#curl -ksd '{"method":"Chain33.CreateTransaction","params":[{"execer":"user.p.para.paracross","actionName":"ParacrossAssetTransfer","payload":{"execName":"user.p.para.paracross","to":"1MAuE8QSbbech3bVKK2JPJJxYxNtT95oSU","amount":100000000}}]}' http://172.20.0.5:8901
# 资产从平行链转移到平行链合约
tx_hash_transferExec=$(curl -ksd '{"method":"Chain33.CreateTransaction","params":[{"execer":"'"${paracross_execer_name}"'","actionName":"TransferToExec","payload":{"execName":"'"${paracross_execer_name}"'","to":"'"${trade_exec_addr}"'","amount":'${amount_trade}', "cointoken":"coins.bty"}}]}' "${para_ip}" | jq -r ".result")
#curl -ksd '{"method":"Chain33.CreateTransaction","params":[{"execer":"user.p.para.paracross","actionName":"TransferToExec","payload":{"execName":"user.p.para.paracross","to":"12bihjzbaYWjcpDiiy9SuAWeqNksQdiN13","amount":10000000, "cointoken":"coins.bty"}}]}' http://172.20.0.5:8901
#create tx group with none
tx_hash_group=$(curl -ksd '{"method":"Chain33.CreateNoBlanaceTxs","params":[{"txHexs":["'"${tx_hash_asset}"'","'"${tx_hash_transferExec}"'"],"privkey":"'"${test_prikey}"'","expire":"120"}]}' "${para_ip}" | jq -r ".result")
#curl -ksd '{"method":"Chain33.CreateNoBlanaceTxs","params":[{"txHexs":["0a15757365722e702e706172612e7061726163726f7373122e10904e22291080c2d72f2222314d41754538515362626563683362564b4b324a504a4a7859784e745439356f535520a08d0630d195faf7d3a1ec9a4c3a223139574a4a7639366e4b4155347348465771476d7371666a786433376a617a716969","0a15757365722e702e706172612e7061726163726f7373124f1004424b0a09636f696e732e6274791080ade2042215757365722e702e706172612e7061726163726f73732a2231326269686a7a626159576a637044696979395375415765714e6b735164694e313320a08d0630a8c984ebb2bb90a5613a223139574a4a7639366e4b4155347348465771476d7371666a786433376a617a716969"],"privkey":"4257D8692EF7FE13C68B65D6A52F03933DB2FA5CE8FAF210B5B8B80C721CED01","expire":"120"}]}' http://172.20.0.5:8901
#sign 1
tx_sign=$(curl -ksd '{"method":"Chain33.SignRawTx","params":[{"privkey":"'"$test_prikey"'","txHex":"'"$tx_hash_group"'","index":2,"expire":"120s"}]}' "${para_ip}" | jq -r ".result")
#curl -ksd '{"method":"Chain33.SignRawTx","params":[{"privkey":"0x24d1fad138be98eebee31440f144aa38c404533f40862995282162bc538e91c8","txHex":"0a10757365722e702e706172612e6e6f6e6512126e6f2d6665652d7472616e73616374696f6e1a6e080112210320bbac09528e19c55b0f89cb37ab265e7e856b1a8c388780322dbbfd194b52ba1a473045022100fe7763b2fa5b42eddccf1a3434cb6d6bb60a5c5c32e5498219e99be01bb94ad302201ecb9931a2bb4e1b0d49ec50ee552a774c1db8a1eb9b2dff47e4b931625e3af220e0a71230a89780b2a5b187990a3a2231466a58697076505142754e6f7a4133506150724b6846703854343166717141707640034a8c050a8e020a10757365722e702e706172612e6e6f6e6512126e6f2d6665652d7472616e73616374696f6e1a6e080112210320bbac09528e19c55b0f89cb37ab265e7e856b1a8c388780322dbbfd194b52ba1a473045022100fe7763b2fa5b42eddccf1a3434cb6d6bb60a5c5c32e5498219e99be01bb94ad302201ecb9931a2bb4e1b0d49ec50ee552a774c1db8a1eb9b2dff47e4b931625e3af220e0a71230a89780b2a5b187990a3a2231466a58697076505142754e6f7a4133506150724b6846703854343166717141707640034a2054ba4451fb8f226dd54b52ec086f4eaa4990d66876899b1badec8ce96ef55208522000f2e5970b5b1854da143f4f3e91bf7eb87d1d62869ef08a2ce3b109994ec3650abb010a15757365722e702e706172612e7061726163726f7373122e10904e22291080c2d72f2222314d41754538515362626563683362564b4b324a504a4a7859784e745439356f535530d195faf7d3a1ec9a4c3a223139574a4a7639366e4b4155347348465771476d7371666a786433376a617a71696940034a2054ba4451fb8f226dd54b52ec086f4eaa4990d66876899b1badec8ce96ef5520852208fb7939bf2701e5af9cef05da33020be682e10c84fde9bd8d24765031fad530b0aba010a15757365722e702e706172612e7061726163726f7373124f1004424b0a09636f696e732e6274791080ade2042215757365722e702e706172612e7061726163726f73732a2231326269686a7a626159576a637044696979395375415765714e6b735164694e313330a8c984ebb2bb90a5613a223139574a4a7639366e4b4155347348465771476d7371666a786433376a617a71696940034a2054ba4451fb8f226dd54b52ec086f4eaa4990d66876899b1badec8ce96ef55208522000f2e5970b5b1854da143f4f3e91bf7eb87d1d62869ef08a2ce3b109994ec365","index":2,"expire":"120s"}]}' http://172.20.0.5:8901
#sign 2
tx_sign2=$(curl -ksd '{"method":"Chain33.SignRawTx","params":[{"privkey":"'"$test_prikey"'","txHex":"'"$tx_sign"'","index":3,"expire":"120s"}]}' "${para_ip}" | jq -r ".result")
#curl -ksd '{"method":"Chain33.SignRawTx","params":[{"privkey":"0x24d1fad138be98eebee31440f144aa38c404533f40862995282162bc538e91c8","txHex":"0a10757365722e702e706172612e6e6f6e6512126e6f2d6665652d7472616e73616374696f6e1a6e080112210320bbac09528e19c55b0f89cb37ab265e7e856b1a8c388780322dbbfd194b52ba1a473045022100fe7763b2fa5b42eddccf1a3434cb6d6bb60a5c5c32e5498219e99be01bb94ad302201ecb9931a2bb4e1b0d49ec50ee552a774c1db8a1eb9b2dff47e4b931625e3af220e0a71230a89780b2a5b187990a3a2231466a58697076505142754e6f7a4133506150724b6846703854343166717141707640034afc050a8e020a10757365722e702e706172612e6e6f6e6512126e6f2d6665652d7472616e73616374696f6e1a6e080112210320bbac09528e19c55b0f89cb37ab265e7e856b1a8c388780322dbbfd194b52ba1a473045022100fe7763b2fa5b42eddccf1a3434cb6d6bb60a5c5c32e5498219e99be01bb94ad302201ecb9931a2bb4e1b0d49ec50ee552a774c1db8a1eb9b2dff47e4b931625e3af220e0a71230a89780b2a5b187990a3a2231466a58697076505142754e6f7a4133506150724b6846703854343166717141707640034a2054ba4451fb8f226dd54b52ec086f4eaa4990d66876899b1badec8ce96ef55208522000f2e5970b5b1854da143f4f3e91bf7eb87d1d62869ef08a2ce3b109994ec3650aab020a15757365722e702e706172612e7061726163726f7373122e10904e22291080c2d72f2222314d41754538515362626563683362564b4b324a504a4a7859784e745439356f53551a6e0801122103589ebf581958aeb8a72ff517f823c878aee16139ecbf0001a4611e9c004fecdf1a473045022100da5ad2bdc6e1e43a01d32c44f116e5d0bf96aa4c16debad49381ea5d11a49835022055a510460df9b63f8f585393d6603abf1388fac0e122b53ef3533f242287915730d195faf7d3a1ec9a4c3a223139574a4a7639366e4b4155347348465771476d7371666a786433376a617a71696940034a2054ba4451fb8f226dd54b52ec086f4eaa4990d66876899b1badec8ce96ef5520852208fb7939bf2701e5af9cef05da33020be682e10c84fde9bd8d24765031fad530b0aba010a15757365722e702e706172612e7061726163726f7373124f1004424b0a09636f696e732e6274791080ade2042215757365722e702e706172612e7061726163726f73732a2231326269686a7a626159576a637044696979395375415765714e6b735164694e313330a8c984ebb2bb90a5613a223139574a4a7639366e4b4155347348465771476d7371666a786433376a617a71696940034a2054ba4451fb8f226dd54b52ec086f4eaa4990d66876899b1badec8ce96ef55208522000f2e5970b5b1854da143f4f3e91bf7eb87d1d62869ef08a2ce3b109994ec365","index":3,"expire":"120s"}]}' http://172.20.0.5:8901
#send
chain33_SendTx "${tx_sign2}" "${para_ip}"
#tx_rst=$(curl -ksd '{"method":"Chain33.SendTransaction","params":[{"token":"BTY","data":"${tx_sign2}"}]'} "${para_ip}" | jq -r ".result" )
local transfer_expect="700000000"
local exec_expect="100000000"
transfer_val=$(paracross_QueryParaBalance "${test_addr}" "$paracross_execer_name")
transfer_exec_val=$(paracross_QueryParaBalance "${test_addr}" "$trade_exec_name")
if [ "${transfer_val}" != $transfer_expect ]; then
echo "paracross_testTxGroup trasfer failed, get=$transfer_val,expec=$transfer_expect"
exit 1
fi
if [ "${transfer_exec_val}" != $exec_expect ]; then
echo "paracross_testTxGroup toexec failed, get=$transfer_exec_val,expec=$exec_expect"
exit 1
fi
echo_rst "$FUNCNAME" 0
}
function run_testcases() {
chain33_lock
chain33_unlock
paracross_GetBlock2MainInfo
paracross_IsSync
paracross_GetHeight
......@@ -318,6 +368,7 @@ function run_testcases() {
paracross_ListNodeGroupStatus
paracross_ListNodeStatus
paracross_Transfer_Withdraw
paracross_testTxGroup "$UNIT_HTTP"
}
function main() {
......@@ -353,6 +404,6 @@ function main() {
fi
}
main "$1" "$2" "$3" "$4"
chain33_debug_function main "$1" "$2" "$3" "$4"
#main http://127.0.0.1:8801
#main http://47.98.253.127:8801 1KSBd17H7ZK8iT37aJztFB22XGwsPTdwE4 0x6da92a632ab7deb67d38c0f6560bcfed28167998f6496db64c258d5e8393a81b user.p.fzmtest.paracross
......@@ -19,7 +19,7 @@ pokerbull_PlayRawTx() {
[ "$ok" == true ]
echo_rst "$FUNCNAME" "$?"
chain33_SignRawTx "$tx" "56942AD84CCF4788ED6DACBC005A1D0C4F91B63BCF0C99A02BE03C8DEAE71138" ${MAIN_HTTP}
chain33_SignRawTx "$tx" "0x0316d5e33e7bce2455413156cb95209f8c641af352ee5d648c647f24383e4d94" ${MAIN_HTTP}
echo "========== # pokerbull play tx end =========="
chain33_BlockWait 1 ${MAIN_HTTP}
......@@ -35,7 +35,7 @@ pokerbull_QuitRawTx() {
[ "$ok" == true ]
echo_rst "$FUNCNAME" "$?"
chain33_SignRawTx "$tx" "56942AD84CCF4788ED6DACBC005A1D0C4F91B63BCF0C99A02BE03C8DEAE71138" ${MAIN_HTTP}
chain33_SignRawTx "$tx" "0x0316d5e33e7bce2455413156cb95209f8c641af352ee5d648c647f24383e4d94" ${MAIN_HTTP}
echo "========== # pokerbull quit tx end =========="
chain33_BlockWait 1 "${MAIN_HTTP}"
......@@ -51,7 +51,7 @@ pokerbull_ContinueRawTx() {
[ "$ok" == true ]
echo_rst "$FUNCNAME" "$?"
chain33_SignRawTx "$tx" "2116459C0EC8ED01AA0EEAE35CAC5C96F94473F7816F114873291217303F6989" ${MAIN_HTTP}
chain33_SignRawTx "$tx" "0xa26038cbdd9e6fbfb85f2c3d032254755e75252b9edccbecc16d9ba117d96705" ${MAIN_HTTP}
echo "========== # pokerbull continue tx end =========="
chain33_BlockWait 1 "${MAIN_HTTP}"
......@@ -67,7 +67,7 @@ pokerbull_StartRawTx() {
[ "$ok" == true ]
echo_rst "$FUNCNAME" "$?"
chain33_SignRawTx "$tx" "56942AD84CCF4788ED6DACBC005A1D0C4F91B63BCF0C99A02BE03C8DEAE71138" ${MAIN_HTTP}
chain33_SignRawTx "$tx" "0x0316d5e33e7bce2455413156cb95209f8c641af352ee5d648c647f24383e4d94" ${MAIN_HTTP}
GAME_ID=$RAW_TX_HASH
echo "========== # pokerbull start tx end =========="
......@@ -84,7 +84,7 @@ pokerbull_QueryResult() {
[ "$ok" == true ]
echo_rst "$FUNCNAME" "$?"
data=$(curl -ksd '{"method":"Chain33.Query","params":[{"execer":"pokerbull","funcName":"QueryGameByAddr","payload":{"addr":"1PUiGcbsccfxW3zuvHXZBJfznziph5miAo"}}]}' ${MAIN_HTTP} | jq -r ".result")
data=$(curl -ksd '{"method":"Chain33.Query","params":[{"execer":"pokerbull","funcName":"QueryGameByAddr","payload":{"addr":"14VkqML8YTRK4o15Cf97CQhpbnRUa6sJY4"}}]}' ${MAIN_HTTP} | jq -r ".result")
[ "$data" != null ]
echo_rst "$FUNCNAME" "$?"
......@@ -103,11 +103,45 @@ init() {
pokerbull_addr=$(curl -ksd '{"method":"Chain33.ConvertExectoAddr","params":[{"execname":"pokerbull"}]}' ${MAIN_HTTP} | jq -r ".result")
fi
local from="1PUiGcbsccfxW3zuvHXZBJfznziph5miAo"
chain33_SendToAddress "$from" "$pokerbull_addr" 10000000000 ${MAIN_HTTP}
local main_ip=${MAIN_HTTP//8901/8801}
#main chain import pri key
#14VkqML8YTRK4o15Cf97CQhpbnRUa6sJY4
chain33_ImportPrivkey "0x0316d5e33e7bce2455413156cb95209f8c641af352ee5d648c647f24383e4d94" "14VkqML8YTRK4o15Cf97CQhpbnRUa6sJY4" "pokerbull1" "${main_ip}"
#1MuVM87DLigWhJxLJKvghTa1po4ZdWtDv1
chain33_ImportPrivkey "0xa26038cbdd9e6fbfb85f2c3d032254755e75252b9edccbecc16d9ba117d96705" "1MuVM87DLigWhJxLJKvghTa1po4ZdWtDv1" "pokerbull2" "$main_ip"
local pokerbull1="14VkqML8YTRK4o15Cf97CQhpbnRUa6sJY4"
local pokerbull2="1MuVM87DLigWhJxLJKvghTa1po4ZdWtDv1"
if [ "$ispara" == false ]; then
chain33_applyCoins "$pokerbull1" 12000000000 "${main_ip}"
chain33_QueryBalance "${pokerbull1}" "$main_ip"
chain33_applyCoins "$pokerbull2" 12000000000 "${main_ip}"
chain33_QueryBalance "${pokerbull2}" "$main_ip"
else
# tx fee
chain33_applyCoins "$pokerbull1" 1000000000 "${main_ip}"
chain33_QueryBalance "${pokerbull1}" "$main_ip"
chain33_applyCoins "$pokerbull2" 1000000000 "${main_ip}"
chain33_QueryBalance "${pokerbull2}" "$main_ip"
local para_ip="${MAIN_HTTP}"
#para chain import pri key
chain33_ImportPrivkey "0x0316d5e33e7bce2455413156cb95209f8c641af352ee5d648c647f24383e4d94" "14VkqML8YTRK4o15Cf97CQhpbnRUa6sJY4" "pokerbull1" "$para_ip"
chain33_ImportPrivkey "0xa26038cbdd9e6fbfb85f2c3d032254755e75252b9edccbecc16d9ba117d96705" "1MuVM87DLigWhJxLJKvghTa1po4ZdWtDv1" "pokerbull2" "$para_ip"
chain33_applyCoins "$pokerbull1" 12000000000 "${para_ip}"
chain33_QueryBalance "${pokerbull1}" "$para_ip"
chain33_applyCoins "$pokerbull2" 12000000000 "${para_ip}"
chain33_QueryBalance "${pokerbull2}" "$para_ip"
fi
chain33_SendToAddress "$pokerbull1" "$pokerbull_addr" 10000000000 ${MAIN_HTTP}
chain33_QueryExecBalance "${pokerbull1}" "pokerbull" "$MAIN_HTTP"
chain33_SendToAddress "$pokerbull2" "$pokerbull_addr" 10000000000 ${MAIN_HTTP}
chain33_QueryExecBalance "${pokerbull2}" "pokerbull" "$MAIN_HTTP"
from="1EDnnePAZN48aC2hiTDzhkczfF39g1pZZX"
chain33_SendToAddress "$from" "$pokerbull_addr" 10000000000 ${MAIN_HTTP}
chain33_BlockWait 1 "${MAIN_HTTP}"
}
......@@ -140,4 +174,4 @@ function main() {
fi
}
main "$1"
chain33_debug_function main "$1"
......@@ -8,20 +8,72 @@ MAIN_HTTP=""
# shellcheck source=/dev/null
source ../dapp-test-common.sh
# TODO
# 1. 合约测试的先后顺序 是否可以在指定合约之后测试
# 2. 或将资产类的合约先测试
# 3. 或资产类的合约提供创建的函数 创建一个某某名字的token
function updateConfig() {
unsignedTx=$(curl -s --data-binary '{"jsonrpc":"2.0","id":2,"method":"Chain33.CreateTransaction","params":[{"execer": "manage","actionName":"Modify","payload":{ "key": "token-blacklist","value": "BTY","op": "add","addr": ""}}]}' -H 'content-type:text/plain;' ${MAIN_HTTP} | jq -r ".result")
if [ "${unsignedTx}" == "" ]; then
echo_rst "update config create tx" 1
return
fi
chain33_SignRawTx "${unsignedTx}" "0x4257d8692ef7fe13c68b65d6a52f03933db2fa5ce8faf210b5b8b80c721ced01" "${MAIN_HTTP}"
}
function token_preCreate() {
unsignedTx=$(curl -s --data-binary '{"jsonrpc":"2.0","id":2,"method":"token.CreateRawTokenPreCreateTx","params":[{"name": "yinhebib", "symbol": "'"$1"'", "total": 1000000000000, "price": 0, "category": 1,"owner":"'"$2"'"}]}' -H 'content-type:text/plain;' ${MAIN_HTTP} | jq -r ".result")
if [ "${unsignedTx}" == "" ]; then
echo_rst "token preCreate create tx" 1
return
fi
chain33_SignRawTx "${unsignedTx}" "0x4257d8692ef7fe13c68b65d6a52f03933db2fa5ce8faf210b5b8b80c721ced01" "${MAIN_HTTP}"
}
function token_finish() {
unsignedTx=$(curl -s --data-binary '{"jsonrpc":"2.0","id":2,"method":"token.CreateRawTokenFinishTx","params":[{"symbol": "'"$1"'", "owner":"'"$2"'"}]}' -H 'content-type:text/plain;' ${MAIN_HTTP} | jq -r ".result")
if [ "${unsignedTx}" == "" ]; then
echo_rst "token finish create tx" 1
return
fi
chain33_SignRawTx "${unsignedTx}" "0x4257d8692ef7fe13c68b65d6a52f03933db2fa5ce8faf210b5b8b80c721ced01" "${MAIN_HTTP}"
}
function token_sendExec() {
unsignedTx=$(curl -s --data-binary '{"jsonrpc":"2.0","id":2,"method":"Chain33.CreateTransaction","params":[{"execer": "'"${token_ame}"'","actionName":"TransferToExec","payload": {"cointoken":"'"$1"'", "amount": "10000000000", "note": "", "to": "'"${retrieve_addr}"'", "execName": "'"${retrieve_name}"'"}}]}' -H 'content-type:text/plain;' ${MAIN_HTTP} | jq -r ".result")
if [ "${unsignedTx}" == "" ]; then
echo_rst "token sendExec create tx" 1
return
fi
chain33_SignRawTx "${unsignedTx}" "$3" "${MAIN_HTTP}"
}
function createToken() {
# symbol owner owner_key
updateConfig
token_preCreate "$1" "$2"
token_finish "$1" "$2"
token_sendExec "$1" "$2" "$3"
}
retrieve_Backup() {
echo "========== # retrieve backup begin =========="
local req='"method":"retrieve.CreateRawRetrieveBackupTx","params":[{"backupAddr":"1EDnnePAZN48aC2hiTDzhkczfF39g1pZZX","defaultAddr":"1PUiGcbsccfxW3zuvHXZBJfznziph5miAo","delayPeriod": 61}]'
tx=$(curl -ksd "{$req}" ${MAIN_HTTP} | jq -r ".result")
local req='{"method":"retrieve.CreateRawRetrieveBackupTx","params":[{"backupAddr":"'$retrieve1'","defaultAddr":"'$retrieve2'","delayPeriod": 61}]}'
tx=$(curl -ksd "$req" ${MAIN_HTTP} | jq -r ".result")
local reqDecode='"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'"$tx"'"}]'
data=$(curl -ksd "{$reqDecode}" ${MAIN_HTTP} | jq -r ".result.txs[0]")
local reqDecode='{"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'"$tx"'"}]}'
data=$(curl -ksd "$reqDecode" ${MAIN_HTTP} | jq -r ".result.txs[0]")
ok=$(jq '(.execer != "")' <<<"$data")
[ "$ok" == true ]
echo_rst "$FUNCNAME" "$?"
chain33_SignRawTx "$tx" "56942AD84CCF4788ED6DACBC005A1D0C4F91B63BCF0C99A02BE03C8DEAE71138" ${MAIN_HTTP}
chain33_SignRawTx "$tx" "$retrieve2_key" ${MAIN_HTTP}
echo "========== # retrieve backup end =========="
chain33_BlockWait 1 "${MAIN_HTTP}"
......@@ -30,17 +82,17 @@ retrieve_Backup() {
retrieve_Prepare() {
echo "========== # retrieve prepare begin =========="
local req='"method":"retrieve.CreateRawRetrievePrepareTx","params":[{"backupAddr":"1EDnnePAZN48aC2hiTDzhkczfF39g1pZZX","defaultAddr":"1PUiGcbsccfxW3zuvHXZBJfznziph5miAo"}]'
tx=$(curl -ksd "{$req}" ${MAIN_HTTP} | jq -r ".result")
local req='{"method":"retrieve.CreateRawRetrievePrepareTx","params":[{"backupAddr":"'$retrieve1'","defaultAddr":"'$retrieve2'"}]}'
tx=$(curl -ksd "$req" ${MAIN_HTTP} | jq -r ".result")
local reqDecode='"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'"$tx"'"}]'
data=$(curl -ksd "{$reqDecode}" ${MAIN_HTTP} | jq -r ".result.txs[0]")
local reqDecode='{"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'"$tx"'"}]}'
data=$(curl -ksd "$reqDecode" ${MAIN_HTTP} | jq -r ".result.txs[0]")
ok=$(jq '(.execer != "")' <<<"$data")
[ "$ok" == true ]
echo_rst "$FUNCNAME" "$?"
chain33_SignRawTx "$tx" "2116459C0EC8ED01AA0EEAE35CAC5C96F94473F7816F114873291217303F6989" ${MAIN_HTTP}
chain33_SignRawTx "$tx" "$retrieve1_key" ${MAIN_HTTP}
echo "========== # retrieve prepare end =========="
chain33_BlockWait 1 "${MAIN_HTTP}"
......@@ -49,17 +101,36 @@ retrieve_Prepare() {
retrieve_Perform() {
echo "========== # retrieve perform begin =========="
local req='"method":"retrieve.CreateRawRetrievePerformTx","params":[{"backupAddr":"1EDnnePAZN48aC2hiTDzhkczfF39g1pZZX","defaultAddr":"1PUiGcbsccfxW3zuvHXZBJfznziph5miAo"}]'
tx=$(curl -ksd "{$req}" ${MAIN_HTTP} | jq -r ".result")
local req='{"method":"retrieve.CreateRawRetrievePerformTx","params":[{"backupAddr":"'$retrieve1'","defaultAddr":"'$retrieve2'"}]}'
tx=$(curl -ksd "$req" ${MAIN_HTTP} | jq -r ".result")
local reqDecode='{"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'"$tx"'"}]}'
data=$(curl -ksd "$reqDecode" ${MAIN_HTTP} | jq -r ".result.txs[0]")
ok=$(jq '(.execer != "")' <<<"$data")
[ "$ok" == true ]
echo_rst "$FUNCNAME" "$?"
chain33_SignRawTx "$tx" "$retrieve1_key" ${MAIN_HTTP}
echo "========== # retrieve perform end =========="
chain33_BlockWait 1 "${MAIN_HTTP}"
}
retrieve_Perform_Token() {
echo "========== # retrieve perform begin =========="
local req='{"method":"retrieve.CreateRawRetrievePerformTx","params":[{"backupAddr":"'$retrieve1'","defaultAddr":"'$retrieve2'","assets": [{"exec":"token","symbol":"'"$symbol"'"}] }]}'
tx=$(curl -ksd "$req" ${MAIN_HTTP} | jq -r ".result")
local reqDecode='"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'"$tx"'"}]'
data=$(curl -ksd "{$reqDecode}" ${MAIN_HTTP} | jq -r ".result.txs[0]")
local reqDecode='{"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'"$tx"'"}]}'
data=$(curl -ksd "$reqDecode" ${MAIN_HTTP} | jq -r ".result.txs[0]")
ok=$(jq '(.execer != "")' <<<"$data")
[ "$ok" == true ]
echo_rst "$FUNCNAME" "$?"
chain33_SignRawTx "$tx" "2116459C0EC8ED01AA0EEAE35CAC5C96F94473F7816F114873291217303F6989" ${MAIN_HTTP}
chain33_SignRawTx "$tx" "$retrieve1_key" ${MAIN_HTTP}
echo "========== # retrieve perform end =========="
chain33_BlockWait 1 "${MAIN_HTTP}"
......@@ -68,17 +139,17 @@ retrieve_Perform() {
retrieve_Cancel() {
echo "========== # retrieve cancel begin =========="
local req='"method":"retrieve.CreateRawRetrieveCancelTx","params":[{"backupAddr":"1EDnnePAZN48aC2hiTDzhkczfF39g1pZZX","defaultAddr":"1PUiGcbsccfxW3zuvHXZBJfznziph5miAo"}]'
tx=$(curl -ksd "{$req}" ${MAIN_HTTP} | jq -r ".result")
local req='{"method":"retrieve.CreateRawRetrieveCancelTx","params":[{"backupAddr":"'$retrieve1'","defaultAddr":"'$retrieve2'"}]}'
tx=$(curl -ksd "$req" ${MAIN_HTTP} | jq -r ".result")
local reqDecode='"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'"$tx"'"}]'
data=$(curl -ksd "{$reqDecode}" ${MAIN_HTTP} | jq -r ".result.txs[0]")
local reqDecode='{"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'"$tx"'"}]}'
data=$(curl -ksd "$reqDecode" ${MAIN_HTTP} | jq -r ".result.txs[0]")
ok=$(jq '(.execer != "")' <<<"$data")
[ "$ok" == true ]
echo_rst "$FUNCNAME" "$?"
chain33_SignRawTx "$tx" "56942AD84CCF4788ED6DACBC005A1D0C4F91B63BCF0C99A02BE03C8DEAE71138" ${MAIN_HTTP}
chain33_SignRawTx "$tx" "$retrieve2_key" ${MAIN_HTTP}
echo "========== # retrieve cancel end =========="
chain33_BlockWait 1 "${MAIN_HTTP}"
......@@ -89,8 +160,22 @@ retrieve_QueryResult() {
local status=$1
local req='"method":"Chain33.Query","params":[{"execer":"retrieve","funcName":"GetRetrieveInfo","payload":{"backupAddress":"1EDnnePAZN48aC2hiTDzhkczfF39g1pZZX", "defaultAddress":"1PUiGcbsccfxW3zuvHXZBJfznziph5miAo"}}]'
data=$(curl -ksd "{$req}" ${MAIN_HTTP} | jq -r ".result")
local req='{"method":"Chain33.Query","params":[{"execer":"retrieve","funcName":"GetRetrieveInfo","payload":{"backupAddress":"'$retrieve1'", "defaultAddress":"'$retrieve2'"}}]}'
data=$(curl -ksd "$req" ${MAIN_HTTP} | jq -r ".result")
ok=$(jq '(.status == '"$status"')' <<<"$data")
[ "$ok" == true ]
echo_rst "$FUNCNAME" "$?"
echo "========== # retrieve query result end =========="
}
retrieve_QueryAssetResult() {
echo "========== # retrieve query result begin =========="
local status=$1
local req='{"method":"Chain33.Query","params":[{"execer":"retrieve","funcName":"GetRetrieveInfo","payload":{"backupAddress":"'$retrieve1'", "defaultAddress":"'$retrieve2'","assetExec":"token", "assetSymbol":"'"$symbol"'"}}]}'
data=$(curl -ksd "$req" ${MAIN_HTTP} | jq -r ".result")
ok=$(jq '(.status == '"$status"')' <<<"$data")
[ "$ok" == true ]
......@@ -102,16 +187,36 @@ init() {
ispara=$(echo '"'"${MAIN_HTTP}"'"' | jq '.|contains("8901")')
echo "ipara=$ispara"
if [ "$ispara" == true ]; then
token_ame="user.p.para.token"
retrieve_name="user.p.para.retrieve"
retrieve_addr=$(curl -ksd '{"method":"Chain33.ConvertExectoAddr","params":[{"execname":"user.p.para.retrieve"}]}' ${MAIN_HTTP} | jq -r ".result")
else
token_ame="token"
retrieve_name="retrieve"
retrieve_addr=$(curl -ksd '{"method":"Chain33.ConvertExectoAddr","params":[{"execname":"retrieve"}]}' ${MAIN_HTTP} | jq -r ".result")
fi
local from="1PUiGcbsccfxW3zuvHXZBJfznziph5miAo"
chain33_SendToAddress "$from" "$retrieve_addr" 1000000000 ${MAIN_HTTP}
retrieve1_key=0xf54a8ffe50b308a2d37f44a9e595fd2d156c09732b712b8548eccf1dce4d0fde
retrieve1=19P3ZQg5VYgzTUGvLD4etFSrh74mk6HUWW
chain33_ImportPrivkey "${retrieve1_key}" "${retrieve1}" "retrieve1" "${MAIN_HTTP}"
chain33_applyCoins "${retrieve1}" 10000000000 "${MAIN_HTTP}"
retrieve2_key=0x61d86bf173ed37835fba9ff5b062382249c1b978cb2d3c6e2a3abbdf38314432
retrieve2=18x7o8Uktqs8RHEcPsMLJvaHKo22swLbqF
chain33_ImportPrivkey "${retrieve2_key}" "${retrieve2}" "retrieve2" "${MAIN_HTTP}"
chain33_applyCoins "${retrieve2}" 10000000000 "${MAIN_HTTP}"
if [ "$ispara" == true ]; then
# for fee
local main_ip=${MAIN_HTTP//8901/8801}
chain33_applyCoins "${retrieve1}" 1000000000 "${main_ip}"
chain33_applyCoins "${retrieve2}" 1000000000 "${main_ip}"
fi
from="1EDnnePAZN48aC2hiTDzhkczfF39g1pZZX"
chain33_SendToAddress "$from" "$retrieve_addr" 1000000000 ${MAIN_HTTP}
chain33_SendToAddress "$retrieve1" "$retrieve_addr" 1000000000 ${MAIN_HTTP}
chain33_SendToAddress "$retrieve2" "$retrieve_addr" 1000000000 ${MAIN_HTTP}
symbol="RETRIEVE"
createToken "$symbol" "$retrieve2" "$retrieve2_key"
chain33_BlockWait 1 "${MAIN_HTTP}"
}
......@@ -134,6 +239,8 @@ function run_test() {
sleep 61
retrieve_Perform
retrieve_QueryResult 3
retrieve_Perform_Token
retrieve_QueryAssetResult 3
}
function main() {
......@@ -152,4 +259,5 @@ function main() {
fi
}
main "$1"
set -x
chain33_debug_function main "$1"
......@@ -168,7 +168,7 @@ func performCmd(cmd *cobra.Command, args []string) {
return
}
for i := 0; i < len(execs); i++ {
params.Assets = append(params.Assets, rpc.Asset{Exec: execs[i], Symbol: symbols[0]})
params.Assets = append(params.Assets, rpc.Asset{Exec: execs[i], Symbol: symbols[i]})
}
ctx := jsonrpc.NewRPCCtx(rpcLaddr, "retrieve.CreateRawRetrievePerformTx", params, nil)
......@@ -206,7 +206,7 @@ func cancelCmd(cmd *cobra.Command, args []string) {
func RetrieveQueryCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "query",
Short: "Backup the wallet",
Short: "show retrieve info",
Run: queryRetrieveCmd,
}
addQueryRetrieveCmdFlags(cmd)
......@@ -218,6 +218,9 @@ func addQueryRetrieveCmdFlags(cmd *cobra.Command) {
cmd.MarkFlagRequired("backup")
cmd.Flags().StringP("default", "t", "", "default address")
cmd.MarkFlagRequired("default")
cmd.Flags().StringP("asset_exec", "e", "", "asset exec")
cmd.Flags().StringP("asset_symbol", "s", "", "asset symbol")
}
func parseRerieveDetail(arg interface{}) (interface{}, error) {
......@@ -246,10 +249,14 @@ func queryRetrieveCmd(cmd *cobra.Command, args []string) {
rpcLaddr, _ := cmd.Flags().GetString("rpc_laddr")
backup, _ := cmd.Flags().GetString("backup")
defaultAddr, _ := cmd.Flags().GetString("default")
exec, _ := cmd.Flags().GetString("asset_exec")
symbol, _ := cmd.Flags().GetString("asset_symbol")
req := &rt.ReqRetrieveInfo{
BackupAddress: backup,
DefaultAddress: defaultAddr,
AssetExec: exec,
AssetSymbol: symbol,
}
var params rpctypes.Query4Jrpc
......
......@@ -97,7 +97,7 @@ func (c *Retrieve) ExecDelLocal_Perform(perf *rt.PerformRetrieve, tx *types.Tran
if types.IsDappFork(c.GetHeight(), rt.RetrieveX, rt.ForkRetriveAssetX) {
if len(perf.Assets) == 0 {
perf.Assets = append(perf.Assets, &types.Asset{Exec: "coins", Symbol: types.GetCoinSymbol()})
perf.Assets = append(perf.Assets, &rt.AssetSymbol{Exec: "coins", Symbol: types.GetCoinSymbol()})
}
}
for _, asset := range perf.Assets {
......
......@@ -104,7 +104,7 @@ func (c *Retrieve) ExecLocal_Perform(perf *rt.PerformRetrieve, tx *types.Transac
}
if types.IsDappFork(c.GetHeight(), rt.RetrieveX, rt.ForkRetriveAssetX) {
if len(perf.Assets) == 0 {
perf.Assets = append(perf.Assets, &types.Asset{Exec: "coins", Symbol: types.GetCoinSymbol()})
perf.Assets = append(perf.Assets, &rt.AssetSymbol{Exec: "coins", Symbol: types.GetCoinSymbol()})
}
}
for _, asset := range perf.Assets {
......
......@@ -5,8 +5,6 @@
package executor
import (
"fmt"
"github.com/33cn/chain33/types"
rt "github.com/33cn/plugin/plugin/dapp/retrieve/types"
)
......@@ -29,11 +27,9 @@ func (r *Retrieve) Query_GetRetrieveInfo(in *rt.ReqRetrieveInfo) (types.Message,
if info.Status == retrievePerform && in.GetAssetExec() != "" {
// retrievePerform状态下,不存在有两种情况
// 1 还没找回, 2 fork 之前是没有coins 找回记录的
count := r.GetLocalDB().PrefixCount(calcRetrieveAssetPrefix(in.BackupAddress, in.DefaultAddress))
// 2 fork 之前是 没有coins 找回记录的, 相当于都找回了
if count == 0 {
return info, nil
}
// localdb not support PrefixCount
// 所以在填写具体资产的情况下, 认为是要找对应的资产
asset, _ := getRetrieveAsset(r.GetLocalDB(), in.BackupAddress, in.DefaultAddress, in.AssetExec, in.AssetSymbol)
if asset != nil {
......@@ -48,8 +44,3 @@ func (r *Retrieve) Query_GetRetrieveInfo(in *rt.ReqRetrieveInfo) (types.Message,
}
return info, nil
}
func calcRetrieveAssetPrefix(backupAddr, defaultAddr string) []byte {
key := fmt.Sprintf("LODB-retrieve-backup-asset:%s:%s:", backupAddr, defaultAddr)
return []byte(key)
}
......@@ -211,7 +211,7 @@ func (action *Action) RetrievePerformAssets(perfRet *rt.PerformRetrieve, default
// 兼容原来的找回, 在不指定的情况下,找回主币
if len(perfRet.Assets) == 0 {
perfRet.Assets = append(perfRet.Assets, &types.Asset{Exec: "coins", Symbol: types.GetCoinSymbol()})
perfRet.Assets = append(perfRet.Assets, &rt.AssetSymbol{Exec: "coins", Symbol: types.GetCoinSymbol()})
//return nil, nil
}
......@@ -224,7 +224,7 @@ func (action *Action) RetrievePerformAssets(perfRet *rt.PerformRetrieve, default
acc := accdb.LoadExecAccount(defaultAddress, action.execaddr)
rlog.Debug("RetrievePerform", "acc.Balance", acc.Balance)
if acc.Balance > 0 {
receipt, err = action.coinsAccount.ExecTransfer(defaultAddress, perfRet.BackupAddress, action.execaddr, acc.Balance)
receipt, err = accdb.ExecTransfer(defaultAddress, perfRet.BackupAddress, action.execaddr, acc.Balance)
if err != nil {
rlog.Debug("RetrievePerform", "ExecTransfer", err)
return nil, err
......
......@@ -40,10 +40,16 @@ message PrepareRetrieve {
string defaultAddress = 2;
}
message AssetSymbol {
string exec = 1;
string symbol = 2;
}
message PerformRetrieve {
string backupAddress = 1;
string defaultAddress = 2;
repeated Asset assets = 3;
repeated AssetSymbol assets = 3;
}
message CancelRetrieve {
......
......@@ -49,6 +49,11 @@ func (c *Jrpc) CreateRawRetrievePerformTx(in *RetrievePerformTx, result *interfa
head := &types.PerformRetrieve{
BackupAddress: in.BackupAddr,
DefaultAddress: in.DefaultAddr,
Assets: []*types.AssetSymbol{},
}
for i := 0; i < len(in.Assets); i++ {
head.Assets = append(head.Assets, &types.AssetSymbol{Exec: in.Assets[i].Exec, Symbol: in.Assets[i].Symbol})
}
reply, err := c.cli.Perform(context.Background(), head)
if err != nil {
......
......@@ -8,11 +8,14 @@ import (
"strings"
"testing"
"github.com/33cn/chain33/common"
commonlog "github.com/33cn/chain33/common/log"
"github.com/33cn/chain33/rpc/jsonclient"
rpctypes "github.com/33cn/chain33/rpc/types"
"github.com/33cn/chain33/types"
"github.com/33cn/chain33/util/testnode"
"github.com/33cn/plugin/plugin/dapp/retrieve/rpc"
pty "github.com/33cn/plugin/plugin/dapp/retrieve/types"
"github.com/stretchr/testify/assert"
......@@ -67,8 +70,28 @@ func testPrepareCmd(t *testing.T, jrpc *jsonclient.JSONClient) error {
}
func testPerformCmd(t *testing.T, jrpc *jsonclient.JSONClient) error {
params := rpc.RetrievePerformTx{}
return jrpc.Call("retrieve.CreateRawRetrievePerformTx", params, nil)
params := rpc.RetrievePerformTx{
BackupAddr: "b",
DefaultAddr: "d",
Assets: []rpc.Asset{{"e", "s"}},
}
var txS string
t.Log("tx info", "x", params.Assets)
err := jrpc.Call("retrieve.CreateRawRetrievePerformTx", &params, &txS)
var tx types.Transaction
bytes, err := common.FromHex(txS)
if err != nil {
return err
}
err = types.Decode(bytes, &tx)
if err != nil {
return err
}
var p2 pty.RetrieveAction
err = types.Decode(tx.Payload, &p2)
t.Log("asset", p2.GetPerform().GetAssets())
return err
}
func testCancelCmd(t *testing.T, jrpc *jsonclient.JSONClient) error {
......
......@@ -43,10 +43,12 @@ func (c *channelClient) Perform(ctx context.Context, v *rt.PerformRetrieve) (*ty
Ty: rt.RetrieveActionPerform,
Value: &rt.RetrieveAction_Perform{Perform: v},
}
tx, err := types.CreateFormatTx(types.ExecName(rt.RetrieveX), types.Encode(perform))
payload := types.Encode(perform)
tx, err := types.CreateFormatTx(types.ExecName(rt.RetrieveX), payload)
if err != nil {
return nil, err
}
data := types.Encode(tx)
return &types.UnsignTx{Data: data}, nil
}
......
......@@ -44,7 +44,7 @@ func (m *RetrievePara) Reset() { *m = RetrievePara{} }
func (m *RetrievePara) String() string { return proto.CompactTextString(m) }
func (*RetrievePara) ProtoMessage() {}
func (*RetrievePara) Descriptor() ([]byte, []int) {
return fileDescriptor_retrieve_7b99e170a1cce215, []int{0}
return fileDescriptor_retrieve_1666ef19b265e4fc, []int{0}
}
func (m *RetrievePara) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_RetrievePara.Unmarshal(m, b)
......@@ -112,7 +112,7 @@ func (m *Retrieve) Reset() { *m = Retrieve{} }
func (m *Retrieve) String() string { return proto.CompactTextString(m) }
func (*Retrieve) ProtoMessage() {}
func (*Retrieve) Descriptor() ([]byte, []int) {
return fileDescriptor_retrieve_7b99e170a1cce215, []int{1}
return fileDescriptor_retrieve_1666ef19b265e4fc, []int{1}
}
func (m *Retrieve) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_Retrieve.Unmarshal(m, b)
......@@ -163,7 +163,7 @@ func (m *RetrieveAction) Reset() { *m = RetrieveAction{} }
func (m *RetrieveAction) String() string { return proto.CompactTextString(m) }
func (*RetrieveAction) ProtoMessage() {}
func (*RetrieveAction) Descriptor() ([]byte, []int) {
return fileDescriptor_retrieve_7b99e170a1cce215, []int{2}
return fileDescriptor_retrieve_1666ef19b265e4fc, []int{2}
}
func (m *RetrieveAction) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_RetrieveAction.Unmarshal(m, b)
......@@ -378,7 +378,7 @@ func (m *BackupRetrieve) Reset() { *m = BackupRetrieve{} }
func (m *BackupRetrieve) String() string { return proto.CompactTextString(m) }
func (*BackupRetrieve) ProtoMessage() {}
func (*BackupRetrieve) Descriptor() ([]byte, []int) {
return fileDescriptor_retrieve_7b99e170a1cce215, []int{3}
return fileDescriptor_retrieve_1666ef19b265e4fc, []int{3}
}
func (m *BackupRetrieve) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_BackupRetrieve.Unmarshal(m, b)
......@@ -431,7 +431,7 @@ func (m *PrepareRetrieve) Reset() { *m = PrepareRetrieve{} }
func (m *PrepareRetrieve) String() string { return proto.CompactTextString(m) }
func (*PrepareRetrieve) ProtoMessage() {}
func (*PrepareRetrieve) Descriptor() ([]byte, []int) {
return fileDescriptor_retrieve_7b99e170a1cce215, []int{4}
return fileDescriptor_retrieve_1666ef19b265e4fc, []int{4}
}
func (m *PrepareRetrieve) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_PrepareRetrieve.Unmarshal(m, b)
......@@ -465,10 +465,56 @@ func (m *PrepareRetrieve) GetDefaultAddress() string {
return ""
}
type AssetSymbol struct {
Exec string `protobuf:"bytes,1,opt,name=exec,proto3" json:"exec,omitempty"`
Symbol string `protobuf:"bytes,2,opt,name=symbol,proto3" json:"symbol,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *AssetSymbol) Reset() { *m = AssetSymbol{} }
func (m *AssetSymbol) String() string { return proto.CompactTextString(m) }
func (*AssetSymbol) ProtoMessage() {}
func (*AssetSymbol) Descriptor() ([]byte, []int) {
return fileDescriptor_retrieve_1666ef19b265e4fc, []int{5}
}
func (m *AssetSymbol) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_AssetSymbol.Unmarshal(m, b)
}
func (m *AssetSymbol) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_AssetSymbol.Marshal(b, m, deterministic)
}
func (dst *AssetSymbol) XXX_Merge(src proto.Message) {
xxx_messageInfo_AssetSymbol.Merge(dst, src)
}
func (m *AssetSymbol) XXX_Size() int {
return xxx_messageInfo_AssetSymbol.Size(m)
}
func (m *AssetSymbol) XXX_DiscardUnknown() {
xxx_messageInfo_AssetSymbol.DiscardUnknown(m)
}
var xxx_messageInfo_AssetSymbol proto.InternalMessageInfo
func (m *AssetSymbol) GetExec() string {
if m != nil {
return m.Exec
}
return ""
}
func (m *AssetSymbol) GetSymbol() string {
if m != nil {
return m.Symbol
}
return ""
}
type PerformRetrieve struct {
BackupAddress string `protobuf:"bytes,1,opt,name=backupAddress,proto3" json:"backupAddress,omitempty"`
DefaultAddress string `protobuf:"bytes,2,opt,name=defaultAddress,proto3" json:"defaultAddress,omitempty"`
Assets []*types.Asset `protobuf:"bytes,3,rep,name=assets,proto3" json:"assets,omitempty"`
Assets []*AssetSymbol `protobuf:"bytes,3,rep,name=assets,proto3" json:"assets,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
......@@ -478,7 +524,7 @@ func (m *PerformRetrieve) Reset() { *m = PerformRetrieve{} }
func (m *PerformRetrieve) String() string { return proto.CompactTextString(m) }
func (*PerformRetrieve) ProtoMessage() {}
func (*PerformRetrieve) Descriptor() ([]byte, []int) {
return fileDescriptor_retrieve_7b99e170a1cce215, []int{5}
return fileDescriptor_retrieve_1666ef19b265e4fc, []int{6}
}
func (m *PerformRetrieve) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_PerformRetrieve.Unmarshal(m, b)
......@@ -512,7 +558,7 @@ func (m *PerformRetrieve) GetDefaultAddress() string {
return ""
}
func (m *PerformRetrieve) GetAssets() []*types.Asset {
func (m *PerformRetrieve) GetAssets() []*AssetSymbol {
if m != nil {
return m.Assets
}
......@@ -531,7 +577,7 @@ func (m *CancelRetrieve) Reset() { *m = CancelRetrieve{} }
func (m *CancelRetrieve) String() string { return proto.CompactTextString(m) }
func (*CancelRetrieve) ProtoMessage() {}
func (*CancelRetrieve) Descriptor() ([]byte, []int) {
return fileDescriptor_retrieve_7b99e170a1cce215, []int{6}
return fileDescriptor_retrieve_1666ef19b265e4fc, []int{7}
}
func (m *CancelRetrieve) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_CancelRetrieve.Unmarshal(m, b)
......@@ -579,7 +625,7 @@ func (m *ReqRetrieveInfo) Reset() { *m = ReqRetrieveInfo{} }
func (m *ReqRetrieveInfo) String() string { return proto.CompactTextString(m) }
func (*ReqRetrieveInfo) ProtoMessage() {}
func (*ReqRetrieveInfo) Descriptor() ([]byte, []int) {
return fileDescriptor_retrieve_7b99e170a1cce215, []int{7}
return fileDescriptor_retrieve_1666ef19b265e4fc, []int{8}
}
func (m *ReqRetrieveInfo) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_ReqRetrieveInfo.Unmarshal(m, b)
......@@ -643,7 +689,7 @@ func (m *RetrieveQuery) Reset() { *m = RetrieveQuery{} }
func (m *RetrieveQuery) String() string { return proto.CompactTextString(m) }
func (*RetrieveQuery) ProtoMessage() {}
func (*RetrieveQuery) Descriptor() ([]byte, []int) {
return fileDescriptor_retrieve_7b99e170a1cce215, []int{8}
return fileDescriptor_retrieve_1666ef19b265e4fc, []int{9}
}
func (m *RetrieveQuery) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_RetrieveQuery.Unmarshal(m, b)
......@@ -711,6 +757,7 @@ func init() {
proto.RegisterType((*RetrieveAction)(nil), "types.RetrieveAction")
proto.RegisterType((*BackupRetrieve)(nil), "types.BackupRetrieve")
proto.RegisterType((*PrepareRetrieve)(nil), "types.PrepareRetrieve")
proto.RegisterType((*AssetSymbol)(nil), "types.AssetSymbol")
proto.RegisterType((*PerformRetrieve)(nil), "types.PerformRetrieve")
proto.RegisterType((*CancelRetrieve)(nil), "types.CancelRetrieve")
proto.RegisterType((*ReqRetrieveInfo)(nil), "types.ReqRetrieveInfo")
......@@ -888,41 +935,43 @@ var _Retrieve_serviceDesc = grpc.ServiceDesc{
Metadata: "retrieve.proto",
}
func init() { proto.RegisterFile("retrieve.proto", fileDescriptor_retrieve_7b99e170a1cce215) }
var fileDescriptor_retrieve_7b99e170a1cce215 = []byte{
// 527 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x55, 0xd1, 0x6e, 0xd3, 0x30,
0x14, 0x9d, 0x5b, 0x9a, 0xae, 0xb7, 0x5b, 0x2a, 0x8c, 0x98, 0xa2, 0x09, 0x4d, 0x55, 0x34, 0xa1,
0xbe, 0x50, 0xa4, 0xc0, 0x0f, 0x74, 0x08, 0x09, 0xde, 0x8a, 0x19, 0xaf, 0x20, 0x37, 0xb9, 0x45,
0x11, 0x6d, 0x12, 0x6c, 0x67, 0x5a, 0xde, 0x78, 0xe1, 0x3b, 0xf8, 0x07, 0xfe, 0x86, 0x17, 0x7e,
0x82, 0x1f, 0x40, 0xb1, 0x1d, 0xcd, 0x29, 0xa9, 0xb4, 0x87, 0x8a, 0xc7, 0x1c, 0x9f, 0x63, 0xdf,
0x7b, 0xee, 0xed, 0x29, 0xf8, 0x02, 0x95, 0x48, 0xf1, 0x06, 0xe7, 0x85, 0xc8, 0x55, 0x4e, 0x07,
0xaa, 0x2a, 0x50, 0x9e, 0x3f, 0x54, 0x82, 0x67, 0x92, 0xc7, 0x2a, 0xcd, 0x33, 0x73, 0x12, 0xfe,
0x24, 0x70, 0xc2, 0x2c, 0x79, 0xc9, 0x05, 0xa7, 0x4f, 0xc1, 0x4f, 0x70, 0xcd, 0xcb, 0x8d, 0x5a,
0x24, 0x89, 0x40, 0x29, 0x03, 0x32, 0x25, 0xb3, 0x11, 0xdb, 0x41, 0xe9, 0x19, 0x78, 0x52, 0x71,
0x55, 0xca, 0xa0, 0x37, 0x25, 0xb3, 0x01, 0xb3, 0x5f, 0xf4, 0x02, 0x20, 0x16, 0xc8, 0x15, 0x5e,
0xa7, 0x5b, 0x0c, 0xfa, 0x53, 0x32, 0xeb, 0x33, 0x07, 0xa1, 0x53, 0x18, 0x17, 0x02, 0x0b, 0x2e,
0x0c, 0xe1, 0x81, 0x26, 0xb8, 0x50, 0xcd, 0x48, 0x70, 0xc3, 0xab, 0x25, 0x8a, 0x34, 0x4f, 0x82,
0x81, 0x61, 0x38, 0x50, 0xf8, 0x09, 0x8e, 0x9b, 0x9a, 0xe9, 0x25, 0x9c, 0xae, 0x78, 0xfc, 0xa5,
0x2c, 0xda, 0xe5, 0xb6, 0x41, 0xfa, 0x0c, 0x86, 0x02, 0x55, 0xdd, 0x60, 0xd0, 0x9b, 0xf6, 0x67,
0xe3, 0xe8, 0xd1, 0x5c, 0x5b, 0x32, 0x77, 0x7b, 0x67, 0x0d, 0x27, 0xfc, 0x43, 0xc0, 0x6f, 0x4e,
0x16, 0xda, 0x2e, 0x1a, 0xc1, 0xd0, 0x16, 0xa9, 0x5f, 0x18, 0x47, 0x67, 0xf6, 0x86, 0xa5, 0x41,
0x1b, 0xfa, 0x9b, 0x23, 0xd6, 0x10, 0xb5, 0x06, 0xc5, 0x3a, 0x17, 0x5b, 0x6d, 0x92, 0xa3, 0x31,
0x68, 0x4b, 0x63, 0x20, 0xfa, 0x1c, 0x3c, 0x53, 0xba, 0xf6, 0x6e, 0x1c, 0x3d, 0xb6, 0x92, 0x2b,
0x0d, 0x3a, 0x0a, 0x4b, 0xab, 0x05, 0x31, 0xcf, 0x62, 0xdc, 0x68, 0x2f, 0xef, 0x04, 0xaf, 0x34,
0xe8, 0x0a, 0x0c, 0x8d, 0xfa, 0xd0, 0x53, 0x95, 0xb6, 0x75, 0xc0, 0x7a, 0xaa, 0xba, 0x1a, 0xc2,
0xe0, 0x86, 0x6f, 0x4a, 0x0c, 0xbf, 0x11, 0xf0, 0xdb, 0xcf, 0xdc, 0xd3, 0xdd, 0x7f, 0x77, 0xa6,
0xd7, 0xb9, 0x33, 0x3b, 0x93, 0xed, 0x77, 0x4d, 0x76, 0xb2, 0xe3, 0xe7, 0x61, 0x4b, 0x08, 0xbf,
0x13, 0x98, 0xec, 0xb8, 0x7f, 0xe0, 0x26, 0x2f, 0xc1, 0xe3, 0x52, 0xa2, 0x92, 0x41, 0x5f, 0x6f,
0xda, 0x89, 0x9d, 0xc7, 0xa2, 0x06, 0x99, 0x3d, 0x0b, 0x3f, 0x82, 0xdf, 0x1e, 0xd0, 0x81, 0xfb,
0xfc, 0x41, 0x60, 0xc2, 0xf0, 0x6b, 0x73, 0xfb, 0xdb, 0x6c, 0x9d, 0x1f, 0xb8, 0xcf, 0x27, 0x30,
0xd2, 0xbd, 0xbc, 0xbe, 0xc5, 0x58, 0x8f, 0x72, 0xc4, 0xee, 0x80, 0x7a, 0xd4, 0xfa, 0xe3, 0x7d,
0xb5, 0x5d, 0xe5, 0x66, 0x35, 0x47, 0xcc, 0x85, 0xc2, 0x5f, 0x04, 0x4e, 0x9b, 0xf2, 0xde, 0x95,
0x28, 0xaa, 0xff, 0xbd, 0x6c, 0xf7, 0x88, 0xa2, 0x0b, 0x00, 0x81, 0x5b, 0x9e, 0x66, 0x9a, 0x60,
0x92, 0xc8, 0x41, 0x9c, 0x10, 0xf4, 0xdc, 0x10, 0x8c, 0x7e, 0x13, 0x38, 0x6e, 0x22, 0x98, 0xbe,
0x84, 0xa1, 0xdd, 0x69, 0xba, 0x27, 0x33, 0xce, 0x27, 0x16, 0xff, 0x90, 0xc9, 0xf4, 0x73, 0x76,
0x7d, 0x1b, 0x1e, 0x69, 0x95, 0x8d, 0x84, 0x3d, 0xa9, 0xd1, 0xa5, 0x8a, 0xc0, 0x33, 0xbf, 0x60,
0xda, 0x9d, 0x1b, 0x7b, 0x34, 0x66, 0x15, 0x69, 0x77, 0x74, 0x74, 0x68, 0x56, 0x9e, 0xfe, 0xf7,
0x78, 0xf1, 0x37, 0x00, 0x00, 0xff, 0xff, 0x32, 0x13, 0x1c, 0xa2, 0x69, 0x06, 0x00, 0x00,
func init() { proto.RegisterFile("retrieve.proto", fileDescriptor_retrieve_1666ef19b265e4fc) }
var fileDescriptor_retrieve_1666ef19b265e4fc = []byte{
// 552 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x55, 0xc1, 0x6e, 0xd3, 0x40,
0x10, 0xed, 0xc6, 0x8d, 0xd3, 0x4c, 0xa8, 0x23, 0x16, 0x51, 0x59, 0x15, 0xaa, 0x22, 0x0b, 0xa1,
0x08, 0x89, 0x20, 0x19, 0x2e, 0x1c, 0x53, 0x84, 0x04, 0xb7, 0x60, 0xca, 0x15, 0xb4, 0x71, 0x26,
0xc8, 0x22, 0xb1, 0xc3, 0xee, 0xa6, 0xaa, 0x6f, 0xdc, 0xf9, 0x08, 0xfe, 0x81, 0xbf, 0xe1, 0xc2,
0x4f, 0xf0, 0x03, 0xc8, 0xb3, 0x6b, 0x65, 0x13, 0x1c, 0xa9, 0x87, 0xa8, 0xb7, 0xf8, 0xed, 0x7b,
0xeb, 0x99, 0x37, 0x93, 0x67, 0x08, 0x24, 0x6a, 0x99, 0xe1, 0x35, 0x8e, 0x56, 0xb2, 0xd0, 0x05,
0x6f, 0xeb, 0x72, 0x85, 0xea, 0xfc, 0xbe, 0x96, 0x22, 0x57, 0x22, 0xd5, 0x59, 0x91, 0x9b, 0x93,
0xe8, 0x17, 0x83, 0x7b, 0x89, 0x25, 0x4f, 0x84, 0x14, 0xfc, 0x09, 0x04, 0x33, 0x9c, 0x8b, 0xf5,
0x42, 0x8f, 0x67, 0x33, 0x89, 0x4a, 0x85, 0x6c, 0xc0, 0x86, 0xdd, 0x64, 0x07, 0xe5, 0x67, 0xe0,
0x2b, 0x2d, 0xf4, 0x5a, 0x85, 0xad, 0x01, 0x1b, 0xb6, 0x13, 0xfb, 0xc4, 0x2f, 0x00, 0x52, 0x89,
0x42, 0xe3, 0x55, 0xb6, 0xc4, 0xd0, 0x1b, 0xb0, 0xa1, 0x97, 0x38, 0x08, 0x1f, 0x40, 0x6f, 0x25,
0x71, 0x25, 0xa4, 0x21, 0x1c, 0x13, 0xc1, 0x85, 0x2a, 0xc6, 0x0c, 0x17, 0xa2, 0x9c, 0xa0, 0xcc,
0x8a, 0x59, 0xd8, 0x36, 0x0c, 0x07, 0x8a, 0x3e, 0xc3, 0x49, 0x5d, 0x33, 0x7f, 0x0c, 0xa7, 0x53,
0x91, 0x7e, 0x5d, 0xaf, 0xb6, 0xcb, 0xdd, 0x06, 0xf9, 0x33, 0xe8, 0x48, 0xd4, 0x55, 0x83, 0x61,
0x6b, 0xe0, 0x0d, 0x7b, 0xf1, 0x83, 0x11, 0x59, 0x32, 0x72, 0x7b, 0x4f, 0x6a, 0x4e, 0xf4, 0x97,
0x41, 0x50, 0x9f, 0x8c, 0xc9, 0x2e, 0x1e, 0x43, 0xc7, 0x16, 0x49, 0x6f, 0xe8, 0xc5, 0x67, 0xf6,
0x86, 0x89, 0x41, 0x6b, 0xfa, 0xdb, 0xa3, 0xa4, 0x26, 0x92, 0x06, 0xe5, 0xbc, 0x90, 0x4b, 0x32,
0xc9, 0xd1, 0x18, 0x74, 0x4b, 0x63, 0x20, 0xfe, 0x1c, 0x7c, 0x53, 0x3a, 0x79, 0xd7, 0x8b, 0x1f,
0x5a, 0xc9, 0x25, 0x81, 0x8e, 0xc2, 0xd2, 0x2a, 0x41, 0x2a, 0xf2, 0x14, 0x17, 0xe4, 0xe5, 0x46,
0xf0, 0x9a, 0x40, 0x57, 0x60, 0x68, 0x3c, 0x80, 0x96, 0x2e, 0xc9, 0xd6, 0x76, 0xd2, 0xd2, 0xe5,
0x65, 0x07, 0xda, 0xd7, 0x62, 0xb1, 0xc6, 0xe8, 0x3b, 0x83, 0x60, 0xfb, 0x35, 0xb7, 0x74, 0xf7,
0xff, 0x9d, 0x69, 0x35, 0xee, 0xcc, 0xce, 0x64, 0xbd, 0xa6, 0xc9, 0xf6, 0x77, 0xfc, 0x3c, 0x6c,
0x09, 0xd1, 0x2b, 0xe8, 0x8d, 0x95, 0x42, 0xfd, 0xa1, 0x5c, 0x4e, 0x8b, 0x05, 0xe7, 0x70, 0x8c,
0x37, 0x98, 0xda, 0x3b, 0xe9, 0x37, 0x6d, 0x36, 0x9d, 0xda, 0x2b, 0xec, 0x53, 0xf4, 0x83, 0x41,
0x7f, 0x67, 0x70, 0x07, 0xf6, 0xe7, 0x29, 0xf8, 0xa2, 0x2a, 0x4e, 0x85, 0x1e, 0x2d, 0x29, 0xb7,
0xa3, 0x74, 0x2a, 0x4e, 0x2c, 0x23, 0xfa, 0x04, 0xc1, 0xf6, 0x84, 0x0f, 0x6c, 0xd4, 0x4f, 0x06,
0xfd, 0x04, 0xbf, 0xd5, 0xb7, 0xbf, 0xcb, 0xe7, 0xc5, 0x81, 0xbb, 0x7d, 0x04, 0x5d, 0xea, 0xe5,
0x4d, 0x35, 0x00, 0x8f, 0x28, 0x1b, 0xa0, 0xda, 0x15, 0xb1, 0x69, 0x9b, 0x76, 0xbb, 0x9b, 0xb8,
0x50, 0xf4, 0x9b, 0xc1, 0x69, 0x5d, 0xde, 0xfb, 0x35, 0xca, 0xf2, 0xae, 0xb7, 0xf5, 0x16, 0x59,
0x76, 0x01, 0x20, 0x71, 0x29, 0xb2, 0x9c, 0x08, 0x26, 0xca, 0x1c, 0xc4, 0x49, 0x51, 0xdf, 0x4d,
0xd1, 0xf8, 0x0f, 0x83, 0x93, 0x3a, 0xc3, 0xf9, 0x4b, 0xe8, 0xd8, 0x3f, 0x05, 0xdf, 0x13, 0x3a,
0xe7, 0x7d, 0x8b, 0x7f, 0xcc, 0x55, 0xf6, 0x25, 0xbf, 0xba, 0x89, 0x8e, 0x48, 0x65, 0x33, 0x65,
0x4f, 0xec, 0x34, 0xa9, 0x62, 0xf0, 0x4d, 0x04, 0xf0, 0xe6, 0xe0, 0xd9, 0xa3, 0x31, 0xab, 0xc8,
0x9b, 0xb3, 0xa7, 0x41, 0x33, 0xf5, 0xe9, 0xf3, 0xf3, 0xe2, 0x5f, 0x00, 0x00, 0x00, 0xff, 0xff,
0x01, 0xad, 0xc9, 0x3d, 0xaa, 0x06, 0x00, 0x00,
}
......@@ -17,7 +17,6 @@ ticket_CreateBindMiner() {
returnAddr=$2
returnPriv=$3
amount=$4
set -x
resp=$(curl -ksd '{"method":"ticket.CreateBindMiner","params":[{"bindAddr":"'"$minerAddr"'", "originAddr":"'"$returnAddr"'", "amount":'"$amount"', "checkBalance":true}]}' -H 'content-type:text/plain;' ${MAIN_HTTP})
ok=$(echo "${resp}" | jq -r ".error")
[[ $ok == null ]]
......@@ -26,25 +25,20 @@ ticket_CreateBindMiner() {
#发送交易
rawTx=$(echo "${resp}" | jq -r ".result.txHex")
chain33_SignRawTx "${rawTx}" "${returnPriv}" ${MAIN_HTTP}
set +x
}
ticket_SetAutoMining() {
flag=$1
set -x
resp=$(curl -ksd '{"method":"ticket.SetAutoMining","params":[{"flag":'"$flag"'}]}' -H 'content-type:text/plain;' ${MAIN_HTTP})
ok=$(jq '(.error|not) and (.result.isOK == true)' <<<"$resp")
set +x
[[ $ok == true ]]
rst=$?
echo_rst "$FUNCNAME" "$rst"
}
ticket_GetTicketCount() {
set -x
resp=$(curl -ksd '{"method":"ticket.GetTicketCount","params":[{}]}' -H 'content-type:text/plain;' ${MAIN_HTTP})
ok=$(jq '(.error|not) and (.result > 0)' <<<"$resp")
set +x
[[ $ok == true ]]
rst=$?
echo_rst "$FUNCNAME" "$rst"
......@@ -52,10 +46,8 @@ ticket_GetTicketCount() {
ticket_CloseTickets() {
addr=$1
set -x
resp=$(curl -ksd '{"method":"ticket.CloseTickets","params":[{"minerAddress":"'"$addr"'"}]}' -H 'content-type:text/plain;' ${MAIN_HTTP})
ok=$(jq '(.error|not) and (.result.hashes | length > 0)' <<<"$resp")
set +x
ok=$(jq '(.error|not)' <<<"$resp")
[[ $ok == true ]]
rst=$?
echo_rst "$FUNCNAME" "$rst"
......@@ -65,13 +57,10 @@ ticket_TicketInfos() {
tid=$1
minerAddr=$2
returnAddr=$3
status=$4
execer="ticket"
funcName="TicketInfos"
set -x
resp=$(curl -ksd '{"method":"Chain33.Query","params":[{"execer":"'"$execer"'","funcName":"'"$funcName"'","payload":{"ticketIds":["'"$tid"'"]}}]}' -H 'content-type:text/plain;' ${MAIN_HTTP})
ok=$(jq '(.error|not) and (.result.tickets | length > 0) and (.result.tickets[0].minerAddress == "'"$minerAddr"'") and (.result.tickets[0].returnAddress == "'"$returnAddr"'") and (.result.tickets[0].status == '"$status"')' <<<"$resp")
set +x
ok=$(jq '(.error|not) and (.result.tickets | length > 0) and (.result.tickets[0].minerAddress == "'"$minerAddr"'") and (.result.tickets[0].returnAddress == "'"$returnAddr"'")' <<<"$resp")
[[ $ok == true ]]
rst=$?
echo_rst "$FUNCNAME" "$rst"
......@@ -84,19 +73,15 @@ ticket_TicketList() {
execer="ticket"
funcName="TicketList"
resp=$(curl -ksd '{"method":"Chain33.Query","params":[{"execer":"'"$execer"'","funcName":"'"$funcName"'","payload":{"addr":"'"$minerAddr"'", "status":'"$status"'}}]}' -H 'content-type:text/plain;' ${MAIN_HTTP})
set -x
ok=$(jq '(.error|not) and (.result.tickets | length > 0) and (.result.tickets[0].minerAddress == "'"$minerAddr"'") and (.result.tickets[0].returnAddress == "'"$returnAddr"'") and (.result.tickets[0].status == '"$status"')' <<<"$resp")
set +x
ticket0=$(echo "${resp}" | jq -r ".result.tickets[0]")
echo -e "######\\n ticket[0] is $ticket0) \\n######"
[[ $ok == true ]]
rst=$?
echo_rst "$FUNCNAME" "$rst"
if [[ $status == 1 ]]; then
ticketId=$(echo "${resp}" | jq -r ".result.tickets[0].ticketId")
echo -e "######\\n ticketId is $ticketId \\n######"
fi
ticket0=$(echo "${resp}" | jq -r ".result.tickets[0]")
echo -e "######\\n ticket[0] is $ticket0) \\n######"
ticketId=$(echo "${resp}" | jq -r ".result.tickets[0].ticketId")
echo -e "######\\n ticketId is $ticketId \\n######"
}
ticket_MinerAddress() {
......@@ -104,10 +89,8 @@ ticket_MinerAddress() {
minerAddr=$2
execer="ticket"
funcName="MinerAddress"
set -x
resp=$(curl -ksd '{"method":"Chain33.Query","params":[{"execer":"'"$execer"'","funcName":"'"$funcName"'","payload":{"data":"'"$returnAddr"'"}}]}' -H 'content-type:text/plain;' ${MAIN_HTTP})
ok=$(jq '(.error|not) and (.result.data == "'"$minerAddr"'")' <<<"$resp")
set +x
[[ $ok == true ]]
rst=$?
echo_rst "$FUNCNAME" "$rst"
......@@ -118,10 +101,8 @@ ticket_MinerSourceList() {
returnAddr=$2
execer="ticket"
funcName="MinerSourceList"
set -x
resp=$(curl -ksd '{"method":"Chain33.Query","params":[{"execer":"'"$execer"'","funcName":"'"$funcName"'","payload":{"data":"'"$minerAddr"'"}}]}' -H 'content-type:text/plain;' ${MAIN_HTTP})
ok=$(jq '(.error|not) and (.result.datas | length > 0) and (.result.datas[0] == "'"$returnAddr"'")' <<<"$resp")
set +x
[[ $ok == true ]]
rst=$?
echo_rst "$FUNCNAME" "$rst"
......@@ -132,10 +113,8 @@ ticket_RandNumHash() {
blockNum=$2
execer="ticket"
funcName="RandNumHash"
set -x
resp=$(curl -ksd '{"method":"Chain33.Query","params":[{"execer":"'"$execer"'","funcName":"'"$funcName"'","payload":{"hash":"'"$hash"'", "blockNum":'"$blockNum"'}}]}' -H 'content-type:text/plain;' ${MAIN_HTTP})
ok=$(jq '(.error|not) and (.result.hash != "")' <<<"$resp")
set +x
[[ $ok == true ]]
rst=$?
echo_rst "$FUNCNAME" "$rst"
......@@ -151,21 +130,19 @@ function run_testcases() {
returnAddr2="1NNaYHkscJaLJ2wUrFNeh6cQXBS4TrFYeB"
returnPriv2="0x794443611e7369a57b078881445b93b754cbc9b9b8f526535ab9c6d21d29203d"
set -x
chain33_SendToAddress "${minerAddr1}" "${minerAddr2}" 100000000 "${MAIN_HTTP}"
chain33_SendToAddress "${minerAddr1}" "${returnAddr2}" $((price + 5 * 100000000)) "${MAIN_HTTP}"
set +x
ticket_SetAutoMining 0
ticket_GetTicketCount
ticket_TicketList "${minerAddr1}" "${returnAddr1}" 1
ticket_TicketInfos "${ticketId}" "${minerAddr1}" "${returnAddr1}" 1
ticket_TicketInfos "${ticketId}" "${minerAddr1}" "${returnAddr1}"
#购票
ticket_CreateBindMiner "${minerAddr2}" "${returnAddr2}" "${returnPriv2}" ${price}
ticket_MinerAddress "${returnAddr2}" "${minerAddr2}"
ticket_MinerSourceList "${minerAddr2}" "${returnAddr2}"
#关闭
ticket_CloseTickets "${minerAddr2}"
ticket_CloseTickets "${minerAddr1}"
chain33_LastBlockhash "${MAIN_HTTP}"
ticket_RandNumHash "${LAST_BLOCK_HASH}" 5
......@@ -193,4 +170,4 @@ function main() {
echo "=========== # ticket rpc test end============="
}
main "$1"
chain33_debug_function main "$1"
#!/usr/bin/env bash
# shellcheck disable=SC2128
# shellcheck source=/dev/null
source ../dapp-test-common.sh
MAIN_HTTP=""
CASE_ERR=""
tokenAddr="1Q8hGLfoGe63efeWa8fJ4Pnukhkngt6poK"
recvAddr="14KEKbYtKKQm4wMthSK9J4La4nAiidGozt"
recvAddr="1CLrYLNhHfCfMUV7mtdqhbMSF6vGmtTvzq"
superManager="0xc34b5d9d44ac7b754806f761d3d4d2c4fe5214f6b074c19f069c4f5c2a29c8cc"
tokenSymbol="ABCDE"
token_addr=""
execName="token"
txHash=""
#color
RED='\033[1;31m'
......@@ -25,77 +29,6 @@ function echo_rst() {
fi
}
function chain33_ImportPrivkey() {
local pri=$2
local acc=$3
local req='"method":"Chain33.ImportPrivkey", "params":[{"privkey":"'"$pri"'", "label":"tokenAddr"}]'
echo "#request: $req"
resp=$(curl -ksd "{$req}" "$1")
echo "#response: $resp"
ok=$(jq '(.error|not) and (.result.label=="tokenAddr") and (.result.acc.addr == "'"$acc"'")' <<<"$resp")
[ "$ok" == true ]
echo_rst "$FUNCNAME" "$?"
}
function Chain33_SendToAddress() {
local from="$1"
local to="$2"
local amount=$3
local req='"method":"Chain33.SendToAddress", "params":[{"from":"'"$from"'","to":"'"$to"'", "amount":'"$amount"', "note":"test\n"}]'
# echo "#request: $req"
resp=$(curl -ksd "{$req}" "${MAIN_HTTP}")
# echo "#response: $resp"
ok=$(jq '(.error|not) and (.result.hash|length==66)' <<<"$resp")
[ "$ok" == true ]
echo_rst "$FUNCNAME" "$?"
hash=$(jq '(.result.hash)' <<<"$resp")
echo "hash=$hash"
# query_tx "$hash"
}
function chain33_unlock() {
ok=$(curl -k -s --data-binary '{"jsonrpc":"2.0","id":2,"method":"Chain33.UnLock","params":[{"passwd":"1314fuzamei","timeout":0}]}' -H 'content-type:text/plain;' ${MAIN_HTTP} | jq -r ".result.isOK")
[ "$ok" == true ]
rst=$?
echo_rst "$FUNCNAME" "$rst"
}
function block_wait() {
local req='"method":"Chain33.GetLastHeader","params":[]'
cur_height=$(curl -ksd "{$req}" ${MAIN_HTTP} | jq ".result.height")
expect=$((cur_height + ${1}))
local count=0
while true; do
new_height=$(curl -ksd "{$req}" ${MAIN_HTTP} | jq ".result.height")
if [ "${new_height}" -ge "${expect}" ]; then
break
fi
count=$((count + 1))
sleep 1
done
echo "wait new block $count s, cur height=$expect,old=$cur_height"
}
function signRawTx() {
unsignedTx=$1
addr=$2
signedTx=$(curl -s --data-binary '{"jsonrpc":"2.0","id":2,"method":"Chain33.SignRawTx","params":[{"addr":"'"${addr}"'","txHex":"'"${unsignedTx}"'","expire":"120s"}]}' -H 'content-type:text/plain;' ${MAIN_HTTP} | jq -r ".result")
if [ "$signedTx" == "null" ]; then
return 1
else
return 0
fi
}
function sendSignedTx() {
txHash=$(curl -s --data-binary '{"jsonrpc":"2.0","id":2,"method":"Chain33.SendTransaction","params":[{"token":"","data":"'"${signedTx}"'"}]}' -H 'content-type:text/plain;' ${MAIN_HTTP} | jq -r ".result")
if [ "$txHash" == "null" ]; then
return 1
else
return 0
fi
}
# 查询交易的执行结果
# 根据传入的规则,校验查询的结果 (参数1: 校验规则 参数2: 预期匹配结果)
function queryTransaction() {
......@@ -113,22 +46,45 @@ function queryTransaction() {
function init() {
ispara=$(echo '"'"${MAIN_HTTP}"'"' | jq '.|contains("8901")')
echo "ipara=$ispara"
chain33_ImportPrivkey "${MAIN_HTTP}" "${superManager}" "${tokenAddr}"
chain33_ImportPrivkey "${superManager}" "${tokenAddr}" "tokenAddr" "${MAIN_HTTP}"
local main_ip=${MAIN_HTTP//8901/8801}
#main chain import pri key
#1CLrYLNhHfCfMUV7mtdqhbMSF6vGmtTvzq
chain33_ImportPrivkey "0x882c963ce2afbedc2353cb417492aa9e889becd878a10f2529fc9e6c3b756128" "1CLrYLNhHfCfMUV7mtdqhbMSF6vGmtTvzq" "token1" "${main_ip}"
local ACCOUNT_A="1CLrYLNhHfCfMUV7mtdqhbMSF6vGmtTvzq"
if [ "$ispara" == false ]; then
chain33_applyCoins "$ACCOUNT_A" 12000000000 "${main_ip}"
chain33_QueryBalance "${ACCOUNT_A}" "$main_ip"
else
# tx fee
chain33_applyCoins "$ACCOUNT_A" 1000000000 "${main_ip}"
chain33_QueryBalance "${ACCOUNT_A}" "$main_ip"
local para_ip="${MAIN_HTTP}"
#para chain import pri key
chain33_ImportPrivkey "0x882c963ce2afbedc2353cb417492aa9e889becd878a10f2529fc9e6c3b756128" "1CLrYLNhHfCfMUV7mtdqhbMSF6vGmtTvzq" "token1" "$para_ip"
chain33_applyCoins "$ACCOUNT_A" 12000000000 "${para_ip}"
chain33_QueryBalance "${ACCOUNT_A}" "$para_ip"
fi
if [ "$ispara" == true ]; then
execName="user.p.para.token"
token_addr=$(curl -ksd '{"method":"Chain33.ConvertExectoAddr","params":[{"execname":"user.p.para.token"}]}' ${MAIN_HTTP} | jq -r ".result")
Chain33_SendToAddress "$recvAddr" "$tokenAddr" 100000000000
block_wait 2
Chain33_SendToAddress "$tokenAddr" "$token_addr" 1000000000
block_wait 2
chain33_SendToAddress "$recvAddr" "$tokenAddr" 10000000000 "${MAIN_HTTP}"
chain33_BlockWait 2 "${MAIN_HTTP}"
chain33_SendToAddress "$tokenAddr" "$token_addr" 1000000000 "${MAIN_HTTP}"
chain33_BlockWait 2 "${MAIN_HTTP}"
else
token_addr=$(curl -ksd '{"method":"Chain33.ConvertExectoAddr","params":[{"execname":"token"}]}' ${MAIN_HTTP} | jq -r ".result")
from="12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
Chain33_SendToAddress "$from" "$tokenAddr" 10000000000
block_wait 2
Chain33_SendToAddress "$tokenAddr" "$token_addr" 1000000000
block_wait 2
chain33_SendToAddress "$from" "$tokenAddr" 10000000000 "${MAIN_HTTP}"
chain33_BlockWait 2 "${MAIN_HTTP}"
chain33_SendToAddress "$tokenAddr" "$token_addr" 1000000000 "${MAIN_HTTP}"
chain33_BlockWait 2 "${MAIN_HTTP}"
fi
echo "token=$token_addr"
updateConfig
......@@ -141,13 +97,8 @@ function updateConfig() {
return
fi
signRawTx "${unsignedTx}" "${tokenAddr}"
echo_rst "update config signRawTx" "$?"
sendSignedTx
echo_rst "update config sendSignedTx" "$?"
block_wait 2
chain33_SignRawTx "${unsignedTx}" "${superManager}" "${MAIN_HTTP}"
txHash=$RAW_TX_HASH
queryTransaction ".error | not" "true"
echo_rst "update config queryExecRes" "$?"
......@@ -159,13 +110,8 @@ function token_preCreate() {
return
fi
signRawTx "${unsignedTx}" "${tokenAddr}"
echo_rst "token preCreate signRawTx" "$?"
sendSignedTx
echo_rst "token preCreate sendSignedTx" "$?"
block_wait 2
chain33_SignRawTx "${unsignedTx}" "${superManager}" "${MAIN_HTTP}"
txHash=$RAW_TX_HASH
queryTransaction ".error | not" "true"
echo_rst "token preCreate queryExecRes" "$?"
......@@ -186,13 +132,8 @@ function token_finish() {
return
fi
signRawTx "${unsignedTx}" "${tokenAddr}"
echo_rst "token finish signRawTx" "$?"
sendSignedTx
echo_rst "token finish sendSignedTx" "$?"
block_wait 2
chain33_SignRawTx "${unsignedTx}" "${superManager}" "${MAIN_HTTP}"
txHash=$RAW_TX_HASH
queryTransaction ".error | not" "true"
echo_rst "token finish queryExecRes" "$?"
......@@ -252,13 +193,8 @@ function token_burn() {
return
fi
signRawTx "${unsignedTx}" "${tokenAddr}"
echo_rst "token burn signRawTx" "$?"
sendSignedTx
echo_rst "token burn sendSignedTx" "$?"
block_wait 2
chain33_SignRawTx "${unsignedTx}" "${superManager}" "${MAIN_HTTP}"
txHash=$RAW_TX_HASH
queryTransaction ".error | not" "true"
echo_rst "token burn queryExecRes" "$?"
......@@ -271,13 +207,8 @@ function token_mint() {
return
fi
signRawTx "${unsignedTx}" "${tokenAddr}"
echo_rst "token mint signRawTx" "$?"
sendSignedTx
echo_rst "token mint sendSignedTx" "$?"
block_wait 2
chain33_SignRawTx "${unsignedTx}" "${superManager}" "${MAIN_HTTP}"
txHash=$RAW_TX_HASH
queryTransaction ".error | not" "true"
echo_rst "token mint queryExecRes" "$?"
......@@ -289,13 +220,8 @@ function token_transfer() {
return
fi
signRawTx "${unsignedTx}" "${tokenAddr}"
echo_rst "token transfer signRawTx" "$?"
sendSignedTx
echo_rst "token transfer sendSignedTx" "$?"
block_wait 2
chain33_SignRawTx "${unsignedTx}" "${superManager}" "${MAIN_HTTP}"
txHash=$RAW_TX_HASH
queryTransaction ".error | not" "true"
echo_rst "token transfer queryExecRes" "$?"
......@@ -308,13 +234,8 @@ function token_sendExec() {
return
fi
signRawTx "${unsignedTx}" "${tokenAddr}"
echo_rst "token sendExec signRawTx" "$?"
sendSignedTx
echo_rst "token sendExec sendSignedTx" "$?"
block_wait 2
chain33_SignRawTx "${unsignedTx}" "${superManager}" "${MAIN_HTTP}"
txHash=$RAW_TX_HASH
queryTransaction ".error | not" "true"
echo_rst "token sendExec queryExecRes" "$?"
......@@ -327,13 +248,8 @@ function token_withdraw() {
return
fi
signRawTx "${unsignedTx}" "${tokenAddr}"
echo_rst "token withdraw signRawTx" "$?"
sendSignedTx
echo_rst "token withdraw sendSignedTx" "$?"
block_wait 2
chain33_SignRawTx "${unsignedTx}" "${superManager}" "${MAIN_HTTP}"
txHash=$RAW_TX_HASH
queryTransaction ".error | not" "true"
echo_rst "token withdraw queryExecRes" "$?"
......@@ -375,4 +291,4 @@ function main() {
fi
}
main "$1"
chain33_debug_function main "$1"
......@@ -8,7 +8,7 @@ MAIN_HTTP=""
CASE_ERR=""
trade_addr=""
tradeAddr="12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
tradeBuyerAddr="14KEKbYtKKQm4wMthSK9J4La4nAiidGozt"
tradeBuyerAddr="1CvLe1qNaC7tCf5xmfAqJ9UJkMhtmhUKNg"
tokenSymbol="TOKEN"
#color
......@@ -132,7 +132,7 @@ function trade_createBuyTx() {
return
fi
chain33_SignRawTx "${unsignedTx}" "0xCC38546E9E659D15E6B4893F0AB32A06D103931A8230B0BDE71459D2B27D6944" "${MAIN_HTTP}"
chain33_SignRawTx "${unsignedTx}" "0xaeef1ad76d43a2056d0dcb57d5bf1ba96471550614ab9e7f611ef9c5ca403f42" "${MAIN_HTTP}"
queryTransaction ".error | not" "true"
echo_rst "trade createBuyTx queryExecRes" "$?"
......@@ -200,7 +200,7 @@ function trade_buyLimit() {
return
fi
chain33_SignRawTx "${unsignedTx}" "CC38546E9E659D15E6B4893F0AB32A06D103931A8230B0BDE71459D2B27D6944" "${MAIN_HTTP}"
chain33_SignRawTx "${unsignedTx}" "0xaeef1ad76d43a2056d0dcb57d5bf1ba96471550614ab9e7f611ef9c5ca403f42" "${MAIN_HTTP}"
queryTransaction ".error | not" "true"
echo_rst "trade buyLimit queryExecRes" "$?"
......@@ -278,7 +278,29 @@ function init() {
token_addr=$(curl -ksd '{"method":"Chain33.ConvertExectoAddr","params":[{"execname":"'"${tokenExecName}"'"}]}' ${MAIN_HTTP} | jq -r ".result")
fi
chain33_SendToAddress "$tradeAddr" "$tradeBuyerAddr" 10000000000 "${MAIN_HTTP}"
local main_ip=${MAIN_HTTP//8901/8801}
#main chain import pri key
#1CvLe1qNaC7tCf5xmfAqJ9UJkMhtmhUKNg
chain33_ImportPrivkey "0xaeef1ad76d43a2056d0dcb57d5bf1ba96471550614ab9e7f611ef9c5ca403f42" "1CvLe1qNaC7tCf5xmfAqJ9UJkMhtmhUKNg" "trade1" "${main_ip}"
local ACCOUNT_A="1CvLe1qNaC7tCf5xmfAqJ9UJkMhtmhUKNg"
if [ "$ispara" == false ]; then
chain33_applyCoins "$ACCOUNT_A" 12000000000 "${main_ip}"
chain33_QueryBalance "${ACCOUNT_A}" "$main_ip"
else
# tx fee
chain33_applyCoins "$ACCOUNT_A" 1000000000 "${main_ip}"
chain33_QueryBalance "${ACCOUNT_A}" "$main_ip"
local para_ip="${MAIN_HTTP}"
#para chain import pri key
chain33_ImportPrivkey "0xaeef1ad76d43a2056d0dcb57d5bf1ba96471550614ab9e7f611ef9c5ca403f42" "1CvLe1qNaC7tCf5xmfAqJ9UJkMhtmhUKNg" "trade1" "$para_ip"
chain33_applyCoins "$ACCOUNT_A" 12000000000 "${para_ip}"
chain33_QueryBalance "${ACCOUNT_A}" "$para_ip"
fi
chain33_SendToAddress "$tradeAddr" "$trade_addr" 10000000000 "${MAIN_HTTP}"
chain33_SendToAddress "$tradeAddr" "$token_addr" 10000000000 "${MAIN_HTTP}"
chain33_BlockWait 2 "${MAIN_HTTP}"
......@@ -293,7 +315,7 @@ function init() {
token_balance
token_transfer "${tradeBuyerAddr}"
token_sendExec "0x4257d8692ef7fe13c68b65d6a52f03933db2fa5ce8faf210b5b8b80c721ced01"
token_sendExec "CC38546E9E659D15E6B4893F0AB32A06D103931A8230B0BDE71459D2B27D6944 "
token_sendExec "0xaeef1ad76d43a2056d0dcb57d5bf1ba96471550614ab9e7f611ef9c5ca403f42 "
}
function run_test() {
......@@ -332,4 +354,4 @@ function main() {
fi
}
main "$1"
chain33_debug_function main "$1"
......@@ -174,7 +174,7 @@ func TestRealNodeMempool(t *testing.T) {
mock33.WaitHeight(0)
mock33.SendHot()
mock33.WaitHeight(1)
n := 20
n := 10
done := make(chan struct{}, n)
keys := make([]crypto.PrivKey, n)
for i := 0; i < n; i++ {
......@@ -186,7 +186,7 @@ func TestRealNodeMempool(t *testing.T) {
mock33.Wait()
for i := 0; i < n; i++ {
go func(priv crypto.PrivKey) {
for i := 0; i < 100; i++ {
for i := 0; i < 30; i++ {
tx := util.CreateCoinsTx(priv, mock33.GetGenesisAddress(), types.Coin/1000)
reply, err := mock33.GetAPI().SendTx(tx)
if err != nil {
......
......@@ -163,7 +163,7 @@ func TestRealNodeMempool(t *testing.T) {
mock33.WaitHeight(0)
mock33.SendHot()
mock33.WaitHeight(1)
n := 20
n := 10
done := make(chan struct{}, n)
keys := make([]crypto.PrivKey, n)
for i := 0; i < n; i++ {
......@@ -175,7 +175,7 @@ func TestRealNodeMempool(t *testing.T) {
mock33.Wait()
for i := 0; i < n; i++ {
go func(priv crypto.PrivKey) {
for i := 0; i < 100; i++ {
for i := 0; i < 30; i++ {
tx := util.CreateCoinsTx(priv, mock33.GetGenesisAddress(), types.Coin/1000)
reply, err := mock33.GetAPI().SendTx(tx)
if err != nil {
......
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