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
9ce4e51b
Commit
9ce4e51b
authored
Jun 02, 2020
by
QM
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updata unit test
parent
f4c76841
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
64 additions
and
15 deletions
+64
-15
setupTestEnv.go
...ethereum/ebrelayer/ethcontract/test/setup/setupTestEnv.go
+12
-12
chain33_test.go
...dapp/x2ethereum/ebrelayer/relayer/chain33/chain33_test.go
+15
-2
ethereum_test.go
...pp/x2ethereum/ebrelayer/relayer/ethereum/ethereum_test.go
+0
-0
ethsim_test.go
...dapp/x2ethereum/ebrelayer/relayer/ethereum/ethsim_test.go
+37
-1
No files found.
plugin/dapp/x2ethereum/ebrelayer/ethcontract/test/setup/setupTestEnv.go
View file @
9ce4e51b
...
@@ -54,12 +54,12 @@ func PrepareTestEnv() (bind.ContractBackend, *ethtxs.DeployPara) {
...
@@ -54,12 +54,12 @@ func PrepareTestEnv() (bind.ContractBackend, *ethtxs.DeployPara) {
return
sim
,
para
return
sim
,
para
}
}
func
PrepareTestEnvironment
()
(
bind
.
ContractBackend
,
*
ethtxs
.
DeployPara
)
{
func
PrepareTestEnvironment
(
deployerPrivateKey
string
,
ethValidatorAddrKeys
[]
string
)
(
bind
.
ContractBackend
,
*
ethtxs
.
DeployPara
)
{
var
deployerPrivateKey
=
"8656d2bc732a8a816a461ba5e2d8aac7c7f85c26a813df30d5327210465eb230"
//
var deployerPrivateKey = "8656d2bc732a8a816a461ba5e2d8aac7c7f85c26a813df30d5327210465eb230"
var
ethValidatorAddrKeyA
=
"3fa21584ae2e4fd74db9b58e2386f5481607dfa4d7ba0617aaa7858e5025dc1e"
//
var ethValidatorAddrKeyA = "3fa21584ae2e4fd74db9b58e2386f5481607dfa4d7ba0617aaa7858e5025dc1e"
var
ethValidatorAddrKeyB
=
"a5f3063552f4483cfc20ac4f40f45b798791379862219de9e915c64722c1d400"
//
var ethValidatorAddrKeyB = "a5f3063552f4483cfc20ac4f40f45b798791379862219de9e915c64722c1d400"
var
ethValidatorAddrKeyC
=
"bbf5e65539e9af0eb0cfac30bad475111054b09c11d668fc0731d54ea777471e"
//
var ethValidatorAddrKeyC = "bbf5e65539e9af0eb0cfac30bad475111054b09c11d668fc0731d54ea777471e"
var
ethValidatorAddrKeyD
=
"c9fa31d7984edf81b8ef3b40c761f1847f6fcd5711ab2462da97dc458f1f896b"
//
var ethValidatorAddrKeyD = "c9fa31d7984edf81b8ef3b40c761f1847f6fcd5711ab2462da97dc458f1f896b"
genesiskey
,
_
:=
crypto
.
HexToECDSA
(
deployerPrivateKey
)
genesiskey
,
_
:=
crypto
.
HexToECDSA
(
deployerPrivateKey
)
alloc
:=
make
(
core
.
GenesisAlloc
)
alloc
:=
make
(
core
.
GenesisAlloc
)
...
@@ -70,15 +70,15 @@ func PrepareTestEnvironment() (bind.ContractBackend, *ethtxs.DeployPara) {
...
@@ -70,15 +70,15 @@ func PrepareTestEnvironment() (bind.ContractBackend, *ethtxs.DeployPara) {
}
}
alloc
[
genesisAddr
]
=
genesisAccount
alloc
[
genesisAddr
]
=
genesisAccount
ethValidatorAddrKey
:=
make
([]
string
,
0
)
//
ethValidatorAddrKey := make([]string, 0)
ethValidatorAddrKey
=
append
(
ethValidatorAddrKey
,
ethValidatorAddrKeyA
)
//
ethValidatorAddrKey = append(ethValidatorAddrKey, ethValidatorAddrKeyA)
ethValidatorAddrKey
=
append
(
ethValidatorAddrKey
,
ethValidatorAddrKeyB
)
//
ethValidatorAddrKey = append(ethValidatorAddrKey, ethValidatorAddrKeyB)
ethValidatorAddrKey
=
append
(
ethValidatorAddrKey
,
ethValidatorAddrKeyC
)
//
ethValidatorAddrKey = append(ethValidatorAddrKey, ethValidatorAddrKeyC)
ethValidatorAddrKey
=
append
(
ethValidatorAddrKey
,
ethValidatorAddrKeyD
)
//
ethValidatorAddrKey = append(ethValidatorAddrKey, ethValidatorAddrKeyD)
var
InitValidators
[]
common
.
Address
var
InitValidators
[]
common
.
Address
var
ValidatorPriKey
[]
*
ecdsa
.
PrivateKey
var
ValidatorPriKey
[]
*
ecdsa
.
PrivateKey
for
_
,
v
:=
range
ethValidatorAddrKey
{
for
_
,
v
:=
range
ethValidatorAddrKey
s
{
key
,
_
:=
crypto
.
HexToECDSA
(
v
)
key
,
_
:=
crypto
.
HexToECDSA
(
v
)
addr
:=
crypto
.
PubkeyToAddress
(
key
.
PublicKey
)
addr
:=
crypto
.
PubkeyToAddress
(
key
.
PublicKey
)
InitValidators
=
append
(
InitValidators
,
addr
)
InitValidators
=
append
(
InitValidators
,
addr
)
...
...
plugin/dapp/x2ethereum/ebrelayer/relayer/chain33/chain33_test.go
View file @
9ce4e51b
...
@@ -175,9 +175,22 @@ func (r *suiteChain33Relayer) newChain33Relayer() *Relayer4Chain33 {
...
@@ -175,9 +175,22 @@ func (r *suiteChain33Relayer) newChain33Relayer() *Relayer4Chain33 {
}
}
func
(
r
*
suiteChain33Relayer
)
deployContracts
()
{
func
(
r
*
suiteChain33Relayer
)
deployContracts
()
{
// 0x8AFDADFC88a1087c9A1D6c0F5Dd04634b87F303a
var
deployerPrivateKey
=
"8656d2bc732a8a816a461ba5e2d8aac7c7f85c26a813df30d5327210465eb230"
// 0x92C8b16aFD6d423652559C6E266cBE1c29Bfd84f
var
ethValidatorAddrKeyA
=
"3fa21584ae2e4fd74db9b58e2386f5481607dfa4d7ba0617aaa7858e5025dc1e"
var
ethValidatorAddrKeyB
=
"a5f3063552f4483cfc20ac4f40f45b798791379862219de9e915c64722c1d400"
var
ethValidatorAddrKeyC
=
"bbf5e65539e9af0eb0cfac30bad475111054b09c11d668fc0731d54ea777471e"
var
ethValidatorAddrKeyD
=
"c9fa31d7984edf81b8ef3b40c761f1847f6fcd5711ab2462da97dc458f1f896b"
ethValidatorAddrKeys
:=
make
([]
string
,
0
)
ethValidatorAddrKeys
=
append
(
ethValidatorAddrKeys
,
ethValidatorAddrKeyA
)
ethValidatorAddrKeys
=
append
(
ethValidatorAddrKeys
,
ethValidatorAddrKeyB
)
ethValidatorAddrKeys
=
append
(
ethValidatorAddrKeys
,
ethValidatorAddrKeyC
)
ethValidatorAddrKeys
=
append
(
ethValidatorAddrKeys
,
ethValidatorAddrKeyD
)
ctx
:=
context
.
Background
()
ctx
:=
context
.
Background
()
var
backend
bind
.
ContractBackend
var
backend
bind
.
ContractBackend
backend
,
r
.
para
=
setup
.
PrepareTestEnvironment
()
backend
,
r
.
para
=
setup
.
PrepareTestEnvironment
(
deployerPrivateKey
,
ethValidatorAddrKeys
)
r
.
sim
=
backend
.
(
*
backends
.
SimulatedBackend
)
r
.
sim
=
backend
.
(
*
backends
.
SimulatedBackend
)
balance
,
_
:=
r
.
sim
.
BalanceAt
(
ctx
,
r
.
para
.
Deployer
,
nil
)
balance
,
_
:=
r
.
sim
.
BalanceAt
(
ctx
,
r
.
para
.
Deployer
,
nil
)
...
@@ -206,7 +219,7 @@ func (r *suiteChain33Relayer) syncProc(syncCfg *ebTypes.SyncTxReceiptConfig) {
...
@@ -206,7 +219,7 @@ func (r *suiteChain33Relayer) syncProc(syncCfg *ebTypes.SyncTxReceiptConfig) {
mockapi
:=
&
mocks
.
QueueProtocolAPI
{}
mockapi
:=
&
mocks
.
QueueProtocolAPI
{}
// 这里对需要mock的方法打桩,Close是必须的,其它方法根据需要
// 这里对需要mock的方法打桩,Close是必须的,其它方法根据需要
mockapi
.
On
(
"Close"
)
.
Return
()
mockapi
.
On
(
"Close"
)
.
Return
()
mockapi
.
On
(
"Add
SubscribeTxReceipt
"
,
mock
.
Anything
)
.
Return
(
&
ret
,
nil
)
mockapi
.
On
(
"Add
PushSubscribe
"
,
mock
.
Anything
)
.
Return
(
&
ret
,
nil
)
mockapi
.
On
(
"GetLastHeader"
,
mock
.
Anything
)
.
Return
(
&
he
,
nil
)
mockapi
.
On
(
"GetLastHeader"
,
mock
.
Anything
)
.
Return
(
&
he
,
nil
)
mockapi
.
On
(
"GetConfig"
,
mock
.
Anything
)
.
Return
(
chainTestCfg
,
nil
)
mockapi
.
On
(
"GetConfig"
,
mock
.
Anything
)
.
Return
(
chainTestCfg
,
nil
)
...
...
plugin/dapp/x2ethereum/ebrelayer/relayer/ethereum/ethereum_test.go
View file @
9ce4e51b
This diff is collapsed.
Click to expand it.
plugin/dapp/x2ethereum/ebrelayer/relayer/ethereum/eth
S
im_test.go
→
plugin/dapp/x2ethereum/ebrelayer/relayer/ethereum/eth
s
im_test.go
View file @
9ce4e51b
...
@@ -92,6 +92,29 @@ func (r *suiteEthRelayerSim) Test_4_DeployContrcts() {
...
@@ -92,6 +92,29 @@ func (r *suiteEthRelayerSim) Test_4_DeployContrcts() {
r
.
Error
(
err
)
r
.
Error
(
err
)
}
}
func
(
r
*
suiteEthRelayerSim
)
Test_5_Show
()
{
//addr, err = r.ethRelayer.ShowLockStatics("123")
//fmt.Println(addr, err)
//
//addr, err = r.ethRelayer.ShowDepositStatics("123")
//fmt.Println(addr, err)
//
//addr, err = r.ethRelayer.ShowTokenAddrBySymbol("bty")
//fmt.Println(addr, err)
//addr, err := r.ethRelayer.CreateBridgeToken("bty")
//r.NoError(err)
//ethtxs.PendingDuration4TxExeuction = 10
//tokenAddr, err := r.ethRelayer.CreateERC20Token("testc")
//r.Error(err)
//fmt.Println(addr, err)
//
//addr, err = r.ethRelayer.MintERC20Token(tokenAddr, r.ethRelayer.ethValidator.String(), "20000000000000")
//r.Error(err)
//fmt.Println(addr, err)
}
//func (r *suiteEthRelayerSim) TestSim_4_LockEth() {
//func (r *suiteEthRelayerSim) TestSim_4_LockEth() {
// ctx := context.Background()
// ctx := context.Background()
// bridgeBankBalance, err := r.sim.BalanceAt(ctx, r.x2EthDeployInfo.BridgeBank.Address, nil)
// bridgeBankBalance, err := r.sim.BalanceAt(ctx, r.x2EthDeployInfo.BridgeBank.Address, nil)
...
@@ -316,8 +339,21 @@ latter:
...
@@ -316,8 +339,21 @@ latter:
}
}
func
(
r
*
suiteEthRelayerSim
)
deploySimContracts
()
{
func
(
r
*
suiteEthRelayerSim
)
deploySimContracts
()
{
// 0x8AFDADFC88a1087c9A1D6c0F5Dd04634b87F303a
var
deployerPrivateKey
=
"8656d2bc732a8a816a461ba5e2d8aac7c7f85c26a813df30d5327210465eb230"
// 0x92C8b16aFD6d423652559C6E266cBE1c29Bfd84f
var
ethValidatorAddrKeyA
=
"3fa21584ae2e4fd74db9b58e2386f5481607dfa4d7ba0617aaa7858e5025dc1e"
var
ethValidatorAddrKeyB
=
"a5f3063552f4483cfc20ac4f40f45b798791379862219de9e915c64722c1d400"
var
ethValidatorAddrKeyC
=
"bbf5e65539e9af0eb0cfac30bad475111054b09c11d668fc0731d54ea777471e"
var
ethValidatorAddrKeyD
=
"c9fa31d7984edf81b8ef3b40c761f1847f6fcd5711ab2462da97dc458f1f896b"
ethValidatorAddrKeys
:=
make
([]
string
,
0
)
ethValidatorAddrKeys
=
append
(
ethValidatorAddrKeys
,
ethValidatorAddrKeyA
)
ethValidatorAddrKeys
=
append
(
ethValidatorAddrKeys
,
ethValidatorAddrKeyB
)
ethValidatorAddrKeys
=
append
(
ethValidatorAddrKeys
,
ethValidatorAddrKeyC
)
ethValidatorAddrKeys
=
append
(
ethValidatorAddrKeys
,
ethValidatorAddrKeyD
)
ctx
:=
context
.
Background
()
ctx
:=
context
.
Background
()
r
.
backend
,
r
.
para
=
setup
.
PrepareTestEnvironment
()
r
.
backend
,
r
.
para
=
setup
.
PrepareTestEnvironment
(
deployerPrivateKey
,
ethValidatorAddrKeys
)
r
.
sim
=
r
.
backend
.
(
*
backends
.
SimulatedBackend
)
r
.
sim
=
r
.
backend
.
(
*
backends
.
SimulatedBackend
)
balance
,
_
:=
r
.
sim
.
BalanceAt
(
ctx
,
r
.
para
.
Deployer
,
nil
)
balance
,
_
:=
r
.
sim
.
BalanceAt
(
ctx
,
r
.
para
.
Deployer
,
nil
)
...
...
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