Skip to content

Commit 5ca1d9b

Browse files
committed
unable to fix tests (WIP)
1 parent 3917fcc commit 5ca1d9b

File tree

1 file changed

+41
-4
lines changed

1 file changed

+41
-4
lines changed

lib/babe/babe_integration_test.go

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
// Copyright 2021 ChainSafe Systems (ON)
22
// SPDX-License-Identifier: LGPL-3.0-only
33

4-
//go:build integration
5-
64
package babe
75

86
import (
97
"fmt"
8+
provisioner "github.com/ChainSafe/gossamer/dot/parachain/provisioner/messages"
9+
parachaintypes "github.com/ChainSafe/gossamer/dot/parachain/types"
10+
"go.uber.org/mock/gomock"
1011
"testing"
1112
"time"
1213

@@ -35,6 +36,14 @@ var AuthorOnEverySlotBABEConfig = &types.BabeConfiguration{
3536
SecondarySlots: 0,
3637
}
3738

39+
type mockOverseerMessenger struct {
40+
ch chan any
41+
}
42+
43+
func (m mockOverseerMessenger) OverseerChannel() chan<- any {
44+
return m.ch
45+
}
46+
3847
func TestService_SlotDuration(t *testing.T) {
3948
duration, err := time.ParseDuration("1000ms")
4049
require.NoError(t, err)
@@ -182,7 +191,32 @@ func TestService_HandleSlotWithLaggingSlot(t *testing.T) {
182191
preRuntimeDigest,
183192
)
184193

185-
block, err := builder.buildBlock(&genesisHeader, slot, rt)
194+
ctrl := gomock.NewController(t)
195+
bs := NewMockBlockState(ctrl)
196+
bs.EXPECT().GetHeader(gomock.Any()).Return(&types.Header{
197+
ParentHash: emptyHash,
198+
Number: 0,
199+
}, nil)
200+
201+
ovChan := make(chan any)
202+
go func() {
203+
ovMsg := <-ovChan
204+
waitForActivation, ok := ovMsg.(parachaintypes.WaitForActivation)
205+
require.True(t, ok)
206+
waitForActivation.ResponseCh <- nil
207+
208+
ovMsg = <-ovChan
209+
provisionerInherentReq, ok := ovMsg.(provisioner.RequestInherentData)
210+
require.True(t, ok)
211+
// Provide valid inherent data with required bitfields and heads
212+
provisionerInherentReq.ProvisionerInherentData <- provisioner.ProvisionerInherentData{
213+
Bitfields: []parachaintypes.CheckedSignedAvailabilityBitfield{},
214+
BackedCandidates: []parachaintypes.BackedCandidate{},
215+
Disputes: []parachaintypes.DisputeStatementSet{},
216+
}
217+
}()
218+
219+
block, err := builder.buildBlock(&genesisHeader, slot, rt, bs, mockOverseerMessenger{ch: ovChan})
186220
require.NoError(t, err)
187221

188222
fmt.Println(epochDescriptor.startSlot)
@@ -255,7 +289,10 @@ func TestService_HandleSlotWithSameSlot(t *testing.T) {
255289
preRuntimeDigest,
256290
)
257291

258-
block, err := builder.buildBlock(&genesisHeader, slot, runtime)
292+
ctrl := gomock.NewController(t)
293+
bs := NewMockBlockState(ctrl)
294+
295+
block, err := builder.buildBlock(&genesisHeader, slot, runtime, bs, mockOverseerMessenger{ch: make(chan any)})
259296
require.NoError(t, err)
260297

261298
// Create new non authority service

0 commit comments

Comments
 (0)