| 330 | |
| 331 | |
| 332 | TEST_F(ReplicaTest, Promise) |
| 333 | { |
| 334 | const string path = os::getcwd() + "/.log"; |
| 335 | initializer.flags.path = path; |
| 336 | ASSERT_SOME(initializer.execute()); |
| 337 | |
| 338 | Replica replica(path); |
| 339 | |
| 340 | PromiseRequest request; |
| 341 | request.set_proposal(2); |
| 342 | |
| 343 | Future<PromiseResponse> response = |
| 344 | protocol::promise(replica.pid(), request); |
| 345 | |
| 346 | AWAIT_READY(response); |
| 347 | |
| 348 | EXPECT_EQ(PromiseResponse::ACCEPT, response->type()); |
| 349 | EXPECT_TRUE(response->okay()); |
| 350 | EXPECT_EQ(2u, response->proposal()); |
| 351 | EXPECT_TRUE(response->has_position()); |
| 352 | EXPECT_EQ(0u, response->position()); |
| 353 | EXPECT_FALSE(response->has_action()); |
| 354 | |
| 355 | request.set_proposal(1); |
| 356 | |
| 357 | response = protocol::promise(replica.pid(), request); |
| 358 | |
| 359 | AWAIT_READY(response); |
| 360 | |
| 361 | EXPECT_EQ(PromiseResponse::REJECT, response->type()); |
| 362 | EXPECT_FALSE(response->okay()); |
| 363 | EXPECT_EQ(2u, response->proposal()); // Highest proposal seen so far. |
| 364 | EXPECT_FALSE(response->has_position()); |
| 365 | EXPECT_FALSE(response->has_action()); |
| 366 | |
| 367 | request.set_proposal(3); |
| 368 | |
| 369 | response = protocol::promise(replica.pid(), request); |
| 370 | |
| 371 | AWAIT_READY(response); |
| 372 | |
| 373 | EXPECT_EQ(PromiseResponse::ACCEPT, response->type()); |
| 374 | EXPECT_TRUE(response->okay()); |
| 375 | EXPECT_EQ(3u, response->proposal()); |
| 376 | EXPECT_TRUE(response->has_position()); |
| 377 | EXPECT_EQ(0u, response->position()); |
| 378 | EXPECT_FALSE(response->has_action()); |
| 379 | } |
| 380 | |
| 381 | |
| 382 | TEST_F(ReplicaTest, Append) |
nothing calls this directly
no test coverage detected