-
Notifications
You must be signed in to change notification settings - Fork 190
/
test_common.go
78 lines (68 loc) · 3.09 KB
/
test_common.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package types
import (
"testing"
"github.com/cosmos/peggy/x/oracle"
"github.com/stretchr/testify/require"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
)
const (
TestEthereumChainID = 3
TestBridgeContractAddress = "0xC4cE93a5699c68241fc2fB503Fb0f21724A624BB"
TestAddress = "cosmos1gn8409qq9hnrxde37kuxwx5hrxpfpv8426szuv"
TestValidator = "cosmos1xdp5tvt7lxh8rf9xx07wy2xlagzhq24ha48xtq"
TestNonce = 0
TestTokenContractAddress = "0x0000000000000000000000000000000000000000"
TestEthereumAddress = "0x7B95B6EC7EbD73572298cEf32Bb54FA408207359"
AltTestEthereumAddress = "0x7B95B6EC7EbD73572298cEf32Bb54FA408207344"
TestCoinsAmount = 10
TestCoinsSymbol = "eth"
TestCoinsLockedSymbol = "peggyeth"
AltTestCoinsAmount = 12
AltTestCoinsSymbol = "eth"
)
//Ethereum-bridge specific stuff
func CreateTestEthMsg(t *testing.T, validatorAddress sdk.ValAddress, claimType ClaimType) MsgCreateEthBridgeClaim {
testEthereumAddress := NewEthereumAddress(TestEthereumAddress)
testContractAddress := NewEthereumAddress(TestBridgeContractAddress)
testTokenAddress := NewEthereumAddress(TestTokenContractAddress)
ethClaim := CreateTestEthClaim(
t, testContractAddress, testTokenAddress, validatorAddress,
testEthereumAddress, TestCoinsAmount, TestCoinsSymbol, claimType)
ethMsg := NewMsgCreateEthBridgeClaim(ethClaim)
return ethMsg
}
func CreateTestEthClaim(
t *testing.T, testContractAddress EthereumAddress, testTokenAddress EthereumAddress,
validatorAddress sdk.ValAddress, testEthereumAddress EthereumAddress, amount int64, symbol string, claimType ClaimType,
) EthBridgeClaim {
testCosmosAddress, err1 := sdk.AccAddressFromBech32(TestAddress)
require.NoError(t, err1)
ethClaim := NewEthBridgeClaim(
TestEthereumChainID, testContractAddress, TestNonce, symbol,
testTokenAddress, testEthereumAddress, testCosmosAddress, validatorAddress, amount, claimType)
return ethClaim
}
func CreateTestBurnMsg(t *testing.T, testCosmosSender string, ethereumReceiver EthereumAddress,
coinsAmount int64, coinsSymbol string) MsgBurn {
testCosmosAddress, err := sdk.AccAddressFromBech32(TestAddress)
require.NoError(t, err)
burnEth := NewMsgBurn(TestEthereumChainID, testCosmosAddress, ethereumReceiver, coinsAmount, coinsSymbol)
return burnEth
}
func CreateTestQueryEthProphecyResponse(
cdc *codec.Codec, t *testing.T, validatorAddress sdk.ValAddress, claimType ClaimType,
) QueryEthProphecyResponse {
testEthereumAddress := NewEthereumAddress(TestEthereumAddress)
testContractAddress := NewEthereumAddress(TestBridgeContractAddress)
testTokenAddress := NewEthereumAddress(TestTokenContractAddress)
ethBridgeClaim := CreateTestEthClaim(t, testContractAddress, testTokenAddress, validatorAddress,
testEthereumAddress, TestCoinsAmount, TestCoinsSymbol, claimType)
oracleClaim, _ := CreateOracleClaimFromEthClaim(cdc, ethBridgeClaim)
ethBridgeClaims := []EthBridgeClaim{ethBridgeClaim}
return NewQueryEthProphecyResponse(
oracleClaim.ID,
oracle.NewStatus(oracle.PendingStatusText, ""),
ethBridgeClaims,
)
}