diff --git a/api/bootloader/device.go b/api/bootloader/device.go index 69d97ea..45ffb26 100644 --- a/api/bootloader/device.go +++ b/api/bootloader/device.go @@ -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" @@ -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 { @@ -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. @@ -93,7 +90,6 @@ func NewDevice( product: product, status: &Status{}, onStatusChanged: onStatusChanged, - sleep: time.Sleep, } } @@ -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() } diff --git a/api/bootloader/device_export_test.go b/api/bootloader/device_export_test.go deleted file mode 100644 index 01a4df4..0000000 --- a/api/bootloader/device_export_test.go +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2018-2019 Shift Cryptosecurity AG -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package bootloader - -import "time" - -func (device *Device) TstSetSleep(sleep func(time.Duration)) { - device.sleep = sleep -} diff --git a/api/bootloader/device_test.go b/api/bootloader/device_test.go index 40f3a04..bec0cec 100644 --- a/api/bootloader/device_test.go +++ b/api/bootloader/device_test.go @@ -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" @@ -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)) @@ -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) }) }