Skip to content

Commit

Permalink
CLN: After self review
Browse files Browse the repository at this point in the history
  • Loading branch information
mariusmihaic committed Oct 25, 2024
1 parent 5770a3d commit 3d1706a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
16 changes: 5 additions & 11 deletions process/sync/storageBootstrap/shardStorageBootstrapper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,6 @@ func TestShardStorageBootstrapper_cleanupNotarizedStorageForHigherNoncesIfExist(
testCleanupNotarizedStorageForHigherNoncesIfExist(t, core.MetachainShardId, &block.MetaBlock{}, NewShardStorageBootstrapperFactory())
}

type bootStrapCleaner interface {
cleanupNotarizedStorageForHigherNoncesIfExist(
crossNotarizedHeaders []bootstrapStorage.BootstrapHeaderInfo,
)
}

func testCleanupNotarizedStorageForHigherNoncesIfExist(
t *testing.T,
shardID uint32,
Expand Down Expand Up @@ -228,16 +222,16 @@ func testCleanupNotarizedStorageForHigherNoncesIfExist(
ssb, err := factory.CreateBootstrapperFromStorage(args)
require.Nil(t, err)

ssbCleaner, castOk := ssb.(bootStrapCleaner)
storageHandler, castOk := ssb.(storageBootstrapperHandler)
require.True(t, castOk)

crossNotarizedHeaders := make([]bootstrapStorage.BootstrapHeaderInfo, 0)
crossNotarizedHeaders = append(crossNotarizedHeaders, bootstrapStorage.BootstrapHeaderInfo{ShardId: 0, Nonce: 1})
ssbCleaner.cleanupNotarizedStorageForHigherNoncesIfExist(crossNotarizedHeaders)
storageHandler.cleanupNotarizedStorageForHigherNoncesIfExist(crossNotarizedHeaders)
assert.Equal(t, 0, numCalled)

crossNotarizedHeaders = append(crossNotarizedHeaders, bootstrapStorage.BootstrapHeaderInfo{ShardId: shardID, Nonce: metaNonce})
ssbCleaner.cleanupNotarizedStorageForHigherNoncesIfExist(crossNotarizedHeaders)
storageHandler.cleanupNotarizedStorageForHigherNoncesIfExist(crossNotarizedHeaders)
assert.Equal(t, 0, numCalled)
assert.Equal(t, maxNumOfConsecutiveNoncesNotFoundAccepted, numKeysNotFound-1)

Expand All @@ -246,14 +240,14 @@ func testCleanupNotarizedStorageForHigherNoncesIfExist(
_ = header.SetNonce(metaNonceToDelete)
marshalledMetaBlock, _ = baseArgs.Marshalizer.Marshal(header)

ssbCleaner.cleanupNotarizedStorageForHigherNoncesIfExist(crossNotarizedHeaders)
storageHandler.cleanupNotarizedStorageForHigherNoncesIfExist(crossNotarizedHeaders)
assert.Equal(t, 0, numCalled)
assert.Equal(t, maxNumOfConsecutiveNoncesNotFoundAccepted*2, numKeysNotFound-1)

numKeysNotFound = 0
bForceError = false

ssbCleaner.cleanupNotarizedStorageForHigherNoncesIfExist(crossNotarizedHeaders)
storageHandler.cleanupNotarizedStorageForHigherNoncesIfExist(crossNotarizedHeaders)
assert.Equal(t, 2, numCalled)
assert.Equal(t, maxNumOfConsecutiveNoncesNotFoundAccepted*2, numKeysNotFound-1)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func (ssb *sovereignChainShardStorageBootstrapper) cleanupNotarizedStorage(shard

shardHeader, err := process.GetShardHeaderFromStorage(shardHeaderHash, ssb.marshalizer, ssb.store)
if err != nil {
log.Debug("shard header is not found in BlockHeaderUnit storage",
log.Debug("sovereign shard header is not found in BlockHeaderUnit storage",
"hash", shardHeaderHash)
return
}
Expand Down

0 comments on commit 3d1706a

Please sign in to comment.