Commit 97cc9c23 authored by mdj33's avatar mdj33

add common addr func for main and para chain

parent f155ca84
...@@ -96,6 +96,7 @@ chain33_SendToAddress() { ...@@ -96,6 +96,7 @@ chain33_SendToAddress() {
[ "$ok" == true ] [ "$ok" == true ]
hash=$(jq -r ".result.hash" <<<"$resp") hash=$(jq -r ".result.hash" <<<"$resp")
echo "hash"
chain33_QueryTx "$hash" "$MAIN_HTTP" chain33_QueryTx "$hash" "$MAIN_HTTP"
} }
...@@ -164,3 +165,47 @@ chain33_LastBlockhash() { ...@@ -164,3 +165,47 @@ chain33_LastBlockhash() {
LAST_BLOCK_HASH=$result LAST_BLOCK_HASH=$result
echo -e "######\\n last blockhash is $LAST_BLOCK_HASH \\n######" echo -e "######\\n last blockhash is $LAST_BLOCK_HASH \\n######"
} }
ip=$(echo "$ip" | cut -d':' -f 1)
chain33_getMainChainCoins() {
echo "chain33_getMainChainCoins"
if [ "$#" -lt 3 ]; then
echo "chain33_getMainCoins wrong params"
exit 1
fi
local MAIN_HTTP=$1
local targetAddr=$2
local count=$3
if [ $count -gt 10000000000 ]; then
echo "chain33_getMainCoins wrong coins count,should less than 100 00000000"
exit 1
fi
local poolAddr="0x9d315182e56fde7fadb94408d360203894e5134216944e858f9b31f70e9ecf40"
M_HTTP=${MAIN_HTTP//8901/8801}
chain33_SendToAddress "${poolAddr}" "${targetAddr}" $count "${M_HTTP}"
}
chain33_getParaChainCoins() {
echo "chain33_getParaChainCoins"
if [ "$#" -lt 3 ]; then
echo "chain33_getParaChainCoins wrong params"
exit 1
fi
local MAIN_HTTP=$1
local targetAddr=$2
local count=$3
if [ $count -gt 100000000000 ]; then
echo "chain33_getMainCoins wrong coins count,should less than 1000 00000000"
exit 1
fi
local poolAddr="0x9d315182e56fde7fadb94408d360203894e5134216944e858f9b31f70e9ecf40"
P_HTTP=${MAIN_HTTP//8801/8901}
chain33_SendToAddress "${poolAddr}" "${targetAddr}" $count "${P_HTTP}"
}
\ No newline at end of file
...@@ -10,7 +10,7 @@ function dapp_test_rpc() { ...@@ -10,7 +10,7 @@ function dapp_test_rpc() {
if [ -d dapptest ]; then if [ -d dapptest ]; then
cp $DAPP_TEST_COMMON dapptest/ cp $DAPP_TEST_COMMON dapptest/
cd dapptest || return cd dapptest || return
dir=$(find . -maxdepth 1 -type d ! -name dapptest ! -name multisig ! -name paracross ! -name . | sed 's/^\.\///' | sort) dir=$(find . -maxdepth 1 -type d ! -name dapptest ! -name multisig ! -name paracross ! -name evm ! -name game ! -name guess ! -name hashlock ! -name js ! -name lottery ! -name pokerbull ! -name . | sed 's/^\.\///' | sort)
echo "dapps list: $dir" echo "dapps list: $dir"
for app in $dir; do for app in $dir; do
echo "=========== # $app rpc test =============" echo "=========== # $app rpc test ============="
......
...@@ -382,6 +382,11 @@ function dapp_test_address() { ...@@ -382,6 +382,11 @@ function dapp_test_address() {
hash=$(${1} send coins transfer -a 1500 -n transfer -t 1PUiGcbsccfxW3zuvHXZBJfznziph5miAo -k 2116459C0EC8ED01AA0EEAE35CAC5C96F94473F7816F114873291217303F6989) hash=$(${1} send coins transfer -a 1500 -n transfer -t 1PUiGcbsccfxW3zuvHXZBJfznziph5miAo -k 2116459C0EC8ED01AA0EEAE35CAC5C96F94473F7816F114873291217303F6989)
echo "${hash}" echo "${hash}"
#total allocation for rpc test
hash=$(${1} send coins transfer -a 5000 -n transfer -t 1PcGKYYoLn1PLLJJodc1UpgWGeFAQasAkx -k 2116459C0EC8ED01AA0EEAE35CAC5C96F94473F7816F114873291217303F6989)
echo "${hash}"
block_wait "${1}" 1 block_wait "${1}" 1
} }
...@@ -427,7 +432,7 @@ function main() { ...@@ -427,7 +432,7 @@ function main() {
### test cases ### ### test cases ###
ip=$(${CLI} net info | jq -r ".externalAddr") ip=$(${CLI} net info | jq -r ".externalAddr")
ip=$(echo "$ip" | cut -d':' -f 1) ip=$(echo "$ip" | cut -d':' -f 1)
dapp_run test "${ip}" #dapp_run test "${ip}"
### rpc test ### ### rpc test ###
rpc_test "${ip}" rpc_test "${ip}"
......
...@@ -140,6 +140,8 @@ function para_transfer() { ...@@ -140,6 +140,8 @@ function para_transfer() {
para_transfer2account "1E5saiXVb9mW8wcWUUZjsHJPZs5GmdzuSY" para_transfer2account "1E5saiXVb9mW8wcWUUZjsHJPZs5GmdzuSY"
para_transfer2account "1PUiGcbsccfxW3zuvHXZBJfznziph5miAo" para_transfer2account "1PUiGcbsccfxW3zuvHXZBJfznziph5miAo"
para_transfer2account "1EDnnePAZN48aC2hiTDzhkczfF39g1pZZX" para_transfer2account "1EDnnePAZN48aC2hiTDzhkczfF39g1pZZX"
#rpc test pool addr
para_transfer2account "1PcGKYYoLn1PLLJJodc1UpgWGeFAQasAkx" 500000
block_wait "${CLI}" 2 block_wait "${CLI}" 2
echo "=========== # main chain send to paracross =============" echo "=========== # main chain send to paracross ============="
...@@ -175,7 +177,11 @@ function main_transfer2account() { ...@@ -175,7 +177,11 @@ function main_transfer2account() {
function para_transfer2account() { function para_transfer2account() {
echo "${1}" echo "${1}"
hash1=$(${PARA_CLI} send coins transfer -a 1000 -n transfer -t "${1}" -k 0xCC38546E9E659D15E6B4893F0AB32A06D103931A8230B0BDE71459D2B27D6944) local coins=1000
if [ "$#" -ge 2 ]; then
coins="$2"
fi
hash1=$(${PARA_CLI} send coins transfer -a "$coins" -n transfer -t "${1}" -k 0xCC38546E9E659D15E6B4893F0AB32A06D103931A8230B0BDE71459D2B27D6944)
echo "${hash1}" echo "${hash1}"
} }
......
#!/usr/bin/env bash #!/usr/bin/env bash
# shellcheck disable=SC2128 # shellcheck disable=SC2128
# shellcheck source=/dev/null
source ../dapp-test-common.sh
MAIN_HTTP="" MAIN_HTTP=""
CASE_ERR="" CASE_ERR=""
...@@ -61,35 +64,9 @@ function query_tx() { ...@@ -61,35 +64,9 @@ function query_tx() {
done done
} }
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"
}
chain33_ImportPrivkey() {
local pri=$2
local acc=$3
local req='"method":"Chain33.ImportPrivkey", "params":[{"privkey":"'"$pri"'", "label":"relayimportkey1"}]'
echo "#request: $req"
resp=$(curl -ksd "{$req}" "$1")
echo "#response: $resp"
ok=$(jq '(.error|not) and (.result.label=="relayimportkey1") and (.result.acc.addr == "'"$acc"'")' <<<"$resp")
[ "$ok" == true ]
echo_rst "$FUNCNAME" "$?"
}
signrawtx() { signrawtx() {
txHex="$1" txHex="$1"
priKey="$2" priKey="$2"
...@@ -287,16 +264,16 @@ init() { ...@@ -287,16 +264,16 @@ init() {
if [ "$ispara" == true ]; then if [ "$ispara" == true ]; then
relay_addr=$(curl -ksd '{"method":"Chain33.ConvertExectoAddr","params":[{"execname":"user.p.para.relay"}]}' ${MAIN_HTTP} | jq -r ".result") relay_addr=$(curl -ksd '{"method":"Chain33.ConvertExectoAddr","params":[{"execname":"user.p.para.relay"}]}' ${MAIN_HTTP} | jq -r ".result")
else else
chain33_ImportPrivkey "${MAIN_HTTP}" "0x9c451df9e5cb05b88b28729aeaaeb3169a2414097401fcb4c79c1971df734588" "1E5saiXVb9mW8wcWUUZjsHJPZs5GmdzuSY" # chain33_ImportPrivkey "${MAIN_HTTP}" "0x9c451df9e5cb05b88b28729aeaaeb3169a2414097401fcb4c79c1971df734588" "1E5saiXVb9mW8wcWUUZjsHJPZs5GmdzuSY"
relay_addr=$(curl -ksd '{"method":"Chain33.ConvertExectoAddr","params":[{"execname":"relay"}]}' ${MAIN_HTTP} | jq -r ".result") relay_addr=$(curl -ksd '{"method":"Chain33.ConvertExectoAddr","params":[{"execname":"relay"}]}' ${MAIN_HTTP} | jq -r ".result")
fi fi
echo "relayaddr=$relay_addr" echo "relayaddr=$relay_addr"
from="12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv" local testAddr="1G5Cjy8LuQex2fuYv3gzb7B8MxAnxLEqt3"
Chain33_SendToAddress "$from" "$relay_addr" 10000000000 chain33_getMainChainCoins "${MAIN_HTTP}" "$testAddr" 10000000000
chain33_getParaChainCoins "${MAIN_HTTP}" "$testAddr" 10000000000
chain33_SendToAddress "$testAddr" "$relay_addr" 8000000000 "${MAIN_HTTP}"
from="1E5saiXVb9mW8wcWUUZjsHJPZs5GmdzuSY"
Chain33_SendToAddress "$from" "$relay_addr" 10000000000
block_wait 1 block_wait 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