diff --git a/pkg/messaging-discovery/client/http_message.go b/pkg/messaging-discovery/client/http_message.go index 39b2a0bd3f..6d50604a85 100644 --- a/pkg/messaging-discovery/client/http_message.go +++ b/pkg/messaging-discovery/client/http_message.go @@ -1,7 +1,6 @@ package client import ( - "errors" "fmt" "net/http" ) @@ -21,9 +20,3 @@ type HTTPMessage struct { func (h HTTPMessage) String() string { return fmt.Sprintf("status code: %d. message: %s", h.Code, h.Message) } - -// ToError returns an error representing the httpMessage for error comparisons, this is preferred for this type instead -// of implementing error -func (h HTTPMessage) ToError() error { - return errors.New(h.String()) -} diff --git a/pkg/messaging-discovery/client/testing.go b/pkg/messaging-discovery/client/testing.go index c0483d995b..5c4ca288e6 100644 --- a/pkg/messaging-discovery/client/testing.go +++ b/pkg/messaging-discovery/client/testing.go @@ -93,27 +93,26 @@ func (m *mockClient) UpdateEntry(ctx context.Context, sk cipher.SecKey, e *Entry for { err = m.SetEntry(ctx, e) + if err == nil { + return nil + } + if err != ErrValidationWrongSequence { + e.Sequence-- + return err + } + rE, entryErr := m.Entry(ctx, e.Static) + if entryErr != nil { + return err + } + if rE.Timestamp > e.Timestamp { // If there is a more up to date entry drop update + e.Sequence = rE.Sequence + return nil + } + e.Sequence = rE.Sequence + 1 + err := e.Sign(sk) if err != nil { - if err != ErrValidationWrongSequence { - e.Sequence-- - return err - } - rE, entryErr := m.Entry(ctx, e.Static) - if entryErr != nil { - return err - } - if rE.Timestamp > e.Timestamp { // If there is a more up to date entry drop update - e.Sequence = rE.Sequence - return nil - } - e.Sequence = rE.Sequence + 1 - err := e.Sign(sk) - if err != nil { - return err - } - continue + return err } - return nil } }