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