Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
plugin
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
link33
plugin
Commits
0d1d05f0
Commit
0d1d05f0
authored
May 14, 2019
by
vipwzw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto ci
parent
080e43fa
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
40 additions
and
49 deletions
+40
-49
docker-compose.sh
build/docker-compose.sh
+5
-5
build.sh
plugin/dapp/paracross/cmd/build.sh
+0
-1
test-rpc.sh
plugin/dapp/relay/cmd/test/test-rpc.sh
+33
-37
relay.go
plugin/dapp/relay/commands/relay.go
+0
-1
exec.go
plugin/dapp/relay/executor/exec.go
+0
-1
rpc.go
plugin/dapp/relay/rpc/rpc.go
+2
-4
No files found.
build/docker-compose.sh
View file @
0d1d05f0
...
...
@@ -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
()
{
...
...
plugin/dapp/paracross/cmd/build.sh
View file @
0d1d05f0
...
...
@@ -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
...
...
plugin/dapp/relay/cmd/test/test-rpc.sh
View file @
0d1d05f0
...
...
@@ -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
"
...
...
plugin/dapp/relay/commands/relay.go
View file @
0d1d05f0
...
...
@@ -564,4 +564,3 @@ func relaySaveBtcHead(cmd *cobra.Command, args []string) {
ctx
:=
jsonclient
.
NewRPCCtx
(
rpcLaddr
,
"relay.CreateRawRelaySaveBTCHeadTx"
,
params
,
&
res
)
ctx
.
RunWithoutMarshal
()
}
plugin/dapp/relay/executor/exec.go
View file @
0d1d05f0
...
...
@@ -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
())
...
...
plugin/dapp/relay/rpc/rpc.go
View file @
0d1d05f0
...
...
@@ -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
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment