-
Notifications
You must be signed in to change notification settings - Fork 266
Expand file tree
/
Copy pathexecutor_test.go
More file actions
123 lines (105 loc) · 3.25 KB
/
Copy pathexecutor_test.go
File metadata and controls
123 lines (105 loc) · 3.25 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
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
package executing
import (
"testing"
"time"
"github.com/ipfs/go-datastore"
"github.com/ipfs/go-datastore/sync"
"github.com/rs/zerolog"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/evstack/ev-node/block/internal/cache"
"github.com/evstack/ev-node/block/internal/common"
"github.com/evstack/ev-node/pkg/config"
"github.com/evstack/ev-node/pkg/genesis"
"github.com/evstack/ev-node/pkg/store"
"github.com/evstack/ev-node/types"
)
func TestExecutor_BroadcasterIntegration(t *testing.T) {
// Create in-memory store
ds := sync.MutexWrap(datastore.NewMapDatastore())
memStore := store.New(ds)
// Create cache
cacheManager, err := cache.NewManager(config.DefaultConfig(), memStore, zerolog.Nop())
require.NoError(t, err)
metrics := common.NopMetrics()
signerAddr, _, testSigner := buildTestSigner(t)
// Create genesis
gen := genesis.Genesis{
ChainID: "test-chain",
InitialHeight: 1,
StartTime: time.Now(),
ProposerAddress: signerAddr,
}
// Create mock broadcasters
headerBroadcaster := common.NewMockBroadcaster[*types.P2PSignedHeader](t)
dataBroadcaster := common.NewMockBroadcaster[*types.P2PData](t)
// Create executor with broadcasters
executor, err := NewExecutor(
memStore,
nil, // nil executor (we're not testing execution)
nil, // nil sequencer (we're not testing sequencing)
testSigner, // test signer (required for executor)
cacheManager,
metrics,
config.DefaultConfig(),
gen,
headerBroadcaster,
dataBroadcaster,
zerolog.Nop(),
common.DefaultBlockOptions(),
make(chan error, 1),
nil,
)
require.NoError(t, err)
// Verify broadcasters are set
assert.NotNil(t, executor.headerBroadcaster)
assert.NotNil(t, executor.dataBroadcaster)
assert.Equal(t, headerBroadcaster, executor.headerBroadcaster)
assert.Equal(t, dataBroadcaster, executor.dataBroadcaster)
// Verify other properties
assert.Equal(t, memStore, executor.store)
assert.Equal(t, cacheManager, executor.cache)
assert.Equal(t, gen, executor.genesis)
}
func TestExecutor_NilBroadcasters(t *testing.T) {
// Create in-memory store
ds := sync.MutexWrap(datastore.NewMapDatastore())
memStore := store.New(ds)
// Create cache
cacheManager, err := cache.NewManager(config.DefaultConfig(), memStore, zerolog.Nop())
require.NoError(t, err)
metrics := common.NopMetrics()
signerAddr, _, testSigner := buildTestSigner(t)
// Create genesis
gen := genesis.Genesis{
ChainID: "test-chain",
InitialHeight: 1,
StartTime: time.Now(),
ProposerAddress: signerAddr,
}
// Create executor with nil broadcasters (light node scenario)
executor, err := NewExecutor(
memStore,
nil, // nil executor
nil, // nil sequencer
testSigner, // test signer (required for executor)
cacheManager,
metrics,
config.DefaultConfig(),
gen,
nil, // nil header broadcaster
nil, // nil data broadcaster
zerolog.Nop(),
common.DefaultBlockOptions(),
make(chan error, 1),
nil,
)
require.NoError(t, err)
// Verify broadcasters are nil
assert.Nil(t, executor.headerBroadcaster)
assert.Nil(t, executor.dataBroadcaster)
// Verify other properties
assert.Equal(t, memStore, executor.store)
assert.Equal(t, cacheManager, executor.cache)
assert.Equal(t, gen, executor.genesis)
}