From bc4cc19df5f53519ca1aabd3cf161b6d78ffc16c Mon Sep 17 00:00:00 2001 From: cirakg Date: Tue, 27 Oct 2026 01:01:18 +0100 Subject: fix(pin): the work after a PIN and the change queue run in steps After a correct or new PIN, promoting pending entries and applying waiting "Require PIN" changes ran in the event of the last PBKDF2 step; 16 waiting changes tripped the watchdog on the Forerunner 70. ChangeQueue.LockJob now does it in steps while the PIN screen shows "Checking...", saves what it did to the results and refreshes the glance after Set PIN too. The list title decrypted every waiting change at each start. Queue items are now [action, box] (aad OTPW-Q-2 + action code), so they are counted without decrypting; 0.9.0 items are still read. A replacement is checked when it arrives and its material is sealed apart (qm.). Large buffers are wiped and UTF-8-checked in pieces (Jobs.Wiper, Bytes.utf8Prefix, SealedBox.openKeep/sealKeep). "Phone changes" reads behind "Reading...", and Confirm all / Reject all act only on the changes shown. Storage full no longer stops the app at the PIN. Found by the review of b8addc8/096b5a4 and a new make watchdog test; the diff was reviewed again and its findings fixed. fr70: make lint, make test (176), make watchdog (19 cases at two steps per event), make screenshots pass; list_locked and list_reset goldens show "Results ready (menu)". Co-Authored-By: Claude Opus 5.5 --- test/settings/ManageTest.mc | 39 ++++++++++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 9 deletions(-) (limited to 'test/settings/ManageTest.mc') diff --git a/test/settings/ManageTest.mc b/test/settings/ManageTest.mc index 1f050c5..4c93f60 100644 --- a/test/settings/ManageTest.mc +++ b/test/settings/ManageTest.mc @@ -1,6 +1,7 @@ // Author: cirakg & claude ai // Summary: Tests for the Manage entry form: every action on unlocked entries, the PIN queue for locked ones, IDs, repeats and damage. +import Toybox.Application; import Toybox.Lang; import Toybox.Test; @@ -43,9 +44,29 @@ module ManageFixtures { return s; } + // What PinView runs after a correct PIN: promotion and waiting locks. + function applyLocks(v as Vault) as LockJob { + var job = new LockJob(v, true); + Jobs.runToCompletion(job, 1); + return job; + } + + // Every queued item, opened (the ones that verify). + function load(v as Vault) as Array { + var items = ChangeQueue.items(v); + var out = [] as Array; + for (var i = 0; i < items.size(); i++) { + var a = ChangeQueue.open(v, items[i], new Jobs.Wiper(), true); + if (a != null) { + out.add(a); + } + } + return out; + } + // Confirm the waiting changes, as after a correct PIN. function confirm(v as Vault) as ChangeQueueJob { - var job = new ChangeQueueJob(v); + var job = new ChangeQueueJob(v, null); Jobs.runToCompletion(job, 1); return job; } @@ -256,7 +277,7 @@ function manageLocksEntries(logger as Test.Logger) as Boolean { } // Waiting "Require PIN" changes apply at the next PIN without "Confirm -// all" (the PIN screen calls applyLocks); other changes keep waiting, and +// all" (the PIN screen runs LockJob); other changes keep waiting, and // the results of a following "Confirm all" list the locks too. (:test) function manageQueuedLocksApplyAtNextPin(logger as Test.Logger) as Boolean { @@ -271,14 +292,14 @@ function manageQueuedLocksApplyAtNextPin(logger as Test.Logger) as Boolean { s = ManageFixtures.send(vault, ids[1], ManageAction.LOCK); SettingsFixtures.run(vault, s); var counted = ChangeQueue.count(vault) == 3 && ChangeQueue.countLocks(vault) == 2; - ChangeQueue.applyLocks(vault); // still locked: nothing happens + ManageFixtures.applyLocks(vault); // still locked: nothing happens var untouched = ChangeQueue.count(vault) == 3 && !ManageFixtures.isLocked(vault, ids[0]); StorageFixtures.unlock(vault, StorageFixtures.PIN); - ChangeQueue.applyLocks(vault); + var locks = ManageFixtures.applyLocks(vault); var left = ChangeQueue.descriptions(vault); var applied = ManageFixtures.isLocked(vault, ids[0]) && ManageFixtures.isLocked(vault, ids[1]) && left.size() == 1 && left[0].equals("Delete: " + bank + " Bank (alice@example.com)") - && ChangeQueue.countLocks(vault) == 0 && vault.ids().indexOf(bank) >= 0; + && ChangeQueue.countLocks(vault) == 0 && vault.ids().indexOf(bank) >= 0 && locks.lines.size() == 2; var job = ManageFixtures.confirm(vault); var reported = job.lines.size() == 3 && job.lines[0].find(ids[0] + " ") == 0 && job.lines[0].find("now requires the PIN") != null && SettingsFixtures.hasLine(job.lines, "Deleted " + bank); @@ -299,7 +320,7 @@ function manageQueueKeepsLateArrivals(logger as Test.Logger) as Boolean { var safe = ManageFixtures.addLocked(vault, "Safe"); var s = ManageFixtures.send(vault, bank, ManageAction.DELETE); SettingsFixtures.run(vault, s); - var job = new ChangeQueueJob(vault); + var job = new ChangeQueueJob(vault, null); job.step(1); s = ManageFixtures.send(vault, safe, ManageAction.DELETE); SettingsFixtures.run(vault, s); @@ -337,10 +358,10 @@ function manageQueueIsSealedAndLimited(logger as Test.Logger) as Boolean { b.id = "M3P9"; b.action = ManageAction.DELETE; ChangeQueue.add(vault, b); - var raw = (vault.storage() as MemoryBackend).raw(ChangeQueue.KEY) as Array; - var box = raw[0]; + var raw = (vault.storage() as MemoryBackend).raw(ChangeQueue.KEY) as Array>; + var box = raw[0][1] as ByteArray; box[20] = box[20] ^ 1; - var loaded = ChangeQueue.load(vault); + var loaded = ManageFixtures.load(vault); var sealed = loaded.size() == 1 && loaded[0].id.equals("M3P9") && loaded[0].action == ManageAction.DELETE; var roundTrip = ManageAction.fromBytes(a.toBytes()); var same = roundTrip != null && roundTrip.decoded && roundTrip.label.equals("Bank") -- cgit v1.2.3