Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test Fix: Controller calls only valid when building a block #1442

Merged
merged 11 commits into from
Jul 24, 2023
Merged

Conversation

heifner
Copy link
Member

@heifner heifner commented Jul 21, 2023

When interacting with controller many calls including push_transaction & preactivate_feature require a pending block. Update test_utils.hpp used by test_read_only_trx.cpp to only interact with controller when it is building a block (has a pending block).

Included in this PR are try-catches around application exec() since it can throw and if the exceptions are not caught then the test terminates making it very difficult to find the actual issue with the test.

Resolves #1435

@heifner heifner added the OCI Work exclusive to OCI team label Jul 21, 2023
} );
fc::scoped_exit<std::function<void()>> on_except = [&](){
if (app_thread.joinable())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instread of having these two app_thread.join();, why not put line 102 to 176 in a block and rely on the scoped_exit to join the app_thread?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Comment on lines +105 to +106
if (trx_future.wait_for(std::chrono::seconds(5)) == std::future_status::timeout)
throw std::runtime_error("failed to execute trx: " + ptrx->get_transaction().actions.at(0).name.to_string() + " to account: " + account.to_string());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we posted on the app_thread a lambda containing references to local variables. And, upon a 5s timer, we can throw an exception and exit the stack frame holding these local variable. I Think it could be an issue if the app thread executes the lambda afterwards.
Maybe it would be better to make_shared the promise and pass a shared_ptr to it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Comment on lines 127 to 128
std::atomic<bool> feature_set = false;
// has to execute when pending block is not null
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, I think we should pass a shared_ptr to std::atomic<bool> to make sure the lambda doesn't reference a non-existing stack frame.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@heifner heifner requested a review from greg7mdp July 24, 2023 14:05
Comment on lines 78 to 79
std::shared_ptr<std::promise<transaction_trace_ptr>> trx_promise = std::make_shared<std::promise<transaction_trace_ptr>>();
std::future<transaction_trace_ptr> trx_future = trx_promise->get_future();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small detail, I think auto would be nice here (type is spelled out in the make_shared).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

}
feature_promise.set_value();
});
std::shared_ptr<std::atomic<bool>> feature_set = std::make_shared<std::atomic<bool>>(false);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same auto remark.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@@ -87,7 +87,7 @@ BOOST_AUTO_TEST_CASE(not_check_configs_if_no_read_only_threads) {
test_configs_common(specific_args, app_init_status::succeeded);
}

void test_trxs_common(std::vector<const char*>& specific_args, bool test_disable_tierup = false) {
void test_trxs_common(std::vector<const char*>& specific_args, bool test_disable_tierup = false) { try {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we already re-indent most of the function, maybe move the try to its own line.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OCI Work exclusive to OCI team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Test failure: plugin_test
3 participants