Skip to content

Commit

Permalink
* Patch for testnet v1034
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastianMarian committed Oct 23, 2019
1 parent ddc2942 commit ef7b0d9
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 32 deletions.
8 changes: 4 additions & 4 deletions process/sync/baseForkDetector.go
Original file line number Diff line number Diff line change
Expand Up @@ -463,10 +463,10 @@ func (bfd *baseForkDetector) shouldAddBlockInForkDetector(
return nil
}

roundTooOld := int64(header.GetRound()) < bfd.rounder.Index()-finality
if roundTooOld {
return ErrLowerRoundInBlock
}
//roundTooOld := int64(header.GetRound()) < bfd.rounder.Index()-finality
//if roundTooOld {
// return ErrLowerRoundInBlock
//}

return nil
}
56 changes: 28 additions & 28 deletions process/sync/baseForkDetector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -728,20 +728,20 @@ func TestShardForkDetector_ShouldAddBlockInForkDetectorShouldWork(t *testing.T)
assert.Nil(t, err)
}

func TestShardForkDetector_ShouldAddBlockInForkDetectorShouldErrLowerRoundInBlock(t *testing.T) {
t.Parallel()
rounderMock := &mock.RounderMock{RoundIndex: 10}
sfd, _ := sync.NewShardForkDetector(rounderMock)
hdr := &block.Header{Nonce: 1, Round: 1}

hdr.Round = uint64(rounderMock.RoundIndex - process.ShardBlockFinality - 1)
err := sfd.ShouldAddBlockInForkDetector(hdr, process.BHReceived, process.ShardBlockFinality)
assert.Equal(t, sync.ErrLowerRoundInBlock, err)

sfd.SetProbableHighestNonce(hdr.GetNonce() + process.MaxNoncesDifference + 1)
err = sfd.ShouldAddBlockInForkDetector(hdr, process.BHProposed, process.ShardBlockFinality)
assert.Equal(t, sync.ErrLowerRoundInBlock, err)
}
//func TestShardForkDetector_ShouldAddBlockInForkDetectorShouldErrLowerRoundInBlock(t *testing.T) {
// t.Parallel()
// rounderMock := &mock.RounderMock{RoundIndex: 10}
// sfd, _ := sync.NewShardForkDetector(rounderMock)
// hdr := &block.Header{Nonce: 1, Round: 1}
//
// hdr.Round = uint64(rounderMock.RoundIndex - process.ShardBlockFinality - 1)
// err := sfd.ShouldAddBlockInForkDetector(hdr, process.BHReceived, process.ShardBlockFinality)
// assert.Equal(t, sync.ErrLowerRoundInBlock, err)
//
// sfd.SetProbableHighestNonce(hdr.GetNonce() + process.MaxNoncesDifference + 1)
// err = sfd.ShouldAddBlockInForkDetector(hdr, process.BHProposed, process.ShardBlockFinality)
// assert.Equal(t, sync.ErrLowerRoundInBlock, err)
//}

func TestMetaForkDetector_ShouldAddBlockInForkDetectorShouldWork(t *testing.T) {
t.Parallel()
Expand All @@ -766,20 +766,20 @@ func TestMetaForkDetector_ShouldAddBlockInForkDetectorShouldWork(t *testing.T) {
assert.Nil(t, err)
}

func TestMetaForkDetector_ShouldAddBlockInForkDetectorShouldErrLowerRoundInBlock(t *testing.T) {
t.Parallel()
rounderMock := &mock.RounderMock{RoundIndex: 10}
mfd, _ := sync.NewMetaForkDetector(rounderMock)
hdr := &block.MetaBlock{Nonce: 1, Round: 1}

hdr.Round = uint64(rounderMock.RoundIndex - process.MetaBlockFinality - 1)
err := mfd.ShouldAddBlockInForkDetector(hdr, process.BHReceived, process.MetaBlockFinality)
assert.Equal(t, sync.ErrLowerRoundInBlock, err)

mfd.SetProbableHighestNonce(hdr.GetNonce() + process.MaxNoncesDifference + 1)
err = mfd.ShouldAddBlockInForkDetector(hdr, process.BHProposed, process.MetaBlockFinality)
assert.Equal(t, sync.ErrLowerRoundInBlock, err)
}
//func TestMetaForkDetector_ShouldAddBlockInForkDetectorShouldErrLowerRoundInBlock(t *testing.T) {
// t.Parallel()
// rounderMock := &mock.RounderMock{RoundIndex: 10}
// mfd, _ := sync.NewMetaForkDetector(rounderMock)
// hdr := &block.MetaBlock{Nonce: 1, Round: 1}
//
// hdr.Round = uint64(rounderMock.RoundIndex - process.MetaBlockFinality - 1)
// err := mfd.ShouldAddBlockInForkDetector(hdr, process.BHReceived, process.MetaBlockFinality)
// assert.Equal(t, sync.ErrLowerRoundInBlock, err)
//
// mfd.SetProbableHighestNonce(hdr.GetNonce() + process.MaxNoncesDifference + 1)
// err = mfd.ShouldAddBlockInForkDetector(hdr, process.BHProposed, process.MetaBlockFinality)
// assert.Equal(t, sync.ErrLowerRoundInBlock, err)
//}

func TestShardForkDetector_AddFinalHeadersShouldNotChangeTheFinalCheckpoint(t *testing.T) {
t.Parallel()
Expand Down

0 comments on commit ef7b0d9

Please sign in to comment.