-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
test_chains.go
85 lines (75 loc) · 2.36 KB
/
test_chains.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
79
80
81
82
83
84
85
package test
import (
"fmt"
"testing"
"time"
"github.com/cosmos/relayer/relayer"
"github.com/cosmos/cosmos-sdk/server"
"github.com/stretchr/testify/require"
)
const (
// SEED1 is a mnenomic
//nolint:lll
SEED1 = "cake blossom buzz suspect image view round utility meat muffin humble club model latin similar glow draw useless kiwi snow laugh gossip roof public"
// SEED2 is a mnemonic
//nolint:lll
SEED2 = "near little movie lady moon fuel abandon gasp click element muscle elbow taste indoor soft soccer like occur legend coin near random normal adapt"
)
var (
// GAIA BLOCK TIMEOUTS are located in the gaia setup script in the
// setup directory.
// timeout_commit = "1000ms"
// timeout_propose = "1000ms"
// 3 second relayer timeout works well with these block times
gaiaTestConfig = testChainConfig{
dockerfile: "docker/gaiad/Dockerfile",
timeout: 3 * time.Second,
rpcPort: "26657",
accountPrefix: "cosmos",
trustingPeriod: "330h",
}
// AKASH BLOCK TIMEOUTS on jackzampolin/akashtest:master
// timeout_commit = "1000ms"
// timeout_propose = "1000ms"
// 3 second relayer timeout works well with these block times
// This is built from contrib/Dockerfile.test from the akash repository:
akashTestConfig = testChainConfig{
dockerfile: "docker/akash/Dockerfile",
timeout: 3 * time.Second,
rpcPort: "26657",
accountPrefix: "akash",
trustingPeriod: "330h",
}
seeds = []string{SEED1, SEED2}
)
type (
// testChain represents the different configuration options for spinning up a test
// cosmos-sdk based blockchain
testChain struct {
chainID string
seed int
t testChainConfig
}
// testChainConfig represents the chain specific docker and codec configurations
// required.
testChainConfig struct {
dockerfile string
rpcPort string
timeout time.Duration
accountPrefix string
trustingPeriod string
}
)
// newTestChain generates a new instance of *Chain with a free TCP port configured as the RPC port
func newTestChain(t *testing.T, tc testChain) *relayer.Chain {
_, port, err := server.FreeTCPAddr()
require.NoError(t, err)
return &relayer.Chain{
Key: "testkey",
ChainID: tc.chainID,
RPCAddr: fmt.Sprintf("http://localhost:%s", port),
AccountPrefix: tc.t.accountPrefix,
GasAdjustment: 1.3,
TrustingPeriod: tc.t.trustingPeriod,
}
}