Commit 40205e4a authored by pengjun's avatar pengjun

#484 update rpc_test

parent 10722274
......@@ -27,18 +27,6 @@ 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"
......@@ -294,8 +282,10 @@ function init() {
chain33_QueryBalance "${ACCOUNT_A}" "$para_ip"
fi
Chain33_SendToAddress "$ACCOUNT_A" "$from" 11000000000
from="14KEKbYtKKQm4wMthSK9J4La4nAiidGozt"
Chain33_SendToAddress "$ACCOUNT_A" "$from" 11000000000
block_wait 2
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")
......
#!/usr/bin/env bash
# shellcheck disable=SC2128
# shellcheck source=/dev/null
source ../dapp-test-common.sh
MAIN_HTTP=""
CASE_ERR=""
tokenAddr="1CLrYLNhHfCfMUV7mtdqhbMSF6vGmtTvzq"
tokenAddr="1Q8hGLfoGe63efeWa8fJ4Pnukhkngt6poK"
recvAddr="14KEKbYtKKQm4wMthSK9J4La4nAiidGozt"
superManager="0xc34b5d9d44ac7b754806f761d3d4d2c4fe5214f6b074c19f069c4f5c2a29c8cc"
tokenSymbol="ABCDE"
token_addr=""
execName="token"
......@@ -26,6 +25,34 @@ 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 ]
......@@ -86,35 +113,20 @@ function queryTransaction() {
function init() {
ispara=$(echo '"'"${MAIN_HTTP}"'"' | jq '.|contains("8901")')
echo "ipara=$ispara"
local main_ip=${MAIN_HTTP//8901/8801}
#main chain import pri key
#1CLrYLNhHfCfMUV7mtdqhbMSF6vGmtTvzq
chain33_ImportPrivkey "0x882c963ce2afbedc2353cb417492aa9e889becd878a10f2529fc9e6c3b756128" "1CLrYLNhHfCfMUV7mtdqhbMSF6vGmtTvzq" "token1" "${main_ip}"
local token1="1CLrYLNhHfCfMUV7mtdqhbMSF6vGmtTvzq"
if [ "$ispara" == false ]; then
chain33_applyCoins "$token1" 12000000000 "${main_ip}"
chain33_QueryBalance "${token1}" "$main_ip"
else
# tx fee
chain33_applyCoins "$token1" 1000000000 "${main_ip}"
chain33_QueryBalance "${token1}" "$main_ip"
local para_ip="${MAIN_HTTP}"
#para chain import pri key
chain33_ImportPrivkey "0x882c963ce2afbedc2353cb417492aa9e889becd878a10f2529fc9e6c3b756128" "1CLrYLNhHfCfMUV7mtdqhbMSF6vGmtTvzq" "token1" "$para_ip"
chain33_applyCoins "$token1" 12000000000 "${para_ip}"
chain33_QueryBalance "${token1}" "$para_ip"
fi
chain33_ImportPrivkey "${MAIN_HTTP}" "${superManager}" "${tokenAddr}"
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
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
fi
......
......@@ -7,8 +7,8 @@ source ../dapp-test-common.sh
MAIN_HTTP=""
CASE_ERR=""
trade_addr=""
tradeAddr="1CvLe1qNaC7tCf5xmfAqJ9UJkMhtmhUKNg"
tradeBuyerAddr="1MbEtj189WoUGgLvX5vNosBVB4xmL3dAyJ"
tradeAddr="12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
tradeBuyerAddr="14KEKbYtKKQm4wMthSK9J4La4nAiidGozt"
tokenSymbol="TOKEN"
#color
......@@ -23,7 +23,7 @@ function updateConfig() {
return
fi
chain33_SignRawTx "${unsignedTx}" "0xaeef1ad76d43a2056d0dcb57d5bf1ba96471550614ab9e7f611ef9c5ca403f42" "${MAIN_HTTP}"
chain33_SignRawTx "${unsignedTx}" "0x4257d8692ef7fe13c68b65d6a52f03933db2fa5ce8faf210b5b8b80c721ced01" "${MAIN_HTTP}"
queryTransaction ".error | not" "true"
echo_rst "update config queryExecRes" "$?"
......@@ -36,7 +36,7 @@ function token_preCreate() {
return
fi
chain33_SignRawTx "${unsignedTx}" "0xaeef1ad76d43a2056d0dcb57d5bf1ba96471550614ab9e7f611ef9c5ca403f42" "${MAIN_HTTP}"
chain33_SignRawTx "${unsignedTx}" "0x4257d8692ef7fe13c68b65d6a52f03933db2fa5ce8faf210b5b8b80c721ced01" "${MAIN_HTTP}"
queryTransaction ".error | not" "true"
echo_rst "token preCreate queryExecRes" "$?"
......@@ -49,7 +49,7 @@ function token_finish() {
return
fi
chain33_SignRawTx "${unsignedTx}" "0xaeef1ad76d43a2056d0dcb57d5bf1ba96471550614ab9e7f611ef9c5ca403f42" "${MAIN_HTTP}"
chain33_SignRawTx "${unsignedTx}" "0x4257d8692ef7fe13c68b65d6a52f03933db2fa5ce8faf210b5b8b80c721ced01" "${MAIN_HTTP}"
queryTransaction ".error | not" "true"
echo_rst "token finish queryExecRes" "$?"
......@@ -81,7 +81,7 @@ function token_transfer() {
return
fi
chain33_SignRawTx "${unsignedTx}" "0xaeef1ad76d43a2056d0dcb57d5bf1ba96471550614ab9e7f611ef9c5ca403f42" "${MAIN_HTTP}"
chain33_SignRawTx "${unsignedTx}" "0x4257d8692ef7fe13c68b65d6a52f03933db2fa5ce8faf210b5b8b80c721ced01" "${MAIN_HTTP}"
queryTransaction ".error | not" "true"
echo_rst "token transfer queryExecRes" "$?"
......@@ -108,7 +108,7 @@ function trade_createSellTx() {
return
fi
chain33_SignRawTx "${unsignedTx}" "0xaeef1ad76d43a2056d0dcb57d5bf1ba96471550614ab9e7f611ef9c5ca403f42" "${MAIN_HTTP}"
chain33_SignRawTx "${unsignedTx}" "0x4257d8692ef7fe13c68b65d6a52f03933db2fa5ce8faf210b5b8b80c721ced01" "${MAIN_HTTP}"
queryTransaction ".error | not" "true"
echo_rst "trade createSellTx queryExecRes" "$?"
......@@ -132,7 +132,7 @@ function trade_createBuyTx() {
return
fi
chain33_SignRawTx "${unsignedTx}" "0xfac83e59be12fb5cf21821c78e6f44d370b0b0a2c67902452d47a572d3c24d14" "${MAIN_HTTP}"
chain33_SignRawTx "${unsignedTx}" "0xCC38546E9E659D15E6B4893F0AB32A06D103931A8230B0BDE71459D2B27D6944" "${MAIN_HTTP}"
queryTransaction ".error | not" "true"
echo_rst "trade createBuyTx queryExecRes" "$?"
......@@ -200,7 +200,7 @@ function trade_buyLimit() {
return
fi
chain33_SignRawTx "${unsignedTx}" "0xfac83e59be12fb5cf21821c78e6f44d370b0b0a2c67902452d47a572d3c24d14" "${MAIN_HTTP}"
chain33_SignRawTx "${unsignedTx}" "CC38546E9E659D15E6B4893F0AB32A06D103931A8230B0BDE71459D2B27D6944" "${MAIN_HTTP}"
queryTransaction ".error | not" "true"
echo_rst "trade buyLimit queryExecRes" "$?"
......@@ -227,7 +227,7 @@ function trade_revokeBuy() {
return
fi
chain33_SignRawTx "${unsignedTx}" "0xaeef1ad76d43a2056d0dcb57d5bf1ba96471550614ab9e7f611ef9c5ca403f42" "${MAIN_HTTP}"
chain33_SignRawTx "${unsignedTx}" "0x4257d8692ef7fe13c68b65d6a52f03933db2fa5ce8faf210b5b8b80c721ced01" "${MAIN_HTTP}"
queryTransaction ".error | not" "true"
echo_rst "trade revokeBuy queryExecRes" "$?"
......@@ -240,7 +240,7 @@ function trade_revoke() {
return
fi
chain33_SignRawTx "${unsignedTx}" "0xaeef1ad76d43a2056d0dcb57d5bf1ba96471550614ab9e7f611ef9c5ca403f42" "${MAIN_HTTP}"
chain33_SignRawTx "${unsignedTx}" "0x4257d8692ef7fe13c68b65d6a52f03933db2fa5ce8faf210b5b8b80c721ced01" "${MAIN_HTTP}"
queryTransaction ".error | not" "true"
echo_rst "trade revoke queryExecRes" "$?"
......@@ -278,39 +278,9 @@ function init() {
token_addr=$(curl -ksd '{"method":"Chain33.ConvertExectoAddr","params":[{"execname":"'"${tokenExecName}"'"}]}' ${MAIN_HTTP} | jq -r ".result")
fi
local main_ip=${MAIN_HTTP//8901/8801}
#main chain import pri key
#1CvLe1qNaC7tCf5xmfAqJ9UJkMhtmhUKNg
chain33_ImportPrivkey "0xaeef1ad76d43a2056d0dcb57d5bf1ba96471550614ab9e7f611ef9c5ca403f42" "1CvLe1qNaC7tCf5xmfAqJ9UJkMhtmhUKNg" "trade1" "${main_ip}"
#1MbEtj189WoUGgLvX5vNosBVB4xmL3dAyJ
chain33_ImportPrivkey "0xfac83e59be12fb5cf21821c78e6f44d370b0b0a2c67902452d47a572d3c24d14" "1MbEtj189WoUGgLvX5vNosBVB4xmL3dAyJ" "trade2" "$main_ip"
if [ "$ispara" == false ]; then
chain33_applyCoins "$tradeAddr" 12000000000 "${main_ip}"
chain33_QueryBalance "${tradeAddr}" "$main_ip"
chain33_applyCoins "$tradeBuyerAddr" 12000000000 "${main_ip}"
chain33_QueryBalance "${tradeBuyerAddr}" "$main_ip"
else
# tx fee
chain33_applyCoins "$tradeAddr" 1000000000 "${main_ip}"
chain33_QueryBalance "${tradeAddr}" "$main_ip"
chain33_applyCoins "$tradeBuyerAddr" 1000000000 "${main_ip}"
chain33_QueryBalance "${tradeBuyerAddr}" "$main_ip"
local para_ip="${MAIN_HTTP}"
#para chain import pri key
chain33_ImportPrivkey "0xaeef1ad76d43a2056d0dcb57d5bf1ba96471550614ab9e7f611ef9c5ca403f42" "1CvLe1qNaC7tCf5xmfAqJ9UJkMhtmhUKNg" "trade1" "$para_ip"
chain33_ImportPrivkey "0xfac83e59be12fb5cf21821c78e6f44d370b0b0a2c67902452d47a572d3c24d14" "1MbEtj189WoUGgLvX5vNosBVB4xmL3dAyJ" "trade2" "$para_ip"
chain33_applyCoins "$tradeAddr" 12000000000 "${para_ip}"
chain33_QueryBalance "${tradeAddr}" "$para_ip"
chain33_applyCoins "$tradeBuyerAddr" 12000000000 "${para_ip}"
chain33_QueryBalance "${tradeBuyerAddr}" "$para_ip"
fi
chain33_SendToAddress "$tradeAddr" "$tradeBuyerAddr" 10000000000 "${MAIN_HTTP}"
chain33_SendToAddress "$tradeAddr" "$trade_addr" 10000000000 "${MAIN_HTTP}"
chain33_SendToAddress "$tradeAddr" "$token_addr" 1000000000 "${MAIN_HTTP}"
chain33_SendToAddress "$tradeAddr" "$token_addr" 10000000000 "${MAIN_HTTP}"
chain33_BlockWait 2 "${MAIN_HTTP}"
chain33_SendToAddress "$tradeBuyerAddr" "$trade_addr" 10000000000 "${MAIN_HTTP}"
chain33_BlockWait 2 "${MAIN_HTTP}"
......@@ -322,8 +292,8 @@ function init() {
token_finish
token_balance
token_transfer "${tradeBuyerAddr}"
token_sendExec "0xaeef1ad76d43a2056d0dcb57d5bf1ba96471550614ab9e7f611ef9c5ca403f42"
token_sendExec "0xfac83e59be12fb5cf21821c78e6f44d370b0b0a2c67902452d47a572d3c24d14 "
token_sendExec "0x4257d8692ef7fe13c68b65d6a52f03933db2fa5ce8faf210b5b8b80c721ced01"
token_sendExec "CC38546E9E659D15E6B4893F0AB32A06D103931A8230B0BDE71459D2B27D6944 "
}
function run_test() {
......
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