@@ -166,6 +166,7 @@ private Q_SLOTS:
166166 void nodeInformationRowsExposeDiagnostics ();
167167 void initEmitsRequestedInitialize ();
168168 void initGuardBlocksSecondEmission ();
169+ void shutdownPollingStartsShutdownBeforeEmittingSignal ();
169170};
170171
171172void NodeModelTests::refreshMempoolInfoUpdatesProperties ()
@@ -1384,6 +1385,32 @@ void NodeModelTests::initGuardBlocksSecondEmission()
13841385 QCOMPARE (spy.count (), 1 );
13851386}
13861387
1388+ void NodeModelTests::shutdownPollingStartsShutdownBeforeEmittingSignal ()
1389+ {
1390+ NiceMock<MockNode> node;
1391+ MempoolState mempool;
1392+ InstallDefaultHandlers (node);
1393+ InstallMempoolGetters (node, mempool);
1394+ ON_CALL (node, shutdownRequested ()).WillByDefault (Return (true ));
1395+
1396+ NodeModel model{node};
1397+ WaitForInitialMempoolRefresh (mempool);
1398+
1399+ QSignalSpy shutdown_spy{&model, &NodeModel::requestedShutdown};
1400+ bool started_before_signal{false };
1401+ EXPECT_CALL (node, startShutdown ()).WillOnce (Invoke ([&] {
1402+ started_before_signal = shutdown_spy.count () == 0 ;
1403+ }));
1404+
1405+ model.startShutdownPolling ();
1406+
1407+ QTRY_COMPARE_WITH_TIMEOUT (shutdown_spy.count (), 1 , ASYNC_TIMEOUT_MS );
1408+ QVERIFY (started_before_signal);
1409+
1410+ model.requestShutdown ();
1411+ QCOMPARE (shutdown_spy.count (), 1 );
1412+ }
1413+
13871414#ifdef BITCOINQML_NO_TEST_MAIN
13881415BITCOINQML_REGISTER_QT_TEST (NodeModelTests)
13891416#else
0 commit comments