headless test plan for firmware updates. add end-to-end test for getLatestFirmwareForDevice
Opened this issue · 1 comments
as reminder, this is fundamentally how to do a firmware update:
import getDeviceInfo from '@ledgerhq/live-common/lib/getDeviceInfo'
import manager from '@ledgerhq/live-common/lib/manager'
import prepare from '@ledgerhq/live-common/lib/hw/firmwareUpdate-prepare'
import main from '@ledgerhq/live-common/lib/hw/firmwareUpdate-main'
const deviceInfo = await withDevice('')(t => getDeviceInfo(t))
const firmware = await manager.getLatestFirmwareForDevice(deviceInfo)
if (!firmware) return "up to date"
concat(
prepare('', firmware),
main('', firmware)
).subscribe(e => console.log(e))
see that the key part here is getDeviceInfo
and getLatestFirmwareForDevice
.
For getDeviceInfo
, we already have tests on many versions and we've recently seen how it's important to have these tests & all versions covered.
For getLatestFirmwareForDevice
, we MUST have a end-to-end test. It involves Manager API calls (so it's mainly the backend team's scope) but it's still good to have this end-to-end test. What's cool is that it just takes deviceInfo
parameter, so it would be easy to do the same kind of tests but starting from chosen static deviceInfo object. We must do that on every major firmware version we have.
Now, concerning prepare
and main
, this is way trickier and not something we can actually test, it's more the scope of firmware team to test this part even tho it would be good to have a way to test this (but since a HSM secured channel is involved here, we can't do without a device).
in that context, what could be in fact mocked is the whole "socket session", we could have a split on mocking what createSocket is doing and emit mocked observable events.