MCPcopy Create free account
hub / github.com/ElementsProject/elements / BOOST_AUTO_TEST_CASE

Function BOOST_AUTO_TEST_CASE

src/test/validationinterface_tests.cpp:19–47  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17};
18
19BOOST_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
49class TestInterface : public CValidationInterface
50{

Callers

nothing calls this directly

Calls 5

BlockCheckedMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected