-
Notifications
You must be signed in to change notification settings - Fork 199
/
componentsHelper.go
91 lines (79 loc) · 3.11 KB
/
componentsHelper.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
package factory
import (
"bytes"
"fmt"
"path"
"runtime/pprof"
"testing"
"github.com/multiversx/mx-chain-go/common"
"github.com/multiversx/mx-chain-go/config"
"github.com/multiversx/mx-chain-go/p2p"
logger "github.com/multiversx/mx-chain-logger-go"
)
var log = logger.GetOrCreate("integrationtests")
// PrintStack -
func PrintStack() {
buffer := new(bytes.Buffer)
err := pprof.Lookup("goroutine").WriteTo(buffer, 2)
if err != nil {
log.Debug("could not dump goroutines")
}
log.Debug(fmt.Sprintf("\n%s", buffer.String()))
}
// CreateDefaultConfig -
func CreateDefaultConfig(tb testing.TB) *config.Configs {
configPathsHolder := createConfigurationsPathsHolder()
generalConfig, _ := common.LoadMainConfig(configPathsHolder.MainConfig)
ratingsConfig, _ := common.LoadRatingsConfig(configPathsHolder.Ratings)
economicsConfig, _ := common.LoadEconomicsConfig(configPathsHolder.Economics)
prefsConfig, _ := common.LoadPreferencesConfig(configPathsHolder.Preferences)
p2pConfig, _ := common.LoadP2PConfig(configPathsHolder.P2p)
externalConfig, _ := common.LoadExternalConfig(configPathsHolder.External)
systemSCConfig, _ := common.LoadSystemSmartContractsConfig(configPathsHolder.SystemSC)
epochConfig, _ := common.LoadEpochConfig(configPathsHolder.Epoch)
roundConfig, _ := common.LoadRoundConfig(configPathsHolder.RoundActivation)
p2pConfig.KadDhtPeerDiscovery.Enabled = false
prefsConfig.Preferences.DestinationShardAsObserver = "0"
prefsConfig.Preferences.ConnectionWatcherType = p2p.ConnectionWatcherTypePrint
configs := &config.Configs{}
configs.GeneralConfig = generalConfig
configs.RatingsConfig = ratingsConfig
configs.EconomicsConfig = economicsConfig
configs.SystemSCConfig = systemSCConfig
configs.PreferencesConfig = prefsConfig
configs.P2pConfig = p2pConfig
configs.ExternalConfig = externalConfig
configs.EpochConfig = epochConfig
configs.RoundConfig = roundConfig
configs.FlagsConfig = &config.ContextFlagsConfig{
WorkingDir: tb.TempDir(),
UseLogView: true,
Version: Version,
}
configs.ConfigurationPathsHolder = configPathsHolder
configs.ImportDbConfig = &config.ImportDbConfig{}
return configs
}
func createConfigurationsPathsHolder() *config.ConfigurationPathsHolder {
var concatPath = func(filename string) string {
return path.Join(BaseNodeConfigPath, filename)
}
return &config.ConfigurationPathsHolder{
MainConfig: concatPath(ConfigPath),
Ratings: concatPath(RatingsPath),
Economics: concatPath(EconomicsPath),
Preferences: concatPath(PrefsPath),
External: concatPath(ExternalPath),
P2p: concatPath(P2pPath),
Epoch: concatPath(EpochPath),
SystemSC: concatPath(SystemSCConfigPath),
GasScheduleDirectoryName: concatPath(GasSchedule),
RoundActivation: concatPath(RoundActivationPath),
Nodes: NodesSetupPath,
Genesis: GenesisPath,
SmartContracts: GenesisSmartContracts,
ValidatorKey: ValidatorKeyPemPath,
ApiRoutes: "",
P2pKey: P2pKeyPath,
}
}