Commit 37865157 authored by whisker's avatar whisker

Merge branch 'x2eth_200507' of https://github.com/zhengjunhe/plugin into x2eth_200507

parents 43f35118 4596d426
This diff is collapsed.
...@@ -588,7 +588,8 @@ func (ethRelayer *EthereumRelayer) filterLogEventsProc(logchan chan<- types.Log, ...@@ -588,7 +588,8 @@ func (ethRelayer *EthereumRelayer) filterLogEventsProc(logchan chan<- types.Log,
panic(errinfo) panic(errinfo)
} }
relayerLog.Info(title, "received logs", len(logs)) relayerLog.Info(title, "received logs with number", len(logs),
"start height", query.FromBlock.String(), "stop height", query.ToBlock.String())
for _, log := range logs { for _, log := range logs {
relayerLog.Info(title, "received log with topics", log.Topics[0].Hex(), "BlockNumber", log.BlockNumber) relayerLog.Info(title, "received log with topics", log.Topics[0].Hex(), "BlockNumber", log.BlockNumber)
if _, exist := eventSig[log.Topics[0].Hex()]; !exist { if _, exist := eventSig[log.Topics[0].Hex()]; !exist {
......
...@@ -13,7 +13,6 @@ import ( ...@@ -13,7 +13,6 @@ import (
"github.com/33cn/chain33/types" "github.com/33cn/chain33/types"
chain33types "github.com/33cn/chain33/types" chain33types "github.com/33cn/chain33/types"
"github.com/33cn/chain33/util" "github.com/33cn/chain33/util"
common2 "github.com/33cn/plugin/plugin/dapp/x2Ethereum/executor/common"
types2 "github.com/33cn/plugin/plugin/dapp/x2Ethereum/types" types2 "github.com/33cn/plugin/plugin/dapp/x2Ethereum/types"
"github.com/stretchr/testify/mock" "github.com/stretchr/testify/mock"
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
...@@ -74,7 +73,7 @@ func (x *suiteX2Ethereum) SetupSuite() { ...@@ -74,7 +73,7 @@ func (x *suiteX2Ethereum) SetupSuite() {
tx.Nonce = 1 tx.Nonce = 1
tx.Sign(types.SECP256K1, privFrom) tx.Sign(types.SECP256K1, privFrom)
x.action = newAction(x2eth, tx, 0) x.action, _ = newAction(x2eth, tx, 0)
x.x2eth = x2eth x.x2eth = x2eth
x.addrX2Eth = address.ExecAddress(driverName) x.addrX2Eth = address.ExecAddress(driverName)
...@@ -178,9 +177,8 @@ func (x *suiteX2Ethereum) Test_4_Eth2Chain33() { ...@@ -178,9 +177,8 @@ func (x *suiteX2Ethereum) Test_4_Eth2Chain33() {
EthereumSender: ethereumAddr, EthereumSender: ethereumAddr,
Chain33Receiver: chain33Receiver, Chain33Receiver: chain33Receiver,
ValidatorAddress: addValidator1, ValidatorAddress: addValidator1,
Amount: 10, Amount: "10",
ClaimType: common2.LockText, ClaimType: int64(types2.LOCK_CLAIM_TYPE),
EthSymbol: symbol,
} }
receipt, err := x.action.procMsgEth2Chain33(payload) receipt, err := x.action.procMsgEth2Chain33(payload)
...@@ -198,20 +196,20 @@ func (x *suiteX2Ethereum) Test_4_Eth2Chain33() { ...@@ -198,20 +196,20 @@ func (x *suiteX2Ethereum) Test_4_Eth2Chain33() {
x.query_GetEthProphecy("000x7B95B6EC7EbD73572298cEf32Bb54FA408207359", types2.EthBridgeStatus_SuccessStatusText) x.query_GetEthProphecy("000x7B95B6EC7EbD73572298cEf32Bb54FA408207359", types2.EthBridgeStatus_SuccessStatusText)
x.query_GetSymbolTotalAmountByTxType(symbol, 1, "lock", 10) x.query_GetSymbolTotalAmountByTxType(symbol, 1, "lock", 10)
payload.Amount = 3 payload.Amount = "3"
payload.Nonce = 1 payload.Nonce = 1
payload.ClaimType = common2.BurnText payload.ClaimType = int64(types2.BURN_CLAIM_TYPE)
payload.ValidatorAddress = addValidator1 payload.ValidatorAddress = addValidator1
receipt, err = x.action.procWithdrawEth(payload) receipt, err = x.action.procWithdrawEth(payload)
x.NoError(err) x.NoError(err)
x.setDb(receipt) x.setDb(receipt)
payload.ValidatorAddress = addValidator2 payload.ValidatorAddress = addValidator2
payload.Amount = 2 payload.Amount = "2"
receipt, err = x.action.procWithdrawEth(payload) receipt, err = x.action.procWithdrawEth(payload)
x.Equal(err, types2.ErrClaimInconsist) x.Equal(err, types2.ErrClaimInconsist)
payload.Amount = 3 payload.Amount = "3"
receipt, err = x.action.procWithdrawEth(payload) receipt, err = x.action.procWithdrawEth(payload)
x.NoError(err) x.NoError(err)
x.setDb(receipt) x.setDb(receipt)
...@@ -220,7 +218,7 @@ func (x *suiteX2Ethereum) Test_4_Eth2Chain33() { ...@@ -220,7 +218,7 @@ func (x *suiteX2Ethereum) Test_4_Eth2Chain33() {
x.query_GetSymbolTotalAmount(symbol, 1, 7) x.query_GetSymbolTotalAmount(symbol, 1, 7)
x.query_GetSymbolTotalAmountByTxType(symbol, 1, "withdraw", 3) x.query_GetSymbolTotalAmountByTxType(symbol, 1, "withdraw", 3)
payload.Amount = 10 payload.Amount = "10"
payload.Nonce = 2 payload.Nonce = 2
payload.ValidatorAddress = addValidator1 payload.ValidatorAddress = addValidator1
receipt, err = x.action.procWithdrawEth(payload) receipt, err = x.action.procWithdrawEth(payload)
...@@ -228,9 +226,9 @@ func (x *suiteX2Ethereum) Test_4_Eth2Chain33() { ...@@ -228,9 +226,9 @@ func (x *suiteX2Ethereum) Test_4_Eth2Chain33() {
receipt, err = x.action.procWithdrawEth(payload) receipt, err = x.action.procWithdrawEth(payload)
x.Equal(types.ErrNoBalance, err) x.Equal(types.ErrNoBalance, err)
payload.Amount = 1 payload.Amount = "1"
payload.Nonce = 3 payload.Nonce = 3
payload.ClaimType = common2.LockText payload.ClaimType = int64(types2.LOCK_CLAIM_TYPE)
payload.ValidatorAddress = addValidator1 payload.ValidatorAddress = addValidator1
receipt, err = x.action.procMsgEth2Chain33(payload) receipt, err = x.action.procMsgEth2Chain33(payload)
x.setDb(receipt) x.setDb(receipt)
...@@ -248,8 +246,7 @@ func (x *suiteX2Ethereum) Test_5_Chain33ToEth() { ...@@ -248,8 +246,7 @@ func (x *suiteX2Ethereum) Test_5_Chain33ToEth() {
TokenContract: tokenContractAddress, TokenContract: tokenContractAddress,
Chain33Sender: addValidator1, Chain33Sender: addValidator1,
EthereumReceiver: ethereumAddr, EthereumReceiver: ethereumAddr,
Amount: 5, Amount: "5",
EthSymbol: symbol,
LocalCoinSymbol: "bty", LocalCoinSymbol: "bty",
LocalCoinExec: coinExec, LocalCoinExec: coinExec,
} }
...@@ -261,7 +258,7 @@ func (x *suiteX2Ethereum) Test_5_Chain33ToEth() { ...@@ -261,7 +258,7 @@ func (x *suiteX2Ethereum) Test_5_Chain33ToEth() {
x.query_GetSymbolTotalAmount("bty", 2, 5) x.query_GetSymbolTotalAmount("bty", 2, 5)
x.query_GetSymbolTotalAmountByTxType("bty", 2, "lock", 5) x.query_GetSymbolTotalAmountByTxType("bty", 2, "lock", 5)
msgLock.Amount = 4 msgLock.Amount = "4"
receipt, err = x.action.procMsgBurn(msgLock) receipt, err = x.action.procMsgBurn(msgLock)
x.NoError(err) x.NoError(err)
x.setDb(receipt) x.setDb(receipt)
...@@ -272,7 +269,7 @@ func (x *suiteX2Ethereum) Test_5_Chain33ToEth() { ...@@ -272,7 +269,7 @@ func (x *suiteX2Ethereum) Test_5_Chain33ToEth() {
receipt, err = x.action.procMsgBurn(msgLock) receipt, err = x.action.procMsgBurn(msgLock)
x.Equal(err, types.ErrNoBalance) x.Equal(err, types.ErrNoBalance)
msgLock.Amount = 1 msgLock.Amount = "1"
receipt, err = x.action.procMsgBurn(msgLock) receipt, err = x.action.procMsgBurn(msgLock)
x.NoError(err) x.NoError(err)
x.setDb(receipt) x.setDb(receipt)
......
...@@ -287,6 +287,33 @@ function updata_relayer_toml() { ...@@ -287,6 +287,33 @@ function updata_relayer_toml() {
#sed -i 's/192.168.3.156/'${pushHost}'/g' "../build/relayer.toml" #sed -i 's/192.168.3.156/'${pushHost}'/g' "../build/relayer.toml"
} }
# 更新配置文件 $1 为 BridgeRegistry 合约地址; $2 等待区块 默认10; $3 relayer.toml 地址
function updata_relayer_toml_ropston() {
local BridgeRegistry=${1}
local maturityDegree=${2}
local file=${3}
local chain33Host=127.0.0.1
local pushHost=127.0.0.1
local line=$(delete_line_show ${file} "chain33Host")
# 在第 line 行后面 新增合约地址
sed -i ''${line}' a chain33Host="http://'${chain33Host}':8801"' "${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/#BridgeRegistry=\"0x40BFE5eD039A9a2Eb42ece2E2CA431bFa7Cf4c42\"/BridgeRegistry=\"'${BridgeRegistry}'\"/g' "../build/relayer.toml"
#sed -i 's/192.168.64.2/'${chain33Host}'/g' "../build/relayer.toml"
#sed -i 's/192.168.3.156/'${pushHost}'/g' "../build/relayer.toml"
}
# 更新 B C D 的配置文件 # 更新 B C D 的配置文件
function updata_all_relayer_toml() { function updata_all_relayer_toml() {
local port=9901 local port=9901
...@@ -409,7 +436,7 @@ function wait_prophecy_finish() { ...@@ -409,7 +436,7 @@ function wait_prophecy_finish() {
set -x set -x
} }
# eth 区块等待 $1:等待高度 # eth 区块等待 $1:等待高度 $2:url地址,默认为 http://localhost:7545,测试网络用 https://ropsten-rpc.linkpool.io/
function eth_block_wait() { function eth_block_wait() {
set +x set +x
if [[ $# -lt 0 ]]; then if [[ $# -lt 0 ]]; then
...@@ -417,11 +444,24 @@ function eth_block_wait() { ...@@ -417,11 +444,24 @@ function eth_block_wait() {
exit 1 exit 1
fi fi
local cur_height=$(curl -ksd '{"id":1,"jsonrpc":"2.0","method":"eth_blockNumber","params":[]}' http://localhost:7545 | jq -r ".result") local cur_height=""
local new_height=""
local url=${2}
if [ "${url}" == "" ]; then
cur_height=$(curl -ksd '{"id":1,"jsonrpc":"2.0","method":"eth_blockNumber","params":[]}' http://localhost:7545 | jq -r ".result")
else
cur_height=$(curl -H "Content-Type: application/json" -X POST --data '{"id":1,"jsonrpc":"2.0","method":"eth_blockNumber","params":[]}' ${url} | jq -r ".result")
fi
local expect=$((cur_height + ${1} + 1)) local expect=$((cur_height + ${1} + 1))
local count=0 local count=0
while true; do while true; do
new_height=$(curl -ksd '{"id":1,"jsonrpc":"2.0","method":"eth_blockNumber","params":[]}' http://localhost:7545 | jq -r ".result") if [ "${url}" == "" ]; then
new_height=$(curl -ksd '{"id":1,"jsonrpc":"2.0","method":"eth_blockNumber","params":[]}' http://localhost:7545 | jq -r ".result")
else
new_height=$(curl -H "Content-Type: application/json" -X POST --data '{"id":1,"jsonrpc":"2.0","method":"eth_blockNumber","params":[]}' ${url} | jq -r ".result")
fi
if [[ ${new_height} -ge ${expect} ]]; then if [[ ${new_height} -ge ${expect} ]]; then
break break
fi fi
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment