aboutsummaryrefslogtreecommitdiff
path: root/src/test/validationinterface_tests.cpp
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2020-04-27 10:35:32 -0400
committerMarcoFalke <falke.marco@gmail.com>2020-05-13 19:58:20 -0400
commit7777f2a4bb1f9d843bc50a4e35085cfbb2808780 (patch)
treea4bde70689d7d39b7e551d18ff62260265b8cde8 /src/test/validationinterface_tests.cpp
parentfa5ceb25fce2200edf6b8ebfa6d4f01ed6774b95 (diff)
miner: Avoid stack-use-after-return in validationinterface
This is achieved by switching to a shared_ptr. Also, switch the validationinterfaces in the tests to use shared_ptrs for the same reason.
Diffstat (limited to 'src/test/validationinterface_tests.cpp')
-rw-r--r--src/test/validationinterface_tests.cpp8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/test/validationinterface_tests.cpp b/src/test/validationinterface_tests.cpp
index 14f09ae905..d2fc20e625 100644
--- a/src/test/validationinterface_tests.cpp
+++ b/src/test/validationinterface_tests.cpp
@@ -12,7 +12,6 @@
BOOST_FIXTURE_TEST_SUITE(validationinterface_tests, TestingSetup)
-/**
struct TestSubscriberNoop final : public CValidationInterface {
void BlockChecked(const CBlock&, const BlockValidationState&) override {}
};
@@ -34,9 +33,9 @@ BOOST_AUTO_TEST_CASE(unregister_validation_interface_race)
std::thread sub{[&] {
// keep going for about 1 sec, which is 250k iterations
for (int i = 0; i < 250000; i++) {
- TestSubscriberNoop sub{};
- RegisterValidationInterface(&sub);
- UnregisterValidationInterface(&sub);
+ auto sub = std::make_shared<TestSubscriberNoop>();
+ RegisterSharedValidationInterface(sub);
+ UnregisterSharedValidationInterface(sub);
}
// tell the other thread we are done
generate = false;
@@ -46,7 +45,6 @@ BOOST_AUTO_TEST_CASE(unregister_validation_interface_race)
sub.join();
BOOST_CHECK(!generate);
}
-*/
class TestInterface : public CValidationInterface
{