MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / runClockRewindCheck

Function runClockRewindCheck

app/src/Licensing/OfflineSelfTest.cpp:142–160  ·  view source on GitHub ↗

* @brief Confirms the monotonic floor pins now to a previously observed future time. */

Source from the content-addressed store, hash-verified

140 * @brief Confirms the monotonic floor pins now to a previously observed future time.
141 */
142[[nodiscard]] static int runClockRewindCheck()
143{
144 QSettings settings(QStringLiteral("SerialStudioSelfTest"), QStringLiteral("OfflineClock"));
145 settings.clear();
146
147 Licensing::SimpleCrypt crypt(0x0123456789abcdefULL);
148 crypt.setIntegrityProtectionMode(Licensing::SimpleCrypt::ProtectionHash);
149
150 const auto future = QDateTime::currentDateTime().addYears(5);
151 settings.beginGroup("licensing");
152 settings.setValue("lastSeen", crypt.encryptToString(future.toString(Qt::RFC2822Date)));
153 settings.endGroup();
154
155 const auto floored = Licensing::MonotonicClock::nowFloored(settings, crypt);
156 settings.clear();
157
158 return expect("clock floored to previously observed future (rewind blocked)",
159 floored >= future.addSecs(-60));
160}
161
162//--------------------------------------------------------------------------------------------------
163// Entry point

Callers 1

runOfflineSelfTestMethod · 0.85

Calls 4

expectFunction · 0.85
encryptToStringMethod · 0.80
clearMethod · 0.45

Tested by

no test coverage detected