| 20 | }; |
| 21 | |
| 22 | BOOST_AUTO_TEST_CASE(unregister_validation_interface_race) |
| 23 | { |
| 24 | std::atomic<bool> generate{true}; |
| 25 | |
| 26 | // Start thread to generate notifications |
| 27 | std::thread gen{[&] { |
| 28 | BlockValidationState state_dummy; |
| 29 | while (generate) { |
| 30 | m_node.validation_signals->BlockChecked(std::make_shared<const CBlock>(), state_dummy); |
| 31 | } |
| 32 | }}; |
| 33 | |
| 34 | // Start thread to consume notifications |
| 35 | std::thread sub{[&] { |
| 36 | // keep going for about 1 sec, which is 250k iterations |
| 37 | for (int i = 0; i < 250000; i++) { |
| 38 | auto sub = std::make_shared<TestSubscriberNoop>(); |
| 39 | m_node.validation_signals->RegisterSharedValidationInterface(sub); |
| 40 | m_node.validation_signals->UnregisterSharedValidationInterface(sub); |
| 41 | } |
| 42 | // tell the other thread we are done |
| 43 | generate = false; |
| 44 | }}; |
| 45 | |
| 46 | gen.join(); |
| 47 | sub.join(); |
| 48 | BOOST_CHECK(!generate); |
| 49 | } |
| 50 | |
| 51 | class TestInterface : public CValidationInterface |
| 52 | { |
nothing calls this directly
no test coverage detected