Skip to content

Commit

Permalink
Fix captive core toml history entries
Browse files Browse the repository at this point in the history
  • Loading branch information
tamirms committed Jan 5, 2024
1 parent d1e4c7c commit c262b67
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ingest/ledgerbackend/toml.go
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ func (c *CaptiveCoreToml) setDefaults(params CaptiveCoreTomlParams) {
for i, val := range params.HistoryArchiveURLs {
name := fmt.Sprintf("HISTORY.h%d", i)
c.HistoryEntries[c.tablePlaceholders.newPlaceholder(name)] = History{
Get: fmt.Sprintf("curl -sf %s/{0} -o {1}", val),
Get: fmt.Sprintf("curl -sf %s/{0} -o {1}", strings.TrimSuffix(val, "/")),
}
}
}
Expand Down
22 changes: 22 additions & 0 deletions ingest/ledgerbackend/toml_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,28 @@ func TestGenerateConfig(t *testing.T) {
}
}

func TestHistoryArchiveURLTrailingSlash(t *testing.T) {
httpPort := uint(8000)
peerPort := uint(8000)
logPath := "logPath"

Check failure on line 401 in ingest/ledgerbackend/toml_test.go

View workflow job for this annotation

GitHub Actions / golangci

string `logPath` has 4 occurrences, make it a constant (goconst)

params := CaptiveCoreTomlParams{
NetworkPassphrase: "Public Global Stellar Network ; September 2015",
HistoryArchiveURLs: []string{"http://localhost:1170/"},
HTTPPort: &httpPort,
PeerPort: &peerPort,
LogPath: &logPath,
Strict: false,
}

captiveCoreToml, err := NewCaptiveCoreToml(params)
assert.NoError(t, err)
assert.Len(t, captiveCoreToml.HistoryEntries, 1)
for _, entry := range captiveCoreToml.HistoryEntries {
assert.Equal(t, "curl -sf http://localhost:1170/{0} -o {1}", entry.Get)
}
}

func TestExternalStorageConfigUsesDatabaseToml(t *testing.T) {
var err error
var captiveCoreToml *CaptiveCoreToml
Expand Down

0 comments on commit c262b67

Please sign in to comment.