Commit 0d1d05f0 authored by vipwzw's avatar vipwzw

auto ci

parent 080e43fa
......@@ -328,7 +328,7 @@ function transfer() {
}
function base_config() {
# sync
# sync
transfer "${CLI}"
# transfer "${CLI4}"
}
......@@ -338,10 +338,10 @@ function base_test() {
system_test_rpc "http://${1}:8801"
dapp_test_rpc "http://${1}:8801"
fi
# if [ "$DAPP" == "paracross" ]; then
# system_test_rpc "http://${1}:8901"
# dapp_test_rpc "http://${1}:8901"
# fi
# if [ "$DAPP" == "paracross" ]; then
# system_test_rpc "http://${1}:8901"
# dapp_test_rpc "http://${1}:8901"
# fi
}
function dapp_run() {
......
......@@ -6,7 +6,6 @@ strapp=${strcmd%/cmd*}
OUT_DIR="${1}/$strapp"
PARACLI="${OUT_DIR}/chain33-para-cli"
PARANAME=para
SRC_CLI=github.com/33cn/plugin/cli
......
......@@ -43,7 +43,7 @@ function query_tx() {
ret=$(curl -ksd "{$req}" ${MAIN_HTTP} | jq -r ".result.tx.hash")
echo "====query tx= ${1} "
if [ "${ret}" != "${1}" ]; then
block_wait 1
block_wait 1
times=$((times - 1))
if [ $times -le 0 ]; then
echo "====query tx=$1 failed"
......@@ -61,46 +61,46 @@ Chain33_SendToAddress() {
to="$2"
amount=$3
req='"method":"Chain33.SendToAddress", "params":[{"from":"'"$from"'","to":"'"$to"'", "amount":'"$amount"', "note":"test\n"}]'
# echo "#request: $req"
# echo "#request: $req"
resp=$(curl -ksd "{$req}" "${MAIN_HTTP}")
echo "#response: $resp"
echo "#response: $resp"
ok=$(jq '(.error|not) and (.result.hash|length==66)' <<<"$resp")
[ "$ok" == true ]
echo_rst "$FUNCNAME" "$?"
}
signrawtx(){
signrawtx() {
txHex="$1"
priKey="$2"
req='"method":"Chain33.SignRawTx","params":[{"privkey":"'"$priKey"'","txHex":"'"$txHex"'","expire":"120s"}]'
# echo "#request SignRawTx: $req"
signedTx=$(curl -ksd "{$req}" ${MAIN_HTTP} |jq -r ".result")
# echo "signedTx=$signedTx"
if [ "$signedTx" != null ];then
# echo "#request SignRawTx: $req"
signedTx=$(curl -ksd "{$req}" ${MAIN_HTTP} | jq -r ".result")
# echo "signedTx=$signedTx"
if [ "$signedTx" != null ]; then
sendTx "$signedTx"
else
echo "signedTx null error"
fi
}
sendTx(){
sendTx() {
signedTx=$1
req='"method":"Chain33.SendTransaction","params":[{"token":"BTY","data":"'"$signedTx"'"}]'
# echo "#request sendTx: $req"
# curl -ksd "{$req}" ${MAIN_HTTP}
resp=$(curl -ksd "{$req}" ${MAIN_HTTP})
err=$(jq '(.error)' <<< "$resp")
txhash=$(jq -r ".result" <<< "$resp")
if [ "$err" == null ];then
err=$(jq '(.error)' <<<"$resp")
txhash=$(jq -r ".result" <<<"$resp")
if [ "$err" == null ]; then
echo "tx hash: $txhash"
query_tx "$txhash"
else
echo "send tx error:$err"
fi
}
relay_CreateRawRelayOrderTx() {
req='"method":"relay.CreateRawRelayOrderTx","params":[{"operation":0,"coin":"BTC","amount":299000000,"addr":"1Am9UTGfdnxabvcywYG2hvzr6qK8T3oUZT","btyAmount":20000000000,"coinWaits":6}]'
# echo "#request: $req"
......@@ -116,8 +116,8 @@ relay_CreateRawRelayOrderTx() {
relay_CreateRawRelayAcceptTx() {
req='"method":"Chain33.Query", "params":[{"execer":"relay","funcName":"GetSellRelayOrder","payload":{"addr":"12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv","status":"pending","coins":["BTC"],"pageNumber":0,"pageSize":0}}]'
# echo "#request: $req"
id=$(curl -ksd "{$req}" ${MAIN_HTTP} |jq -r ".result.relayorders[0].id")
if [ "$id" == null ];then
id=$(curl -ksd "{$req}" ${MAIN_HTTP} | jq -r ".result.relayorders[0].id")
if [ "$id" == null ]; then
echo "id is null"
echo_rst "$FUNCNAME" "$?"
exit 1
......@@ -138,8 +138,8 @@ relay_CreateRawRelayAcceptTx() {
relay_CreateRawRelayRevokeTx() {
req='"method":"Chain33.Query", "params":[{"execer":"relay","funcName":"GetSellRelayOrder","payload":{"addr":"12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv","status":"pending","coins":["BTC"],"pageNumber":0,"pageSize":0}}]'
# echo "#request: $req"
id=$(curl -ksd "{$req}" ${MAIN_HTTP} |jq -r ".result.relayorders[0].id")
if [ "$id" == null ];then
id=$(curl -ksd "{$req}" ${MAIN_HTTP} | jq -r ".result.relayorders[0].id")
if [ "$id" == null ]; then
echo "id is null"
echo_rst "$FUNCNAME" "$?"
exit 1
......@@ -155,14 +155,13 @@ relay_CreateRawRelayRevokeTx() {
rawtx=$(jq -r ".result" <<<"$resp")
signrawtx "$rawtx" "4257D8692EF7FE13C68B65D6A52F03933DB2FA5CE8FAF210B5B8B80C721CED01"
}
relay_CreateRawRelayConfirmTx() {
req='"method":"Chain33.Query", "params":[{"execer":"relay","funcName":"GetRelayOrderByStatus","payload":{"addr":"","status":"locking","coins":["BTC"],"pageNumber":0,"pageSize":0}}]'
# echo "#request: $req"
id=$(curl -ksd "{$req}" ${MAIN_HTTP} |jq -r ".result.relayorders[0].id")
if [ "$id" == null ];then
id=$(curl -ksd "{$req}" ${MAIN_HTTP} | jq -r ".result.relayorders[0].id")
if [ "$id" == null ]; then
echo "id is null"
echo_rst "$FUNCNAME" "$?"
exit 1
......@@ -180,8 +179,6 @@ relay_CreateRawRelayConfirmTx() {
}
relay_CreateRawRelaySaveBTCHeadTx() {
req='"method":"relay.CreateRawRelaySaveBTCHeadTx","params":[{"hash":"5e7d9c599cd040ec2ba53f4dee28028710be8c135e779f65c56feadaae34c3f2","height":10,"version":536870912,"merkleRoot":"ab91cd4160e1379c337eee6b7a4bdbb7399d70268d86045aba150743c00c90b6","time":1530862108,"nonce":0,"bits":545259519,"previousHash":"604efe53975ab06cad8748fd703ad5bc960e8b752b2aae98f0f871a4a05abfc7","isReset":true}]'
# echo "#request: $req"
......@@ -208,11 +205,10 @@ relay_CreateRawRelaySaveBTCHeadTx_11() {
}
query_GetRelayOrderByStatus(){
query_GetRelayOrderByStatus() {
status="$1"
req='"method":"Chain33.Query", "params":[{"execer":"relay","funcName":"GetRelayOrderByStatus","payload":{"addr":"","status":"'"$status"'","coins":["BTC"],"pageNumber":0,"pageSize":0}}]'
# echo "#request: $req"
# echo "#request: $req"
resp=$(curl -ksd "{$req}" ${MAIN_HTTP})
# echo "#response: $resp"
ok=$(jq '(.error|not) and (.result.relayorders[0].id != "")' <<<"$resp")
......@@ -220,7 +216,7 @@ query_GetRelayOrderByStatus(){
echo_rst "$FUNCNAME" "$?"
}
query_GetSellRelayOrder(){
query_GetSellRelayOrder() {
req='"method":"Chain33.Query", "params":[{"execer":"relay","funcName":"GetSellRelayOrder","payload":{"addr":"12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv","status":"pending","coins":["BTC"],"pageNumber":0,"pageSize":0}}]'
# echo "#request: $req"
resp=$(curl -ksd "{$req}" ${MAIN_HTTP})
......@@ -231,7 +227,7 @@ query_GetSellRelayOrder(){
}
query_GetBuyRelayOrder(){
query_GetBuyRelayOrder() {
req='"method":"Chain33.Query", "params":[{"execer":"relay","funcName":"GetBuyRelayOrder","payload":{"addr":"14KEKbYtKKQm4wMthSK9J4La4nAiidGozt","status":"locking","coins":["BTC"],"pageNumber":0,"pageSize":0}}]'
# echo "#request: $req"
resp=$(curl -ksd "{$req}" ${MAIN_HTTP})
......@@ -242,40 +238,40 @@ query_GetBuyRelayOrder(){
}
query_GetBTCHeaderList(){
query_GetBTCHeaderList() {
req='"method":"Chain33.Query", "params":[{"execer":"relay","funcName":"GetBTCHeaderList","payload":{"reqHeight":"10","counts":10,"direction":0}}]'
# echo "#request: $req"
# echo "#request: $req"
resp=$(curl -ksd "{$req}" ${MAIN_HTTP})
echo "#response: $resp"
echo "#response: $resp"
ok=$(jq '(.error|not) and (.result.heights|length == 2)' <<<"$resp")
[ "$ok" == true ]
echo_rst "$FUNCNAME" "$?"
}
query_GetBTCHeaderCurHeight(){
query_GetBTCHeaderCurHeight() {
req='"method":"Chain33.Query", "params":[{"execer":"relay","funcName":"GetBTCHeaderCurHeight","payload":{"baseHeight":"0"}}]'
# echo "#request: $req"
# echo "#request: $req"
resp=$(curl -ksd "{$req}" ${MAIN_HTTP})
echo "#response: $resp"
echo "#response: $resp"
ok=$(jq '(.error|not) and (.result.baseHeight == "10") and (.result.curHeight == "10")' <<<"$resp")
[ "$ok" == true ]
echo_rst "$FUNCNAME" "$?"
}
init(){
init() {
from="12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
exec_relay_addr="1rhRgzbz264eyJu7Ac63wepsm9TsEpwXM"
Chain33_SendToAddress "$from" "$exec_relay_addr" 100000000000
to="14KEKbYtKKQm4wMthSK9J4La4nAiidGozt"
Chain33_SendToAddress "$from" "$to" 50000000000
block_wait 1
block_wait 1
from="14KEKbYtKKQm4wMthSK9J4La4nAiidGozt"
Chain33_SendToAddress "$from" "$exec_relay_addr" 20000000000
block_wait 1
block_wait 1
}
function run_testcases() {
......@@ -300,8 +296,8 @@ function run_testcases() {
relay_CreateRawRelaySaveBTCHeadTx_11
query_GetBTCHeaderList
}
function rpc_test() {
MAIN_HTTP="$1"
echo "main_ip=$MAIN_HTTP"
......
......@@ -564,4 +564,3 @@ func relaySaveBtcHead(cmd *cobra.Command, args []string) {
ctx := jsonclient.NewRPCCtx(rpcLaddr, "relay.CreateRawRelaySaveBTCHeadTx", params, &res)
ctx.RunWithoutMarshal()
}
......@@ -34,7 +34,6 @@ func (r *relay) Exec_Verify(payload *rty.RelayVerify, tx *types.Transaction, ind
return action.verifyTx(payload)
}
func (r *relay) Exec_BtcHeaders(payload *rty.BtcHeaders, tx *types.Transaction, index int) (*types.Receipt, error) {
action := newRelayDB(r, tx)
return action.saveBtcHeader(payload, r.GetLocalDB())
......
......@@ -41,8 +41,6 @@ func createRawRelayConfirmTx(parm *ty.RelayConfirmTx) ([]byte, error) {
return types.CallCreateTx(types.ExecName(ty.RelayX), "ConfirmTx", parm)
}
func createRawRelaySaveBTCHeadTx(parm *ty.BtcHeader) ([]byte, error) {
if parm == nil {
return nil, types.ErrInvalidParam
......@@ -52,8 +50,8 @@ func createRawRelaySaveBTCHeadTx(parm *ty.BtcHeader) ([]byte, error) {
PreviousHash: parm.PreviousHash,
MerkleRoot: parm.MerkleRoot,
Height: parm.Height,
Version: parm.Version,
Time: parm.Time,
Version: parm.Version,
Time: parm.Time,
Nonce: parm.Nonce,
Bits: parm.Bits,
IsReset: parm.IsReset,
......
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