-
-
Notifications
You must be signed in to change notification settings - Fork 739
Expand file tree
/
Copy pathconfig_loader_test.go
More file actions
74 lines (66 loc) · 1.61 KB
/
config_loader_test.go
File metadata and controls
74 lines (66 loc) · 1.61 KB
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
//go:build integration
package tests
import (
"testing"
"github.com/trezor/blockbook/bchain"
)
// TestLoadBlockchainCfgEnvOverride verifies env-based overrides land in blockchaincfg.json.
func TestLoadBlockchainCfgEnvOverride(t *testing.T) {
const wantHTTP = "http://backend_hostname:1234"
const wantWS = "ws://backend_hostname:1234"
tests := []struct {
name string
buildEnv string
httpEnv string
wsEnv string
}{
{
name: "default-dev",
httpEnv: "BB_DEV_RPC_URL_HTTP_ethereum",
wsEnv: "BB_DEV_RPC_URL_WS_ethereum",
},
{
name: "prod",
buildEnv: "prod",
httpEnv: "BB_PROD_RPC_URL_HTTP_ethereum",
wsEnv: "BB_PROD_RPC_URL_WS_ethereum",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
t.Setenv("BB_BUILD_ENV", tt.buildEnv)
t.Setenv(tt.httpEnv, wantHTTP)
t.Setenv(tt.wsEnv, wantWS)
cfg := bchain.LoadBlockchainCfg(t, "ethereum")
if cfg.RpcUrl != wantHTTP {
t.Fatalf("expected rpc_url %q, got %q", wantHTTP, cfg.RpcUrl)
}
if cfg.RpcUrlWs != wantWS {
t.Fatalf("expected rpc_url_ws %q, got %q", wantWS, cfg.RpcUrlWs)
}
})
}
}
func TestLoadBlockchainCfgTraceTimeout(t *testing.T) {
tests := []struct {
coinAlias string
want string
}{
{
coinAlias: "polygon_archive",
want: "20s",
},
{
coinAlias: "arbitrum_archive",
want: "20s",
},
}
for _, tt := range tests {
t.Run(tt.coinAlias, func(t *testing.T) {
cfg := bchain.LoadBlockchainCfg(t, tt.coinAlias)
if cfg.TraceTimeout != tt.want {
t.Fatalf("expected trace_timeout %q, got %q", tt.want, cfg.TraceTimeout)
}
})
}
}