MCPcopy Create free account
hub / github.com/DeAI-Artist/Linkis / waitForAndValidateBlockWithTx

Function waitForAndValidateBlockWithTx

consensus/reactor_test.go:601–634  ·  view source on GitHub ↗
(
	t *testing.T,
	n int,
	activeVals map[string]struct{},
	blocksSubs []types.Subscription,
	css []*State,
	txs ...[]byte,
)

Source from the content-addressed store, hash-verified

599}
600
601func waitForAndValidateBlockWithTx(
602 t *testing.T,
603 n int,
604 activeVals map[string]struct{},
605 blocksSubs []types.Subscription,
606 css []*State,
607 txs ...[]byte,
608) {
609 timeoutWaitGroup(t, n, func(j int) {
610 ntxs := 0
611 BLOCK_TX_LOOP:
612 for {
613 css[j].Logger.Debug("waitForAndValidateBlockWithTx", "ntxs", ntxs)
614 msg := <-blocksSubs[j].Out()
615 newBlock := msg.Data().(types.EventDataNewBlock).Block
616 css[j].Logger.Debug("waitForAndValidateBlockWithTx: Got block", "height", newBlock.Height)
617 err := validateBlock(newBlock, activeVals)
618 assert.Nil(t, err)
619
620 // check that txs match the txs we're waiting for.
621 // note they could be spread over multiple blocks,
622 // but they should be in order.
623 for _, tx := range newBlock.Data.Txs {
624 assert.EqualValues(t, txs[ntxs], tx)
625 ntxs++
626 }
627
628 if ntxs == len(txs) {
629 break BLOCK_TX_LOOP
630 }
631 }
632
633 }, css)
634}
635
636func waitForBlockWithUpdatedValsAndValidateIt(
637 t *testing.T,

Callers 2

Calls 5

timeoutWaitGroupFunction · 0.85
DataMethod · 0.80
validateBlockFunction · 0.70
DebugMethod · 0.65
OutMethod · 0.65

Tested by

no test coverage detected