/
factory.go
152 lines (141 loc) · 4.51 KB
/
factory.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
package configurer
import (
"errors"
"testing"
"github.com/osmosis-labs/osmosis/v20/tests/e2e/configurer/chain"
"github.com/osmosis-labs/osmosis/v20/tests/e2e/containers"
"github.com/osmosis-labs/osmosis/v20/tests/e2e/initialization"
)
type Configurer interface {
ConfigureChains() error
ClearResources() error
GetChainConfig(chainIndex int) *chain.Config
RunSetup() error
RunValidators() error
RunIBC() error
}
var (
// each started validator containers corresponds to one of
// the configurations below.
validatorConfigsChainA = []*initialization.NodeConfig{
{
// this is a node that is used to state-sync from so its snapshot-interval
// is frequent.
Name: "prune-default-snapshot-state-sync-from",
Pruning: "default",
PruningKeepRecent: "0",
PruningInterval: "0",
SnapshotInterval: 25,
SnapshotKeepRecent: 10,
IsValidator: true,
},
{
Name: "prune-nothing-snapshot",
Pruning: "nothing",
PruningKeepRecent: "0",
PruningInterval: "0",
SnapshotInterval: 1500,
SnapshotKeepRecent: 2,
IsValidator: true,
},
{
Name: "prune-custom-10000-13-snapshot",
Pruning: "custom",
PruningKeepRecent: "10000",
PruningInterval: "13",
SnapshotInterval: 1500,
SnapshotKeepRecent: 2,
IsValidator: true,
},
{
Name: "prune-everything-no-snapshot",
Pruning: "everything",
PruningKeepRecent: "0",
PruningInterval: "0",
SnapshotInterval: 0,
SnapshotKeepRecent: 0,
IsValidator: true,
},
}
validatorConfigsChainB = []*initialization.NodeConfig{
{
Name: "prune-default-snapshot",
Pruning: "default",
PruningKeepRecent: "0",
PruningInterval: "0",
SnapshotInterval: 1500,
SnapshotKeepRecent: 2,
IsValidator: true,
},
{
Name: "prune-nothing-snapshot",
Pruning: "nothing",
PruningKeepRecent: "0",
PruningInterval: "0",
SnapshotInterval: 1500,
SnapshotKeepRecent: 2,
IsValidator: true,
},
{
Name: "prune-custom-snapshot",
Pruning: "custom",
PruningKeepRecent: "10000",
PruningInterval: "13",
SnapshotInterval: 1500,
SnapshotKeepRecent: 2,
IsValidator: true,
},
}
)
// New returns a new Configurer depending on the values of its parameters.
// - If only isIBCEnabled, we want to have 2 chains initialized at the current
// Git branch version of Osmosis codebase.
// - If only isUpgradeEnabled, that is invalid and an error is returned.
// - If both isIBCEnabled and isUpgradeEnabled, we want 2 chains with IBC initialized
// at the previous Osmosis version.
// - If !isIBCEnabled and !isUpgradeEnabled, we only need one chain at the current
// Git branch version of the Osmosis code.
func New(t *testing.T, isIBCEnabled, isDebugLogEnabled bool, upgradeSettings UpgradeSettings) (Configurer, error) {
t.Helper()
containerManager, err := containers.NewManager(upgradeSettings.IsEnabled, upgradeSettings.ForkHeight > 0, isDebugLogEnabled)
if err != nil {
return nil, err
}
if isIBCEnabled && upgradeSettings.IsEnabled {
// skip none - configure two chains via Docker
// to utilize the older version of osmosis to upgrade from
return NewUpgradeConfigurer(t,
[]*chain.Config{
chain.New(t, containerManager, initialization.ChainAID, validatorConfigsChainA),
chain.New(t, containerManager, initialization.ChainBID, validatorConfigsChainB),
},
withUpgrade(withIBC(baseSetup)), // base set up with IBC and upgrade
containerManager,
upgradeSettings.Version,
upgradeSettings.ForkHeight,
), nil
} else if isIBCEnabled {
// configure two chains from current Git branch
return NewCurrentBranchConfigurer(t,
[]*chain.Config{
chain.New(t, containerManager, initialization.ChainAID, validatorConfigsChainA),
chain.New(t, containerManager, initialization.ChainBID, validatorConfigsChainB),
},
withIBC(baseSetup), // base set up with IBC
containerManager,
), nil
} else if upgradeSettings.IsEnabled {
// invalid - IBC tests must be enabled for upgrade
// to function
return nil, errors.New("IBC tests must be enabled for upgrade to work")
} else {
// configure one chain from current Git branch
return NewCurrentBranchConfigurer(t,
[]*chain.Config{
chain.New(t, containerManager, initialization.ChainAID, validatorConfigsChainA),
},
baseSetup, // base set up only
containerManager,
), nil
}
}