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

Allow log server to return consistency proofs where first=second #819

Merged
merged 4 commits into from
Sep 12, 2017

Conversation

Martin2112
Copy link
Contributor

@Martin2112 Martin2112 commented Sep 6, 2017

This is for additional compatiblity with the older C++ log server code. Needs a corresponding change to CTFE, which will follow:

google/certificate-transparency-go#74

This is for additional compatiblity with the older C++ log server code.
@codecov-io
Copy link

codecov-io commented Sep 7, 2017

Codecov Report

Merging #819 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #819   +/-   ##
=======================================
  Coverage   53.47%   53.47%           
=======================================
  Files           7        7           
  Lines         374      374           
=======================================
  Hits          200      200           
  Misses        156      156           
  Partials       18       18

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3cf59cd...4e5abde. Read the comment docs.

}
}

func TestGetConsistencyProof(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like a lot of these tests could be collapsed into a table-driven one which includes a wantError flag, no?
Perhaps that could be done in a follow-up, though.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it could be done but seemed out of scope for this change.

@@ -51,7 +51,7 @@ func validateGetConsistencyProofRequest(req *trillian.GetConsistencyProofRequest
if req.SecondTreeSize <= 0 {
return status.Errorf(codes.InvalidArgument, "GetConsistencyProofRequest.SecondTreeSize: %v, want > 0", req.SecondTreeSize)
}
if req.SecondTreeSize <= req.FirstTreeSize {
if req.SecondTreeSize < req.FirstTreeSize {
return status.Errorf(codes.InvalidArgument, "GetConsistencyProofRequest.FirstTreeSize: %v < GetConsistencyProofRequest.SecondTreeSize: %v, want > ", req.FirstTreeSize, req.SecondTreeSize)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

want >=

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@Martin2112
Copy link
Contributor Author

Finally got Travis to run. PTAL.

@Martin2112
Copy link
Contributor Author

@daviddrysdale can you take a quick look? I've got a followup in progress to address the test comment Al made.


response, err := server.GetConsistencyProof(context.Background(), &testCases[i])
if err != nil {
t.Fatalf("failed to get consistency proof: %v", err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

t.Errorf and continue so the loop continues
(OK to defer if you've got a follow-up PR that makes things more table-driven overall)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, upcoming PR moves the consistency proof tests into one table test.

testCases := []trillian.GetConsistencyProofRequest{getConsistencyProofRequest7, getConsistencyProofRequest44}
nodeIDs := [][]storage.NodeID{nodeIdsConsistencySize4ToSize7, {}}
hashes := [][][]byte{{[]byte("nodehash")}, {}}
nodes := [][]storage.Node{{{NodeID: stestonly.MustCreateNodeIDForTreeCoords(2, 1, 64), NodeRevision: 3, Hash: []byte("nodehash")}}, {}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to put all the per-test case info into a single struct:

vars tests = []struct {
  req trillian.GetConsistencyProofRequest
  nodeIDs []storage.NodeID
  hashes [][]byte
  nodes []storage.Node
}{
  {
    req: &getConsistencyProofRequest7,
    nodeIDs: nodeIdsConsistencySize4ToSize7,
    hashes: [][]byte{{[]byte("nodehash")},
    nodes: []storage.Node{{NodeID: stestonly.MustCreateNodeIDForTreeCoords(2, 1, 64), NodeRevision: 3, Hash: []byte("nodehash")}},
  },
  {
    req: &getConsistencyProofRequest44,
  },
}
for _, test := range tests {
   ...

(drop if this is coming in follow-up PR)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I've got this done but the branch is based off this one.

@Martin2112 Martin2112 merged commit a6546d0 into google:master Sep 12, 2017
@Martin2112 Martin2112 deleted the fix-consistency-range branch September 12, 2017 15:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants