Skip to content

Commit 178f62b

Browse files
committed
Address comments
1 parent 2ac3f3f commit 178f62b

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

internal/scti/handlers_test.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ func (f *fixedTimeSource) Now() time.Time {
8989
}
9090

9191
// setupTestLog creates a test TesseraCT log using a POSIX backend.
92+
//
93+
// It returns the log and the path to the storage directory.
9294
func setupTestLog(t *testing.T) (*log, string) {
9395
t.Helper()
9496
storageDir := t.TempDir()
@@ -109,7 +111,7 @@ func setupTestLog(t *testing.T) (*log, string) {
109111
rejectUnexpired: false,
110112
}
111113

112-
log, err := NewLog(t.Context(), origin, signer, cvOpts, newPosixStorageFunc(t, storageDir), newFixedTimeSource(fakeTime))
114+
log, err := NewLog(t.Context(), origin, signer, cvOpts, newPOSIXStorageFunc(t, storageDir), newFixedTimeSource(fakeTime))
113115
if err != nil {
114116
t.Fatalf("newLog(): %v", err)
115117
}
@@ -130,13 +132,13 @@ func setupTestServer(t *testing.T, log *log, path string) *httptest.Server {
130132
return httptest.NewServer(handler)
131133
}
132134

133-
// newPosixStorageFunc returns a function to create a new storage.CTStorage instance with:
135+
// newPOSIXStorageFunc returns a function to create a new storage.CTStorage instance with:
134136
// - a POSIX Tessera storage driver
135137
// - a POSIX issuer storage system
136138
// - a BBolt deduplication database
137139
//
138140
// It also prepares directories to host the log and the deduplication database.
139-
func newPosixStorageFunc(t *testing.T, root string) storage.CreateStorage {
141+
func newPOSIXStorageFunc(t *testing.T, root string) storage.CreateStorage {
140142
t.Helper()
141143

142144
return func(ctx context.Context, signer note.Signer) (*storage.CTStorage, error) {
@@ -317,15 +319,15 @@ func parseChain(t *testing.T, isPrecert bool, pemChain []string, root *x509.Cert
317319
pool := loadCertsIntoPoolOrDie(t, pemChain)
318320
leafChain := pool.RawCertificates()
319321
if !leafChain[len(leafChain)-1].Equal(root) {
320-
// The submitted chain may not include a root, but the generated LogLeaf will
322+
// The submitted chain may not include a root, but the generated LogLeaf will.
321323
fullChain := make([]*x509.Certificate, len(leafChain)+1)
322324
copy(fullChain, leafChain)
323325
fullChain[len(leafChain)] = root
324326
leafChain = fullChain
325327
}
326328
entry, err := entryFromChain(leafChain, isPrecert, fakeTimeMillis)
327329
if err != nil {
328-
t.Fatalf("failed to create entry")
330+
t.Fatalf("Failed to create entry")
329331
}
330332

331333
return entry, leafChain
@@ -534,7 +536,7 @@ func TestAddChain(t *testing.T) {
534536
}
535537

536538
// Check that the leaf bundle contains the expected leaf.
537-
bPath := path.Join(dir, logDir, "tile/data", layout.NWithSuffix(0, test.wantLogSize/256, uint8(test.wantLogSize)))
539+
bPath := path.Join(dir, logDir, "tile/data", layout.NWithSuffix(0, test.wantLogSize/layout.EntryBundleWidth, uint8(test.wantLogSize)))
538540
bundle, err := os.ReadFile(bPath)
539541
if err != nil {
540542
t.Errorf("Failed to read leaf bundle at %q: %v", bPath, err)
@@ -660,7 +662,7 @@ func TestAddPreChain(t *testing.T) {
660662
}
661663

662664
// Check that the leaf bundle contains the expected leaf.
663-
bPath := path.Join(dir, logDir, "tile/data", layout.NWithSuffix(0, test.wantLogSize/256, uint8(test.wantLogSize)))
665+
bPath := path.Join(dir, logDir, "tile/data", layout.NWithSuffix(0, test.wantLogSize/layout.EntryBundleWidth, uint8(test.wantLogSize)))
664666
bundle, err := os.ReadFile(bPath)
665667
if err != nil {
666668
t.Errorf("Failed to read leaf bundle at %q: %v", bPath, err)

0 commit comments

Comments
 (0)