-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathtest_helper.go
40 lines (32 loc) · 937 Bytes
/
test_helper.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
package main
import (
"encoding/json"
"log"
"os"
"github.com/RiemaLabs/modular-indexer-committee/ord/getter"
)
func loadMain(hashedHeight uint) (*getter.OPIOrdGetterTest, RuntimeArguments) {
arguments := RuntimeArguments{
EnableService: false,
EnableCommittee: false,
EnableStateRootCache: false,
EnableTest: false,
TestBlockHeightLimit: 0,
}
// Get the configuration.
configFile, err := os.ReadFile("config.json")
if err != nil {
log.Fatalf("Failed to read config file: %v", err)
}
err = json.Unmarshal(configFile, &GlobalConfig)
if err != nil {
log.Fatalf("Failed to parse config file: %v", err)
}
// Use OPI database as the getter.
gd := getter.DatabaseConfig(GlobalConfig.Database)
g, err := getter.NewOPIOrdGetterTest(&gd, arguments.TestBlockHeightLimit, hashedHeight)
if err != nil {
log.Fatalf("Failed to catchup the latest state: %v", err)
}
return g, arguments
}