fix(train): only the firmware version the person agreed to is written (ADR 0030, D55)

Relayed by the instance, the version asked again before downloading was written even where it wasn't the one shown and agreed to, and the band recorded as at the agreed one. Another version now writes nothing and is offered instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
This commit is contained in:
Tizian 「ティツィアーン」 2026-10-30 12:55:42 +01:00
commit ac6cff179f
Signed by: raisondetredev
GPG key ID: 07F6FCF405488B64

View file

@ -583,6 +583,26 @@ void main() {
expect(File('${folder.path}/loop_firmware.zip').existsSync(), isFalse);
});
test('through the instance, another version than the one agreed to is '
'never written: it is offered instead', () async {
final relay = FakeFirmwareRelay()..version = '2.1.0';
final loop = await setUpBand(relay: relay);
loop.setFirmwareVia(FirmwareVia.instance);
await loop.checkFirmware();
relay.version = '2.2.0';
platform.calls.clear();
await expectLater(loop.updateFirmware(), throwsA(isA<LoopFailed>()));
expect(relay.downloaded, isEmpty);
expect(
platform.calls.where((c) => c.startsWith('updateFirmware')),
isEmpty,
);
expect(store().read()?.firmwareOffered, '2.2.0');
expect(store().read()?.firmware, isNot('2.2.0'));
});
test('a read failing leaves the band untouched', () async {
platform.firmwareOffered = '2.1.0';
final loop = await setUpBand();