Skip to content

Commit

Permalink
use proper err response for emulator
Browse files Browse the repository at this point in the history
use ErrNoDeviceConnected as response when not emulator is available
ref fibercrypto#165
  • Loading branch information
Alvaro Denis committed Mar 3, 2020
1 parent 881dcc9 commit bb55119
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/integration/proxy/sequencer.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,11 @@ func (sq *Sequencer) handleInputInteraction(cf ActionConfirmFrom, msg wire.Messa

func (sq *Sequencer) handleFirstCommandResponse(cf ActionConfirmFrom, successMsgKind messages.MessageType, commandName string, err error, msg wire.Message) (wire.Message, error) {
if err != nil {
sq.log.WithError(err).Errorln(commandName + ": sending message failed")
if err == skywallet.ErrNoDeviceConnected {
sq.log.WithError(err).Infoln(commandName + ": sending message failed")
} else {
sq.log.WithError(err).Errorln(commandName + ": sending message failed")
}
return wire.Message{}, err
}
for msg.Kind != uint16(successMsgKind) && msg.Kind != uint16(messages.MessageType_MessageType_Failure) {
Expand Down
4 changes: 4 additions & 0 deletions src/skywallet/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"fmt"
"io"
"runtime"
"strings"
"sync"
"time"

Expand Down Expand Up @@ -207,6 +208,9 @@ func sendToDevice(dev usb.Device, chunks [][64]byte) (wire.Message, error) {

msg, err = wire.ReadFrom(dev)
if err != nil {
if strings.Contains(err.Error(), "read: connection refused") {
return wire.Message{}, ErrNoDeviceConnected
}
return wire.Message{}, err
}

Expand Down

0 comments on commit bb55119

Please sign in to comment.