Skip to content

Commit

Permalink
Add test for bad coordinator endpoint
Browse files Browse the repository at this point in the history
GitHub Issue mit-dci#131 identified a bug that made it impossible to trigger
the error "Failed to start coordinator client"
in sentinel_2pc::controller::init.  Since a previous commit fixed the bug,
the error can now be triggered.  This commit adds a unit test that
specifically triggers the error.

Signed-off-by: Michael L. Szulczewski <[email protected]>
  • Loading branch information
mszulcz-mitre committed Jun 19, 2022
1 parent 77288a8 commit a75ee1f
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/unit/sentinel_2pc/controller_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,3 +169,22 @@ TEST_F(sentinel_2pc_test, tx_validation_test) {
});
ASSERT_TRUE(res);
}

TEST_F(sentinel_2pc_test, bad_coordinator_endpoint) {
// Replace the valid coordinator endpoint defined in the fixture
// with an invalid endpoint.
m_opts.m_coordinator_endpoints.clear();
const auto bad_coordinator_ep
= std::make_pair("abcdefg", m_coordinator_port);
m_opts.m_coordinator_endpoints.resize(1);
m_opts.m_coordinator_endpoints[0].push_back(bad_coordinator_ep);

// Initialize a new controller with the invalid controller endpoint.
auto ctl = std::make_unique<cbdc::sentinel_2pc::controller>(0,
m_opts,
m_logger);

// Check that the controller with the invalid coordinator enpoint
// fails to initialize correctly.
ASSERT_FALSE(ctl->init());
}

0 comments on commit a75ee1f

Please sign in to comment.