Skip to content

Commit efa9504

Browse files
authored
ci(filter): create initial chainsync tests (#320)
Signed-off-by: Chris Gianelloni <[email protected]>
1 parent be413ca commit efa9504

File tree

1 file changed

+87
-0
lines changed

1 file changed

+87
-0
lines changed

filter/chainsync/chainsync_test.go

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
// Copyright 2025 Blink Labs Software
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package chainsync
16+
17+
import "testing"
18+
19+
// MockLogger is a mock implementation of the plugin.Logger interface
20+
type MockLogger struct{}
21+
22+
func (l *MockLogger) Info(msg string, args ...interface{}) {}
23+
func (l *MockLogger) Error(msg string, args ...interface{}) {}
24+
func (l *MockLogger) Debug(msg string, args ...interface{}) {}
25+
func (l *MockLogger) Warn(msg string, args ...interface{}) {}
26+
func (l *MockLogger) Trace(msg string, args ...interface{}) {}
27+
28+
func TestNewChainSync(t *testing.T) {
29+
c := New()
30+
if c == nil {
31+
t.Fatalf("expected non-nil ChainSync instance")
32+
}
33+
}
34+
35+
func TestChainSync_Start(t *testing.T) {
36+
c := New()
37+
err := c.Start()
38+
if err != nil {
39+
t.Fatalf("expected no error, got %v", err)
40+
}
41+
// Additional checks can be added here
42+
}
43+
44+
func TestChainSync_Stop(t *testing.T) {
45+
c := New()
46+
err := c.Stop()
47+
if err != nil {
48+
t.Fatalf("expected no error, got %v", err)
49+
}
50+
// Check if channels are closed
51+
select {
52+
case <-c.inputChan:
53+
default:
54+
t.Fatalf("expected inputChan to be closed")
55+
}
56+
select {
57+
case <-c.outputChan:
58+
default:
59+
t.Fatalf("expected outputChan to be closed")
60+
}
61+
select {
62+
case <-c.errorChan:
63+
default:
64+
t.Fatalf("expected errorChan to be closed")
65+
}
66+
}
67+
68+
func TestChainSync_ErrorChan(t *testing.T) {
69+
c := New()
70+
if c.ErrorChan() == nil {
71+
t.Fatalf("expected non-nil errorChan")
72+
}
73+
}
74+
75+
func TestChainSync_InputChan(t *testing.T) {
76+
c := New()
77+
if c.InputChan() == nil {
78+
t.Fatalf("expected non-nil inputChan")
79+
}
80+
}
81+
82+
func TestChainSync_OutputChan(t *testing.T) {
83+
c := New()
84+
if c.OutputChan() == nil {
85+
t.Fatalf("expected non-nil outputChan")
86+
}
87+
}

0 commit comments

Comments
 (0)