diff --git a/src/blockstore/utils/Key.cpp b/src/blockstore/utils/Key.cpp index 41c547dc..18ac49b8 100644 --- a/src/blockstore/utils/Key.cpp +++ b/src/blockstore/utils/Key.cpp @@ -35,12 +35,6 @@ Key Key::CreateRandomKey() { return result; } -Key Key::CreateDummyKey() { - Key result; - std::memset(result._key, 0, KEYLENGTH_BINARY); - return result; -} - Key Key::FromString(const std::string &key) { assert(key.size() == KEYLENGTH_STRING); Key result; diff --git a/src/blockstore/utils/Key.h b/src/blockstore/utils/Key.h index 5ff5249b..3441dc8a 100644 --- a/src/blockstore/utils/Key.h +++ b/src/blockstore/utils/Key.h @@ -16,7 +16,6 @@ public: static constexpr unsigned int KEYLENGTH_STRING = 2 * KEYLENGTH_BINARY; // Hex encoding static Key CreateRandomKey(); - static Key CreateDummyKey(); static Key FromString(const std::string &key); std::string AsString() const; diff --git a/src/test/blockstore/interface/helpers/BlockStoreWithRandomKeysTest.cpp b/src/test/blockstore/interface/helpers/BlockStoreWithRandomKeysTest.cpp index 4ca71e7f..45835c5d 100644 --- a/src/test/blockstore/interface/helpers/BlockStoreWithRandomKeysTest.cpp +++ b/src/test/blockstore/interface/helpers/BlockStoreWithRandomKeysTest.cpp @@ -38,6 +38,7 @@ class BlockStoreWithRandomKeysTest: public Test { public: BlockStoreWithRandomKeysMock blockStoreMock; BlockStore &blockStore = blockStoreMock; + const blockstore::Key key = Key::FromString("1491BB4932A389EE14BC7090AC772972"); }; TEST_F(BlockStoreWithRandomKeysTest, SizeIsPassedThrough0) { @@ -65,7 +66,7 @@ TEST_F(BlockStoreWithRandomKeysTest, KeyHasCorrectSize) { } TEST_F(BlockStoreWithRandomKeysTest, TwoBlocksGetDifferentKeys) { - Key first_key = Key::CreateDummyKey(); + Key first_key = key; EXPECT_CALL(blockStoreMock, do_create(_, _)) .WillOnce(Invoke([&first_key](const Key &key, size_t) { first_key = key; @@ -81,7 +82,7 @@ TEST_F(BlockStoreWithRandomKeysTest, TwoBlocksGetDifferentKeys) { } TEST_F(BlockStoreWithRandomKeysTest, WillTryADifferentKeyIfKeyAlreadyExists) { - Key first_key = Key::CreateDummyKey(); + Key first_key = key; EXPECT_CALL(blockStoreMock, do_create(_, _)) .WillOnce(Invoke([&first_key](const Key &key, size_t) { first_key = key; @@ -96,7 +97,7 @@ TEST_F(BlockStoreWithRandomKeysTest, WillTryADifferentKeyIfKeyAlreadyExists) { } TEST_F(BlockStoreWithRandomKeysTest, WillTryADifferentKeyIfKeyAlreadyExistsTwoTimes) { - Key first_key = Key::CreateDummyKey(); + Key first_key = key; EXPECT_CALL(blockStoreMock, do_create(_, _)) .WillOnce(Invoke([&first_key](const Key &key, size_t) { first_key = key; diff --git a/src/test/blockstore/testutils/BlockStoreTest.h b/src/test/blockstore/testutils/BlockStoreTest.h index d78b3b13..803f56a9 100644 --- a/src/test/blockstore/testutils/BlockStoreTest.h +++ b/src/test/blockstore/testutils/BlockStoreTest.h @@ -85,7 +85,7 @@ public: void TestAfterCreate_FlushesWhenDestructed() { DataBlockFixture randomData(size); - blockstore::Key key = blockstore::Key::CreateDummyKey(); + blockstore::Key key = key; { auto block = blockStore->create(size); key = block.key; @@ -97,7 +97,7 @@ public: void TestAfterLoad_FlushesWhenDestructed() { DataBlockFixture randomData(size); - blockstore::Key key = blockstore::Key::CreateDummyKey(); + blockstore::Key key = key; { key = blockStore->create(size).key; auto block = blockStore->load(key); @@ -109,17 +109,18 @@ public: void TestLoadNonExistingBlock() { EXPECT_FALSE( - (bool)blockStore->load(blockstore::Key::CreateRandomKey()) + (bool)blockStore->load(key) ); } void TestLoadNonExistingBlockWithEmptyKey() { EXPECT_FALSE( - (bool)blockStore->load(blockstore::Key::CreateDummyKey()) + (bool)blockStore->load(key) ); } private: + const blockstore::Key key = blockstore::Key::FromString("1491BB4932A389EE14BC7090AC772972"); std::unique_ptr blockStore; size_t size; diff --git a/src/test/blockstore/testutils/BlockStoreWithRandomKeysTest.h b/src/test/blockstore/testutils/BlockStoreWithRandomKeysTest.h index 84e9ce2a..2dc16313 100644 --- a/src/test/blockstore/testutils/BlockStoreWithRandomKeysTest.h +++ b/src/test/blockstore/testutils/BlockStoreWithRandomKeysTest.h @@ -21,7 +21,7 @@ public: "Given test fixture for instantiating the (type parameterized) BlockStoreWithRandomKeysTest must inherit from BlockStoreWithRandomKeysTestFixture" ); - blockstore::Key key = blockstore::Key::CreateDummyKey(); + blockstore::Key key = blockstore::Key::FromString("1491BB4932A389EE14BC7090AC772972"); const std::vector SIZES = {0, 1, 1024, 4096, 10*1024*1024};