-
Notifications
You must be signed in to change notification settings - Fork 32
/
suite_test.go
80 lines (68 loc) · 2.26 KB
/
suite_test.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
package service_test
import (
"testing"
"time"
"github.com/synapsecns/sanguine/core"
"github.com/synapsecns/sanguine/core/metrics"
"github.com/synapsecns/sanguine/core/metrics/localmetrics"
"github.com/synapsecns/sanguine/services/scribe/metadata"
"github.com/Flaque/filet"
. "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"
"github.com/synapsecns/sanguine/core/testsuite"
"github.com/synapsecns/sanguine/ethergo/signer/signer/localsigner"
"github.com/synapsecns/sanguine/ethergo/signer/wallet"
"github.com/synapsecns/sanguine/services/scribe/db"
"github.com/synapsecns/sanguine/services/scribe/db/datastore/sql/sqlite"
"github.com/synapsecns/sanguine/services/scribe/testutil"
)
type ScribeSuite struct {
*testsuite.TestSuite
testDB db.EventDB
manager *testutil.DeployManager
wallet wallet.Wallet
signer *localsigner.Signer
metrics metrics.Handler
nullMetrics metrics.Handler
runVolumeTest bool
}
// NewScribeSuite creates a new scribe test suite.
func NewScribeSuite(tb testing.TB) *ScribeSuite {
tb.Helper()
return &ScribeSuite{
TestSuite: testsuite.NewTestSuite(tb),
runVolumeTest: true,
}
}
// SetupTest sets up the test suite.
func (s *ScribeSuite) SetupTest() {
s.TestSuite.SetupTest()
s.SetTestTimeout(time.Minute * 10)
sqliteStore, err := sqlite.NewSqliteStore(s.GetTestContext(), filet.TmpDir(s.T(), ""), s.metrics, false)
Nil(s.T(), err)
s.testDB = sqliteStore
s.manager = testutil.NewDeployManager(s.T())
s.wallet, err = wallet.FromRandom()
Nil(s.T(), err)
s.signer = localsigner.NewSigner(s.wallet.PrivateKey())
}
func (s *ScribeSuite) SetupSuite() {
s.TestSuite.SetupSuite()
// don't use metrics on ci for integration tests
isCI := core.GetEnvBool("CI", false)
useMetrics := !isCI
metricsHandler := metrics.Null
if useMetrics {
localmetrics.SetupTestJaeger(s.GetSuiteContext(), s.T())
metricsHandler = metrics.Jaeger
}
var err error
s.metrics, err = metrics.NewByType(s.GetSuiteContext(), metadata.BuildInfo(), metricsHandler)
Nil(s.T(), err)
s.nullMetrics, err = metrics.NewByType(s.GetSuiteContext(), metadata.BuildInfo(), metrics.Null)
Nil(s.T(), err)
}
// TestScribeSuite tests the scribe suite.
func TestScribeSuite(t *testing.T) {
suite.Run(t, NewScribeSuite(t))
}