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
03e6466a
Commit
03e6466a
authored
May 29, 2020
by
QM
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updata test sh
parent
92895210
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
51 deletions
+34
-51
allRelayerTest.sh
plugin/dapp/x2ethereum/cmd/build/allRelayerTest.sh
+16
-16
perf_test.sh
plugin/dapp/x2ethereum/cmd/build/perf_test.sh
+10
-34
ethereum.go
...in/dapp/x2ethereum/ebrelayer/relayer/ethereum/ethereum.go
+6
-0
publicTest.sh
plugin/dapp/x2ethereum/testsh/publicTest.sh
+2
-1
No files found.
plugin/dapp/x2ethereum/cmd/build/allRelayerTest.sh
View file @
03e6466a
...
...
@@ -464,55 +464,55 @@ function TestETH2Chain33Erc20Kill() {
# token4erc20 在 chain33 上先有 token,同时 mint
tokenSymbol
=
"testcc"
result
=
$(${
CLIA
}
relayer ethereum token4erc20
-s
"
${
tokenSymbol
}
"
)
tokenAddr
=
$(
cli_ret
"
${
result
}
"
"token4erc20"
".addr"
)
tokenAddr
2
=
$(
cli_ret
"
${
result
}
"
"token4erc20"
".addr"
)
# 先铸币 1000
result
=
$(${
CLIA
}
relayer ethereum mint
-m
1000
-o
"
${
ethReceiverAddr1
}
"
-t
"
${
tokenAddr
}
"
)
result
=
$(${
CLIA
}
relayer ethereum mint
-m
1000
-o
"
${
ethReceiverAddr1
}
"
-t
"
${
tokenAddr
2
}
"
)
cli_ret
"
${
result
}
"
"mint"
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethReceiverAddr1
}
"
-t
"
${
tokenAddr
}
"
)
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethReceiverAddr1
}
"
-t
"
${
tokenAddr
2
}
"
)
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
}
"
)
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
bridgeBankAddr
}
"
-t
"
${
tokenAddr
2
}
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"0"
kill_ebrelayerC
kill_ebrelayerD
# lock 100
result
=
$(${
CLIA
}
relayer ethereum lock
-m
100
-k
"
${
ethReceiverAddrKey1
}
"
-r
"
${
chain33Validator1
}
"
-t
"
${
tokenAddr
}
"
)
result
=
$(${
CLIA
}
relayer ethereum lock
-m
100
-k
"
${
ethReceiverAddrKey1
}
"
-r
"
${
chain33Validator1
}
"
-t
"
${
tokenAddr
2
}
"
)
cli_ret
"
${
result
}
"
"lock"
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethReceiverAddr1
}
"
-t
"
${
tokenAddr
}
"
)
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethReceiverAddr1
}
"
-t
"
${
tokenAddr
2
}
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"900"
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
bridgeBankAddr
}
"
-t
"
${
tokenAddr
}
"
)
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
bridgeBankAddr
}
"
-t
"
${
tokenAddr
2
}
"
)
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
".[]"
)
result
=
$(${
Chain33Cli
}
x2ethereum balance
-s
"
${
chain33Validator1
}
"
-t
"
${
tokenSymbol
}
"
-a
"
${
tokenAddr
2
}
"
| jq
".res"
| jq
".[]"
)
balance_ret
"
${
result
}
"
"0"
start_ebrelayerC
start_ebrelayerD
result
=
$(${
Chain33Cli
}
x2ethereum balance
-s
"
${
chain33Validator1
}
"
-t
"
${
tokenSymbol
}
"
-a
"
${
tokenAddr
}
"
| jq
".res"
| jq
".[]"
)
result
=
$(${
Chain33Cli
}
x2ethereum balance
-s
"
${
chain33Validator1
}
"
-t
"
${
tokenSymbol
}
"
-a
"
${
tokenAddr
2
}
"
| jq
".res"
| jq
".[]"
)
balance_ret
"
${
result
}
"
"100"
kill_ebrelayerC
kill_ebrelayerD
# 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
2
}
"
-k
"
${
chain33Validator1
}
"
)
block_wait
"
${
Chain33Cli
}
"
$((
maturityDegree
+
2
))
check_tx
"
${
Chain33Cli
}
"
"
${
hash
}
"
result
=
$(${
Chain33Cli
}
x2ethereum balance
-s
"
${
chain33Validator1
}
"
-t
"
${
tokenSymbol
}
"
-a
"
${
tokenAddr
}
"
| jq
".res"
| jq
".[]"
)
result
=
$(${
Chain33Cli
}
x2ethereum balance
-s
"
${
chain33Validator1
}
"
-t
"
${
tokenSymbol
}
"
-a
"
${
tokenAddr
2
}
"
| jq
".res"
| jq
".[]"
)
balance_ret
"
${
result
}
"
"0"
eth_block_wait 2
...
...
@@ -520,10 +520,10 @@ function TestETH2Chain33Erc20Kill() {
start_ebrelayerC
start_ebrelayerD
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethReceiverAddr2
}
"
-t
"
${
tokenAddr
}
"
)
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethReceiverAddr2
}
"
-t
"
${
tokenAddr
2
}
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"100"
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
bridgeBankAddr
}
"
-t
"
${
tokenAddr
}
"
)
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
bridgeBankAddr
}
"
-t
"
${
tokenAddr
2
}
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"0"
echo
-e
"
${
GRE
}
===========
$FUNCNAME
end ===========
${
NOC
}
"
...
...
@@ -552,9 +552,9 @@ function AllRelayerMainTest() {
TestETH2Chain33Erc20
# kill relayer and start relayer
#
TestChain33ToEthAssetsKill
#
TestETH2Chain33AssetsKill
#
TestETH2Chain33Erc20Kill
TestChain33ToEthAssetsKill
TestETH2Chain33AssetsKill
TestETH2Chain33Erc20Kill
echo
-e
"
${
GRE
}
===========
$FUNCNAME
end ===========
${
NOC
}
"
}
plugin/dapp/x2ethereum/cmd/build/perf_test.sh
View file @
03e6466a
...
...
@@ -11,7 +11,6 @@ CLIA="./ebcli_A"
Chain33_CLI
=
""
Ethsender
=
"0xa4ea64a583f6e51c3799335b28a8f0529570a635"
privateKeys[0]
=
"8656d2bc732a8a816a461ba5e2d8aac7c7f85c26a813df30d5327210465eb230"
privateKeys[1]
=
"3fa21584ae2e4fd74db9b58e2386f5481607dfa4d7ba0617aaa7858e5025dc1e"
privateKeys[2]
=
"1385016736f7379884763f4a39811d1391fa156a7ca017be6afffa52bb327695"
...
...
@@ -19,7 +18,6 @@ privateKeys[3]="4ae589fe3837dcfc90d1c85b8423dc30841525cbebc41dfb537868b0f8376bbf
privateKeys[4]
=
"62ca4122aac0e6f35bed02fc15c7ddbdaa07f2f2a1821c8b8210b891051e3ee9"
privateKeys[5]
=
"355b876d7cbcb930d5dfab767f66336ce327e082cbaa1877210c1bae89b1df71"
privateKeys[6]
=
"9dc6df3a8ab139a54d8a984f54958ae0661f880229bf3bdbb886b87d58b56a08"
ethAddress[0]
=
"0x8AFDADFC88a1087c9A1D6c0F5Dd04634b87F303a"
ethAddress[1]
=
"0x92C8b16aFD6d423652559C6E266cBE1c29Bfd84f"
ethAddress[2]
=
"0xdb15E7327aDc83F2878624bBD6307f5Af1B477b4"
...
...
@@ -33,8 +31,7 @@ tokenAddr=""
tokenAddrBty
=
""
loop_send_lock_eth
()
{
#while 遍历数组
# ======================== Ethereum Lock =========================================
# 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'
)
...
...
@@ -61,14 +58,12 @@ 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'
)
diff
=
$(
(
nowChain33Balance
-
preChain33Balance
)
)
diff
=
$(
echo
"
$nowChain33Balance
-
$preChain33Balance
"
| bc
)
check_number
"
${
diff
}
"
7
}
loop_send_burn_eth
()
{
# =========================== Chain33 Burn ========================================
echo
-e
"
${
GRE
}
=========== Chain33 Burn begin ===========
${
NOC
}
"
preChain33Balance
=
$(${
Chain33_CLI
}
x2ethereum balance
-s
12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
-t
eth | jq
".res"
| jq
".[]"
| jq
".balance"
|
sed
's/\"//g'
)
...
...
@@ -97,14 +92,11 @@ loop_send_burn_eth() {
let
i++
done
nowChain33Balance
=
$(${
Chain33_CLI
}
x2ethereum balance
-s
12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
-t
eth | jq
".res"
| jq
".[]"
| jq
".balance"
|
sed
's/\"//g'
)
diff
=
$(
(
preChain33Balance
-
nowChain33Balance
)
)
diff
=
$(
echo
"
$preChain33Balance
-
$nowChain33Balance
"
| bc
)
check_number
"
${
diff
}
"
7
}
loop_send_lock_bty
()
{
# =========================== Chain33 Lock =========================================
echo
-e
"
${
GRE
}
=========== Chain33 Lock begin ===========
${
NOC
}
"
preChain33Balance
=
$(${
Chain33_CLI
}
account balance
-a
12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
-e
x2ethereum | jq
-r
".balance"
|
sed
's/\"//g'
)
...
...
@@ -130,15 +122,11 @@ loop_send_lock_bty() {
let
i++
done
nowChain33Balance
=
$(${
Chain33_CLI
}
account balance
-a
12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
-e
x2ethereum | jq
-r
".balance"
|
sed
's/\"//g'
)
check_number
"
${
nowChain33Balance
}
"
"188.0000"
check_number
"
${
preChain33Balance
}
"
"195.0000"
diff
=
$(
echo
"
$preChain33Balance
-
$nowChain33Balance
"
| bc
)
check_number
"
${
diff
}
"
7
}
loop_send_burn_bty
()
{
# =========================== Ethereum Burn ========================================
echo
-e
"
${
GRE
}
=========== Ethereum Burn begin ===========
${
NOC
}
"
preChain33Balance
=
$(${
Chain33_CLI
}
account balance
-a
12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
-e
x2ethereum | jq
-r
".balance"
|
sed
's/\"//g'
)
...
...
@@ -165,31 +153,24 @@ loop_send_burn_bty() {
let
i++
done
nowChain33Balance
=
$(${
Chain33_CLI
}
account balance
-a
12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
-e
x2ethereum | jq
-r
".balance"
|
sed
's/\"//g'
)
check_number
"
${
preChain33Balance
}
"
"188.0000"
check_number
"
${
nowChain33Balance
}
"
"195.0000"
diff
=
$(
echo
"
$nowChain33Balance
-
$preChain33Balance
"
| bc
)
check_number
"
${
diff
}
"
7
}
loop_send_lock_erc20
()
{
# ======================== Ethereum 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'
)
i
=
0
preEthBalance
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
Ethsender
}
"
-t
"
${
tokenAddr
}
"
| jq
-r
".balance"
)
approveTxHash
=
$(${
CLIA
}
relayer ethereum approve
-m
10
-k
"
${
privateKeys
[5]
}
"
-t
"
${
tokenAddr
}
"
)
echo
${
i
}
"lock-async erc20 approve tx hash:"
"
${
approveTxHash
}
"
i
=
0
echo
${
i
}
"lock-async erc20 approve tx hash:"
"
${
approveTxHash
}
"
while
[[
i
-lt
${#
privateKeys
[@]
}
]]
;
do
ethTxHash
=
$(${
CLIA
}
relayer ethereum lock-async
-m
1
-k
"
${
privateKeys
[5]
}
"
-r
12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
-t
"
${
tokenAddr
}
"
)
echo
${
i
}
"lock-async erc20 tx hash:"
"
${
ethTxHash
}
"
# shellcheck disable=SC2219
let
i++
done
eth_block_wait
$((
maturityDegree
+
2
))
nowEthBalance
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
Ethsender
}
"
-t
"
${
tokenAddr
}
"
| jq
-r
".balance"
)
...
...
@@ -200,14 +181,10 @@ loop_send_lock_erc20() {
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
()
{
# =========================== Chain33 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'
)
i
=
0
...
...
@@ -230,9 +207,8 @@ 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'
)
diff
=
$(
(
preChain33Balance
-
nowChain33Balance
)
)
diff
=
$(
echo
"
$preChain33Balance
-
$nowChain33Balance
"
| bc
)
check_number
"
${
diff
}
"
7
}
...
...
plugin/dapp/x2ethereum/ebrelayer/relayer/ethereum/ethereum.go
View file @
03e6466a
...
...
@@ -15,6 +15,7 @@ import (
"errors"
"fmt"
"math/big"
"regexp"
"sync"
"sync/atomic"
"time"
...
...
@@ -603,6 +604,11 @@ func (ethRelayer *Relayer4Ethereum) subscribeEvent() {
}
func
(
ethRelayer
*
Relayer4Ethereum
)
IsValidatorActive
(
addr
string
)
(
bool
,
error
)
{
re
:=
regexp
.
MustCompile
(
"^0x[0-9a-fA-F]{40}$"
)
if
!
re
.
MatchString
(
addr
)
{
return
false
,
errors
.
New
(
"this address is not an ethereum address"
)
}
return
ethtxs
.
IsActiveValidator
(
common
.
HexToAddress
(
addr
),
ethRelayer
.
x2EthContracts
.
Valset
)
}
...
...
plugin/dapp/x2ethereum/testsh/publicTest.sh
View file @
03e6466a
...
...
@@ -288,7 +288,8 @@ function check_number() {
echo
-e
"
${
RED
}
wrong check number parameters
${
NOC
}
"
exit
1
fi
if
[[
${
1
}
!=
"
${
2
}
"
]]
;
then
if
[
"
$(
echo
"
$1
<
$2
"
| bc
)
"
-eq
1
]
||
[
"
$(
echo
"
$1
>
$2
"
| bc
)
"
-eq
1
]
;
then
echo
-e
"
${
RED
}
error number, expect
${
1
}
, get
${
2
}${
NOC
}
"
exit
1
fi
...
...
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