MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / BOOST_AUTO_TEST_CASE

Function BOOST_AUTO_TEST_CASE

src/test/validationinterface_tests.cpp:22–49  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

20};
21
22BOOST_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
51class TestInterface : public CValidationInterface
52{

Callers

nothing calls this directly

Calls 7

joinMethod · 0.80
BlockCheckedMethod · 0.45
CallMethod · 0.45
resetMethod · 0.45

Tested by

no test coverage detected