Skip to content

Commit 4dd759a

Browse files
committed
fix: add assertions for RpcServer start() and fix buffer overflow
- raft_manager_tests: Add ASSERT_TRUE for RpcServer::start() in SetUp() - storage_manager_tests: Fix buffer overflow by using PAGE_SIZE instead of 512
1 parent 3e8117a commit 4dd759a

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

tests/raft_manager_tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class RaftManagerTests : public ::testing::Test {
3131
config_.cluster_port = TEST_PORT;
3232
cm_ = std::make_unique<ClusterManager>(&config_);
3333
rpc_ = std::make_unique<RpcServer>(TEST_PORT);
34-
rpc_->start();
34+
ASSERT_TRUE(rpc_->start()) << "RpcServer failed to start - port may be in use";
3535
manager_ = std::make_unique<RaftManager>("node1", *cm_, *rpc_);
3636
}
3737

tests/storage_manager_tests.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,8 @@ TEST_F(StorageManagerTests, PartialReadReturnsFalse) {
110110
ASSERT_TRUE(sm_->open_file(filename));
111111

112112
// Write a small amount of data
113-
char write_buf[512];
114-
std::memset(write_buf, 0xAB, 512);
113+
char write_buf[StorageManager::PAGE_SIZE];
114+
std::memset(write_buf, 0xAB, StorageManager::PAGE_SIZE);
115115
ASSERT_TRUE(sm_->write_page(filename, 0, write_buf));
116116

117117
// Try to read the small write as a full page should succeed (EOF handling fills zeros)

0 commit comments

Comments
 (0)