Commit 692c8c0a authored by pengjun's avatar pengjun

#627 fix test_rpc

parent 139dae83
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
set -e set -e
set -o pipefail set -o pipefail
# shellcheck source=/dev/null
source ../dapp-test-common.sh
function main() { function main() {
echo "Collateralize cases has integrated in Issuance test" echo "Collateralize cases has integrated in Issuance test"
......
...@@ -8,6 +8,8 @@ ISSU_ID="" ...@@ -8,6 +8,8 @@ ISSU_ID=""
DEBT_ID="" DEBT_ID=""
COLL_ID="" COLL_ID=""
BORROW_ID="" BORROW_ID=""
issuance_addr=""
collateralize_addr=""
SystemManager="0x4257d8692ef7fe13c68b65d6a52f03933db2fa5ce8faf210b5b8b80c721ced01" SystemManager="0x4257d8692ef7fe13c68b65d6a52f03933db2fa5ce8faf210b5b8b80c721ced01"
TokenSuperManager="0xc34b5d9d44ac7b754806f761d3d4d2c4fe5214f6b074c19f069c4f5c2a29c8cc" TokenSuperManager="0xc34b5d9d44ac7b754806f761d3d4d2c4fe5214f6b074c19f069c4f5c2a29c8cc"
TokenAddr="1Q8hGLfoGe63efeWa8fJ4Pnukhkngt6poK" TokenAddr="1Q8hGLfoGe63efeWa8fJ4Pnukhkngt6poK"
...@@ -26,7 +28,7 @@ source ../dapp-test-common.sh ...@@ -26,7 +28,7 @@ source ../dapp-test-common.sh
issuance_Create() { issuance_Create() {
echo "========== # issuance create begin ==========" echo "========== # issuance create begin =========="
tx=$(curl -ksd '{"method":"Chain33.CreateTransaction","params":[{"execer":"issuance","actionName":"IssuanceCreate","payload":{"debtCeiling":"1000.1", "totalBalance":"10000.1"}}]}' ${MAIN_HTTP} | jq -r ".result") tx=$(curl -ksd '{"method":"Chain33.CreateTransaction","params":[{"execer":"issuance","actionName":"IssuanceCreate","payload":{"debtCeiling":1000.1, "totalBalance":10000.1}}]}' ${MAIN_HTTP} | jq -r ".result")
data=$(curl -ksd '{"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'"$tx"'"}]}' ${MAIN_HTTP} | jq -r ".result.txs[0]") data=$(curl -ksd '{"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'"$tx"'"}]}' ${MAIN_HTTP} | jq -r ".result.txs[0]")
ok=$(jq '(.execer != "")' <<<"$data") ok=$(jq '(.execer != "")' <<<"$data")
...@@ -83,7 +85,7 @@ issuance_Feed() { ...@@ -83,7 +85,7 @@ issuance_Feed() {
issuance_Debt() { issuance_Debt() {
echo "========== # issuance debt begin ==========" echo "========== # issuance debt begin =========="
tx=$(curl -ksd '{"method":"Chain33.CreateTransaction","params":[{"execer":"issuance","actionName":"Continue","payload":{"gameId":"'$GAME_ID'"}}]}' ${MAIN_HTTP} | jq -r ".result") tx=$(curl -ksd '{"method":"Chain33.CreateTransaction","params":[{"execer":"issuance","actionName":"IssuanceDebt","payload":{"issuanceId":"'"${ISSU_ID}"'", "value":10}}]}' ${MAIN_HTTP} | jq -r ".result")
data=$(curl -ksd '{"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'"$tx"'"}]}' ${MAIN_HTTP} | jq -r ".result.txs[0]") data=$(curl -ksd '{"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'"$tx"'"}]}' ${MAIN_HTTP} | jq -r ".result.txs[0]")
ok=$(jq '(.execer != "")' <<<"$data") ok=$(jq '(.execer != "")' <<<"$data")
...@@ -143,7 +145,7 @@ issuance_Close() { ...@@ -143,7 +145,7 @@ issuance_Close() {
collateralize_Manage() { collateralize_Manage() {
echo "========== # collateralize manage begin ==========" echo "========== # collateralize manage begin =========="
tx=$(curl -ksd '{"method":"Chain33.CreateTransaction","params":[{"execer":"collateralize","actionName":"CollateralizeManage","payload":{"debtCeiling":"1000.1", "totalBalance":"10000.1"}}]}' ${MAIN_HTTP} | jq -r ".result") tx=$(curl -ksd '{"method":"Chain33.CreateTransaction","params":[{"execer":"collateralize","actionName":"CollateralizeManage","payload":{"debtCeiling":1000.1, "totalBalance":10000.1}}]}' ${MAIN_HTTP} | jq -r ".result")
data=$(curl -ksd '{"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'"$tx"'"}]}' ${MAIN_HTTP} | jq -r ".result.txs[0]") data=$(curl -ksd '{"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'"$tx"'"}]}' ${MAIN_HTTP} | jq -r ".result.txs[0]")
ok=$(jq '(.execer != "")' <<<"$data") ok=$(jq '(.execer != "")' <<<"$data")
...@@ -163,7 +165,7 @@ collateralize_Manage() { ...@@ -163,7 +165,7 @@ collateralize_Manage() {
collateralize_Create() { collateralize_Create() {
echo "========== # collateralize create begin ==========" echo "========== # collateralize create begin =========="
tx=$(curl -ksd '{"method":"Chain33.CreateTransaction","params":[{"execer":"collateralize","actionName":"CollateralizeCreate","payload":{"debtCeiling":"1000.1", "totalBalance":"10000.1"}}]}' ${MAIN_HTTP} | jq -r ".result") tx=$(curl -ksd '{"method":"Chain33.CreateTransaction","params":[{"execer":"collateralize","actionName":"CollateralizeCreate","payload":{"debtCeiling":1000.1, "totalBalance":10000.1}}]}' ${MAIN_HTTP} | jq -r ".result")
data=$(curl -ksd '{"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'"$tx"'"}]}' ${MAIN_HTTP} | jq -r ".result.txs[0]") data=$(curl -ksd '{"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'"$tx"'"}]}' ${MAIN_HTTP} | jq -r ".result.txs[0]")
ok=$(jq '(.execer != "")' <<<"$data") ok=$(jq '(.execer != "")' <<<"$data")
...@@ -206,7 +208,7 @@ collateralize_Feed() { ...@@ -206,7 +208,7 @@ collateralize_Feed() {
collateralize_Borrow() { collateralize_Borrow() {
echo "========== # collateralize borrow begin ==========" echo "========== # collateralize borrow begin =========="
tx=$(curl -ksd '{"method":"Chain33.CreateTransaction","params":[{"execer":"collateralize","actionName":"CollateralizeBorrow","payload":{"collateralizeId":"'"${COLL_ID}"'", "value":100.1}}]}' ${MAIN_HTTP} | jq -r ".result") tx=$(curl -ksd '{"method":"Chain33.CreateTransaction","params":[{"execer":"collateralize","actionName":"CollateralizeBorrow","payload":{"collateralizeId":"'"${COLL_ID}"'", "value":10.1}}]}' ${MAIN_HTTP} | jq -r ".result")
data=$(curl -ksd '{"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'"$tx"'"}]}' ${MAIN_HTTP} | jq -r ".result.txs[0]") data=$(curl -ksd '{"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'"$tx"'"}]}' ${MAIN_HTTP} | jq -r ".result.txs[0]")
ok=$(jq '(.execer != "")' <<<"$data") ok=$(jq '(.execer != "")' <<<"$data")
...@@ -313,6 +315,9 @@ init() { ...@@ -313,6 +315,9 @@ init() {
chain33_applyCoins "${CollateralizeAddr}" 12000000000 "${main_ip}" chain33_applyCoins "${CollateralizeAddr}" 12000000000 "${main_ip}"
chain33_QueryBalance "${CollateralizeAddr}" "$main_ip" chain33_QueryBalance "${CollateralizeAddr}" "$main_ip"
chain33_applyCoins "${TokenAddr}" 12000000000 "${main_ip}"
chain33_QueryBalance "${TokenAddr}" "$main_ip"
else else
# tx fee # tx fee
chain33_applyCoins ${IssuanceAddr1} 1000000000 "${main_ip}" chain33_applyCoins ${IssuanceAddr1} 1000000000 "${main_ip}"
...@@ -327,6 +332,9 @@ init() { ...@@ -327,6 +332,9 @@ init() {
chain33_applyCoins "${CollateralizeAddr}" 1000000000 "${main_ip}" chain33_applyCoins "${CollateralizeAddr}" 1000000000 "${main_ip}"
chain33_QueryBalance "${CollateralizeAddr}" "$main_ip" chain33_QueryBalance "${CollateralizeAddr}" "$main_ip"
chain33_applyCoins "${TokenAddr}" 1000000000 "${main_ip}"
chain33_QueryBalance "${TokenAddr}" "$main_ip"
local para_ip="${MAIN_HTTP}" local para_ip="${MAIN_HTTP}"
#para chain import pri key #para chain import pri key
#1C9t6uNcmbUgebt9HZfKweNb58hUcq5MZY #1C9t6uNcmbUgebt9HZfKweNb58hUcq5MZY
...@@ -391,7 +399,7 @@ manage() { ...@@ -391,7 +399,7 @@ manage() {
# #
# chain33_SignRawTx "$tx" ${SystemManager} ${MAIN_HTTP} # chain33_SignRawTx "$tx" ${SystemManager} ${MAIN_HTTP}
# echo "========== # issuance add issuance-guarantor end ==========" # echo "========== # issuance add issuance-guarantor end =========="
chain33_BlockWait 1 ${MAIN_HTTP} # chain33_BlockWait 1 ${MAIN_HTTP}
} }
token() { token() {
...@@ -421,7 +429,7 @@ token() { ...@@ -421,7 +429,7 @@ token() {
chain33_BlockWait 1 ${MAIN_HTTP} chain33_BlockWait 1 ${MAIN_HTTP}
echo "========== # issuance add token precreate begin ==========" echo "========== # issuance add token precreate begin =========="
tx=$(curl -ksd '{"method":"Chain33.CreateRawTokenPreCreateTx","params":[{"name": "ccny", "symbol": "CCNY", "total": 100000000, "price": 1, "category": 1,"owner":"'${TokenAddr}'"}]}' ${MAIN_HTTP} | jq -r ".result") tx=$(curl -ksd '{"method":"token.CreateRawTokenPreCreateTx","params":[{"name": "ccny", "symbol": "CCNY", "total": 10000000000000000, "price": 0, "category": 1,"owner":"'${TokenAddr}'"}]}' ${MAIN_HTTP} | jq -r ".result")
data=$(curl -ksd '{"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'"$tx"'"}]}' ${MAIN_HTTP} | jq -r ".result.txs[0]") data=$(curl -ksd '{"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'"$tx"'"}]}' ${MAIN_HTTP} | jq -r ".result.txs[0]")
ok=$(jq '(.execer != "")' <<<"$data") ok=$(jq '(.execer != "")' <<<"$data")
...@@ -433,7 +441,7 @@ token() { ...@@ -433,7 +441,7 @@ token() {
chain33_BlockWait 1 ${MAIN_HTTP} chain33_BlockWait 1 ${MAIN_HTTP}
echo "========== # issuance add token finish begin ==========" echo "========== # issuance add token finish begin =========="
tx=$(curl -ksd '{"method":"Chain33.CreateRawTokenFinishTx","params":[{"symbol": "CCNY", "owner":"'${TokenAddr}'"}]}' ${MAIN_HTTP} | jq -r ".result") tx=$(curl -ksd '{"method":"token.CreateRawTokenFinishTx","params":[{"symbol": "CCNY", "owner":"'${TokenAddr}'"}]}' ${MAIN_HTTP} | jq -r ".result")
data=$(curl -ksd '{"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'"$tx"'"}]}' ${MAIN_HTTP} | jq -r ".result.txs[0]") data=$(curl -ksd '{"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'"$tx"'"}]}' ${MAIN_HTTP} | jq -r ".result.txs[0]")
ok=$(jq '(.execer != "")' <<<"$data") ok=$(jq '(.execer != "")' <<<"$data")
...@@ -445,7 +453,7 @@ token() { ...@@ -445,7 +453,7 @@ token() {
chain33_BlockWait 1 ${MAIN_HTTP} chain33_BlockWait 1 ${MAIN_HTTP}
echo "========== # issuance add token transfer begin ==========" echo "========== # issuance add token transfer begin =========="
tx=$(curl -ksd '{"method":"Chain33.CreateTransaction","params":[{"execer": "token","actionName":"Transfer","payload": {"cointoken":"CCNY", "amount": "100000", "note": "", "to": "'"${IssuanceAddr1}"'"}}]}' ${MAIN_HTTP} | jq -r ".result") tx=$(curl -ksd '{"method":"Chain33.CreateTransaction","params":[{"execer": "token","actionName":"Transfer","payload": {"cointoken":"CCNY", "amount": "10000000000000", "note": "", "to": "'"${IssuanceAddr1}"'"}}]}' ${MAIN_HTTP} | jq -r ".result")
data=$(curl -ksd '{"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'"$tx"'"}]}' ${MAIN_HTTP} | jq -r ".result.txs[0]") data=$(curl -ksd '{"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'"$tx"'"}]}' ${MAIN_HTTP} | jq -r ".result.txs[0]")
ok=$(jq '(.execer != "")' <<<"$data") ok=$(jq '(.execer != "")' <<<"$data")
...@@ -454,7 +462,16 @@ token() { ...@@ -454,7 +462,16 @@ token() {
chain33_SignRawTx "${tx}" "${TokenSuperManager}" "${MAIN_HTTP}" chain33_SignRawTx "${tx}" "${TokenSuperManager}" "${MAIN_HTTP}"
tx=$(curl -ksd '{"method":"Chain33.CreateTransaction","params":[{"execer": "token","actionName":"Transfer","payload": {"cointoken":"CCNY", "amount": "1000", "note": "", "to": "'"${CollateralizeAddr}"'"}}]}' ${MAIN_HTTP} | jq -r ".result") tx=$(curl -ksd '{"method":"Chain33.CreateTransaction","params":[{"execer": "token","actionName":"Transfer","payload": {"cointoken":"CCNY", "amount": "10000000000000", "note": "", "to": "'"${IssuanceAddr3}"'"}}]}' ${MAIN_HTTP} | jq -r ".result")
data=$(curl -ksd '{"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'"$tx"'"}]}' ${MAIN_HTTP} | jq -r ".result.txs[0]")
ok=$(jq '(.execer != "")' <<<"$data")
[ "$ok" == true ]
echo_rst "$FUNCNAME" "$?"
chain33_SignRawTx "${tx}" "${TokenSuperManager}" "${MAIN_HTTP}"
tx=$(curl -ksd '{"method":"Chain33.CreateTransaction","params":[{"execer": "token","actionName":"Transfer","payload": {"cointoken":"CCNY", "amount": "100000000000", "note": "", "to": "'"${CollateralizeAddr}"'"}}]}' ${MAIN_HTTP} | jq -r ".result")
data=$(curl -ksd '{"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'"$tx"'"}]}' ${MAIN_HTTP} | jq -r ".result.txs[0]") data=$(curl -ksd '{"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'"$tx"'"}]}' ${MAIN_HTTP} | jq -r ".result.txs[0]")
ok=$(jq '(.execer != "")' <<<"$data") ok=$(jq '(.execer != "")' <<<"$data")
...@@ -464,6 +481,36 @@ token() { ...@@ -464,6 +481,36 @@ token() {
chain33_SignRawTx "${tx}" "${TokenSuperManager}" "${MAIN_HTTP}" chain33_SignRawTx "${tx}" "${TokenSuperManager}" "${MAIN_HTTP}"
echo "========== # issuance add token transfer end ==========" echo "========== # issuance add token transfer end =========="
chain33_BlockWait 1 ${MAIN_HTTP} chain33_BlockWait 1 ${MAIN_HTTP}
echo "========== # issuance add token transfer to issuance begin =========="
tx=$(curl -ksd '{"method":"Chain33.CreateTransaction","params":[{"execer": "token","actionName":"Transfer","payload": {"cointoken":"CCNY", "amount": "10000000000000", "note": "", "to": "'"${issuance_addr}"'"}}]}' ${MAIN_HTTP} | jq -r ".result")
data=$(curl -ksd '{"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'"$tx"'"}]}' ${MAIN_HTTP} | jq -r ".result.txs[0]")
ok=$(jq '(.execer != "")' <<<"$data")
[ "$ok" == true ]
echo_rst "$FUNCNAME" "$?"
chain33_SignRawTx "${tx}" "${IssuancePriv1}" "${MAIN_HTTP}"
tx=$(curl -ksd '{"method":"Chain33.CreateTransaction","params":[{"execer": "token","actionName":"Transfer","payload": {"cointoken":"CCNY", "amount": "10000000000000", "note": "", "to": "'"${collateralize_addr}"'"}}]}' ${MAIN_HTTP} | jq -r ".result")
data=$(curl -ksd '{"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'"$tx"'"}]}' ${MAIN_HTTP} | jq -r ".result.txs[0]")
ok=$(jq '(.execer != "")' <<<"$data")
[ "$ok" == true ]
echo_rst "$FUNCNAME" "$?"
chain33_SignRawTx "${tx}" "${IssuancePriv3}" "${MAIN_HTTP}"
tx=$(curl -ksd '{"method":"Chain33.CreateTransaction","params":[{"execer": "token","actionName":"Transfer","payload": {"cointoken":"CCNY", "amount": "100000000000", "note": "", "to": "'"${collateralize_addr}"'"}}]}' ${MAIN_HTTP} | jq -r ".result")
data=$(curl -ksd '{"method":"Chain33.DecodeRawTransaction","params":[{"txHex":"'"$tx"'"}]}' ${MAIN_HTTP} | jq -r ".result.txs[0]")
ok=$(jq '(.execer != "")' <<<"$data")
[ "$ok" == true ]
echo_rst "$FUNCNAME" "$?"
chain33_SignRawTx "${tx}" "${CollateralizePriv}" "${MAIN_HTTP}"
echo "========== # issuance add token transfer to issuance end =========="
chain33_BlockWait 1 ${MAIN_HTTP}
} }
function issuance_test() { function issuance_test() {
...@@ -481,10 +528,10 @@ function issuance_test() { ...@@ -481,10 +528,10 @@ function issuance_test() {
} }
function collateralize_test() { function collateralize_test() {
collateralize_Create
collateralize_Manage collateralize_Manage
collateralize_Create
collateralize_Feed collateralize_Feed
collateralize_Borrow collateralize_Borrow
...@@ -503,6 +550,7 @@ function main() { ...@@ -503,6 +550,7 @@ function main() {
init init
manage manage
token
issuance_test issuance_test
collateralize_test collateralize_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