Unverified Commit 53a3f129 authored by 33cn's avatar 33cn Committed by GitHub

Merge pull request #635 from jpeng-go/master

#484 update rpc_test
parents babba433 fa1b1ba6
......@@ -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 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 1 | 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() {
......
......@@ -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
......
......@@ -168,7 +168,7 @@ func DposPerf() {
dposClient := cs.(*Client)
dposClient.csState.QueryCycleBoundaryInfo(task.Cycle)
dposClient.csState.GetCBInfoByCircle(task.Cycle)
//dposClient.csState.GetCBInfoByCircle(task.Cycle)
dposClient.csState.QueryVrf(pubkey, task.Cycle)
dposClient.csState.QueryVrfs(dposClient.csState.validatorMgr.Validators, task.Cycle)
dposClient.csState.GetVrfInfoByCircle(task.Cycle, VrfQueryTypeM)
......@@ -200,12 +200,12 @@ 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 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)
......
......@@ -13,7 +13,7 @@ func TestTicker(t *testing.T) {
ticker.Start()
ti := timeoutInfo{
Duration: time.Second * time.Duration(2),
Duration: time.Second * time.Duration(3),
State: InitStateType,
}
fmt.Println("timeoutInfo:", ti.String())
......
#!/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"
......@@ -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"
......@@ -260,4 +260,4 @@ function main() {
}
set -x
main "$1"
chain33_debug_function main "$1"
......@@ -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"
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