/
t__utils.go
132 lines (100 loc) · 3.16 KB
/
t__utils.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
/*
GloFlow application and media management/publishing platform
Copyright (C) 2021 Ivan Trajkovic
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
package gf_eth_core
import (
"os"
"fmt"
"testing"
"github.com/gloflow/gloflow/go/gf_core"
)
//-------------------------------------------------
func TestGenAddress(pTest *testing.T) {
privateKeyHexStr, publicKeyHexStr, addressHexStr, _ := EthGenerateKeys()
fmt.Printf("private key hex - %s\n", privateKeyHexStr)
fmt.Printf("public key hex - %s\n", publicKeyHexStr)
fmt.Printf("address hex - %s\n", addressHexStr)
}
//---------------------------------------------------
func TgetRuntime() (*GF_runtime, *GF_metrics, error) {
//-----------------------
// MONGODB_HOST
var mongoDBhostPortStr string
envMongoDBhostPortStr := os.Getenv("GF_TEST_MONGODB_HOST_PORT")
if envMongoDBhostPortStr != "" {
mongoDBhostPortStr = envMongoDBhostPortStr
} else {
mongoDBhostPortStr = "localhost:27017"
}
//-----------------------
// MONGODB_HOST
var sqlHostStr string
envSQLhostStr := os.Getenv("GF_TEST_SQL_HOST_PORT")
if envSQLhostStr != "" {
sqlHostStr = envSQLhostStr
} else {
sqlHostStr = "localhost:5432"
}
//-----------------------
// RUNTIME_SYS
logFun, logNewFun := gf_core.LogsInit()
runtimeSys := &gf_core.RuntimeSys{
ServiceNameStr: "gf_web3_monitor_test",
LogFun: logFun,
LogNewFun: logNewFun,
// SENTRY - enable it for error reporting
ErrorsSendToSentryBool: true,
}
// VALIDATOR
validator := gf_core.ValidateInit()
runtimeSys.Validator = validator
// HTTP_PROXY
// if traffic should be routed through a http proxy
var httpProxyURIstr string
envHTTPproxyURIstr := os.Getenv("GF_TEST_HTTP_PROXY_URI")
if envHTTPproxyURIstr != "" {
httpProxyURIstr = envHTTPproxyURIstr
}
runtimeSys.HTTPproxyServerURIstr = httpProxyURIstr
config := &GF_config{
Mongodb_host_str: mongoDBhostPortStr,
Mongodb_db_name_str: "gf_web3_monitor_test",
}
// RUNTIME
runtime, err := RuntimeGet(config, runtimeSys)
if err != nil {
return nil, nil, err
}
//--------------------
// SQL
dbNameStr := "gf_tests"
dbUserStr := "gf"
dbHostStr := sqlHostStr
sqlDB, gfErr := gf_core.DBsqlConnect(dbNameStr,
dbUserStr,
"", // config.SQLpassStr,
dbHostStr,
runtimeSys)
if gfErr != nil {
panic(-1)
}
runtimeSys.SQLdb = sqlDB
//--------------------
// SENTRY
// FIX!! - load this from ENV var
sentryEndpointURIstr := "https://702b507d193d45029674fbf98bcedaaf@o502595.ingest.sentry.io/5590469"
SentryInit(sentryEndpointURIstr)
return runtime, nil, nil
}