Skip to content

Commit

Permalink
tests: Fixed LoadFromEmptyStorage
Browse files Browse the repository at this point in the history
  • Loading branch information
EduMenges committed May 13, 2024
1 parent 07e08da commit e7b53f6
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions test/src/blockchain/block_storage_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ class BlockStorageTest : public test::CRDTFixture
header_repo_( std::make_shared<KeyValueBlockHeaderRepository>( db_, hasher, "teststorage-963/" ) )
{
root_hash.put( std::vector<uint8_t>( 32UL, 1 ) );

CreateWithGenesis();
}

std::shared_ptr<KeyValueBlockStorage> CreateWithGenesis()
Expand Down Expand Up @@ -69,6 +67,8 @@ class BlockStorageTest : public test::CRDTFixture
*/
TEST_F( BlockStorageTest, CreateWithExistingGenesis )
{
(void)CreateWithGenesis();

EXPECT_OUTCOME_ERROR(
res,
KeyValueBlockStorage::createWithGenesis( root_hash, db_, hasher, header_repo_, block_handler ),
Expand All @@ -83,6 +83,8 @@ TEST_F( BlockStorageTest, CreateWithExistingGenesis )
*/
TEST_F( BlockStorageTest, LoadFromExistingStorage )
{
(void)CreateWithGenesis();

auto new_block_storage_res = KeyValueBlockStorage::loadExisting( db_, hasher, header_repo_, block_handler );
EXPECT_TRUE( new_block_storage_res.has_value() );
}
Expand All @@ -95,16 +97,9 @@ TEST_F( BlockStorageTest, LoadFromExistingStorage )
*/
TEST_F( BlockStorageTest, LoadFromEmptyStorage )
{
auto empty_storage = std::make_shared<GenericStorageMock<Buffer, Buffer>>();

//EXPECT_CALL(*empty_storage, get(_))
// trying to get last finalized block hash to ensure he not exists yet
// .WillOnce(Return(KeyValueBlockStorage::Error::FINALIZED_BLOCK_NOT_FOUND));

//EXPECT_OUTCOME_ERROR(
// res,
// KeyValueBlockStorage::loadExisting(empty_storage, hasher, block_handler),
// KeyValueBlockStorage::Error::FINALIZED_BLOCK_NOT_FOUND);
EXPECT_OUTCOME_ERROR( res,
KeyValueBlockStorage::loadExisting( db_, hasher, header_repo_, block_handler ),
KeyValueBlockStorage::Error::FINALIZED_BLOCK_NOT_FOUND );
}

/**
Expand Down

0 comments on commit e7b53f6

Please sign in to comment.