forked from hyperledger/fabric-x-committer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathruntime.go
More file actions
584 lines (505 loc) · 19 KB
/
Copy pathruntime.go
File metadata and controls
584 lines (505 loc) · 19 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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
/*
Copyright IBM Corp. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
package runner
import (
"context"
"fmt"
"math/rand"
"path/filepath"
"testing"
"time"
"github.com/hyperledger/fabric-protos-go-apiv2/common"
"github.com/hyperledger/fabric-x-common/internaltools/configtxgen"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"google.golang.org/protobuf/types/known/durationpb"
"github.com/hyperledger/fabric-x-committer/api/protoblocktx"
"github.com/hyperledger/fabric-x-committer/api/protocoordinatorservice"
"github.com/hyperledger/fabric-x-committer/api/protoloadgen"
"github.com/hyperledger/fabric-x-committer/api/protonotify"
"github.com/hyperledger/fabric-x-committer/api/protoqueryservice"
"github.com/hyperledger/fabric-x-committer/api/types"
"github.com/hyperledger/fabric-x-committer/cmd/config"
"github.com/hyperledger/fabric-x-committer/loadgen/workload"
"github.com/hyperledger/fabric-x-committer/service/sidecar"
"github.com/hyperledger/fabric-x-committer/service/sidecar/sidecarclient"
"github.com/hyperledger/fabric-x-committer/service/vc"
"github.com/hyperledger/fabric-x-committer/service/vc/dbtest"
"github.com/hyperledger/fabric-x-committer/utils/connection"
"github.com/hyperledger/fabric-x-committer/utils/deliver"
"github.com/hyperledger/fabric-x-committer/utils/logging"
"github.com/hyperledger/fabric-x-committer/utils/ordererconn"
"github.com/hyperledger/fabric-x-committer/utils/serialization"
"github.com/hyperledger/fabric-x-committer/utils/signature"
"github.com/hyperledger/fabric-x-committer/utils/signature/sigtest"
"github.com/hyperledger/fabric-x-committer/utils/test"
)
type (
// CommitterRuntime represents a test system of Coordinator, SigVerifier, VCService and Query processes.
CommitterRuntime struct {
SystemConfig config.SystemConfig
MockOrderer *ProcessWithConfig
Sidecar *ProcessWithConfig
Coordinator *ProcessWithConfig
QueryService *ProcessWithConfig
Verifier []*ProcessWithConfig
VcService []*ProcessWithConfig
dbEnv *vc.DatabaseTestEnv
ordererStream *test.BroadcastStream
CoordinatorClient protocoordinatorservice.CoordinatorClient
QueryServiceClient protoqueryservice.QueryServiceClient
sidecarClient *sidecarclient.Client
notifyClient protonotify.NotifierClient
notifyStream protonotify.Notifier_OpenNotificationStreamClient
CommittedBlock chan *common.Block
TxBuilder *workload.TxBuilder
config *Config
seedForCryptoGen *rand.Rand
LastReceivedBlockNumber uint64
CredFactory *test.CredentialsFactory
}
// Crypto holds crypto material for a namespace.
Crypto struct {
Namespace string
Profile *workload.Policy
HashSigner *workload.HashSignerVerifier
NsSigner *sigtest.NsSigner
PubKey []byte
PubKeyPath string
}
// Config represents the runtime configuration.
Config struct {
NumVerifiers int
NumVCService int
BlockSize uint64
BlockTimeout time.Duration
LoadgenBlockLimit uint64
// DBConnection configures the runtime to operate with a custom database connection.
DBConnection *dbtest.Connection
// TLS configures the secure level between the components: none | tls | mtls
TLSMode string
// CrashTest is true to indicate a service crash is expected, and not a failure.
CrashTest bool
}
)
// Service flags.
const (
Orderer = 1 << iota
Sidecar
Coordinator
Verifier
VC
QueryService
LoadGenForOnlyOrderer
LoadGenForOrderer
LoadGenForCommitter
LoadGenForCoordinator
LoadGenForVerifier
LoadGenForVCService
LoadGenForDistributedLoadGen
CommitterTxPath = Sidecar | Coordinator | Verifier | VC
FullTxPath = Orderer | CommitterTxPath
FullTxPathWithLoadGen = FullTxPath | LoadGenForOrderer
FullTxPathWithQuery = FullTxPath | QueryService
CommitterTxPathWithLoadGen = CommitterTxPath | LoadGenForCommitter
// loadGenMatcher is used to extract only the load generator flags from the full service flags value.
loadGenMatcher = LoadGenForOnlyOrderer | LoadGenForOrderer | LoadGenForCommitter | LoadGenForCoordinator |
LoadGenForVCService | LoadGenForVerifier
TestChannelName = "channel1"
)
// NewRuntime creates a new test runtime.
func NewRuntime(t *testing.T, conf *Config) *CommitterRuntime {
t.Helper()
c := &CommitterRuntime{
config: conf,
SystemConfig: config.SystemConfig{
BlockSize: conf.BlockSize,
BlockTimeout: conf.BlockTimeout,
LoadGenBlockLimit: conf.LoadgenBlockLimit,
LoadGenWorkers: 1,
Policy: &workload.PolicyProfile{
ChannelID: TestChannelName,
NamespacePolicies: make(map[string]*workload.Policy),
},
Logging: &logging.DefaultConfig,
},
CommittedBlock: make(chan *common.Block, 100),
seedForCryptoGen: rand.New(rand.NewSource(10)),
}
c.AddOrUpdateNamespaces(t, types.MetaNamespaceID, workload.GeneratedNamespaceID, "1", "2", "3")
t.Log("Making DB env")
if conf.DBConnection == nil {
c.dbEnv = vc.NewDatabaseTestEnv(t)
} else {
c.dbEnv = vc.NewDatabaseTestEnvWithCustomConnection(t, conf.DBConnection)
}
s := &c.SystemConfig
s.DB.Name = c.dbEnv.DBConf.Database
s.DB.Password = c.dbEnv.DBConf.Password
s.DB.LoadBalance = c.dbEnv.DBConf.LoadBalance
s.DB.Endpoints = c.dbEnv.DBConf.Endpoints
s.DB.TLS = c.dbEnv.DBConf.TLS
s.LedgerPath = t.TempDir()
s.ConfigBlockPath = filepath.Join(t.TempDir(), "config-block.pb.bin")
t.Log("Allocating ports")
ports := portAllocator{}
defer ports.close()
s.Endpoints.Orderer = ports.allocatePorts(t, 1)
s.Endpoints.Verifier = ports.allocatePorts(t, conf.NumVerifiers)
s.Endpoints.VCService = ports.allocatePorts(t, conf.NumVCService)
s.Endpoints.Query = ports.allocatePorts(t, 1)[0]
s.Endpoints.Coordinator = ports.allocatePorts(t, 1)[0]
s.Endpoints.Sidecar = ports.allocatePorts(t, 1)[0]
s.Endpoints.LoadGen = ports.allocatePorts(t, 1)[0]
s.Policy.OrdererEndpoints = make([]*ordererconn.Endpoint, len(s.Endpoints.Orderer))
for i, e := range s.Endpoints.Orderer {
s.Policy.OrdererEndpoints[i] = &ordererconn.Endpoint{MspID: "org", Endpoint: *e.Server}
}
test.LogStruct(t, "System Parameters", s)
t.Log("Creating config block")
configBlock, err := workload.CreateConfigBlock(s.Policy)
require.NoError(t, err)
err = configtxgen.WriteOutputBlock(configBlock, s.ConfigBlockPath)
require.NoError(t, err)
t.Log("create TLS manager and clients certificate")
c.CredFactory = test.NewCredentialsFactory(t)
s.ClientTLS, _ = c.CredFactory.CreateClientCredentials(t, c.config.TLSMode)
t.Log("Create processes")
c.MockOrderer = newProcess(t, cmdOrderer, s.WithEndpoint(s.Endpoints.Orderer[0]))
for i, e := range s.Endpoints.Verifier {
p := cmdVerifier
p.Name = fmt.Sprintf("%s-%d", p.Name, i)
// we generate different keys for each verifier.
c.Verifier = append(c.Verifier, newProcess(t, p, c.createSystemConfigWithServerTLS(t, e)))
}
for i, e := range s.Endpoints.VCService {
p := cmdVC
p.Name = fmt.Sprintf("%s-%d", p.Name, i)
// we generate different keys for each vc-service.
c.VcService = append(c.VcService, newProcess(t, p, c.createSystemConfigWithServerTLS(t, e)))
}
c.Coordinator = newProcess(t, cmdCoordinator, c.createSystemConfigWithServerTLS(t, s.Endpoints.Coordinator))
c.QueryService = newProcess(t, cmdQuery, c.createSystemConfigWithServerTLS(t, s.Endpoints.Query))
c.Sidecar = newProcess(t, cmdSidecar, c.createSystemConfigWithServerTLS(t, s.Endpoints.Sidecar))
t.Log("Create clients")
c.CoordinatorClient = protocoordinatorservice.NewCoordinatorClient(
test.NewSecuredConnection(t, s.Endpoints.Coordinator.Server, c.SystemConfig.ClientTLS),
)
c.QueryServiceClient = protoqueryservice.NewQueryServiceClient(
test.NewSecuredConnection(t, s.Endpoints.Query.Server, c.SystemConfig.ClientTLS),
)
c.notifyClient = protonotify.NewNotifierClient(
test.NewSecuredConnection(t, s.Endpoints.Sidecar.Server, c.SystemConfig.ClientTLS),
)
c.ordererStream, err = test.NewBroadcastStream(t.Context(), &ordererconn.Config{
Connection: ordererconn.ConnectionConfig{
Endpoints: s.Policy.OrdererEndpoints,
},
ChannelID: s.Policy.ChannelID,
Identity: s.Policy.Identity,
ConsensusType: ordererconn.Bft,
})
require.NoError(t, err)
t.Cleanup(c.ordererStream.CloseConnections)
c.sidecarClient, err = sidecarclient.New(&sidecarclient.Parameters{
ChannelID: s.Policy.ChannelID,
Client: test.NewTLSClientConfig(s.ClientTLS, s.Endpoints.Sidecar.Server),
})
require.NoError(t, err)
t.Cleanup(c.sidecarClient.CloseConnections)
return c
}
// Start runs all services and load generator as configured by the serviceFlags.
func (c *CommitterRuntime) Start(t *testing.T, serviceFlags int) {
t.Helper()
require.Falsef(t, isMoreThanOneBitSet((Orderer|LoadGenForCommitter)&serviceFlags),
"cannot use load generator for committer with an orderer")
t.Log("Running services")
if loadGenMatcher&serviceFlags != 0 {
c.startLoadGen(t, serviceFlags)
}
if Orderer&serviceFlags != 0 {
c.MockOrderer.Restart(t)
}
if Verifier&serviceFlags != 0 {
for _, p := range c.Verifier {
p.Restart(t)
}
}
if VC&serviceFlags != 0 {
for _, p := range c.VcService {
p.Restart(t)
}
}
if Coordinator&serviceFlags != 0 {
c.Coordinator.Restart(t)
}
if Sidecar&serviceFlags != 0 {
c.Sidecar.Restart(t)
var err error
c.notifyStream, err = c.notifyClient.OpenNotificationStream(t.Context())
require.NoError(t, err)
}
if QueryService&serviceFlags != 0 {
c.QueryService.Restart(t)
}
if Coordinator&serviceFlags != 0 && Sidecar&serviceFlags != 0 {
// We need the sidecar to update the coordinator with the last committed block.
t.Log("Validate coordinator state")
c.ensureAtLeastLastCommittedBlockNumber(t, 0)
}
if Sidecar&serviceFlags != 0 {
c.startBlockDelivery(t)
}
}
func (c *CommitterRuntime) startLoadGen(t *testing.T, serviceFlags int) {
t.Helper()
loadGenFlag := loadGenMatcher & serviceFlags
require.Falsef(t, isMoreThanOneBitSet(loadGenFlag), "only one load generator may be set")
loadGenParams := cmdLoadGen
switch loadGenFlag {
case LoadGenForOnlyOrderer:
loadGenParams.Template = config.TemplateLoadGenOnlyOrderer
case LoadGenForOrderer:
loadGenParams.Template = config.TemplateLoadGenOrderer
case LoadGenForCommitter:
loadGenParams.Template = config.TemplateLoadGenCommitter
case LoadGenForCoordinator:
loadGenParams.Template = config.TemplateLoadGenCoordinator
case LoadGenForVCService:
loadGenParams.Template = config.TemplateLoadGenVC
case LoadGenForVerifier:
loadGenParams.Template = config.TemplateLoadGenVerifier
default:
return
}
s := c.SystemConfig
isDist := serviceFlags&LoadGenForDistributedLoadGen != 0
if isDist {
s.LoadGenWorkers = 0
}
newProcess(t, loadGenParams, c.createSystemConfigWithServerTLS(t, s.Endpoints.LoadGen)).Restart(t)
if isDist {
s.LoadGenWorkers = 1
loadGenParams.Name = "dist-loadgen"
loadGenParams.Template = config.TemplateLoadGenDistributedLoadGenClient
newProcess(t, loadGenParams, s.WithEndpoint(config.ServiceEndpoints{})).Restart(t)
}
}
func (c *CommitterRuntime) startBlockDelivery(t *testing.T) {
t.Helper()
t.Log("Running delivery client")
test.RunServiceForTest(t.Context(), t, func(ctx context.Context) error {
return connection.FilterStreamRPCError(c.sidecarClient.Deliver(ctx, &sidecarclient.DeliverParameters{
EndBlkNum: deliver.MaxBlockNum,
OutputBlock: c.CommittedBlock,
}))
}, func(ctx context.Context) bool {
select {
case <-ctx.Done():
return false
case b := <-c.CommittedBlock:
require.NotNil(t, b)
return true
}
})
}
// AddOrUpdateNamespaces adds policies for namespaces. If already exists, the policy will be updated.
func (c *CommitterRuntime) AddOrUpdateNamespaces(t *testing.T, namespaces ...string) {
t.Helper()
for _, ns := range namespaces {
c.SystemConfig.Policy.NamespacePolicies[ns] = &workload.Policy{
Scheme: signature.Ecdsa,
Seed: c.seedForCryptoGen.Int63(),
}
}
var err error
c.TxBuilder, err = workload.NewTxBuilderFromPolicy(c.SystemConfig.Policy, nil)
require.NoError(t, err)
}
// CreateNamespacesAndCommit creates namespaces in the committer.
func (c *CommitterRuntime) CreateNamespacesAndCommit(t *testing.T, namespaces ...string) {
t.Helper()
if len(namespaces) == 0 {
return
}
t.Logf("Creating namespaces: %v", namespaces)
metaTX, err := workload.CreateNamespacesTX(c.SystemConfig.Policy, 0, namespaces...)
require.NoError(t, err)
c.MakeAndSendTransactionsToOrderer(
t,
[][]*protoblocktx.TxNamespace{metaTX.Namespaces},
[]protoblocktx.Status{protoblocktx.Status_COMMITTED},
)
}
// MakeAndSendTransactionsToOrderer creates a block with given transactions, send it to the committer,
// and verify the result.
func (c *CommitterRuntime) MakeAndSendTransactionsToOrderer(
t *testing.T, txsNs [][]*protoblocktx.TxNamespace, expectedStatus []protoblocktx.Status,
) []string {
t.Helper()
txs := make([]*protoloadgen.TX, len(txsNs))
for i, namespaces := range txsNs {
tx := &protoblocktx.Tx{
Namespaces: namespaces,
}
if expectedStatus != nil && expectedStatus[i] == protoblocktx.Status_ABORTED_SIGNATURE_INVALID {
tx.Endorsements = make([]*protoblocktx.Endorsements, len(namespaces))
for nsIdx := range namespaces {
tx.Endorsements[nsIdx] = test.CreateEndorsementsForThresholdRule([]byte("dummy"))[0]
}
}
txs[i] = c.TxBuilder.MakeTx(tx)
}
return c.SendTransactionsToOrderer(t, txs, expectedStatus)
}
// SendTransactionsToOrderer creates a block with given transactions, send it to the committer, and verify the result.
func (c *CommitterRuntime) SendTransactionsToOrderer(
t *testing.T, txs []*protoloadgen.TX, expectedStatus []protoblocktx.Status,
) []string {
t.Helper()
expected := &ExpectedStatusInBlock{
Statuses: expectedStatus,
TxIDs: make([]string, len(txs)),
}
for i, tx := range txs {
expected.TxIDs[i] = tx.Id
}
if !c.config.CrashTest {
err := c.notifyStream.Send(&protonotify.NotificationRequest{
TxStatusRequest: &protonotify.TxStatusRequest{
TxIds: expected.TxIDs,
},
Timeout: durationpb.New(3 * time.Minute),
})
require.NoError(t, err)
// Allows processing the request before submitting the payload.
time.Sleep(1 * time.Second)
}
err := c.ordererStream.SendBatch(workload.MapToEnvelopeBatch(0, txs))
require.NoError(t, err)
if expectedStatus != nil {
c.ValidateExpectedResultsInCommittedBlock(t, expected)
}
return expected.TxIDs
}
// ExpectedStatusInBlock holds pairs of expected txID and the corresponding status in a block. The order of statuses
// is expected to be the same as in the committed block.
type ExpectedStatusInBlock struct {
TxIDs []string
Statuses []protoblocktx.Status
}
// ValidateExpectedResultsInCommittedBlock validates the status of transactions in the committed block.
func (c *CommitterRuntime) ValidateExpectedResultsInCommittedBlock(t *testing.T, expected *ExpectedStatusInBlock) {
t.Helper()
var blk *common.Block
var ok bool
select {
case blk, ok = <-c.CommittedBlock:
if !ok {
return
}
case <-time.After(2 * time.Minute):
t.Fatalf("Timed out waiting for block #%d", c.LastReceivedBlockNumber+1)
}
c.LastReceivedBlockNumber = blk.Header.Number
t.Logf("Got block #%d", blk.Header.Number)
for txNum, txEnv := range blk.Data.Data {
txBytes, hdr, err := serialization.UnwrapEnvelope(txEnv)
require.NoError(t, err)
require.NotNil(t, hdr)
if hdr.Type == int32(common.HeaderType_CONFIG) {
continue
}
_, err = serialization.UnmarshalTx(txBytes)
require.NoError(t, err)
require.Equal(t, expected.TxIDs[txNum], hdr.TxId)
}
expectedStatuses := make([]string, len(expected.Statuses))
for i, s := range expected.Statuses {
expectedStatuses[i] = s.String()
}
require.NotNil(t, blk.Metadata)
require.Greater(t, len(blk.Metadata.Metadata), int(common.BlockMetadataIndex_TRANSACTIONS_FILTER))
statusBytes := blk.Metadata.Metadata[common.BlockMetadataIndex_TRANSACTIONS_FILTER]
actualStatuses := make([]string, len(statusBytes))
for i, sB := range statusBytes {
actualStatuses[i] = protoblocktx.Status(sB).String()
}
require.Equal(t, expectedStatuses, actualStatuses)
c.ensureLastCommittedBlockNumber(t, blk.Header.Number)
var persistedTxIDs []string
persistedTxIDsStatus := make(map[string]*protoblocktx.StatusWithHeight)
nonDuplicateTxIDsStatus := make(map[string]*protoblocktx.StatusWithHeight)
duplicateTxIDsStatus := make(map[string]*protoblocktx.StatusWithHeight)
for i, tID := range expected.TxIDs {
//nolint:gosec // int -> uint32.
s := types.NewStatusWithHeight(expected.Statuses[i], blk.Header.Number, uint32(i))
if s.Code == protoblocktx.Status_REJECTED_DUPLICATE_TX_ID {
duplicateTxIDsStatus[tID] = s
} else {
nonDuplicateTxIDsStatus[tID] = s
}
if sidecar.IsStatusStoredInDB(s.Code) {
persistedTxIDsStatus[tID] = s
persistedTxIDs = append(persistedTxIDs, tID)
}
}
c.dbEnv.StatusExistsForNonDuplicateTxID(t, persistedTxIDsStatus)
// For the duplicate txID, neither the status nor the height would match the entry in the
// transaction status table.
c.dbEnv.StatusExistsWithDifferentHeightForDuplicateTxID(t, duplicateTxIDsStatus)
ctx, cancel := context.WithTimeout(t.Context(), 1*time.Minute)
defer cancel()
test.EnsurePersistedTxStatus(ctx, t, c.CoordinatorClient, persistedTxIDs, persistedTxIDsStatus)
if len(expected.TxIDs) == 0 || c.config.CrashTest {
return
}
sidecar.RequireNotifications(t, c.notifyStream, blk.Header.Number, expected.TxIDs, expected.Statuses)
}
// CountStatus returns the number of transactions with a given tx status.
func (c *CommitterRuntime) CountStatus(t *testing.T, status protoblocktx.Status) int {
t.Helper()
return c.dbEnv.CountStatus(t, status)
}
// CountAlternateStatus returns the number of transactions not with a given tx status.
func (c *CommitterRuntime) CountAlternateStatus(t *testing.T, status protoblocktx.Status) int {
t.Helper()
return c.dbEnv.CountAlternateStatus(t, status)
}
func (c *CommitterRuntime) ensureLastCommittedBlockNumber(t *testing.T, blkNum uint64) {
t.Helper()
c.ensureAtLeastLastCommittedBlockNumber(t, blkNum)
ctx, cancel := context.WithTimeout(t.Context(), time.Minute)
defer cancel()
lastCommittedBlock, err := c.CoordinatorClient.GetLastCommittedBlockNumber(ctx, nil)
require.NoError(t, err)
require.NotNil(t, lastCommittedBlock.Block)
require.Equal(t, blkNum, lastCommittedBlock.Block.Number)
}
func (c *CommitterRuntime) ensureAtLeastLastCommittedBlockNumber(t *testing.T, blkNum uint64) {
t.Helper()
ctx, cancel := context.WithTimeout(t.Context(), 2*time.Minute)
defer cancel()
require.EventuallyWithT(t, func(ct *assert.CollectT) {
lastCommittedBlock, err := c.CoordinatorClient.GetLastCommittedBlockNumber(ctx, nil)
require.NoError(ct, err)
require.NotNil(ct, lastCommittedBlock.Block)
require.GreaterOrEqual(ct, lastCommittedBlock.Block.Number, blkNum)
}, 2*time.Minute, 250*time.Millisecond)
}
func (c *CommitterRuntime) createSystemConfigWithServerTLS(
t *testing.T,
endpoints config.ServiceEndpoints,
) *config.SystemConfig {
t.Helper()
serviceCfg := c.SystemConfig
serviceCfg.ServiceTLS, _ = c.CredFactory.CreateServerCredentials(t, c.config.TLSMode, endpoints.Server.Host)
serviceCfg.ServiceEndpoints = endpoints
return &serviceCfg
}
func isMoreThanOneBitSet(bits int) bool {
return bits != 0 && bits&(bits-1) != 0
}