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
d756bfcc
Commit
d756bfcc
authored
May 09, 2020
by
QM
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updata test
parent
0f1093a0
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
175 additions
and
16 deletions
+175
-16
build.sh
plugin/dapp/x2Ethereum/cmd/build.sh
+1
-1
allRelayerTest.sh
plugin/dapp/x2Ethereum/cmd/build/allRelayerTest.sh
+163
-11
docker-compose-x2Ethereum.yml
...n/dapp/x2Ethereum/cmd/build/docker-compose-x2Ethereum.yml
+7
-0
publicTest.sh
plugin/dapp/x2Ethereum/testsh/publicTest.sh
+3
-3
x2ethereumTest.sh
plugin/dapp/x2Ethereum/testsh/x2ethereumTest.sh
+1
-1
No files found.
plugin/dapp/x2Ethereum/cmd/build.sh
View file @
d756bfcc
...
...
@@ -17,7 +17,7 @@ go build -i ${FLAG} -v -o "${OUT_DIR}/ebcli_C" -ldflags "-X ${SRC_EBCLI}/buildfl
go build
-i
${
FLAG
}
-v
-o
"
${
OUT_DIR
}
/ebcli_D"
-ldflags
"-X
${
SRC_EBCLI
}
/buildflags.RPCAddr=http://localhost:9904"
"
${
SRC_EBCLI
}
"
cp
../ebrelayer/relayer.toml
"
${
OUT_DIR
}
/relayer.toml"
cp
../
ebrelayer
/publicTest.sh
"
${
OUT_DIR
}
/publicTest.sh"
cp
../
testsh
/publicTest.sh
"
${
OUT_DIR
}
/publicTest.sh"
cp
./build/
*
"
${
OUT_DIR
}
"
OUT_TESTDIR
=
"
${
1
}
/dapptest/
$strapp
"
...
...
plugin/dapp/x2Ethereum/cmd/build/allRelayerTest.sh
View file @
d756bfcc
...
...
@@ -221,9 +221,6 @@ function TestChain33ToEthAssets() {
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethReceiverAddr1
}
"
-t
"
${
tokenAddr
}
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"0"
kill_ebrelayerC
kill_ebrelayerD
# chain33 lock bty
hash
=
$(${
Chain33Cli
}
send x2ethereum lock
-a
5
-t
bty
-r
${
ethReceiverAddr1
}
-q
${
tokenAddr
}
-k
12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
)
block_wait
"
${
Chain33Cli
}
"
$((
maturityDegree
+
2
))
...
...
@@ -235,29 +232,176 @@ function TestChain33ToEthAssets() {
eth_block_wait
$((
maturityDegree
+
2
))
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethReceiverAddr1
}
"
-t
"
${
tokenAddr
}
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"5"
# eth burn
result
=
$(${
CLIA
}
relayer ethereum burn
-m
5
-k
"
${
ethReceiverAddrKey1
}
"
-r
"
${
chain33SenderAddr
}
"
-t
"
${
tokenAddr
}
"
)
cli_ret
"
${
result
}
"
"burn"
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethReceiverAddr1
}
"
-t
"
${
tokenAddr
}
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"0"
start_ebrelayerC
# eth 等待 10 个区块
eth_block_wait
$((
maturityDegree
+
2
))
result
=
$(${
Chain33Cli
}
account balance
-a
"
${
chain33SenderAddr
}
"
-e
x2ethereum
)
balance_ret
"
${
result
}
"
"5"
echo
-e
"
${
GRE
}
===========
$FUNCNAME
end ===========
${
NOC
}
"
}
# eth to chain33
# 在以太坊上锁定资产,然后在 chain33 上铸币,针对 eth 资产
function
TestETH2Chain33Assets
()
{
echo
-e
"
${
GRE
}
===========
$FUNCNAME
begin ===========
${
NOC
}
"
${
CLIA
}
relayer unlock
-p
123456hzj
result
=
$(${
CLIA
}
relayer ethereum bridgeBankAddr
)
bridgeBankAddr
=
$(
cli_ret
"
${
result
}
"
"bridgeBankAddr"
".addr"
)
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
bridgeBankAddr
}
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"0"
# eth lock 0.1
result
=
$(${
CLIA
}
relayer ethereum lock
-m
0.1
-k
"
${
ethReceiverAddrKey1
}
"
-r
12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
)
cli_ret
"
${
result
}
"
"lock"
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
bridgeBankAddr
}
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"0.1"
# eth 等待 10 个区块
eth_block_wait
$((
maturityDegree
+
2
))
result
=
$(${
Chain33Cli
}
x2ethereum balance
-s
12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
-t
eth | jq
".res"
| jq
".[]"
)
balance_ret
"
${
result
}
"
"0.1"
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
)
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 2
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
bridgeBankAddr
}
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"0"
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethReceiverAddr2
}
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
$(
echo
"
${
balance
}
+0.1"
| bc
)
echo
-e
"
${
GRE
}
===========
$FUNCNAME
end ===========
${
NOC
}
"
}
function
TestETH2Chain33Erc20
()
{
echo
-e
"
${
GRE
}
===========
$FUNCNAME
begin ===========
${
NOC
}
"
${
CLIA
}
relayer unlock
-p
123456hzj
# token4erc20 在 chain33 上先有 token,同时 mint
tokenSymbol
=
"testc"
result
=
$(${
CLIA
}
relayer ethereum token4erc20
-s
"
${
tokenSymbol
}
"
)
tokenAddr
=
$(
cli_ret
"
${
result
}
"
"token4erc20"
".addr"
)
# 先铸币 1000
result
=
$(${
CLIA
}
relayer ethereum mint
-m
1000
-o
"
${
ethReceiverAddr1
}
"
-t
"
${
tokenAddr
}
"
)
cli_ret
"
${
result
}
"
"mint"
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethReceiverAddr1
}
"
-t
"
${
tokenAddr
}
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"1000"
result
=
$(${
CLIA
}
relayer ethereum bridgeBankAddr
)
bridgeBankAddr
=
$(
cli_ret
"
${
result
}
"
"bridgeBankAddr"
".addr"
)
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
bridgeBankAddr
}
"
-t
"
${
tokenAddr
}
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"0"
# lock 100
result
=
$(${
CLIA
}
relayer ethereum lock
-m
100
-k
"
${
ethReceiverAddrKey1
}
"
-r
"
${
chain33Validator1
}
"
-t
"
${
tokenAddr
}
"
)
cli_ret
"
${
result
}
"
"lock"
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethReceiverAddr1
}
"
-t
"
${
tokenAddr
}
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"900"
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
bridgeBankAddr
}
"
-t
"
${
tokenAddr
}
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"100"
# eth 等待 10 个区块
eth_block_wait
$((
maturityDegree
+
2
))
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
}
"
)
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 2
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethReceiverAddr2
}
"
-t
"
${
tokenAddr
}
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"100"
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
bridgeBankAddr
}
"
-t
"
${
tokenAddr
}
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"0"
echo
-e
"
${
GRE
}
===========
$FUNCNAME
end ===========
${
NOC
}
"
}
function
TestChain33ToEthAssetsKill
()
{
echo
-e
"
${
GRE
}
===========
$FUNCNAME
begin ===========
${
NOC
}
"
tokenAddr
=
"0x9C3D40A44a2F61Ef8D46fa8C7A731C08FB16cCEF"
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethReceiverAddr2
}
"
-t
"
${
tokenAddr
}
"
)
ok
=
$(
echo
"
${
result
}
"
| jq
-r
.isOK
)
if
[[
${
ok
}
!=
"true"
]]
;
then
# token4chain33 在 以太坊 上先有 bty
result
=
$(${
CLIA
}
relayer ethereum token4chain33
-s
bty
)
tokenAddr
=
$(
cli_ret
"
${
result
}
"
"token4chain33"
".addr"
)
fi
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethReceiverAddr1
}
"
-t
"
${
tokenAddr
}
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"0"
kill_ebrelayerC
kill_ebrelayerD
# chain33 lock bty
hash
=
$(${
Chain33Cli
}
send x2ethereum lock
-a
5
-t
bty
-r
${
ethReceiverAddr2
}
-q
${
tokenAddr
}
-k
12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
)
block_wait
"
${
Chain33Cli
}
"
$((
maturityDegree
+
2
))
check_tx
"
${
Chain33Cli
}
"
"
${
hash
}
"
eth_block_wait
$((
maturityDegree
+
2
))
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethReceiverAddr2
}
"
-t
"
${
tokenAddr
}
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"0"
start_ebrelayerC
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethReceiverAddr2
}
"
-t
"
${
tokenAddr
}
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"5"
# eth burn
result
=
$(${
CLIA
}
relayer ethereum burn
-m
5
-k
"
${
ethReceiverAddrKey
1
}
"
-r
"
${
chain33SenderAddr
}
"
-t
"
${
tokenAddr
}
"
)
result
=
$(${
CLIA
}
relayer ethereum burn
-m
5
-k
"
${
ethReceiverAddrKey
2
}
"
-r
"
${
chain33Validator1
}
"
-t
"
${
tokenAddr
}
"
)
cli_ret
"
${
result
}
"
"burn"
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethReceiverAddr
1
}
"
-t
"
${
tokenAddr
}
"
)
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethReceiverAddr
2
}
"
-t
"
${
tokenAddr
}
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"0"
# eth 等待 10 个区块
eth_block_wait
$((
maturityDegree
+
2
))
result
=
$(${
Chain33Cli
}
account balance
-a
"
${
chain33
SenderAddr
}
"
-e
x2ethereum
)
result
=
$(${
Chain33Cli
}
account balance
-a
"
${
chain33
Validator1
}
"
-e
x2ethereum
)
balance_ret
"
${
result
}
"
"0"
start_ebrelayerD
result
=
$(${
Chain33Cli
}
account balance
-a
"
${
chain33
SenderAddr
}
"
-e
x2ethereum
)
result
=
$(${
Chain33Cli
}
account balance
-a
"
${
chain33
Validator1
}
"
-e
x2ethereum
)
balance_ret
"
${
result
}
"
"5"
echo
-e
"
${
GRE
}
===========
$FUNCNAME
end ===========
${
NOC
}
"
...
...
@@ -265,7 +409,7 @@ function TestChain33ToEthAssets() {
# eth to chain33
# 在以太坊上锁定资产,然后在 chain33 上铸币,针对 eth 资产
function
TestETH2Chain33Assets
()
{
function
TestETH2Chain33Assets
Kill
()
{
echo
-e
"
${
GRE
}
===========
$FUNCNAME
begin ===========
${
NOC
}
"
${
CLIA
}
relayer unlock
-p
123456hzj
...
...
@@ -324,12 +468,12 @@ function TestETH2Chain33Assets() {
echo
-e
"
${
GRE
}
===========
$FUNCNAME
end ===========
${
NOC
}
"
}
function
TestETH2Chain33Erc20
()
{
function
TestETH2Chain33Erc20
Kill
()
{
echo
-e
"
${
GRE
}
===========
$FUNCNAME
begin ===========
${
NOC
}
"
${
CLIA
}
relayer unlock
-p
123456hzj
# token4erc20 在 chain33 上先有 token,同时 mint
tokenSymbol
=
"testc"
tokenSymbol
=
"testc
c
"
result
=
$(${
CLIA
}
relayer ethereum token4erc20
-s
"
${
tokenSymbol
}
"
)
tokenAddr
=
$(
cli_ret
"
${
result
}
"
"token4erc20"
".addr"
)
...
...
@@ -407,12 +551,20 @@ function MainTest() {
echo
-e
"
${
GRE
}
maturityDegree is
${
maturityDegree
}
${
NOC
}
"
fi
# init
StartRelayerAndDeploy
InitChain33Vilators
EthImportKey
# test
TestChain33ToEthAssets
TestETH2Chain33Assets
TestETH2Chain33Erc20
# kill relayer and start relayer
TestChain33ToEthAssetsKill
TestETH2Chain33AssetsKill
TestETH2Chain33Erc20Kill
echo
-e
"
${
GRE
}
===========allTest
$FUNCNAME
end ===========
${
NOC
}
"
}
plugin/dapp/x2Ethereum/cmd/build/docker-compose-x2Ethereum.yml
0 → 100644
View file @
d756bfcc
version
:
'
3'
#services:
# ganachetest:
# build:
# context: .
plugin/dapp/x2Ethereum/testsh/publicTest.sh
View file @
d756bfcc
...
...
@@ -368,11 +368,11 @@ function updata_all_relayer_toml2() {
function
start_trufflesuite
()
{
# 如果原来存在先删除
local
ganacheName
=
ganachetest
local
isExit
=
$(
docker inspect
${
ganacheName
}
| jq
".[]
"
)
if
[[
${
isExit
}
!=
""
]]
;
then
#local isExit=$(docker inspect ${ganacheName} | jq ".[]" | jq ".Id
")
#
if [[ ${isExit} != "" ]]; then
docker stop
${
ganacheName
}
docker
rm
${
ganacheName
}
fi
#
fi
# 启动 eth
docker run
-d
--name
${
ganacheName
}
-p
7545:8545
-l
eth_test trufflesuite/ganache-cli:latest
-a
10
--debug
-b
5
-m
"coast bar giraffe art venue decide symbol law visual crater vital fold"
...
...
plugin/dapp/x2Ethereum/testsh/x2ethereumTest.sh
View file @
d756bfcc
...
...
@@ -376,4 +376,4 @@ function main() {
}
# $1 等待区块 默认10
main
"
${
1
}
"
main
1
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