test/src/storage/trie/trie_storage/trie_storage_backend_test.cpp
TEST_F(TrieDbBackendTest, Batch) {
  auto batch_mock = std::make_unique<WriteBatchMock<Buffer, Buffer>>();
  EXPECT_CALL(*batch_mock,
              put_rvalue(Buffer{kNodePrefix}.put("abc"_buf), "123"_buf))
      .WillOnce(Return(outcome::success()));
  EXPECT_CALL(*batch_mock,
              put_rvalue(Buffer{kNodePrefix}.put("def"_buf), "123"_buf))
      .WillOnce(Return(outcome::success()));
  EXPECT_CALL(*batch_mock, remove(Buffer{kNodePrefix}.put("abc"_buf)))
      .WillOnce(Return(outcome::success()));
  EXPECT_CALL(*batch_mock, commit()).WillOnce(Return(outcome::success()));

  EXPECT_CALL(*storage, batch())
      .WillOnce(Return(testing::ByMove(std::move(batch_mock))));

  auto batch = backend.batch();
  EXPECT_OUTCOME_TRUE_1(batch->put("abc"_buf, "123"_buf));
  EXPECT_OUTCOME_TRUE_1(batch->put("def"_buf, "123"_buf));
  EXPECT_OUTCOME_TRUE_1(batch->remove("abc"_buf));
  EXPECT_OUTCOME_TRUE_1(batch->commit());
}
/**
 * @given trie backend batch
 * @when perform operations on it
 * @then it delegates them to the underlying storage batch with added prefixes
 */
@given trie backend batch
@when perform operations on it
@then it delegates them to the underlying storage batch with added prefixes
@given trie backend batch @when perform operations on it @then it delegates them to the underlying storage batch with added prefixes
TEST_F(TrieDbBackendTest, Batch) {
  auto batch_mock = std::make_unique<WriteBatchMock<Buffer, Buffer>>();
  EXPECT_CALL(*batch_mock,
              put_rvalue(Buffer{kNodePrefix}.put("abc"_buf), "123"_buf))
      .WillOnce(Return(outcome::success()));
  EXPECT_CALL(*batch_mock,
              put_rvalue(Buffer{kNodePrefix}.put("def"_buf), "123"_buf))
      .WillOnce(Return(outcome::success()));
  EXPECT_CALL(*batch_mock, remove(Buffer{kNodePrefix}.put("abc"_buf)))
      .WillOnce(Return(outcome::success()));
  EXPECT_CALL(*batch_mock, commit()).WillOnce(Return(outcome::success()));
  EXPECT_CALL(*storage, batch())
      .WillOnce(Return(testing::ByMove(std::move(batch_mock))));
  auto batch = backend.batch();
  EXPECT_OUTCOME_TRUE_1(batch->put("abc"_buf, "123"_buf));
  EXPECT_OUTCOME_TRUE_1(batch->put("def"_buf, "123"_buf));
  EXPECT_OUTCOME_TRUE_1(batch->remove("abc"_buf));
  EXPECT_OUTCOME_TRUE_1(batch->commit());
}
TEST_F ( TrieDbBackendTest , Batch ) { auto batch_mock = std :: make_unique < WriteBatchMock < Buffer , Buffer > > ( ) ; EXPECT_CALL ( * batch_mock , put_rvalue ( Buffer { kNodePrefix } . put ( " " _buf ) , " " _buf ) ) . WillOnce ( Return ( outcome :: success ( ) ) ) ; EXPECT_CALL ( * batch_mock , put_rvalue ( Buffer { kNodePrefix } . put ( " " _buf ) , " " _buf ) ) . WillOnce ( Return ( outcome :: success ( ) ) ) ; EXPECT_CALL ( * batch_mock , remove ( Buffer { kNodePrefix } . put ( " " _buf ) ) ) . WillOnce ( Return ( outcome :: success ( ) ) ) ; EXPECT_CALL ( * batch_mock , commit ( ) ) . WillOnce ( Return ( outcome :: success ( ) ) ) ; EXPECT_CALL ( * storage , batch ( ) ) . WillOnce ( Return ( testing :: ByMove ( std :: move ( batch_mock ) ) ) ) ; auto batch = backend . batch ( ) ; EXPECT_OUTCOME_TRUE_1 ( batch -> put ( " " _buf , " " _buf ) ) ; EXPECT_OUTCOME_TRUE_1 ( batch -> put ( " " _buf , " " _buf ) ) ; EXPECT_OUTCOME_TRUE_1 ( batch -> remove ( " " _buf ) ) ; EXPECT_OUTCOME_TRUE_1 ( batch -> commit ( ) ) ; }
@given trie backend batch
 @when perform operations on it
 @then it delegates them to the underlying storage batch with added prefixes
@given trie backend batch @when perform operations on it @then it delegates them to the underlying storage batch with added prefixes