Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

api/bootloader: do not wait 5s after upgrade #92

Merged
merged 1 commit into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions api/bootloader/device.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"encoding/binary"
"io"
"math"
"time"

"github.com/digitalbitbox/bitbox02-api-go/api/common"
"github.com/digitalbitbox/bitbox02-api-go/util/errp"
Expand Down Expand Up @@ -62,7 +61,6 @@ type Status struct {
Progress float64 `json:"progress"`
UpgradeSuccessful bool `json:"upgradeSuccessful"`
ErrMsg string `json:"errMsg"`
RebootSeconds int `json:"rebootSeconds"`
}

func toByte(b bool) byte {
Expand All @@ -78,7 +76,6 @@ type Device struct {
product common.Product
status *Status
onStatusChanged func(*Status)
sleep func(time.Duration)
}

// NewDevice creates a new instance of Device.
Expand All @@ -93,7 +90,6 @@ func NewDevice(
product: product,
status: &Status{},
onStatusChanged: onStatusChanged,
sleep: time.Sleep,
}
}

Expand Down Expand Up @@ -301,11 +297,6 @@ func (device *Device) UpgradeFirmware(firmware []byte) error {
device.status.Progress = 0
device.status.UpgradeSuccessful = true
device.onStatusChanged(device.status)
for seconds := 5; seconds > 0; seconds-- {
device.status.RebootSeconds = seconds
device.onStatusChanged(device.status)
device.sleep(time.Second)
}
return device.Reboot()
}

Expand Down
21 changes: 0 additions & 21 deletions api/bootloader/device_export_test.go

This file was deleted.

14 changes: 1 addition & 13 deletions api/bootloader/device_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"fmt"
"io/ioutil"
"testing"
"time"

"github.com/digitalbitbox/bitbox02-api-go/api/bootloader"
"github.com/digitalbitbox/bitbox02-api-go/api/common"
Expand Down Expand Up @@ -259,16 +258,6 @@ func TestUpgradeFirmware(t *testing.T) {
return nil
}

const rebootSeconds = 5
sleepCalls := 0
env.device.TstSetSleep(func(d time.Duration) {
require.Equal(t, time.Second, d)
require.Less(t, sleepCalls, rebootSeconds)
require.True(t, currentStatus.UpgradeSuccessful)
require.Equal(t, rebootSeconds-sleepCalls, currentStatus.RebootSeconds)
sleepCalls++
})

require.Zero(t, *env.device.Status())
require.NoError(t, env.device.UpgradeFirmware(signedFirmware))

Expand Down Expand Up @@ -319,9 +308,8 @@ func TestUpgradeFirmware(t *testing.T) {
require.True(t, status.UpgradeSuccessful)

// reboot
msg, status = takeOne()
msg, _ = takeOne()
require.Equal(t, byte('r'), msg[0])
require.Equal(t, 1, status.RebootSeconds)
})
}

Expand Down
Loading