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
121093cd
Commit
121093cd
authored
May 15, 2020
by
QM
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updata bridgeBank_test.go
parent
89674d65
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
72 additions
and
8 deletions
+72
-8
abiUnpack_test.go
...p/x2Ethereum/ebrelayer/ethcontract/test/abiUnpack_test.go
+53
-0
bridgeBank_test.go
.../x2Ethereum/ebrelayer/ethcontract/test/bridgeBank_test.go
+0
-0
cosmosBridge_test.go
...2Ethereum/ebrelayer/ethcontract/test/cosmosBridge_test.go
+1
-0
oracle_test.go
...dapp/x2Ethereum/ebrelayer/ethcontract/test/oracle_test.go
+1
-0
setupTestEnv.go
...Ethereum/ebrelayer/ethcontract/test/setup/setupTestEnv.go
+10
-3
simulatorDemo.go
...thereum/ebrelayer/ethcontract/test/setup/simulatorDemo.go
+1
-1
valset_test.go
...dapp/x2Ethereum/ebrelayer/ethcontract/test/valset_test.go
+1
-0
exec_test.go
plugin/dapp/x2Ethereum/executor/exec_test.go
+5
-4
No files found.
plugin/dapp/x2Ethereum/ebrelayer/ethcontract/test/abiUnpack_test.go
0 → 100644
View file @
121093cd
package
test
import
(
"encoding/hex"
"fmt"
"github.com/ethereum/go-ethereum/accounts/abi"
"github.com/ethereum/go-ethereum/common"
"math/big"
"strings"
"testing"
)
func
TestUnpackEvent
(
t
*
testing
.
T
)
{
const
abiJSON
=
`[{"constant":false,"inputs":[{"name":"memo","type":"bytes"}],"name":"receive","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"anonymous":false,"inputs":[{"indexed":false,"name":"sender","type":"address"},{"indexed":false,"name":"amount","type":"uint256"},{"indexed":false,"name":"memo","type":"bytes"}],"name":"received","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"sender","type":"address"}],"name":"receivedAddr","type":"event"}]`
abi
,
err
:=
abi
.
JSON
(
strings
.
NewReader
(
abiJSON
))
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
const
hexdata
=
`000000000000000000000000376c47978271565f56deb45495afa69e59c16ab200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000158`
data
,
err
:=
hex
.
DecodeString
(
hexdata
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
if
len
(
data
)
%
32
==
0
{
t
.
Errorf
(
"len(data) is %d, want a non-multiple of 32"
,
len
(
data
))
}
type
ReceivedEvent
struct
{
Sender
common
.
Address
Amount
*
big
.
Int
Memo
[]
byte
}
var
ev
ReceivedEvent
err
=
abi
.
Unpack
(
&
ev
,
"received"
,
data
)
if
err
!=
nil
{
t
.
Error
(
err
)
}
fmt
.
Printf
(
"
\n
ReceivedEvent sender:%s"
,
ev
.
Sender
.
String
())
type
ReceivedAddrEvent
struct
{
Sender
common
.
Address
}
var
receivedAddrEv
ReceivedAddrEvent
err
=
abi
.
Unpack
(
&
receivedAddrEv
,
"receivedAddr"
,
data
)
if
err
!=
nil
{
t
.
Error
(
err
)
}
fmt
.
Printf
(
"
\n
receivedAddrEv=%s
\n\n\n
"
,
receivedAddrEv
.
Sender
.
String
())
}
\ No newline at end of file
plugin/dapp/x2Ethereum/ebrelayer/ethcontract/test/bridgeBank_test.go
0 → 100644
View file @
121093cd
This diff is collapsed.
Click to expand it.
plugin/dapp/x2Ethereum/ebrelayer/ethcontract/test/cosmosBridge_test.go
0 → 100644
View file @
121093cd
package
test
plugin/dapp/x2Ethereum/ebrelayer/ethcontract/test/oracle_test.go
0 → 100644
View file @
121093cd
package
test
plugin/dapp/x2Ethereum/ebrelayer/ethcontract/test/setupTestEnv.go
→
plugin/dapp/x2Ethereum/ebrelayer/ethcontract/test/setup
/setup
TestEnv.go
View file @
121093cd
package
test
package
setup
import
(
import
(
"crypto/ecdsa"
"crypto/ecdsa"
...
@@ -21,8 +21,6 @@ func PrepareTestEnv() (bind.ContractBackend, *ethtxs.DeployPara) {
...
@@ -21,8 +21,6 @@ func PrepareTestEnv() (bind.ContractBackend, *ethtxs.DeployPara) {
PrivateKey
:
crypto
.
FromECDSA
(
genesiskey
),
PrivateKey
:
crypto
.
FromECDSA
(
genesiskey
),
}
}
alloc
[
genesisAddr
]
=
genesisAccount
alloc
[
genesisAddr
]
=
genesisAccount
gasLimit
:=
uint64
(
2999280
)
sim
:=
backends
.
NewSimulatedBackend
(
alloc
,
gasLimit
)
var
InitValidators
[]
common
.
Address
var
InitValidators
[]
common
.
Address
var
ValidatorPriKey
[]
*
ecdsa
.
PrivateKey
var
ValidatorPriKey
[]
*
ecdsa
.
PrivateKey
...
@@ -31,8 +29,17 @@ func PrepareTestEnv() (bind.ContractBackend, *ethtxs.DeployPara) {
...
@@ -31,8 +29,17 @@ func PrepareTestEnv() (bind.ContractBackend, *ethtxs.DeployPara) {
addr
:=
crypto
.
PubkeyToAddress
(
key
.
PublicKey
)
addr
:=
crypto
.
PubkeyToAddress
(
key
.
PublicKey
)
InitValidators
=
append
(
InitValidators
,
addr
)
InitValidators
=
append
(
InitValidators
,
addr
)
ValidatorPriKey
=
append
(
ValidatorPriKey
,
key
)
ValidatorPriKey
=
append
(
ValidatorPriKey
,
key
)
account
:=
core
.
GenesisAccount
{
Balance
:
big
.
NewInt
(
100000000
*
100
),
PrivateKey
:
crypto
.
FromECDSA
(
key
),
}
alloc
[
addr
]
=
account
}
}
gasLimit
:=
uint64
(
100000000
)
sim
:=
backends
.
NewSimulatedBackend
(
alloc
,
gasLimit
)
InitPowers
:=
[]
*
big
.
Int
{
big
.
NewInt
(
80
),
big
.
NewInt
(
10
),
big
.
NewInt
(
10
)}
InitPowers
:=
[]
*
big
.
Int
{
big
.
NewInt
(
80
),
big
.
NewInt
(
10
),
big
.
NewInt
(
10
)}
para
:=
&
ethtxs
.
DeployPara
{
para
:=
&
ethtxs
.
DeployPara
{
...
...
plugin/dapp/x2Ethereum/ebrelayer/ethcontract/test/simulatorDemo.go
→
plugin/dapp/x2Ethereum/ebrelayer/ethcontract/test/s
etup/s
imulatorDemo.go
View file @
121093cd
package
test
package
setup
import
(
import
(
"context"
"context"
...
...
plugin/dapp/x2Ethereum/ebrelayer/ethcontract/test/valset_test.go
0 → 100644
View file @
121093cd
package
test
plugin/dapp/x2Ethereum/executor/exec_test.go
View file @
121093cd
package
executor
package
executor
import
(
import
(
//"github.com/33cn/chain33/client"
"testing"
"testing"
apimock
"github.com/33cn/chain33/client/mocks"
apimock
"github.com/33cn/chain33/client/mocks"
...
@@ -73,7 +74,7 @@ func (x *suiteX2Ethereum) SetupSuite() {
...
@@ -73,7 +74,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
)
...
@@ -214,7 +215,7 @@ func (x *suiteX2Ethereum) Test_4_Eth2Chain33() {
...
@@ -214,7 +215,7 @@ func (x *suiteX2Ethereum) Test_4_Eth2Chain33() {
x
.
NoError
(
err
)
x
.
NoError
(
err
)
x
.
setDb
(
receipt
)
x
.
setDb
(
receipt
)
x
.
query_GetEthProphecy
(
"010x7B95B6EC7EbD73572298cEf32Bb54FA408207359"
,
types2
.
EthBridgeStatus_
Withdrawed
StatusText
)
x
.
query_GetEthProphecy
(
"010x7B95B6EC7EbD73572298cEf32Bb54FA408207359"
,
types2
.
EthBridgeStatus_
Success
StatusText
)
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
)
...
@@ -333,10 +334,10 @@ func (x *suiteX2Ethereum) query_GetSymbolTotalAmountByTxType(tokenSymbol string,
...
@@ -333,10 +334,10 @@ func (x *suiteX2Ethereum) query_GetSymbolTotalAmountByTxType(tokenSymbol string,
}
}
func
(
x
*
suiteX2Ethereum
)
query_GetSymbolTotalAmount
(
tokenSymbol
string
,
direction
int64
,
equal
int64
)
{
func
(
x
*
suiteX2Ethereum
)
query_GetSymbolTotalAmount
(
tokenSymbol
string
,
direction
int64
,
equal
int64
)
{
msg
,
err
:=
x
.
x2eth
.
Query_GetSymbolTotalAmount
(
&
types2
.
QuerySymbolAssets
Params
{
TokenSymbol
:
tokenSymbol
,
Direction
:
direction
})
msg
,
err
:=
x
.
x2eth
.
Query_GetSymbolTotalAmount
ByTxType
(
&
types2
.
QuerySymbolAssetsByTxType
Params
{
TokenSymbol
:
tokenSymbol
,
Direction
:
direction
})
x
.
NoError
(
err
)
x
.
NoError
(
err
)
reply
:=
msg
.
(
*
types2
.
ReceiptQuerySymbolAssets
)
reply
:=
msg
.
(
*
types2
.
ReceiptQuerySymbolAssets
)
x
.
Equal
(
reply
.
TotalAmount
,
uint64
(
equal
))
x
.
Equal
(
reply
.
Res
[
0
]
.
TotalAmount
,
uint64
(
equal
))
}
}
func
(
x
*
suiteX2Ethereum
)
query_GetEthProphecy
(
id
string
,
statusTest
types2
.
EthBridgeStatus
)
{
func
(
x
*
suiteX2Ethereum
)
query_GetEthProphecy
(
id
string
,
statusTest
types2
.
EthBridgeStatus
)
{
...
...
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