Skip to content
This repository was archived by the owner on Oct 11, 2024. It is now read-only.

Commit 96723ec

Browse files
committed
update test
1 parent 6792d67 commit 96723ec

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

impl/monitor/monitor.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ package monitor
2121
import (
2222
"bytes"
2323
"errors"
24+
"fmt"
2425
"time"
2526

2627
"github.com/golang/glog"
@@ -37,7 +38,6 @@ import (
3738
mspb "github.com/google/keytransparency/impl/proto/monitor_v1_service"
3839
mupb "github.com/google/keytransparency/impl/proto/mutation_v1_service"
3940

40-
"fmt"
4141
"github.com/google/keytransparency/core/tree/sparse"
4242
)
4343

@@ -56,6 +56,9 @@ var (
5656
// ErrInvalidSignature occurs when the signature on the observed map root is
5757
// invalid.
5858
ErrInvalidSignature = errors.New("Recreated root does not match")
59+
// ErrNothingProcessed occurs when the monitor did not process any mutations /
60+
// smrs yet.
61+
ErrNothingProcessed = errors.New("did not process any mutations yet")
5962
)
6063

6164
// Server holds internal state for the monitor server.
@@ -105,7 +108,7 @@ func (s *Server) GetSignedMapRoot(ctx context.Context, in *ktpb.GetMonitoringReq
105108
if len(s.proccessedSMRs) > 0 {
106109
return s.proccessedSMRs[len(s.proccessedSMRs)-1], nil
107110
}
108-
return nil, errors.New("did not process any mutations yet")
111+
return nil, ErrNothingProcessed
109112
}
110113

111114
// GetSignedMapRootStream is a streaming API similar to GetSignedMapRoot.

impl/monitor/monitor_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import (
2828
func TestGetSignedMapRoot(t *testing.T) {
2929
srv := Server{}
3030
_, err := srv.GetSignedMapRoot(context.TODO(), nil)
31-
if got, want := grpc.Code(err), codes.OK; got != want {
31+
if got, want := err, ErrNothingProcessed; got != want {
3232
t.Errorf("GetSignedMapRoot(_, _): %v, want %v", got, want)
3333
}
3434
}

0 commit comments

Comments
 (0)