Skip to content
Permalink
Browse files

Rename test data files and struct fields to be more informative. (#1296)

I'll follow up by adding more integration tests for batch verification.
  • Loading branch information...
jtoohill committed Jun 6, 2019
1 parent a0ed60a commit 6e02f542852f992e4ed5517368ac7ca51e6a8dbc
@@ -30,7 +30,7 @@ import (
// Test vectors in core/testdata are generated by running
// go generate ./core/testdata
func TestVerifyGetUserResponse(t *testing.T) {
directoryFile := "../testdata/directory.json"
directoryFile := "../testdata/directory_get_and_update.json"
f, err := os.Open(directoryFile)
if err != nil {
t.Fatalf("ReadFile(%v): %v", directoryFile, err)
@@ -45,7 +45,7 @@ func TestVerifyGetUserResponse(t *testing.T) {
t.Fatal(err)
}

respFile := "../testdata/getentryresponse.json"
respFile := "../testdata/get_and_update.json"
b, err := ioutil.ReadFile(respFile)
if err != nil {
t.Fatalf("ReadFile(%v): %v", respFile, err)
@@ -58,15 +58,15 @@ func TestVerifyGetUserResponse(t *testing.T) {
trusted := &types.LogRootV1{}
for _, tc := range getUserResponses {
t.Run(tc.Desc, func(t *testing.T) {
slr, smr, err := v.VerifyRevision(tc.Resp.Revision, *trusted)
slr, smr, err := v.VerifyRevision(tc.GetUserResp.Revision, *trusted)
if err != nil {
t.Errorf("VerifyRevision(): %v", err)
}
if err == nil && tc.TrustNewLog {
trusted = slr
}
if err := v.VerifyMapLeaf(directoryPB.DirectoryId, tc.UserID,
tc.Resp.Leaf, smr); err != nil {
tc.GetUserResp.Leaf, smr); err != nil {
t.Errorf("VerifyMapLeaf(): %v)", err)
}
})
@@ -187,7 +187,7 @@ func TestVRF(t *testing.T) {
// Test vectors in core/testdata are generated by running
// go generate ./core/testdata
func TestProofToHash(t *testing.T) {
directoryFile := "../../../testdata/directory.json"
directoryFile := "../../../testdata/directory_get_and_update.json"
f, err := os.Open(directoryFile)
if err != nil {
t.Fatalf("ReadFile(%v): %v", directoryFile, err)
@@ -202,7 +202,7 @@ func TestProofToHash(t *testing.T) {
t.Fatalf("NewVRFVerifier failure: %v", err)
}

respFile := "../../../testdata/getentryresponse.json"
respFile := "../../../testdata/get_and_update.json"
b, err := ioutil.ReadFile(respFile)
if err != nil {
t.Fatalf("ReadFile(%v): %v", respFile, err)
@@ -213,7 +213,7 @@ func TestProofToHash(t *testing.T) {
}
for _, tc := range getUserResponses {
t.Run(tc.Desc, func(t *testing.T) {
_, err := pk.ProofToHash([]byte(tc.UserID), tc.Resp.GetLeaf().GetVrfProof())
_, err := pk.ProofToHash([]byte(tc.UserID), tc.GetUserResp.GetLeaf().GetVrfProof())
if err != nil {
t.Errorf("ProofToHash(%v): %v)", tc.Desc, err)
}
@@ -56,11 +56,11 @@ type NamedTestFn struct {
// This is done so that tests can be run in different environments in a portable way.
var AllTests = []NamedTestFn{
// Client Tests
{Name: "TestEmptyGetAndUpdate", Fn: TestEmptyGetAndUpdate, DirectoryFilename: "directory.json", RespFilename: "getentryresponse.json"},
{Name: "TestEmptyGetAndUpdate", Fn: TestEmptyGetAndUpdate, DirectoryFilename: "directory_get_and_update.json", RespFilename: "get_and_update.json"},
{Name: "TestListHistory", Fn: TestListHistory},
{Name: "TestBatchUpdate", Fn: TestBatchUpdate},
{Name: "TestBatchCreate", Fn: TestBatchCreate},
{Name: "TestBatchListUserRevisions", Fn: TestBatchListUserRevisions, DirectoryFilename: "directory2.json", RespFilename: "batchlistuserrevisionsresponse.json"},
{Name: "TestBatchListUserRevisions", Fn: TestBatchListUserRevisions, DirectoryFilename: "directory_batch_list_user_revisions.json", RespFilename: "batch_list_user_revisions.json"},
// Monitor Tests
{Name: "TestMonitor", Fn: TestMonitor},
}
@@ -274,7 +274,7 @@ func TestEmptyGetAndUpdate(ctx context.Context, env *Env, t *testing.T) []testda
getUserResps = append(getUserResps, testdata.ResponseVector{
Desc: tc.desc,
UserID: tc.userID,
Resp: e,
GetUserResp: e,
TrustNewLog: trust,
})

Large diffs are not rendered by default.

@@ -1,7 +1,7 @@
{
"directoryId": "integration",
"log": {
"treeId": "4736944785207131422",
"treeId": "5314895645118655427",
"treeType": "PREORDERED_LOG",
"hashStrategy": "RFC6962_SHA256",
"hashAlgorithm": "SHA256",
@@ -11,7 +11,7 @@
}
},
"map": {
"treeId": "2220473335361489152",
"treeId": "4222090242075399064",
"treeType": "MAP",
"hashStrategy": "CONIKS_SHA256",
"hashAlgorithm": "SHA256",
@@ -1,7 +1,7 @@
{
"directoryId": "integration",
"log": {
"treeId": "8324052952552309078",
"treeId": "586935770141358621",
"treeType": "PREORDERED_LOG",
"hashStrategy": "RFC6962_SHA256",
"hashAlgorithm": "SHA256",
@@ -11,7 +11,7 @@
}
},
"map": {
"treeId": "7307496416806145175",
"treeId": "6833519785955711182",
"treeType": "MAP",
"hashStrategy": "CONIKS_SHA256",
"hashAlgorithm": "SHA256",

0 comments on commit 6e02f54

Please sign in to comment.
You can’t perform that action at this time.