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
b375d231
Unverified
Commit
b375d231
authored
Aug 14, 2020
by
33cn
Committed by
GitHub
Aug 14, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #900 from YingQm/fix-x2eth-test
Fix x2eth test
parents
d484af83
39056dfa
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
506 additions
and
330 deletions
+506
-330
dapp-test-rpc.sh
build/dapp-test-rpc.sh
+3
-3
docker-compose-down.sh
build/docker-compose-down.sh
+0
-7
docker-compose-pre.sh
build/docker-compose-pre.sh
+1
-3
docker-compose.sh
build/docker-compose.sh
+6
-6
Dockerfile-x2ethrelay
plugin/dapp/x2ethereum/cmd/build/Dockerfile-x2ethrelay
+10
-0
allRelayerTest.sh
plugin/dapp/x2ethereum/cmd/build/allRelayerTest.sh
+102
-69
docker-compose-ebrelayer.yml
...in/dapp/x2ethereum/cmd/build/docker-compose-ebrelayer.yml
+11
-0
docker-compose-x2Ethereum.yml
...n/dapp/x2ethereum/cmd/build/docker-compose-x2Ethereum.yml
+0
-7
docker-compose-x2ethereum.yml
...n/dapp/x2ethereum/cmd/build/docker-compose-x2ethereum.yml
+27
-0
perf_test.sh
plugin/dapp/x2ethereum/cmd/build/perf_test.sh
+30
-33
publicTest.sh
plugin/dapp/x2ethereum/cmd/build/publicTest.sh
+174
-21
test-rpc.sh
plugin/dapp/x2ethereum/cmd/test/test-rpc.sh
+113
-173
commands.go
plugin/dapp/x2ethereum/commands/commands.go
+0
-1
main.go
plugin/dapp/x2ethereum/ebcli/main.go
+26
-6
relayer.toml
plugin/dapp/x2ethereum/ebrelayer/relayer.toml
+1
-1
config.pb.go
plugin/dapp/x2ethereum/ebrelayer/types/config.pb.go
+1
-0
config.proto
plugin/dapp/x2ethereum/ebrelayer/types/protos/config.proto
+1
-0
No files found.
build/dapp-test-rpc.sh
View file @
b375d231
...
...
@@ -6,7 +6,7 @@ DAPP_TEST_COMMON=dapp-test-common.sh
function
dapp_test_rpc
()
{
local
ip
=
$1
local
node3
=
$2
local
dockerNamePrefix
=
$2
echo
"============ # dapp rpc test begin ============="
if
[
-d
dapptest
]
;
then
cp
"
$DAPP_TEST_COMMON
"
dapptest/
...
...
@@ -15,10 +15,10 @@ function dapp_test_rpc() {
rm
-f
"jobsTicket.log"
rm
-rf
"outdir"
dapps
=
$(
find
.
-maxdepth
1
-type
d
!
-name
dapptest
!
-name
ticket
!
-name
x2ethereum
!
-name
.
|
sed
's/^\.\///'
|
sort
)
dapps
=
$(
find
.
-maxdepth
1
-type
d
!
-name
dapptest
!
-name
ticket
!
-name
.
|
sed
's/^\.\///'
|
sort
)
echo
"dapps list:
$dapps
"
set
+e
parallel
-k
--jobs
40
--results
outdir
--joblog
./jobs.log ./
{}
/
"
${
RPC_TESTFILE
}
"
"
$ip
"
"
$
node3
"
:::
"
$dapps
"
parallel
-k
--jobs
40
--results
outdir
--joblog
./jobs.log ./
{}
/
"
${
RPC_TESTFILE
}
"
"
$ip
"
"
$
dockerNamePrefix
"
:::
"
$dapps
"
local
ret
=
$?
parallel
-k
--jobs
1
--results
outdir
--joblog
./jobsTicket.log ./
{}
/
"
${
RPC_TESTFILE
}
"
"
$ip
"
:::
"ticket"
local
retTicket
=
$?
...
...
build/docker-compose-down.sh
View file @
b375d231
...
...
@@ -41,13 +41,6 @@ function down() {
echo
"=========== # docker-compose down ============="
docker-compose down
--rmi
local
fi
# shellcheck disable=SC2155
local
isGanacheExit
=
$(
docker ps |
grep
ganachetest
)
if
[[
${
isGanacheExit
}
!=
""
]]
;
then
docker stop ganachetest
docker
rm
ganachetest
fi
}
# run script
...
...
build/docker-compose-pre.sh
View file @
b375d231
...
...
@@ -67,7 +67,6 @@ function run_dapp() {
fi
cd
..
echo
"============ run dapp=
$app
end ================="
}
function
run_single_app
()
{
...
...
@@ -101,7 +100,7 @@ function main() {
echo
"============ run main end ================="
find
.
-maxdepth
1
-type
d
-name
"*-ci"
-exec
rm
-rf
{}
\;
dir
=
$(
find
.
-maxdepth
1
-type
d
!
-name
system
!
-name
x2ethereum
!
-name
.
|
sed
's/^\.\///'
)
dir
=
$(
find
.
-maxdepth
1
-type
d
!
-name
system
!
-name
.
|
sed
's/^\.\///'
)
for
app
in
$dir
;
do
run_single_app
"
${
app
}
"
"
$TESTCASEFILE
"
"down"
done
...
...
@@ -145,7 +144,6 @@ function main() {
elif
[
"
${
OP
}
"
==
"modify"
]
;
then
sed
-i
$sedfix
'/^useGithub=.*/a version=1'
chain33.toml
fi
}
# run script
...
...
build/docker-compose.sh
View file @
b375d231
...
...
@@ -15,6 +15,9 @@ set -o pipefail
PWD
=
$(
cd
"
$(
dirname
"
$0
"
)
"
&&
pwd
)
export
PATH
=
"
$PWD
:
$PATH
"
dockerNamePrefix
=
"
${
1
}
"
echo
"dockerNamePrefix :
${
dockerNamePrefix
}
"
NODE3
=
"
${
1
}
_chain33_1"
CLI
=
"docker exec
${
NODE3
}
/root/chain33-cli"
...
...
@@ -58,9 +61,7 @@ if [ -n "${DAPP}" ]; then
DAPP_COMPOSE_FILE
=
"docker-compose-
${
DAPP
}
.yml"
if
[
-e
"
$DAPP_COMPOSE_FILE
"
]
;
then
export
COMPOSE_FILE
=
"docker-compose.yml:
${
DAPP_COMPOSE_FILE
}
"
fi
fi
if
[
-z
"
$DAPP
"
]
||
[
"
$DAPP
"
==
"paracross"
]
;
then
...
...
@@ -462,29 +463,28 @@ function dapp_test_address() {
function
base_config
()
{
# sync
transfer
"
${
CLI
}
"
# transfer "${CLI4}"
}
function
rpc_test
()
{
if
[
"
$DAPP
"
==
""
]
;
then
system_test_rpc
"http://
${
1
}
:8801"
dapp_test_address
"
${
CLI
}
"
dapp_test_rpc
"http://
${
1
}
:8801"
"
${
NODE3
}
"
dapp_test_rpc
"http://
${
1
}
:8801"
"
${
dockerNamePrefix
}
"
fi
if
[
"
$DAPP
"
==
"paracross"
]
;
then
system_test_rpc
"http://
${
1
}
:8901"
dapp_test_address
"
${
CLI
}
"
dapp_test_rpc
"http://
${
1
}
:8901"
fi
}
function
dapp_run
()
{
if
[
-e
"
$DAPP_TEST_FILE
"
]
;
then
${
DAPP
}
"
${
CLI
}
"
"
${
1
}
"
"
${
2
}
"
fi
}
function
main
()
{
echo
"==============================DAPP=
$DAPP
main begin========================================================"
### init para ####
...
...
plugin/dapp/x2ethereum/cmd/build/Dockerfile-x2ethrelay
0 → 100644
View file @
b375d231
FROM ubuntu:16.04
WORKDIR /root
COPY relayer.toml relayer.toml
COPY ebrelayer ebrelayer
COPY ebcli_A ebcli_A
EXPOSE 20000
CMD ["/root/ebrelayer"]
plugin/dapp/x2ethereum/cmd/build/allRelayerTest.sh
View file @
b375d231
...
...
@@ -6,13 +6,6 @@ set +e
source
"./publicTest.sh"
CLIA
=
"./ebcli_A"
CLIB
=
"./ebcli_B"
CLIC
=
"./ebcli_C"
CLID
=
"./ebcli_D"
Chain33Cli
=
"docker exec
${
NODE3
}
/root/chain33-cli"
chain33SenderAddr
=
"14KEKbYtKKQm4wMthSK9J4La4nAiidGozt"
# validatorsAddr=["0x92c8b16afd6d423652559c6e266cbe1c29bfd84f", "0x0df9a824699bc5878232c9e612fe1a5346a5a368", "0xcb074cb21cdddf3ce9c3c0a7ac4497d633c9d9f1", "0xd9dab021e74ecf475788ed7b61356056b2095830"]
ethValidatorAddrKeyA
=
"3fa21584ae2e4fd74db9b58e2386f5481607dfa4d7ba0617aaa7858e5025dc1e"
...
...
@@ -36,25 +29,32 @@ ethReceiverAddrKey2="9dc6df3a8ab139a54d8a984f54958ae0661f880229bf3bdbb886b87d58b
maturityDegree
=
10
tokenAddrBty
=
""
tokenAddr
=
""
ethUrl
=
""
Chain33Cli
=
""
portRelayer
=
20000
function
kill_ebrelayerC
()
{
kill_ebrelayer
"./C/ebrelayer"
#shellcheck disable=SC2154
docker stop
"
${
dockerNamePrefix
}
_ebrelayerc_1"
}
function
kill_ebrelayerD
()
{
kill_ebrelayer
"./D/ebrelayer
"
docker stop
"
${
dockerNamePrefix
}
_ebrelayerd_1
"
}
function
start_ebrelayerC
()
{
start_ebrelayer
"./C/ebrelayer"
"./C/ebrelayer.log"
docker start
"
${
dockerNamePrefix
}
_ebrelayerc_1"
sleep
5
${
CLIC
}
relayer unlock
-p
123456hzj
sleep
5
eth_block_wait
$((
maturityDegree
+
2
))
eth_block_wait
$((
maturityDegree
+
2
))
"
${
ethUrl
}
"
sleep
10
}
function
start_ebrelayerD
()
{
start_ebrelayer
"./D/ebrelayer"
"./D/ebrelayer.log"
docker start
"
${
dockerNamePrefix
}
_ebrelayerd_1"
sleep
5
${
CLID
}
relayer unlock
-p
123456hzj
sleep
5
eth_block_wait
$((
maturityDegree
+
2
))
eth_block_wait
$((
maturityDegree
+
2
))
"
${
ethUrl
}
"
sleep
10
}
...
...
@@ -72,14 +72,73 @@ function InitAndDeploy() {
echo
-e
"
${
GRE
}
===========
$FUNCNAME
end ===========
${
NOC
}
"
}
function
port_exist
()
{
local
prot_ori
=
${
portRelayer
}
grep_port
=
$(
netstat
-tlpn
|
grep
"
\b
${
portRelayer
}
\b
"
)
while
[
-n
"
$grep_port
"
]
;
do
echo
"port
$portRelayer
is in use"
portRelayer
=
$((
portRelayer
+
4
))
grep_port
=
$(
netstat
-tlpn
|
grep
"
\b
${
portRelayer
}
\b
"
)
done
if
[
"
${
portRelayer
}
"
!=
"
${
prot_ori
}
"
]
;
then
sed
-i
's/'
"
${
prot_ori
}
"
'/'
"
${
portRelayer
}
"
'/g'
"./docker-compose-ebrelayer.yml"
fi
}
function
StartRelayerAndDeploy
()
{
echo
-e
"
${
GRE
}
===========
$FUNCNAME
begin ===========
${
NOC
}
"
# stop all docker
docker-compose
-f
docker-compose-ebrelayer.yml down
for
name
in
b c d
;
do
docker-compose
-f
"docker-compose-ebrelayer
${
name
}
.yml"
down
done
# change EthProvider url
dockerAddr
=
$(
get_docker_addr
"
${
dockerNamePrefix
}
_ganachetest_1"
)
ethUrl
=
"http://
${
dockerAddr
}
:8545"
# shellcheck disable=SC2155
local
line
=
$(
delete_line_show
"./relayer.toml"
'EthProvider="ws:'
)
sed
-i
''
"
${
line
}
"
' a EthProvider="ws://'
"
${
dockerAddr
}
"
':8545/"'
"./relayer.toml"
line
=
$(
delete_line_show
"./relayer.toml"
'EthProviderCli="http:'
)
sed
-i
''
"
${
line
}
"
' a EthProviderCli="http://'
"
${
dockerAddr
}
"
':8545"'
"./relayer.toml"
port_exist
docker-compose
-f
docker-compose-ebrelayer.yml up
--build
-d
sleep
1
# 部署合约
InitAndDeploy
# 获取 BridgeRegistry 地址
result
=
$(${
CLIA
}
relayer ethereum bridgeRegistry
)
BridgeRegistry
=
$(
cli_ret
"
${
result
}
"
"bridgeRegistry"
".addr"
)
# kill_ebrelayer "./A/ebrelayer"
docker-compose
-f
docker-compose-ebrelayer.yml down
# 修改 relayer.toml 配置文件
port_exist
updata_relayer_toml
"
${
BridgeRegistry
}
"
${
maturityDegree
}
"./relayer.toml"
updata_docker_relayer_toml
"
${
portRelayer
}
"
docker-compose
-f
docker-compose-ebrelayer.yml up
--build
-d
for
name
in
b c d
;
do
docker-compose
-f
"docker-compose-ebrelayer
$name
.yml"
up
--build
-d
done
sleep
1
echo
-e
"
${
GRE
}
===========
$FUNCNAME
end ===========
${
NOC
}
"
}
function
EthImportKey
()
{
echo
-e
"
${
GRE
}
===========
$FUNCNAME
begin ===========
${
NOC
}
"
# 重启 ebrelayer 并解锁
for
name
in
A B C D
;
do
start_ebrelayer
"./
$name
/ebrelayer"
"./
$name
/ebrelayer.log"
for
name
in
a b c d
;
do
# 导入测试地址私钥
CLI
=
"./ebcli_
$name
"
# shellcheck disable=SC2154
CLI
=
"docker exec
${
dockerNamePrefix
}
_ebrelayer
${
name
}
_1 /root/ebcli_A"
result
=
$(${
CLI
}
relayer set_pwd
-p
123456hzj
)
...
...
@@ -108,38 +167,6 @@ function EthImportKey() {
echo
-e
"
${
GRE
}
===========
$FUNCNAME
end ===========
${
NOC
}
"
}
function
StartRelayerAndDeploy
()
{
echo
-e
"
${
GRE
}
===========
$FUNCNAME
begin ===========
${
NOC
}
"
for
name
in
A B C D
;
do
local
ebrelayer
=
"./
$name
/ebrelayer"
kill_ebrelayer
"
${
ebrelayer
}
"
done
sleep
1
rm
-rf
'./A'
'./B'
'./C'
'./D'
'./datadir'
'./ebrelayer.log'
'./logs'
mkdir
'./A'
'./B'
'./C'
'./D'
cp
'./relayer.toml'
'./A/relayer.toml'
cp
'./ebrelayer'
'./A/ebrelayer'
start_trufflesuite
start_ebrelayer
"./A/ebrelayer"
"./A/ebrelayer.log"
# 部署合约
InitAndDeploy
# 获取 BridgeRegistry 地址
result
=
$(${
CLIA
}
relayer ethereum bridgeRegistry
)
BridgeRegistry
=
$(
cli_ret
"
${
result
}
"
"bridgeRegistry"
".addr"
)
kill_ebrelayer
"./A/ebrelayer"
# 修改 relayer.toml 配置文件
updata_relayer_toml
"
${
BridgeRegistry
}
"
${
maturityDegree
}
"./A/relayer.toml"
updata_all_relayer_toml
echo
-e
"
${
GRE
}
===========
$FUNCNAME
end ===========
${
NOC
}
"
}
# chian33 添加验证着及权重
function
InitChain33Vilators
()
{
echo
-e
"
${
GRE
}
===========
$FUNCNAME
begin ===========
${
NOC
}
"
...
...
@@ -212,14 +239,14 @@ function TestChain33ToEthAssets() {
cli_ret
"
${
result
}
"
"balance"
".balance"
"0"
# chain33 lock bty
hash
=
$(${
Chain33Cli
}
send x2ethereum lock
-a
5
-t
coins.bty
-r
${
ethReceiverAddr1
}
-q
"
${
tokenAddrBty
}
"
-k
12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
)
hash
=
$(${
Chain33Cli
}
send x2ethereum lock
-a
5
-t
coins.bty
-r
${
ethReceiverAddr1
}
-q
"
${
tokenAddrBty
}
"
-
-node_addr
"
${
ethUrl
}
"
-
k
12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
)
block_wait
"
${
Chain33Cli
}
"
$((
maturityDegree
+
2
))
check_tx
"
${
Chain33Cli
}
"
"
${
hash
}
"
result
=
$(${
Chain33Cli
}
account balance
-a
12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
-e
x2ethereum
)
balance_ret
"
${
result
}
"
"195.0000"
eth_block_wait
$((
maturityDegree
+
2
))
eth_block_wait
$((
maturityDegree
+
2
))
"
${
ethUrl
}
"
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethReceiverAddr1
}
"
-t
"
${
tokenAddrBty
}
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"5"
...
...
@@ -232,7 +259,7 @@ function TestChain33ToEthAssets() {
cli_ret
"
${
result
}
"
"balance"
".balance"
"0"
# eth 等待 10 个区块
eth_block_wait
$((
maturityDegree
+
2
))
eth_block_wait
$((
maturityDegree
+
2
))
"
${
ethUrl
}
"
result
=
$(${
Chain33Cli
}
account balance
-a
"
${
chain33SenderAddr
}
"
-e
x2ethereum
)
balance_ret
"
${
result
}
"
"5"
...
...
@@ -260,7 +287,7 @@ function TestETH2Chain33Assets() {
cli_ret
"
${
result
}
"
"balance"
".balance"
"0.1"
# eth 等待 10 个区块
eth_block_wait
$((
maturityDegree
+
2
))
eth_block_wait
$((
maturityDegree
+
2
))
"
${
ethUrl
}
"
result
=
$(${
Chain33Cli
}
x2ethereum balance
-s
12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
-t
eth | jq
".res"
| jq
".[]"
)
balance_ret
"
${
result
}
"
"0.1"
...
...
@@ -268,14 +295,14 @@ function TestETH2Chain33Assets() {
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethReceiverAddr2
}
"
)
balance
=
$(
cli_ret
"
${
result
}
"
"balance"
".balance"
)
hash
=
$(${
Chain33Cli
}
send x2ethereum burn
-a
0.1
-t
eth
-r
${
ethReceiverAddr2
}
-k
12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
)
hash
=
$(${
Chain33Cli
}
send x2ethereum burn
-a
0.1
-t
eth
-r
${
ethReceiverAddr2
}
-
-node_addr
"
${
ethUrl
}
"
-
k
12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
)
block_wait
"
${
Chain33Cli
}
"
$((
maturityDegree
+
2
))
check_tx
"
${
Chain33Cli
}
"
"
${
hash
}
"
result
=
$(${
Chain33Cli
}
x2ethereum balance
-s
12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
-t
eth | jq
".res"
| jq
".[]"
)
balance_ret
"
${
result
}
"
"0"
eth_block_wait
$((
maturityDegree
+
3
))
eth_block_wait
$((
maturityDegree
+
2
))
"
${
ethUrl
}
"
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
bridgeBankAddr
}
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"0"
...
...
@@ -319,20 +346,20 @@ function TestETH2Chain33Erc20() {
cli_ret
"
${
result
}
"
"balance"
".balance"
"100"
# eth 等待 10 个区块
eth_block_wait
$((
maturityDegree
+
2
))
eth_block_wait
$((
maturityDegree
+
2
))
"
${
ethUrl
}
"
result
=
$(${
Chain33Cli
}
x2ethereum balance
-s
"
${
chain33Validator1
}
"
-t
"
${
tokenSymbol
}
"
-a
"
${
tokenAddr
}
"
| jq
".res"
| jq
".[]"
)
balance_ret
"
${
result
}
"
"100"
# chain33 burn 100
hash
=
$(${
Chain33Cli
}
send x2ethereum burn
-a
100
-t
"
${
tokenSymbol
}
"
-r
${
ethReceiverAddr2
}
-q
"
${
tokenAddr
}
"
-k
"
${
chain33Validator1
}
"
)
hash
=
$(${
Chain33Cli
}
send x2ethereum burn
-a
100
-t
"
${
tokenSymbol
}
"
-r
${
ethReceiverAddr2
}
-q
"
${
tokenAddr
}
"
-
-node_addr
"
${
ethUrl
}
"
-
k
"
${
chain33Validator1
}
"
)
block_wait
"
${
Chain33Cli
}
"
$((
maturityDegree
+
2
))
check_tx
"
${
Chain33Cli
}
"
"
${
hash
}
"
result
=
$(${
Chain33Cli
}
x2ethereum balance
-s
"
${
chain33Validator1
}
"
-t
"
${
tokenSymbol
}
"
-a
"
${
tokenAddr
}
"
| jq
".res"
| jq
".[]"
)
balance_ret
"
${
result
}
"
"0"
eth_block_wait
$((
maturityDegree
+
3
))
eth_block_wait
$((
maturityDegree
+
2
))
"
${
ethUrl
}
"
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethReceiverAddr2
}
"
-t
"
${
tokenAddr
}
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"100"
...
...
@@ -359,11 +386,11 @@ function TestChain33ToEthAssetsKill() {
kill_ebrelayerD
# chain33 lock bty
hash
=
$(${
Chain33Cli
}
send x2ethereum lock
-a
5
-t
coins.bty
-r
${
ethReceiverAddr2
}
-q
"
${
tokenAddrBty
}
"
-k
12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
)
hash
=
$(${
Chain33Cli
}
send x2ethereum lock
-a
5
-t
coins.bty
-r
${
ethReceiverAddr2
}
-q
"
${
tokenAddrBty
}
"
-
-node_addr
"
${
ethUrl
}
"
-
k
12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
)
block_wait
"
${
Chain33Cli
}
"
$((
maturityDegree
+
2
))
check_tx
"
${
Chain33Cli
}
"
"
${
hash
}
"
eth_block_wait
$((
maturityDegree
+
2
))
eth_block_wait
$((
maturityDegree
+
2
))
"
${
ethUrl
}
"
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethReceiverAddr2
}
"
-t
"
${
tokenAddrBty
}
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"0"
...
...
@@ -381,7 +408,7 @@ function TestChain33ToEthAssetsKill() {
cli_ret
"
${
result
}
"
"balance"
".balance"
"0"
# eth 等待 10 个区块
eth_block_wait
$((
maturityDegree
+
2
))
eth_block_wait
$((
maturityDegree
+
2
))
"
${
ethUrl
}
"
result
=
$(${
Chain33Cli
}
account balance
-a
"
${
chain33Validator1
}
"
-e
x2ethereum
)
balance_ret
"
${
result
}
"
"0"
...
...
@@ -417,7 +444,7 @@ function TestETH2Chain33AssetsKill() {
cli_ret
"
${
result
}
"
"balance"
".balance"
"0.1"
# eth 等待 10 个区块
eth_block_wait
$((
maturityDegree
+
2
))
eth_block_wait
$((
maturityDegree
+
2
))
"
${
ethUrl
}
"
result
=
$(${
Chain33Cli
}
x2ethereum balance
-s
12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
-t
eth | jq
".res"
| jq
".[]"
)
balance_ret
"
${
result
}
"
"0"
...
...
@@ -434,14 +461,14 @@ function TestETH2Chain33AssetsKill() {
kill_ebrelayerC
kill_ebrelayerD
hash
=
$(${
Chain33Cli
}
send x2ethereum burn
-a
0.1
-t
eth
-r
${
ethReceiverAddr2
}
-k
12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
)
hash
=
$(${
Chain33Cli
}
send x2ethereum burn
-a
0.1
-t
eth
-r
${
ethReceiverAddr2
}
-
-node_addr
"
${
ethUrl
}
"
-
k
12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
)
block_wait
"
${
Chain33Cli
}
"
$((
maturityDegree
+
2
))
check_tx
"
${
Chain33Cli
}
"
"
${
hash
}
"
result
=
$(${
Chain33Cli
}
x2ethereum balance
-s
12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
-t
eth | jq
".res"
| jq
".[]"
)
balance_ret
"
${
result
}
"
"0"
eth_block_wait
$((
maturityDegree
+
3
))
eth_block_wait
$((
maturityDegree
+
2
))
"
${
ethUrl
}
"
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
bridgeBankAddr
}
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"0.1"
...
...
@@ -491,7 +518,7 @@ function TestETH2Chain33Erc20Kill() {
cli_ret
"
${
result
}
"
"balance"
".balance"
"100"
# eth 等待 10 个区块
eth_block_wait
$((
maturityDegree
+
2
))
eth_block_wait
$((
maturityDegree
+
2
))
"
${
ethUrl
}
"
result
=
$(${
Chain33Cli
}
x2ethereum balance
-s
"
${
chain33Validator1
}
"
-t
"
${
tokenSymbol
}
"
-a
"
${
tokenAddr2
}
"
| jq
".res"
| jq
".[]"
)
balance_ret
"
${
result
}
"
"0"
...
...
@@ -506,14 +533,14 @@ function TestETH2Chain33Erc20Kill() {
kill_ebrelayerD
# chain33 burn 100
hash
=
$(${
Chain33Cli
}
send x2ethereum burn
-a
100
-t
"
${
tokenSymbol
}
"
-r
${
ethReceiverAddr2
}
-q
"
${
tokenAddr2
}
"
-k
"
${
chain33Validator1
}
"
)
hash
=
$(${
Chain33Cli
}
send x2ethereum burn
-a
100
-t
"
${
tokenSymbol
}
"
-r
${
ethReceiverAddr2
}
-q
"
${
tokenAddr2
}
"
-
-node_addr
"
${
ethUrl
}
"
-
k
"
${
chain33Validator1
}
"
)
block_wait
"
${
Chain33Cli
}
"
$((
maturityDegree
+
2
))
check_tx
"
${
Chain33Cli
}
"
"
${
hash
}
"
result
=
$(${
Chain33Cli
}
x2ethereum balance
-s
"
${
chain33Validator1
}
"
-t
"
${
tokenSymbol
}
"
-a
"
${
tokenAddr2
}
"
| jq
".res"
| jq
".[]"
)
balance_ret
"
${
result
}
"
"0"
eth_block_wait
$((
maturityDegree
+
3
))
eth_block_wait
$((
maturityDegree
+
2
))
"
${
ethUrl
}
"
start_ebrelayerC
start_ebrelayerD
...
...
@@ -529,9 +556,15 @@ function TestETH2Chain33Erc20Kill() {
function
AllRelayerMainTest
()
{
set
+e
docker_chain33_ip
=
$(
docker inspect
"
${
NODE3
}
"
| jq
".[].NetworkSettings.Networks"
|
grep
"IPAddress"
|
awk
'{ print $2}'
|
sed
's/\"//g'
|
sed
's/,//g'
)
docker_chain33_ip
=
$(
get_docker_addr
"
${
dockerNamePrefix
}
_chain33_1"
)
Chain33Cli
=
"./chain33-cli --rpc_laddr http://
${
docker_chain33_ip
}
:8801"
CLIA
=
"docker exec
${
dockerNamePrefix
}
_ebrelayera_1 /root/ebcli_A"
CLIB
=
"docker exec
${
dockerNamePrefix
}
_ebrelayerb_1 /root/ebcli_A"
CLIC
=
"docker exec
${
dockerNamePrefix
}
_ebrelayerc_1 /root/ebcli_A"
CLID
=
"docker exec
${
dockerNamePrefix
}
_ebrelayerd_1 /root/ebcli_A"
echo
"
${
CLIA
}
"
echo
-e
"
${
GRE
}
===========
$FUNCNAME
begin ===========
${
NOC
}
"
if
[[
${
1
}
!=
""
]]
;
then
...
...
plugin/dapp/x2ethereum/cmd/build/docker-compose-ebrelayer.yml
0 → 100644
View file @
b375d231
version
:
'
3'
services
:
ebrelayera
:
build
:
context
:
.
dockerfile
:
Dockerfile-x2ethrelay
ports
:
-
"
20000:20000"
plugin/dapp/x2ethereum/cmd/build/docker-compose-x2Ethereum.yml
deleted
100644 → 0
View file @
d484af83
version
:
'
3'
#services:
# ganachetest:
# build:
# context: .
plugin/dapp/x2ethereum/cmd/build/docker-compose-x2ethereum.yml
0 → 100644
View file @
b375d231
version
:
'
3'
services
:
ganachetest
:
entrypoint
:
[
"
node"
,
"
/app/ganache-core.docker.cli.js"
,
"
-a"
,
"
10"
,
"
-b"
,
"
2"
,
"
--debug"
,
"
-m"
,
"
coast
bar
giraffe
art
venue
decide
symbol
law
visual
crater
vital
fold"
]
image
:
trufflesuite/ganache-cli:latest
ebrelayera
:
build
:
context
:
.
dockerfile
:
Dockerfile-x2ethrelay
ebrelayerb
:
build
:
context
:
.
dockerfile
:
Dockerfile-x2ethrelay
ebrelayerc
:
build
:
context
:
.
dockerfile
:
Dockerfile-x2ethrelay
ebrelayerd
:
build
:
context
:
.
dockerfile
:
Dockerfile-x2ethrelay
\ No newline at end of file
plugin/dapp/x2ethereum/cmd/build/perf_test.sh
View file @
b375d231
...
...
@@ -6,10 +6,6 @@ set -x
source
"./publicTest.sh"
source
"./allRelayerTest.sh"
CLIA
=
"./ebcli_A"
Chain33_CLI
=
""
Ethsender
=
"0xa4ea64a583f6e51c3799335b28a8f0529570a635"
privateKeys[0]
=
"8656d2bc732a8a816a461ba5e2d8aac7c7f85c26a813df30d5327210465eb230"
privateKeys[1]
=
"3fa21584ae2e4fd74db9b58e2386f5481607dfa4d7ba0617aaa7858e5025dc1e"
...
...
@@ -29,26 +25,31 @@ ethAddress[6]="0x0C05bA5c230fDaA503b53702aF1962e08D0C60BF"
maturityDegree
=
10
tokenAddr
=
""
tokenAddrBty
=
""
CLIA
=
""
ethUrl
=
""
Chain33Cli
=
""
loop_send_lock_eth
()
{
# while 遍历数组
echo
-e
"
${
GRE
}
=========== Ethereum Lock begin ===========
${
NOC
}
"
preChain33Balance
=
$(${
Chain33_CLI
}
x2ethereum balance
-s
12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
-t
eth | jq
".res"
| jq
".[]"
| jq
".balance"
|
sed
's/\"//g'
)
#shellcheck disable=SC2154
preChain33Balance
=
$(${
Chain33Cli
}
x2ethereum balance
-s
12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
-t
eth | jq
".res"
| jq
".[]"
| jq
".balance"
|
sed
's/\"//g'
)
i
=
0
while
[[
i
-lt
${#
privateKeys
[@]
}
]]
;
do
preEthBalance[
$i
]=
$(
curl
-ksd
'{"jsonrpc":"2.0","method":"eth_getBalance","params":["'
${
ethAddress
[i]
}
'", "latest"],"id":1}'
http://localhost:7545
| jq
-r
".result"
)
preEthBalance[
$i
]=
$(
curl
-ksd
'{"jsonrpc":"2.0","method":"eth_getBalance","params":["'
${
ethAddress
[i]
}
'", "latest"],"id":1}'
"
${
ethUrl
}
"
| jq
-r
".result"
)
ethTxHash
=
$(${
CLIA
}
relayer ethereum lock-async
-m
1
-k
"
${
privateKeys
[i]
}
"
-r
12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
)
echo
${
i
}
"lock-async tx hash:"
"
${
ethTxHash
}
"
# shellcheck disable=SC2219
let
i++
done
eth_block_wait
$((
maturityDegree
+
2
))
#shellcheck disable=SC2154
eth_block_wait
$((
maturityDegree
+
2
))
"
${
ethUrl
}
"
i
=
0
while
[[
i
-lt
${#
privateKeys
[@]
}
]]
;
do
nowEthBalance
=
$(
curl
-ksd
'{"jsonrpc":"2.0","method":"eth_getBalance","params":["'
${
ethAddress
[i]
}
'", "latest"],"id":1}'
http://localhost:7545
| jq
-r
".result"
)
nowEthBalance
=
$(
curl
-ksd
'{"jsonrpc":"2.0","method":"eth_getBalance","params":["'
${
ethAddress
[i]
}
'", "latest"],"id":1}'
"
${
ethUrl
}
"
| jq
-r
".result"
)
res
=
$((
preEthBalance[i]
-
nowEthBalance
))
echo
${
i
}
"preBalance"
"
${
preEthBalance
[i]
}
"
"nowBalance"
"
${
nowEthBalance
}
"
"diff"
${
res
}
if
[[
$res
-le
100000000000000000
]]
;
then
...
...
@@ -58,7 +59,7 @@ loop_send_lock_eth() {
# shellcheck disable=SC2219
let
i++
done
nowChain33Balance
=
$(${
Chain33
_CLI
}
x2ethereum balance
-s
12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
-t
eth | jq
".res"
| jq
".[]"
| jq
".balance"
|
sed
's/\"//g'
)
nowChain33Balance
=
$(${
Chain33
Cli
}
x2ethereum balance
-s
12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
-t
eth | jq
".res"
| jq
".[]"
| jq
".balance"
|
sed
's/\"//g'
)
diff
=
$(
echo
"
$nowChain33Balance
-
$preChain33Balance
"
| bc
)
check_number
"
${
diff
}
"
7
}
...
...
@@ -66,22 +67,22 @@ loop_send_lock_eth() {
loop_send_burn_eth
()
{
echo
-e
"
${
GRE
}
=========== Chain33 Burn begin ===========
${
NOC
}
"
preChain33Balance
=
$(${
Chain33
_CLI
}
x2ethereum balance
-s
12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
-t
eth | jq
".res"
| jq
".[]"
| jq
".balance"
|
sed
's/\"//g'
)
preChain33Balance
=
$(${
Chain33
Cli
}
x2ethereum balance
-s
12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
-t
eth | jq
".res"
| jq
".[]"
| jq
".balance"
|
sed
's/\"//g'
)
i
=
0
while
[[
i
-lt
${#
privateKeys
[@]
}
]]
;
do
preEthBalance[
$i
]=
$(
curl
-ksd
'{"jsonrpc":"2.0","method":"eth_getBalance","params":["'
${
ethAddress
[i]
}
'", "latest"],"id":1}'
http://localhost:7545
| jq
-r
".result"
)
ethTxHash
=
$(${
Chain33
_CLI
}
send x2ethereum burn
-a
1
-r
${
ethAddress
[i]
}
-t
eth
-k
12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
)
preEthBalance[
$i
]=
$(
curl
-ksd
'{"jsonrpc":"2.0","method":"eth_getBalance","params":["'
${
ethAddress
[i]
}
'", "latest"],"id":1}'
"
${
ethUrl
}
"
| jq
-r
".result"
)
ethTxHash
=
$(${
Chain33
Cli
}
send x2ethereum burn
-a
1
-r
${
ethAddress
[i]
}
-t
eth
--node_addr
"
${
ethUrl
}
"
-k
12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
)
echo
${
i
}
"burn chain33 tx hash:"
"
${
ethTxHash
}
"
# shellcheck disable=SC2219
let
i++
done
eth_block_wait
$((
maturityDegree
+
2
))
eth_block_wait
$((
maturityDegree
+
2
))
"
${
ethUrl
}
"
i
=
0
while
[[
i
-lt
${#
privateKeys
[@]
}
]]
;
do
nowEthBalance
=
$(
curl
-ksd
'{"jsonrpc":"2.0","method":"eth_getBalance","params":["'
${
ethAddress
[i]
}
'", "latest"],"id":1}'
http://localhost:7545
| jq
-r
".result"
)
nowEthBalance
=
$(
curl
-ksd
'{"jsonrpc":"2.0","method":"eth_getBalance","params":["'
${
ethAddress
[i]
}
'", "latest"],"id":1}'
"
${
ethUrl
}
"
| jq
-r
".result"
)
res
=
$((
nowEthBalance
-
preEthBalance[i]
))
echo
${
i
}
"preBalance"
"
${
preEthBalance
[i]
}
"
"nowBalance"
"
${
nowEthBalance
}
"
"diff"
${
res
}
if
[[
$res
-gt
1000000000000000000
]]
;
then
...
...
@@ -91,7 +92,7 @@ loop_send_burn_eth() {
# shellcheck disable=SC2219
let
i++
done
nowChain33Balance
=
$(${
Chain33
_CLI
}
x2ethereum balance
-s
12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
-t
eth | jq
".res"
| jq
".[]"
| jq
".balance"
|
sed
's/\"//g'
)
nowChain33Balance
=
$(${
Chain33
Cli
}
x2ethereum balance
-s
12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
-t
eth | jq
".res"
| jq
".[]"
| jq
".balance"
|
sed
's/\"//g'
)
diff
=
$(
echo
"
$preChain33Balance
-
$nowChain33Balance
"
| bc
)
check_number
"
${
diff
}
"
7
}
...
...
@@ -99,18 +100,18 @@ loop_send_burn_eth() {
loop_send_lock_bty
()
{
echo
-e
"
${
GRE
}
=========== Chain33 Lock begin ===========
${
NOC
}
"
preChain33Balance
=
$(${
Chain33
_CLI
}
account balance
-a
12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
-e
x2ethereum | jq
-r
".balance"
|
sed
's/\"//g'
)
preChain33Balance
=
$(${
Chain33
Cli
}
account balance
-a
12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
-e
x2ethereum | jq
-r
".balance"
|
sed
's/\"//g'
)
i
=
0
while
[[
i
-lt
${#
privateKeys
[@]
}
]]
;
do
preEthBalance[
$i
]=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethAddress
[i]
}
"
-t
"
${
tokenAddrBty
}
"
| jq
-r
".balance"
)
ethTxHash
=
$(${
Chain33
_CLI
}
send x2ethereum lock
-q
"
${
tokenAddrBty
}
"
-a
1
-r
${
ethAddress
[i]
}
-t
coins.bty
-k
12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
)
ethTxHash
=
$(${
Chain33
Cli
}
send x2ethereum lock
-q
"
${
tokenAddrBty
}
"
-a
1
-r
${
ethAddress
[i]
}
-t
coins.bty
--node_addr
"
${
ethUrl
}
"
-k
12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
)
echo
${
i
}
"lock chain33 tx hash:"
"
${
ethTxHash
}
"
# shellcheck disable=SC2219
let
i++
done
eth_block_wait
$((
maturityDegree
+
2
))
eth_block_wait
$((
maturityDegree
+
2
))
"
${
ethUrl
}
"
i
=
0
while
[[
i
-lt
${#
privateKeys
[@]
}
]]
;
do
...
...
@@ -121,7 +122,7 @@ loop_send_lock_bty() {
# shellcheck disable=SC2219
let
i++
done
nowChain33Balance
=
$(${
Chain33
_CLI
}
account balance
-a
12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
-e
x2ethereum | jq
-r
".balance"
|
sed
's/\"//g'
)
nowChain33Balance
=
$(${
Chain33
Cli
}
account balance
-a
12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
-e
x2ethereum | jq
-r
".balance"
|
sed
's/\"//g'
)
diff
=
$(
echo
"
$preChain33Balance
-
$nowChain33Balance
"
| bc
)
check_number
"
${
diff
}
"
7
}
...
...
@@ -129,7 +130,7 @@ loop_send_lock_bty() {
loop_send_burn_bty
()
{
echo
-e
"
${
GRE
}
=========== Ethereum Burn begin ===========
${
NOC
}
"
preChain33Balance
=
$(${
Chain33
_CLI
}
account balance
-a
12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
-e
x2ethereum | jq
-r
".balance"
|
sed
's/\"//g'
)
preChain33Balance
=
$(${
Chain33
Cli
}
account balance
-a
12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
-e
x2ethereum | jq
-r
".balance"
|
sed
's/\"//g'
)
i
=
0
while
[[
i
-lt
${#
privateKeys
[@]
}
]]
;
do
...
...
@@ -141,7 +142,7 @@ loop_send_burn_bty() {
let
i++
done
eth_block_wait
$((
maturityDegree
+
2
))
eth_block_wait
$((
maturityDegree
+
2
))
"
${
ethUrl
}
"
i
=
0
while
[[
i
-lt
${#
privateKeys
[@]
}
]]
;
do
...
...
@@ -152,14 +153,14 @@ loop_send_burn_bty() {
# shellcheck disable=SC2219
let
i++
done
nowChain33Balance
=
$(${
Chain33
_CLI
}
account balance
-a
12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
-e
x2ethereum | jq
-r
".balance"
|
sed
's/\"//g'
)
nowChain33Balance
=
$(${
Chain33
Cli
}
account balance
-a
12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
-e
x2ethereum | jq
-r
".balance"
|
sed
's/\"//g'
)
diff
=
$(
echo
"
$nowChain33Balance
-
$preChain33Balance
"
| bc
)
check_number
"
${
diff
}
"
7
}
loop_send_lock_erc20
()
{
echo
-e
"
${
GRE
}
=========== Ethereum Lock Erc20 begin ===========
${
NOC
}
"
preChain33Balance
=
$(${
Chain33
_CLI
}
x2ethereum balance
-s
12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
-t
testc | jq
".res"
| jq
".[]"
| jq
".balance"
|
sed
's/\"//g'
)
preChain33Balance
=
$(${
Chain33
Cli
}
x2ethereum balance
-s
12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
-t
testc | jq
".res"
| jq
".[]"
| jq
".balance"
|
sed
's/\"//g'
)
preEthBalance
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
Ethsender
}
"
-t
"
${
tokenAddr
}
"
| jq
-r
".balance"
)
approveTxHash
=
$(${
CLIA
}
relayer ethereum approve
-m
10
-k
"
${
privateKeys
[5]
}
"
-t
"
${
tokenAddr
}
"
)
...
...
@@ -171,32 +172,32 @@ loop_send_lock_erc20() {
# shellcheck disable=SC2219
let
i++
done
eth_block_wait
$((
maturityDegree
+
2
))
eth_block_wait
$((
maturityDegree
+
2
))
"
${
ethUrl
}
"
nowEthBalance
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
Ethsender
}
"
-t
"
${
tokenAddr
}
"
| jq
-r
".balance"
)
res
=
$((
preEthBalance
-
nowEthBalance
))
echo
${
i
}
"preBalance"
"
${
preEthBalance
}
"
"nowBalance"
"
${
nowEthBalance
}
"
"diff"
${
res
}
check_number
"
${
diff
}
"
7
nowChain33Balance
=
$(${
Chain33
_CLI
}
x2ethereum balance
-s
12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
-t
testc | jq
".res"
| jq
".[]"
| jq
".balance"
|
sed
's/\"//g'
)
nowChain33Balance
=
$(${
Chain33
Cli
}
x2ethereum balance
-s
12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
-t
testc | jq
".res"
| jq
".[]"
| jq
".balance"
|
sed
's/\"//g'
)
diff
=
$((
nowChain33Balance
-
preChain33Balance
))
check_number
"
${
diff
}
"
7
}
loop_send_burn_erc20
()
{
echo
-e
"
${
GRE
}
=========== Chain33 Burn Erc20 begin ===========
${
NOC
}
"
preChain33Balance
=
$(${
Chain33
_CLI
}
x2ethereum balance
-s
12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
-t
testc | jq
".res"
| jq
".[]"
| jq
".balance"
|
sed
's/\"//g'
)
preChain33Balance
=
$(${
Chain33
Cli
}
x2ethereum balance
-s
12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
-t
testc | jq
".res"
| jq
".[]"
| jq
".balance"
|
sed
's/\"//g'
)
i
=
0
while
[[
i
-lt
${#
privateKeys
[@]
}
]]
;
do
preEthBalance[i]
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethAddress
[i]
}
"
-t
"
${
tokenAddr
}
"
| jq
-r
".balance"
)
ethTxHash
=
$(${
Chain33
_CLI
}
send x2ethereum burn
-a
1
-r
${
ethAddress
[i]
}
-t
testc
-q
"
${
tokenAddr
}
"
-k
12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
)
ethTxHash
=
$(${
Chain33
Cli
}
send x2ethereum burn
-a
1
-r
${
ethAddress
[i]
}
-t
testc
-q
"
${
tokenAddr
}
"
--node_addr
"
${
ethUrl
}
"
-k
12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
)
echo
${
i
}
"burn chain33 tx hash:"
"
${
ethTxHash
}
"
# shellcheck disable=SC2219
let
i++
done
eth_block_wait
$((
maturityDegree
+
2
))
eth_block_wait
$((
maturityDegree
+
2
))
"
${
ethUrl
}
"
i
=
0
while
[[
i
-lt
${#
privateKeys
[@]
}
]]
;
do
...
...
@@ -207,17 +208,13 @@ loop_send_burn_erc20() {
# shellcheck disable=SC2219
let
i++
done
nowChain33Balance
=
$(${
Chain33
_CLI
}
x2ethereum balance
-s
12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
-t
testc | jq
".res"
| jq
".[]"
| jq
".balance"
|
sed
's/\"//g'
)
nowChain33Balance
=
$(${
Chain33
Cli
}
x2ethereum balance
-s
12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
-t
testc | jq
".res"
| jq
".[]"
| jq
".balance"
|
sed
's/\"//g'
)
diff
=
$(
echo
"
$preChain33Balance
-
$nowChain33Balance
"
| bc
)
check_number
"
${
diff
}
"
7
}
perf_test_main
()
{
echo
-e
"
${
GRE
}
===========
$FUNCNAME
begin ===========
${
NOC
}
"
docker_chain33_ip
=
$(
docker inspect
"
${
NODE3
}
"
| jq
".[].NetworkSettings.Networks"
|
grep
"IPAddress"
|
awk
'{ print $2}'
|
sed
's/\"//g'
|
sed
's/,//g'
)
Chain33_CLI
=
"./chain33-cli --rpc_laddr http://
${
docker_chain33_ip
}
:8801"
if
[[
${
1
}
!=
""
]]
;
then
maturityDegree
=
${
1
}
echo
-e
"
${
GRE
}
maturityDegree is
${
maturityDegree
}
${
NOC
}
"
...
...
plugin/dapp/x2ethereum/cmd/build/publicTest.sh
View file @
b375d231
...
...
@@ -12,6 +12,8 @@ RED='\033[1;31m'
GRE
=
'\033[1;32m'
NOC
=
'\033[0m'
inetAddr
=
""
# 出错退出前拷贝日志文件
function
exit_cp_file
()
{
# shellcheck disable=SC2116
...
...
@@ -23,14 +25,35 @@ function exit_cp_file() {
mkdir
-p
${
dirName
}
fi
for
name
in
A B C D
;
do
cp
"./
$name
/ebrelayer.log"
"
$dirName
/ebrelayer
$name
.log"
for
name
in
a b c d
;
do
# shellcheck disable=SC2154
docker
cp
"
${
dockerNamePrefix
}
_ebrelayer
${
name
}
_1"
:/root/logs/x2Ethereum_relayer.log
"
${
dirName
}
/ebrelayer
${
name
}
.log"
done
docker
cp
"
${
NODE3
}
"
:/root/logs/chain33.log
"
$dirName
/chain33.log"
docker
cp
"
${
dockerNamePrefix
}
_chain33_1"
:/root/logs/chain33.log
"
${
dirName
}
/chain33.log"
exit
1
}
function
copyErrLogs
()
{
if
[
-n
"
$CASE_ERR
"
]
;
then
# /var/lib/jenkins
# shellcheck disable=SC2116
dirNameFa
=
$(
echo
~
)
dirName
=
"
$dirNameFa
/x2ethereumlogs"
if
[
!
-d
"
${
dirName
}
"
]
;
then
# shellcheck disable=SC2086
mkdir
-p
${
dirName
}
fi
for
name
in
a b c d
;
do
# shellcheck disable=SC2154
docker
cp
"
${
dockerNamePrefix
}
_ebrelayer
${
name
}
_rpc_1"
:/root/logs/x2Ethereum_relayer.log
"
${
dirName
}
/ebrelayer
${
name
}
_rpc.log"
done
docker
cp
"
${
dockerNamePrefix
}
_chain33_1"
:/root/logs/chain33.log
"
${
dirName
}
/chain33_rpc.log"
fi
}
function
kill_all_ebrelayer
()
{
for
name
in
A B C D
;
do
local
ebrelayer
=
"./../build/
$name
/ebrelayer"
...
...
@@ -328,34 +351,45 @@ function check_addr() {
fi
}
function
get_inet_addr
()
{
inetAddr
=
$(
ifconfig wlp2s0 |
grep
"inet "
|
awk
'{ print $2}'
|
awk
-F
:
'{print $2}'
)
if
[[
${
inetAddr
}
==
""
]]
;
then
inetAddr
=
$(
ifconfig wlp2s0 |
grep
"inet "
|
awk
'{ print $2}'
)
if
[[
${
inetAddr
}
==
""
]]
;
then
inetAddr
=
$(
ifconfig eth0 |
grep
"inet "
|
awk
'{ print $2}'
|
awk
-F
:
'{print $2}'
)
if
[[
${
inetAddr
}
==
""
]]
;
then
inetAddr
=
$(
ifconfig eth0 |
grep
"inet "
|
awk
'{ print $2}'
)
if
[[
${
inetAddr
}
==
""
]]
;
then
ip addr show eth0
inetAddr
=
$(
ip addr show eth0 |
grep
"inet "
|
awk
'{ print $2}'
|
head
-c-4
)
fi
fi
fi
fi
echo
"
${
inetAddr
}
"
}
# $1 dockerName
function
get_docker_addr
()
{
local
dockerAddr
=
$(
docker inspect
"
${
1
}
"
| jq
".[].NetworkSettings.Networks"
|
grep
"IPAddress"
|
awk
'{ print $2}'
|
sed
's/\"//g'
|
sed
's/,//g'
)
echo
"
${
dockerAddr
}
"
}
# 更新配置文件 $1 为 BridgeRegistry 合约地址; $2 等待区块 默认10; $3 relayer.toml 地址
function
updata_relayer_toml
()
{
local
BridgeRegistry
=
${
1
}
local
maturityDegree
=
${
2
}
local
file
=
${
3
}
# local chain33Host=$(docker inspect "${NODE3}" | jq ".[].NetworkSettings.Networks.${PROJ}_default.IPAddress" | sed 's/\"//g')
local
chain33Host
=
$(
docker inspect
"
${
NODE3
}
"
| jq
".[].NetworkSettings.Networks"
|
grep
"IPAddress"
|
awk
'{ print $2}'
|
sed
's/\"//g'
|
sed
's/,//g'
)
local
chain33Host
=
$(
get_docker_addr
"
${
dockerNamePrefix
}
_chain33_1"
)
if
[[
${
chain33Host
}
==
""
]]
;
then
echo
-e
"
${
RED
}
chain33Host is empty
${
NOC
}
"
exit_cp_file
fi
local
pushHost
=
$(
ifconfig wlp2s0 |
grep
"inet "
|
awk
'{ print $2}'
|
awk
-F
:
'{print $2}'
)
if
[[
${
pushHost
}
==
""
]]
;
then
pushHost
=
$(
ifconfig wlp2s0 |
grep
"inet "
|
awk
'{ print $2}'
)
if
[[
${
pushHost
}
==
""
]]
;
then
pushHost
=
$(
ifconfig eth0 |
grep
"inet "
|
awk
'{ print $2}'
|
awk
-F
:
'{print $2}'
)
if
[[
${
pushHost
}
==
""
]]
;
then
pushHost
=
$(
ifconfig eth0 |
grep
"inet "
|
awk
'{ print $2}'
)
if
[[
${
pushHost
}
==
""
]]
;
then
ip addr show eth0
pushHost
=
$(
ip addr show eth0 |
grep
"inet "
|
awk
'{ print $2}'
|
head
-c-4
)
fi
fi
fi
fi
get_inet_addr
local
pushHost
=
"
${
inetAddr
}
"
if
[[
${
pushHost
}
==
""
]]
;
then
echo
-e
"
${
RED
}
pushHost is empty
${
NOC
}
"
exit_cp_file
...
...
@@ -368,6 +402,9 @@ function updata_relayer_toml() {
line
=
$(
delete_line_show
"
${
file
}
"
"pushHost"
)
sed
-i
''
"
${
line
}
"
' a pushHost="http://'
"
${
pushHost
}
"
':20000"'
"
${
file
}
"
# line=$(delete_line_show "${file}" "pushBind")
# sed -i ''"${line}"' a pushBind="'"${pushHost}"':20000"' "${file}"
line
=
$(
delete_line_show
"
${
file
}
"
"BridgeRegistry"
)
sed
-i
''
"
${
line
}
"
' a BridgeRegistry="'
"
${
BridgeRegistry
}
"
'"'
"
${
file
}
"
...
...
@@ -401,6 +438,121 @@ function updata_relayer_toml_ropston() {
sed
-i
's/maturityDegree=10/'
maturityDegree
=
"
${
maturityDegree
}
"
'/g'
"
${
file
}
"
}
# $1 portRelayer
function
updata_docker_relayer_toml
()
{
local
port
=
$1
local
portRelayer
=
$1
if
[
"
${
portRelayer
}
"
!=
"20000"
]
;
then
sed
-i
's/20000/'
"
${
portRelayer
}
"
'/g'
"./relayer.toml"
sed
-i
's/20000/'
"
${
portRelayer
}
"
'/g'
"./Dockerfile-x2ethrelay"
fi
for
name
in
b c d
;
do
local
file
=
"./relayer
$name
.toml"
cp
'./relayer.toml'
"
${
file
}
"
# 删除配置文件中不需要的字段
for
deleteName
in
"deployerPrivateKey"
"operatorAddr"
"validatorsAddr"
"initPowers"
"deployerPrivateKey"
"deploy"
;
do
delete_line
"
${
file
}
"
"
${
deleteName
}
"
done
port
=
$((
port
+
1
))
sed
-i
's/'
"
${
portRelayer
}
"
'/'
${
port
}
'/g'
"
${
file
}
"
sed
-i
's/x2ethereum/x2ethereum'
${
name
}
'/g'
"
${
file
}
"
local
dockerfile
=
"./Dockerfile-x2ethrelay
$name
"
cp
"./Dockerfile-x2ethrelay"
"
${
dockerfile
}
"
# shellcheck disable=SC2155
local
line
=
$(
delete_line_show
"
${
dockerfile
}
"
"COPY relayer.toml relayer.toml"
)
sed
-i
''
"
${
line
}
"
' a COPY relayer'
$name
'.toml relayer.toml'
"
${
dockerfile
}
"
sed
-i
's/'
"
${
portRelayer
}
"
'/'
"
${
port
}
"
'/g'
"
${
dockerfile
}
"
local
dockeryml
=
"./docker-compose-ebrelayer
$name
.yml"
cp
"./docker-compose-ebrelayer.yml"
"
${
dockeryml
}
"
line
=
$(
delete_line_show
"
${
dockeryml
}
"
"ebrelayera"
)
sed
-i
''
"
${
line
}
"
' a \ \ ebrelayer'
$name
':'
"
${
dockeryml
}
"
line
=
$(
delete_line_show
"
${
dockeryml
}
"
"dockerfile: Dockerfile-x2ethrelay"
)
sed
-i
''
"
${
line
}
"
' a \ \ \ \ \ \ dockerfile: Dockerfile-x2ethrelay'
$name
''
"
${
dockeryml
}
"
sed
-i
's/'
"
${
portRelayer
}
"
'/'
${
port
}
'/g'
"
${
dockeryml
}
"
done
}
# 更新配置文件 $1 为 BridgeRegistry 合约地址; $2 等待区块 默认10; $3 MAIN_HTTP; $4 relayer.toml 地址
function
updata_relayer_toml_rpc
()
{
local
BridgeRegistry
=
${
1
}
local
maturityDegree
=
${
2
}
local
MAIN_HTTP
=
${
3
}
local
file
=
${
4
}
get_inet_addr
local
pushHost
=
"
${
inetAddr
}
"
if
[[
${
pushHost
}
==
""
]]
;
then
echo
-e
"
${
RED
}
pushHost is empty
${
NOC
}
"
fi
# shellcheck disable=SC2155
local
line
=
$(
delete_line_show
"
${
file
}
"
"chain33Host"
)
# 在第 line 行后面 新增合约地址
sed
-i
''
"
${
line
}
"
' a chain33Host="'
"
${
MAIN_HTTP
}
"
'"'
"
${
file
}
"
line
=
$(
delete_line_show
"
${
file
}
"
"pushHost"
)
sed
-i
''
"
${
line
}
"
' a pushHost="http://'
"
${
pushHost
}
"
':20000"'
"
${
file
}
"
line
=
$(
delete_line_show
"
${
file
}
"
"BridgeRegistry"
)
sed
-i
''
"
${
line
}
"
' a BridgeRegistry="'
"
${
BridgeRegistry
}
"
'"'
"
${
file
}
"
sed
-i
's/EthMaturityDegree=10/'
EthMaturityDegree
=
"
${
maturityDegree
}
"
'/g'
"
${
file
}
"
sed
-i
's/maturityDegree=10/'
maturityDegree
=
"
${
maturityDegree
}
"
'/g'
"
${
file
}
"
sed
-i
's/^EthBlockFetchPeriod=.*/EthBlockFetchPeriod=500/g'
"
${
file
}
"
sed
-i
's/^fetchHeightPeriodMs=.*/fetchHeightPeriodMs=500/g'
"
${
file
}
"
}
# $1 portRelayer
function
updata_docker_relayer_toml_rpc
()
{
local
portRelayer
=
$1
local
port
=
$1
sed
-i
's/20000/'
"
${
portRelayer
}
"
'/g'
"./x2ethereum/relayer.toml"
sed
-i
's/20000/'
"
${
portRelayer
}
"
'/g'
"./x2ethereum/Dockerfile-x2ethrelay"
for
name
in
b c d
;
do
local
file
=
"./x2ethereum/relayer
$name
.toml"
cp
'./x2ethereum/relayer.toml'
"
${
file
}
"
# 删除配置文件中不需要的字段
for
deleteName
in
"deployerPrivateKey"
"operatorAddr"
"validatorsAddr"
"initPowers"
"deployerPrivateKey"
"deploy"
;
do
delete_line
"
${
file
}
"
"
${
deleteName
}
"
done
port
=
$((
port
-
1
))
sed
-i
's/'
"
${
portRelayer
}
"
'/'
${
port
}
'/g'
"
${
file
}
"
sed
-i
's/x2ethereum/x2ethereum'
${
name
}
'/g'
"
${
file
}
"
local
dockerfile
=
"./x2ethereum/Dockerfile-x2ethrelay
$name
"
cp
"./x2ethereum/Dockerfile-x2ethrelay"
"
${
dockerfile
}
"
# shellcheck disable=SC2155
local
line
=
$(
delete_line_show
"
${
dockerfile
}
"
"COPY relayer.toml relayer.toml"
)
sed
-i
''
"
${
line
}
"
' a COPY relayer'
$name
'.toml relayer.toml'
"
${
dockerfile
}
"
sed
-i
's/'
"
${
portRelayer
}
"
'/'
"
${
port
}
"
'/g'
"
${
dockerfile
}
"
local
dockeryml
=
"./x2ethereum/docker-compose-ebrelayer
$name
.yml"
cp
"./x2ethereum/docker-compose-ebrelayer.yml"
"
${
dockeryml
}
"
sed
-i
's/ebrelayera/ebrelayer'
${
name
}
'/g'
"
${
dockeryml
}
"
sed
-i
's/Dockerfile-x2ethrelay/Dockerfile-x2ethrelay'
${
name
}
'/g'
"
${
dockeryml
}
"
sed
-i
's/'
"
${
portRelayer
}
"
'/'
${
port
}
'/g'
"
${
dockeryml
}
"
done
}
# 更新 B C D 的配置文件
function
updata_all_relayer_toml
()
{
local
port
=
9901
...
...
@@ -465,6 +617,7 @@ function wait_prophecy_finish() {
fi
count
=
$((
count
+
1
))
if
[[
${
count
}
==
30
]]
;
then
set
-x
echo
-e
"
${
RED
}
failed to get balance
${
NOC
}
"
exit_cp_file
fi
...
...
@@ -474,7 +627,7 @@ function wait_prophecy_finish() {
set
-x
}
# eth 区块等待 $1:等待高度 $2:url地址,默认为 http://localhost:7545,测试网络用 https://ropsten-rpc.linkpool.io/
# eth 区块等待 $1:等待高度
$2:url地址,默认为 http://localhost:7545,测试网络用 https://ropsten-rpc.linkpool.io/
function
eth_block_wait
()
{
set
+x
if
[[
$#
-lt
0
]]
;
then
...
...
plugin/dapp/x2ethereum/cmd/test/test-rpc.sh
View file @
b375d231
#!/usr/bin/env bash
#shellcheck disable=SC2128
#shellcheck source=/dev/null
set
-x
source
../dapp-test-common.sh
source
"../x2ethereum/publicTest.sh"
sendAddress
=
"12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
sendPriKey
=
"0x4257d8692ef7fe13c68b65d6a52f03933db2fa5ce8faf210b5b8b80c721ced01"
MAIN_HTTP
=
""
NODE3
=
""
chain33SenderAddr
=
"14KEKbYtKKQm4wMthSK9J4La4nAiidGozt"
# validatorsAddr=["0x92c8b16afd6d423652559c6e266cbe1c29bfd84f", "0x0df9a824699bc5878232c9e612fe1a5346a5a368", "0xcb074cb21cdddf3ce9c3c0a7ac4497d633c9d9f1", "0xd9dab021e74ecf475788ed7b61356056b2095830"]
ethValidatorAddrKeyA
=
"3fa21584ae2e4fd74db9b58e2386f5481607dfa4d7ba0617aaa7858e5025dc1e"
...
...
@@ -29,116 +28,14 @@ ethReceiverAddrKey1="355b876d7cbcb930d5dfab767f66336ce327e082cbaa1877210c1bae89b
ethReceiverAddr2
=
"0x0c05ba5c230fdaa503b53702af1962e08d0c60bf"
#ethReceiverAddrKey2="9dc6df3a8ab139a54d8a984f54958ae0661f880229bf3bdbb886b87d58b56a08"
maturityDegree
=
5
portRelayer
=
19999
ethUrl
=
""
CLIA_HTTP
=
"http://127.0.0.1:9901"
CLIB_HTTP
=
"http://127.0.0.1:9902"
CLIC_HTTP
=
"http://127.0.0.1:9903"
CLID_HTTP
=
"http://127.0.0.1:9904"
# 更新 B C D 的配置文件
function
updata_all_relayer_toml_rpc
()
{
local
port
=
9901
local
port2
=
20000
for
name
in
B C D
;
do
local
file
=
"./x2ethereum/
$name
/relayer.toml"
cp
'./x2ethereum/A/relayer.toml'
"
${
file
}
"
cp
'./x2ethereum/A/ebrelayer'
"./x2ethereum/
$name
/ebrelayer"
# 删除配置文件中不需要的字段
for
deleteName
in
"deployerPrivateKey"
"operatorAddr"
"validatorsAddr"
"initPowers"
"deployerPrivateKey"
"deploy"
;
do
delete_line
"
${
file
}
"
"
${
deleteName
}
"
done
# 替换端口
port
=
$((
port
+
1
))
sed
-i
's/localhost:9901/localhost:'
${
port
}
'/g'
"
${
file
}
"
port2
=
$((
port2
+
1
))
sed
-i
's/20000/'
${
port2
}
'/g'
"
${
file
}
"
sed
-i
's/x2ethereum/x2ethereum'
${
name
}
'/g'
"
${
file
}
"
done
}
# 更新配置文件 $1 为 BridgeRegistry 合约地址; $2 等待区块 默认10; $3 relayer.toml 地址
function
updata_relayer_toml_rpc
()
{
local
BridgeRegistry
=
${
1
}
local
maturityDegree
=
${
2
}
local
file
=
${
3
}
# shellcheck disable=SC2155
local
pushHost
=
$(
ifconfig wlp2s0 |
grep
"inet "
|
awk
'{ print $2}'
|
awk
-F
:
'{print $2}'
)
if
[[
${
pushHost
}
==
""
]]
;
then
pushHost
=
$(
ifconfig wlp2s0 |
grep
"inet "
|
awk
'{ print $2}'
)
if
[[
${
pushHost
}
==
""
]]
;
then
pushHost
=
$(
ifconfig eth0 |
grep
"inet "
|
awk
'{ print $2}'
|
awk
-F
:
'{print $2}'
)
if
[[
${
pushHost
}
==
""
]]
;
then
pushHost
=
$(
ifconfig eth0 |
grep
"inet "
|
awk
'{ print $2}'
)
if
[[
${
pushHost
}
==
""
]]
;
then
ip addr show eth0
pushHost
=
$(
ip addr show eth0 |
grep
"inet "
|
awk
'{ print $2}'
|
head
-c-4
)
fi
fi
fi
fi
if
[[
${
pushHost
}
==
""
]]
;
then
echo
-e
"
${
RED
}
pushHost is empty
${
NOC
}
"
exit
1
fi
# shellcheck disable=SC2155
local
line
=
$(
delete_line_show
"
${
file
}
"
"chain33Host"
)
# 在第 line 行后面 新增合约地址
sed
-i
''
"
${
line
}
"
' a chain33Host="'
"
${
MAIN_HTTP
}
"
'"'
"
${
file
}
"
line
=
$(
delete_line_show
"
${
file
}
"
"pushHost"
)
sed
-i
''
"
${
line
}
"
' a pushHost="http://'
"
${
pushHost
}
"
':20000"'
"
${
file
}
"
line
=
$(
delete_line_show
"
${
file
}
"
"BridgeRegistry"
)
sed
-i
''
"
${
line
}
"
' a BridgeRegistry="'
"
${
BridgeRegistry
}
"
'"'
"
${
file
}
"
sed
-i
's/EthMaturityDegree=10/'
EthMaturityDegree
=
"
${
maturityDegree
}
"
'/g'
"
${
file
}
"
sed
-i
's/maturityDegree=10/'
maturityDegree
=
"
${
maturityDegree
}
"
'/g'
"
${
file
}
"
sed
-i
's/^EthBlockFetchPeriod=.*/EthBlockFetchPeriod=500/g'
"
${
file
}
"
sed
-i
's/^fetchHeightPeriodMs=.*/fetchHeightPeriodMs=500/g'
"
${
file
}
"
}
function
copyErrLogs
()
{
if
[
-n
"
$CASE_ERR
"
]
;
then
# /var/lib/jenkins
# shellcheck disable=SC2116
dirNameFa
=
$(
echo
~
)
dirName
=
"
$dirNameFa
/x2ethereumlogs"
if
[
!
-d
"
${
dirName
}
"
]
;
then
# shellcheck disable=SC2086
mkdir
-p
${
dirName
}
fi
for
name
in
A B C D
;
do
cp
"./x2ethereum/
$name
/ebrelayer.log"
"
$dirName
/rpc_ebrelayer
$name
.log"
done
pwd
docker
cp
"
${
NODE3
}
"
:/root/logs/chain33.log
"
$dirName
/rpc_chain33.log"
# oldIFS=$IFS
# IFS=//
# # shellcheck disable=SC2207
# arrpwd=($(pwd))
# if [ ${#arrpwd[@]} -ge 3 ]; then
# i=$((${#arrpwd[@]} - 3))
# # shellcheck disable=SC2116
# # shellcheck disable=SC2086
# dockerName=$(echo ${arrpwd[$i]})
# docker cp "${dockerName}_chain33_1":/root/logs/chain33.log "$dirName/rpc_chain33.log"
# fi
# IFS=$oldIFS
fi
}
# $1 sendAddress, $2 balance
function
queryExecBalance
()
{
local
resp
=
""
...
...
@@ -147,7 +44,6 @@ function queryExecBalance() {
local
balance
=
$(
echo
"
$resp
"
| jq
-r
".result"
| jq
".[].balance"
)
if
[
"
${
balance
}
"
!=
"
${
2
}
"
]
;
then
echo_rst
"queryExecBalance"
"1"
"
${
balance
}
!=
${
2
}
"
copyErrLogs
fi
}
...
...
@@ -159,13 +55,12 @@ function queryChain33Balance() {
local
balance
=
$(
echo
$resp
| jq
-r
".result.execAccount"
| jq
".[].account.balance"
)
if
[
"
${
balance
}
"
!=
"
${
2
}
"
]
;
then
echo_rst
"queryChain33Balance"
"1"
"
${
balance
}
!=
${
2
}
"
copyErrLogs
fi
}
# $1 req , $2 balance
function
queryRelayerBalance
()
{
chain33_Http
"
${
1
}
"
${
CLIA_HTTP
}
'(.error|not) and (.result != null)'
"GetBalance"
".result.balance"
chain33_Http
"
${
1
}
"
"
${
CLIA_HTTP
}
"
'(.error|not) and (.result != null)'
"GetBalance"
".result.balance"
if
[
"
${
RETURN_RESP
}
"
!=
"
${
2
}
"
]
;
then
echo_rst
"queryRelayerBalance"
"1"
"
${
RETURN_RESP
}
!=
${
2
}
"
copyErrLogs
...
...
@@ -179,39 +74,87 @@ function queryChain33X2ethBalance() {
local
balance
=
$(
echo
"
${
RETURN_RESP
}
"
| jq
-r
".res"
| jq
".[].balance"
|
sed
's/\"//g'
)
if
[
"
${
balance
}
"
!=
"
${
2
}
"
]
;
then
echo_rst
"queryChain33X2ethBalance"
"1"
"
${
balance
}
!=
${
2
}
"
copyErrLogs
fi
}
function
StartRelayerAndDeploy
()
{
echo
-e
"
${
GRE
}
===========
$FUNCNAME
begin ===========
${
NOC
}
"
for
name
in
A B C D
;
do
local
ebrelayer
=
"./x2ethereum/
$name
/ebrelayer"
kill_ebrelayer
"
${
ebrelayer
}
"
cp
../x2ethereum/
*
./x2ethereum/
for
dockerName
in
ganachetest ebrelayera ebrelayerb ebrelayerc ebrelayerd
;
do
line
=
$(
delete_line_show
"./x2ethereum/docker-compose-x2ethereum.yml"
"
${
dockerName
}
:"
)
sed
-i
''
"
${
line
}
"
' a \ \ '
${
dockerName
}
'_rpc:'
"./x2ethereum/docker-compose-x2ethereum.yml"
done
sleep
1
rm
-rf
'./x2ethereum/A'
'./x2ethereum/B'
'./x2ethereum/C'
'./x2ethereum/D'
mkdir
'./x2ethereum/A'
'./x2ethereum/B'
'./x2ethereum/C'
'./x2ethereum/D'
cp
'../x2ethereum/relayer.toml'
'./x2ethereum/A/relayer.toml'
cp
'../x2ethereum/ebrelayer'
'./x2ethereum/A/ebrelayer'
docker-compose
-f
./x2ethereum/docker-compose-x2ethereum.yml up
--build
-d
sleep
5
start_trufflesuite
# change EthProvider url
dockerAddr
=
$(
get_docker_addr
"
${
dockerNamePrefix
}
_ganachetest_rpc_1"
)
ethUrl
=
"http://
${
dockerAddr
}
:8545"
# shellcheck disable=SC2155
local
line
=
$(
delete_line_show
"./x2ethereum/relayer.toml"
'EthProvider="ws:'
)
sed
-i
''
"
${
line
}
"
' a EthProvider="ws://'
"
${
dockerAddr
}
"
':8545/"'
"./x2ethereum/relayer.toml"
line
=
$(
delete_line_show
"./x2ethereum/relayer.toml"
'EthProviderCli="http:'
)
sed
-i
''
"
${
line
}
"
' a EthProviderCli="http://'
"
${
dockerAddr
}
"
':8545"'
"./x2ethereum/relayer.toml"
grep_port
=
$(
netstat
-tlpn
|
grep
"
\b
${
portRelayer
}
\b
"
)
while
[
-n
"
$grep_port
"
]
;
do
echo
"port
$portRelayer
is in use"
portRelayer
=
$((
portRelayer
-
4
))
grep_port
=
$(
netstat
-tlpn
|
grep
"
\b
${
portRelayer
}
\b
"
)
done
line
=
$(
delete_line_show
"./x2ethereum/docker-compose-ebrelayer.yml"
"20000:20000"
)
sed
-i
''
"
${
line
}
"
' a \ \ \ \ \ \ -\ "'
${
portRelayer
}
':'
${
portRelayer
}
'"'
"./x2ethereum/docker-compose-ebrelayer.yml"
line
=
$(
delete_line_show
"./x2ethereum/docker-compose-ebrelayer.yml"
"ebrelayera:"
)
sed
-i
''
"
${
line
}
"
' a \ \ ebrelayera_rpc:'
"./x2ethereum/docker-compose-ebrelayer.yml"
line
=
$(
delete_line_show
"./x2ethereum/relayer.toml"
"localhost:9901"
)
sed
-i
''
"
${
line
}
"
' a JrpcBindAddr=":9901"'
"./x2ethereum/relayer.toml"
docker-compose
-f
./x2ethereum/docker-compose-ebrelayer.yml up
--build
-d
sleep
1
ebrelayeraRpcHost
=
$(
get_docker_addr
"
${
dockerNamePrefix
}
_ebrelayera_rpc_1"
)
if
[[
${
ebrelayeraRpcHost
}
==
""
]]
;
then
echo
-e
"
${
RED
}
ebrelayeraRpcHost a is empty
${
NOC
}
"
fi
CLIA_HTTP
=
"http://
${
ebrelayeraRpcHost
}
:9901"
start_ebrelayer
"./x2ethereum/A/ebrelayer"
"./x2ethereum/A/ebrelayer.log"
# 部署合约
InitAndDeploy
# 获取 BridgeRegistry 地址
local
req
=
'{"method":"Manager.ShowBridgeRegistryAddr","params":[{}]}'
chain33_Http
"
$req
"
${
CLIA_HTTP
}
'(.error|not) and (.result != null)'
"
$FUNCNAME
"
".result.addr"
chain33_Http
"
$req
"
"
${
CLIA_HTTP
}
"
'(.error|not) and (.result != null)'
"
$FUNCNAME
"
".result.addr"
local
BridgeRegistry
=
"
$RETURN_RESP
"
kill_ebrelayer
"./x2ethereum/A/ebrelayer"
docker-compose
-f
./x2ethereum/docker-compose-ebrelayer.yml down
# 修改 relayer.toml 配置文件
updata_relayer_toml_rpc
"
${
BridgeRegistry
}
"
"
${
maturityDegree
}
"
"./x2ethereum/A/relayer.toml"
updata_all_relayer_toml_rpc
updata_relayer_toml_rpc
"
${
BridgeRegistry
}
"
"
${
maturityDegree
}
"
"
${
MAIN_HTTP
}
"
"./x2ethereum/relayer.toml"
updata_docker_relayer_toml_rpc
${
portRelayer
}
docker-compose
-f
"./x2ethereum/docker-compose-ebrelayer.yml"
up
--build
-d
for
name
in
b c d
;
do
docker-compose
-f
"./x2ethereum/docker-compose-ebrelayer
$name
.yml"
down
docker-compose
-f
"./x2ethereum/docker-compose-ebrelayer
$name
.yml"
up
--build
-d
done
sleep
1
ebrelayeraRpcHost
=
$(
get_docker_addr
"
${
dockerNamePrefix
}
_ebrelayera_rpc_1"
)
CLIA_HTTP
=
"http://
${
ebrelayeraRpcHost
}
:9901"
ebrelayeraRpcHost
=
$(
get_docker_addr
"
${
dockerNamePrefix
}
_ebrelayerb_rpc_1"
)
CLIB_HTTP
=
"http://
${
ebrelayeraRpcHost
}
:9901"
ebrelayeraRpcHost
=
$(
get_docker_addr
"
${
dockerNamePrefix
}
_ebrelayerc_rpc_1"
)
CLIC_HTTP
=
"http://
${
ebrelayeraRpcHost
}
:9901"
ebrelayeraRpcHost
=
$(
get_docker_addr
"
${
dockerNamePrefix
}
_ebrelayerd_rpc_1"
)
CLID_HTTP
=
"http://
${
ebrelayeraRpcHost
}
:9901"
docker ps
-a
echo
-e
"
${
GRE
}
===========
$FUNCNAME
end ===========
${
NOC
}
"
}
...
...
@@ -219,13 +162,13 @@ function StartRelayerAndDeploy() {
function
InitAndDeploy
()
{
echo
-e
"
${
GRE
}
===========
$FUNCNAME
begin ===========
${
NOC
}
"
local
req
=
'{"method":"Manager.SetPassphase","params":[{"Passphase":"123456hzj"}]}'
chain33_Http
"
$req
"
${
CLIA_HTTP
}
'(.error|not) and (.result != null)'
"SetPassphase"
".result"
chain33_Http
"
$req
"
"
${
CLIA_HTTP
}
"
'(.error|not) and (.result != null)'
"SetPassphase"
".result"
local
req
=
'{"method":"Manager.Unlock","params":["123456hzj"]}'
chain33_Http
"
$req
"
${
CLIA_HTTP
}
'(.error|not) and (.result != null)'
"Unlock"
".result"
chain33_Http
"
$req
"
"
${
CLIA_HTTP
}
"
'(.error|not) and (.result != null)'
"Unlock"
".result"
local
req
=
'{"method":"Manager.DeployContrcts","params":[{}]}'
chain33_Http
"
$req
"
${
CLIA_HTTP
}
'(.error|not) and (.result != null)'
"
$FUNCNAME
"
".result"
chain33_Http
"
$req
"
"
${
CLIA_HTTP
}
"
'(.error|not) and (.result != null)'
"
$FUNCNAME
"
".result"
echo
-e
"
${
GRE
}
===========
$FUNCNAME
end ===========
${
NOC
}
"
}
...
...
@@ -278,41 +221,35 @@ function InitChain33Vilators() {
function
EthImportKey
()
{
echo
-e
"
${
GRE
}
===========
$FUNCNAME
begin ===========
${
NOC
}
"
local
port
=
9901
# 重启 ebrelayer 并解锁
for
name
in
A B C D
;
do
start_ebrelayer
"./x2ethereum/
$name
/ebrelayer"
"./x2ethereum/
$name
/ebrelayer.log"
local
CLI_HTTP
=
"http://127.0.0.1:
${
port
}
"
if
[
"
${
name
}
"
!=
"A"
]
;
then
local
req
=
'{"method":"Manager.SetPassphase","params":[{"Passphase":"123456hzj"}]}'
chain33_Http
"
$req
"
${
CLI_HTTP
}
'(.error|not) and (.result != null)'
"SetPassphase"
".result"
fi
req
=
'{"method":"Manager.Unlock","params":["123456hzj"]}'
chain33_Http
"
$req
"
${
CLI_HTTP
}
'(.error|not) and (.result != null)'
"Unlock"
".result"
port
=
$((
port
+
1
))
done
local
req
=
'{"method":"Manager.ImportChain33PrivateKey4EthRelayer","params":["'
${
chain33ValidatorKey1
}
'"]}'
chain33_Http
"
$req
"
${
CLIA_HTTP
}
'(.error|not) and (.result != null)'
"ImportChain33PrivateKey4EthRelayer"
".result"
# 解锁
local
req
=
'{"method":"Manager.SetPassphase","params":[{"Passphase":"123456hzj"}]}'
chain33_Http
"
$req
"
"
${
CLIA_HTTP
}
"
'(.error|not) and (.result != null)'
"SetPassphase"
".result"
chain33_Http
"
$req
"
"
${
CLIB_HTTP
}
"
'(.error|not) and (.result != null)'
"SetPassphase"
".result"
chain33_Http
"
$req
"
"
${
CLIC_HTTP
}
"
'(.error|not) and (.result != null)'
"SetPassphase"
".result"
chain33_Http
"
$req
"
"
${
CLID_HTTP
}
"
'(.error|not) and (.result != null)'
"SetPassphase"
".result"
req
=
'{"method":"Manager.Unlock","params":["123456hzj"]}'
chain33_Http
"
$req
"
"
${
CLIA_HTTP
}
"
'(.error|not) and (.result != null)'
"Unlock"
".result"
chain33_Http
"
$req
"
"
${
CLIB_HTTP
}
"
'(.error|not) and (.result != null)'
"Unlock"
".result"
chain33_Http
"
$req
"
"
${
CLIC_HTTP
}
"
'(.error|not) and (.result != null)'
"Unlock"
".result"
chain33_Http
"
$req
"
"
${
CLID_HTTP
}
"
'(.error|not) and (.result != null)'
"Unlock"
".result"
req
=
'{"method":"Manager.ImportChain33PrivateKey4EthRelayer","params":["'
${
chain33ValidatorKey1
}
'"]}'
chain33_Http
"
$req
"
"
${
CLIA_HTTP
}
"
'(.error|not) and (.result != null)'
"ImportChain33PrivateKey4EthRelayer"
".result"
req
=
'{"method":"Manager.ImportChain33PrivateKey4EthRelayer","params":["'
${
chain33ValidatorKey2
}
'"]}'
chain33_Http
"
$req
"
${
CLIB_HTTP
}
'(.error|not) and (.result != null)'
"ImportChain33PrivateKey4EthRelayer"
".result"
chain33_Http
"
$req
"
"
${
CLIB_HTTP
}
"
'(.error|not) and (.result != null)'
"ImportChain33PrivateKey4EthRelayer"
".result"
req
=
'{"method":"Manager.ImportChain33PrivateKey4EthRelayer","params":["'
${
chain33ValidatorKey3
}
'"]}'
chain33_Http
"
$req
"
${
CLIC_HTTP
}
'(.error|not) and (.result != null)'
"ImportChain33PrivateKey4EthRelayer"
".result"
chain33_Http
"
$req
"
"
${
CLIC_HTTP
}
"
'(.error|not) and (.result != null)'
"ImportChain33PrivateKey4EthRelayer"
".result"
req
=
'{"method":"Manager.ImportChain33PrivateKey4EthRelayer","params":["'
${
chain33ValidatorKey4
}
'"]}'
chain33_Http
"
$req
"
${
CLID_HTTP
}
'(.error|not) and (.result != null)'
"ImportChain33PrivateKey4EthRelayer"
".result"
chain33_Http
"
$req
"
"
${
CLID_HTTP
}
"
'(.error|not) and (.result != null)'
"ImportChain33PrivateKey4EthRelayer"
".result"
req
=
'{"method":"Manager.ImportChain33RelayerPrivateKey","params":[{"privateKey":"'
${
ethValidatorAddrKeyA
}
'"}]}'
chain33_Http
"
$req
"
${
CLIA_HTTP
}
'(.error|not) and (.result != null)'
"ImportChain33RelayerPrivateKey"
".result"
chain33_Http
"
$req
"
"
${
CLIA_HTTP
}
"
'(.error|not) and (.result != null)'
"ImportChain33RelayerPrivateKey"
".result"
req
=
'{"method":"Manager.ImportChain33RelayerPrivateKey","params":[{"privateKey":"'
${
ethValidatorAddrKeyB
}
'"}]}'
chain33_Http
"
$req
"
${
CLIB_HTTP
}
'(.error|not) and (.result != null)'
"ImportChain33RelayerPrivateKey"
".result"
chain33_Http
"
$req
"
"
${
CLIB_HTTP
}
"
'(.error|not) and (.result != null)'
"ImportChain33RelayerPrivateKey"
".result"
req
=
'{"method":"Manager.ImportChain33RelayerPrivateKey","params":[{"privateKey":"'
${
ethValidatorAddrKeyC
}
'"}]}'
chain33_Http
"
$req
"
${
CLIC_HTTP
}
'(.error|not) and (.result != null)'
"ImportChain33RelayerPrivateKey"
".result"
chain33_Http
"
$req
"
"
${
CLIC_HTTP
}
"
'(.error|not) and (.result != null)'
"ImportChain33RelayerPrivateKey"
".result"
req
=
'{"method":"Manager.ImportChain33RelayerPrivateKey","params":[{"privateKey":"'
${
ethValidatorAddrKeyD
}
'"}]}'
chain33_Http
"
$req
"
${
CLID_HTTP
}
'(.error|not) and (.result != null)'
"ImportChain33RelayerPrivateKey"
".result"
chain33_Http
"
$req
"
"
${
CLID_HTTP
}
"
'(.error|not) and (.result != null)'
"ImportChain33RelayerPrivateKey"
".result"
echo
-e
"
${
GRE
}
===========
$FUNCNAME
end ===========
${
NOC
}
"
}
...
...
@@ -321,9 +258,8 @@ function TestChain33ToEthAssets() {
echo
-e
"
${
GRE
}
===========
$FUNCNAME
begin ===========
${
NOC
}
"
# token4chain33 在 以太坊 上先有 bty
local
req
=
'{"method":"Manager.CreateBridgeToken","params":["coins.bty"]}'
chain33_Http
"
$req
"
${
CLIA_HTTP
}
'(.error|not) and (.result != null)'
"CreateBridgeToken"
".result.addr"
chain33_Http
"
$req
"
"
${
CLIA_HTTP
}
"
'(.error|not) and (.result != null)'
"CreateBridgeToken"
".result.addr"
tokenAddrBty
=
${
RETURN_RESP
}
# tokenAddrBty="0x9C3D40A44a2F61Ef8D46fa8C7A731C08FB16cCEF"
req
=
'{"method":"Manager.GetBalance","params":[{"owner":"'
${
ethReceiverAddr1
}
'","tokenAddr":"'
${
tokenAddrBty
}
'"}]}'
queryRelayerBalance
"
$req
"
"0"
...
...
@@ -335,20 +271,20 @@ function TestChain33ToEthAssets() {
queryExecBalance
"
${
sendAddress
}
"
"19500000000"
eth_block_wait
$((
maturityDegree
+
2
))
eth_block_wait
$((
maturityDegree
+
2
))
"
${
ethUrl
}
"
req
=
'{"method":"Manager.GetBalance","params":[{"owner":"'
${
ethReceiverAddr1
}
'","tokenAddr":"'
${
tokenAddrBty
}
'"}]}'
queryRelayerBalance
"
$req
"
"5"
# eth burn
req
=
'{"method":"Manager.Burn","params":[{"ownerKey":"'
${
ethReceiverAddrKey1
}
'","tokenAddr":"'
${
tokenAddrBty
}
'","chain33Receiver":"'
${
chain33SenderAddr
}
'","amount":"500000000"}]}'
chain33_Http
"
$req
"
${
CLIA_HTTP
}
'(.error|not) and (.result != null)'
"Burn"
".result"
chain33_Http
"
$req
"
"
${
CLIA_HTTP
}
"
'(.error|not) and (.result != null)'
"Burn"
".result"
req
=
'{"method":"Manager.GetBalance","params":[{"owner":"'
${
ethReceiverAddr1
}
'","tokenAddr":"'
${
tokenAddrBty
}
'"}]}'
queryRelayerBalance
"
$req
"
"0"
# eth 等待 10 个区块
eth_block_wait
$((
maturityDegree
+
2
))
eth_block_wait
$((
maturityDegree
+
2
))
"
${
ethUrl
}
"
queryExecBalance
"
${
chain33SenderAddr
}
"
"500000000"
...
...
@@ -360,7 +296,7 @@ function TestChain33ToEthAssets() {
function
TestETH2Chain33Assets
()
{
echo
-e
"
${
GRE
}
===========
$FUNCNAME
begin ===========
${
NOC
}
"
local
req
=
'{"method":"Manager.ShowBridgeBankAddr","params":[{}]}'
chain33_Http
"
$req
"
${
CLIA_HTTP
}
'(.error|not) and (.result != null)'
"ShowBridgeBankAddr"
".result.addr"
chain33_Http
"
$req
"
"
${
CLIA_HTTP
}
"
'(.error|not) and (.result != null)'
"ShowBridgeBankAddr"
".result.addr"
bridgeBankAddr
=
"
${
RETURN_RESP
}
"
req
=
'{"method":"Manager.GetBalance","params":[{"owner":"'
${
bridgeBankAddr
}
'","tokenAddr":""}]}'
...
...
@@ -368,19 +304,19 @@ function TestETH2Chain33Assets() {
# eth lock 0.1
req
=
'{"method":"Manager.LockEthErc20Asset","params":[{"ownerKey":"'
${
ethReceiverAddrKey1
}
'","tokenAddr":"","amount":"100000000000000000","chain33Receiver":"'
${
sendAddress
}
'"}]}'
chain33_Http
"
$req
"
${
CLIA_HTTP
}
'(.error|not) and (.result != null)'
"LockEthErc20Asset"
".result"
chain33_Http
"
$req
"
"
${
CLIA_HTTP
}
"
'(.error|not) and (.result != null)'
"LockEthErc20Asset"
".result"
req
=
'{"method":"Manager.GetBalance","params":[{"owner":"'
${
bridgeBankAddr
}
'","tokenAddr":""}]}'
queryRelayerBalance
"
$req
"
"0.1"
# eth 等待 10 个区块
eth_block_wait
$((
maturityDegree
+
2
))
eth_block_wait
$((
maturityDegree
+
2
))
"
${
ethUrl
}
"
req
=
'{"method":"Chain33.Query","params":[{"execer":"x2ethereum","funcName":"GetRelayerBalance","payload":{"tokenSymbol":"eth","address":"'
${
sendAddress
}
'","tokenAddr":"0x0000000000000000000000000000000000000000"}}]}'
queryChain33X2ethBalance
"
${
req
}
"
"0.1"
req
=
'{"method":"Manager.GetBalance","params":[{"owner":"'
${
ethReceiverAddr2
}
'","tokenAddr":""}]}'
chain33_Http
"
${
req
}
"
${
CLIA_HTTP
}
'(.error|not) and (.result != null)'
"GetBalance"
".result.balance"
chain33_Http
"
${
req
}
"
"
${
CLIA_HTTP
}
"
'(.error|not) and (.result != null)'
"GetBalance"
".result.balance"
local
balance
=
${
RETURN_RESP
}
# burn 0.1
...
...
@@ -390,7 +326,7 @@ function TestETH2Chain33Assets() {
req
=
'{"method":"Chain33.Query","params":[{"execer":"x2ethereum","funcName":"GetRelayerBalance","payload":{"tokenSymbol":"eth","address":"'
${
sendAddress
}
'","tokenAddr":"0x0000000000000000000000000000000000000000"}}]}'
queryChain33X2ethBalance
"
${
req
}
"
"0"
eth_block_wait
$((
maturityDegree
+
3
))
eth_block_wait
$((
maturityDegree
+
2
))
"
${
ethUrl
}
"
req
=
'{"method":"Manager.GetBalance","params":[{"owner":"'
${
bridgeBankAddr
}
'","tokenAddr":""}]}'
queryRelayerBalance
"
$req
"
"0"
...
...
@@ -406,18 +342,18 @@ function TestETH2Chain33Erc20() {
echo
-e
"
${
GRE
}
===========
$FUNCNAME
begin ===========
${
NOC
}
"
# token4erc20 在 chain33 上先有 token,同时 mint
local
req
=
'{"method":"Manager.CreateERC20Token","params":["testc"]}'
chain33_Http
"
$req
"
${
CLIA_HTTP
}
'(.error|not) and (.result != null)'
"CreateERC20Token"
".result.addr"
chain33_Http
"
$req
"
"
${
CLIA_HTTP
}
"
'(.error|not) and (.result != null)'
"CreateERC20Token"
".result.addr"
tokenAddr
=
"
${
RETURN_RESP
}
"
# 先铸币 1000
req
=
'{"method":"Manager.MintErc20","params":[{"owner":"'
${
ethReceiverAddr1
}
'","tokenAddr":"'
${
tokenAddr
}
'","amount":"100000000000"}]}'
chain33_Http
"
$req
"
${
CLIA_HTTP
}
'(.error|not) and (.result != null)'
"MintErc20"
".result.addr"
chain33_Http
"
$req
"
"
${
CLIA_HTTP
}
"
'(.error|not) and (.result != null)'
"MintErc20"
".result.addr"
req
=
'{"method":"Manager.GetBalance","params":[{"owner":"'
${
ethReceiverAddr1
}
'","tokenAddr":"'
${
tokenAddr
}
'"}]}'
queryRelayerBalance
"
$req
"
"1000"
local
req
=
'{"method":"Manager.ShowBridgeBankAddr","params":[{}]}'
chain33_Http
"
$req
"
${
CLIA_HTTP
}
'(.error|not) and (.result != null)'
"ShowBridgeBankAddr"
".result.addr"
chain33_Http
"
$req
"
"
${
CLIA_HTTP
}
"
'(.error|not) and (.result != null)'
"ShowBridgeBankAddr"
".result.addr"
bridgeBankAddr
=
"
${
RETURN_RESP
}
"
req
=
'{"method":"Manager.GetBalance","params":[{"owner":"'
${
bridgeBankAddr
}
'","tokenAddr":"'
${
tokenAddr
}
'"}]}'
...
...
@@ -425,7 +361,7 @@ function TestETH2Chain33Erc20() {
# lock 100
req
=
'{"method":"Manager.LockEthErc20Asset","params":[{"ownerKey":"'
${
ethReceiverAddrKey1
}
'","tokenAddr":"'
${
tokenAddr
}
'","amount":"10000000000","chain33Receiver":"'
${
chain33Validator1
}
'"}]}'
chain33_Http
"
$req
"
${
CLIA_HTTP
}
'(.error|not) and (.result != null)'
"LockEthErc20Asset"
".result"
chain33_Http
"
$req
"
"
${
CLIA_HTTP
}
"
'(.error|not) and (.result != null)'
"LockEthErc20Asset"
".result"
req
=
'{"method":"Manager.GetBalance","params":[{"owner":"'
${
ethReceiverAddr1
}
'","tokenAddr":"'
${
tokenAddr
}
'"}]}'
queryRelayerBalance
"
$req
"
"900"
...
...
@@ -434,7 +370,7 @@ function TestETH2Chain33Erc20() {
queryRelayerBalance
"
$req
"
"100"
# eth 等待 10 个区块
eth_block_wait
$((
maturityDegree
+
2
))
eth_block_wait
$((
maturityDegree
+
2
))
"
${
ethUrl
}
"
req
=
'{"method":"Chain33.Query","params":[{"execer":"x2ethereum","funcName":"GetRelayerBalance","payload":{"tokenSymbol":"testc","address":"'
${
chain33Validator1
}
'","tokenAddr":"'
${
tokenAddr
}
'"}}]}'
queryChain33X2ethBalance
"
${
req
}
"
"100"
...
...
@@ -447,7 +383,7 @@ function TestETH2Chain33Erc20() {
req
=
'{"method":"Chain33.Query","params":[{"execer":"x2ethereum","funcName":"GetRelayerBalance","payload":{"tokenSymbol":"testc","address":"'
${
chain33Validator1
}
'","tokenAddr":"'
${
tokenAddr
}
'"}}]}'
queryChain33X2ethBalance
"
${
req
}
"
"0"
eth_block_wait
$((
maturityDegree
+
3
))
eth_block_wait
$((
maturityDegree
+
2
))
"
${
ethUrl
}
"
req
=
'{"method":"Manager.GetBalance","params":[{"owner":"'
${
ethReceiverAddr2
}
'","tokenAddr":"'
${
tokenAddr
}
'"}]}'
queryRelayerBalance
"
$req
"
"100"
...
...
@@ -459,11 +395,11 @@ function TestETH2Chain33Erc20() {
}
function
rpc_test
()
{
set
-x
set
+e
set
-x
chain33_RpcTestBegin x2ethereum
MAIN_HTTP
=
"
$1
"
NODE3
=
"
$2
"
dockerNamePrefix
=
"
$2
"
echo
"main_ip=
$MAIN_HTTP
"
ispara
=
$(
echo
'"'
"
${
MAIN_HTTP
}
"
'"'
| jq
'.|contains("8901")'
)
...
...
@@ -477,6 +413,10 @@ function rpc_test() {
TestChain33ToEthAssets
TestETH2Chain33Assets
TestETH2Chain33Erc20
copyErrLogs
docker-compose
-f
./x2ethereum/docker-compose-x2ethereum.yml down
fi
chain33_RpcTestRst x2ethereum
"
$CASE_ERR
"
}
...
...
plugin/dapp/x2ethereum/commands/commands.go
View file @
b375d231
...
...
@@ -72,7 +72,6 @@ func addChain33ToEthFlags(cmd *cobra.Command) {
cmd
.
Flags
()
.
Float64P
(
"amount"
,
"a"
,
float64
(
0
),
"the amount of this contract want to lock"
)
_
=
cmd
.
MarkFlagRequired
(
"amount"
)
}
func
burn
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
...
...
plugin/dapp/x2ethereum/ebcli/main.go
View file @
b375d231
...
...
@@ -5,6 +5,7 @@
package
main
import
(
"flag"
"fmt"
"net/http"
"os"
...
...
@@ -13,13 +14,18 @@ import (
"github.com/33cn/chain33/common/log"
"github.com/33cn/chain33/pluginmgr"
"github.com/33cn/plugin/plugin/dapp/x2ethereum/ebcli/buildflags"
relayerTypes
"github.com/33cn/plugin/plugin/dapp/x2ethereum/ebrelayer/types"
tml
"github.com/BurntSushi/toml"
"github.com/spf13/cobra"
)
var
rootCmd
=
&
cobra
.
Command
{
Use
:
"chain33xEth-relayer"
+
"-cli"
,
Short
:
"chain33xEth-relayer"
+
"client tools"
,
}
var
(
rootCmd
=
&
cobra
.
Command
{
Use
:
"chain33xEth-relayer"
+
"-cli"
,
Short
:
"chain33xEth-relayer"
+
"client tools"
,
}
configPath
=
flag
.
String
(
"f"
,
""
,
"configfile"
)
)
func
init
()
{
rootCmd
.
AddCommand
(
...
...
@@ -59,19 +65,33 @@ func run(RPCAddr, NodeAddr string) {
log
.
SetLogLevel
(
"error"
)
rootCmd
.
PersistentFlags
()
.
String
(
"rpc_laddr"
,
RPCAddr
,
"http url"
)
rootCmd
.
PersistentFlags
()
.
String
(
"node_addr"
,
NodeAddr
,
"eth node url"
)
//rootCmd.PersistentFlags().String("rpc_laddr", "", "http url")
if
err
:=
rootCmd
.
Execute
();
err
!=
nil
{
fmt
.
Println
(
err
)
os
.
Exit
(
1
)
}
}
func
initCfg
(
path
string
)
*
relayerTypes
.
RelayerConfig
{
var
cfg
relayerTypes
.
RelayerConfig
if
_
,
err
:=
tml
.
DecodeFile
(
path
,
&
cfg
);
err
!=
nil
{
fmt
.
Println
(
err
)
os
.
Exit
(
-
1
)
}
return
&
cfg
}
func
main
()
{
if
*
configPath
==
""
{
*
configPath
=
"relayer.toml"
}
cfg
:=
initCfg
(
*
configPath
)
if
buildflags
.
RPCAddr
==
""
{
buildflags
.
RPCAddr
=
"http://localhost:9901"
}
if
buildflags
.
NodeAddr
==
""
{
buildflags
.
NodeAddr
=
"http://127.0.0.1:7545"
buildflags
.
NodeAddr
=
cfg
.
EthProviderCli
}
run
(
buildflags
.
RPCAddr
,
buildflags
.
NodeAddr
)
}
plugin/dapp/x2ethereum/ebrelayer/relayer.toml
View file @
b375d231
# 本配置文件专门用于33复杂美闪电网络使用,即lns33
title
=
"x2Ethereum_relayer"
#用于cli向该relayer进行配置
JrpcBindAddr
=
"localhost:9901"
EthProviderCli
=
"http://127.0.0.1:7545"
EthProvider
=
"ws://127.0.0.1:7545/"
#EthProvider="wss://rinkeby.infura.io/ws/v3/404eb4acc421426ebeb6e92c7ce9a270"
#EthProvider="wss://ropsten.infura.io/ws/v3/404eb4acc421426ebeb6e92c7ce9a270"
...
...
plugin/dapp/x2ethereum/ebrelayer/types/config.pb.go
View file @
b375d231
...
...
@@ -69,6 +69,7 @@ type RelayerConfig struct {
Deploy
*
Deploy
`protobuf:"bytes,7,opt,name=deploy" json:"deploy,omitempty"`
EthMaturityDegree
int32
`protobuf:"varint,8,opt,name=ethMaturityDegree" json:"ethMaturityDegree,omitempty"`
EthBlockFetchPeriod
int32
`protobuf:"varint,9,opt,name=ethBlockFetchPeriod" json:"ethBlockFetchPeriod,omitempty"`
EthProviderCli
string
`protobuf:"bytes,10,opt,name=ethProviderCli" json:"ethProviderCli,omitempty"`
}
func
(
m
*
RelayerConfig
)
Reset
()
{
*
m
=
RelayerConfig
{}
}
...
...
plugin/dapp/x2ethereum/ebrelayer/types/protos/config.proto
View file @
b375d231
...
...
@@ -40,6 +40,7 @@ message RelayerConfig {
Deploy
deploy
=
7
;
int32
ethMaturityDegree
=
8
;
int32
ethBlockFetchPeriod
=
9
;
string
ethProviderCli
=
10
;
}
message
SyncTxReceiptConfig
{
...
...
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