Skip to content

Commit

Permalink
Fixes the multiple block proposals test case
Browse files Browse the repository at this point in the history
  • Loading branch information
charithabandi committed Dec 12, 2024
1 parent c2a4406 commit f9fc75b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
11 changes: 10 additions & 1 deletion node/consensus/engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ func TestValidatorStateMachine(t *testing.T) {
{
name: "blkPropNew",
trigger: func(t *testing.T, leader, val *ConsensusEngine) {
val.NotifyBlockProposal(blkProp1.blk)
val.NotifyBlockProposal(blkProp2.blk)
},
verify: func(t *testing.T, leader, val *ConsensusEngine) error {
return verifyStatus(t, val, Executed, 0, blkProp2.blkHash)
Expand Down Expand Up @@ -553,8 +553,10 @@ func TestValidatorStateMachine(t *testing.T) {
val := New(ceConfigs[1])
blkProp1, err = leader.createBlockProposal()
assert.NoError(t, err)
time.Sleep(300 * time.Millisecond) // just to ensure that the block hashes are different due to start time
blkProp2, err = leader.createBlockProposal()
assert.NoError(t, err)
t.Logf("blkProp1: %s, blkProp2: %s", blkProp1.blkHash.String(), blkProp2.blkHash.String())

ctx, cancel := context.WithCancel(context.Background())
var wg sync.WaitGroup
Expand Down Expand Up @@ -838,6 +840,13 @@ func (ce *ConsensusEngine) blockResult() *blockResult {
return ce.state.blockRes
}

func (ce *ConsensusEngine) resetCount() int64 {
ce.cancelFnMtx.Lock()
defer ce.cancelFnMtx.Unlock()

return ce.numResets
}

// should satisfy the SnapshotModule interface
type snapshotStore struct {
}
Expand Down
3 changes: 3 additions & 0 deletions node/consensus/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ type BlockStore interface {
GetByHeight(height int64) (types.Hash, *ktypes.Block, types.Hash, error)
StoreResults(hash types.Hash, results []ktypes.TxResult) error
// Results(hash types.Hash) ([]types.TxResult, error)

}

type BlockProcessor interface {
Expand All @@ -47,4 +48,6 @@ type BlockProcessor interface {
CheckTx(ctx context.Context, tx *ktypes.Transaction, recheck bool) error

GetValidators() []*ktypes.Validator

BlockExecutionStatus() ktypes.BlockExecutionStatus
}

0 comments on commit f9fc75b

Please sign in to comment.