Skip to content

Commit

Permalink
Merge pull request #5170 from stellar/pass_user_agent_in_ledger_backend
Browse files Browse the repository at this point in the history
ingest/ledgerbackend - Pass user agent in ledger backend
  • Loading branch information
chowbao committed Jan 18, 2024
2 parents ed7ae81 + a234e65 commit 77cb331
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
39 changes: 39 additions & 0 deletions historyarchive/archive_pool_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Copyright 2016 Stellar Development Foundation and contributors. Licensed
// under the Apache License, Version 2.0. See the COPYING file at the root
// of this distribution or at http://www.apache.org/licenses/LICENSE-2.0

package historyarchive

import (
"net/http"
"net/http/httptest"
"testing"

"github.com/stellar/go/support/storage"
"github.com/stretchr/testify/assert"
)

func TestConfiguresHttpUserAgentForArchivePool(t *testing.T) {
var userAgent string
var archiveURLs []string
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
userAgent = r.Header["User-Agent"][0]
w.WriteHeader(http.StatusOK)
}))
defer server.Close()
archiveURLs = append(archiveURLs, server.URL)

archiveOptions := ArchiveOptions{
ConnectOptions: storage.ConnectOptions{
UserAgent: "uatest",
},
}

archivePool, err := NewArchivePool(archiveURLs, archiveOptions)
assert.NoError(t, err)

ok, err := archivePool.BucketExists(EmptyXdrArrayHash())
assert.True(t, ok)
assert.NoError(t, err)
assert.Equal(t, userAgent, "uatest")
}
3 changes: 2 additions & 1 deletion ingest/ledgerbackend/captive_core_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@ func NewCaptive(config CaptiveCoreConfig) (*CaptiveStellarCore, error) {
NetworkPassphrase: config.NetworkPassphrase,
CheckpointFrequency: config.CheckpointFrequency,
ConnectOptions: storage.ConnectOptions{
Context: config.Context,
Context: config.Context,
UserAgent: config.UserAgent,
},
},
)
Expand Down

0 comments on commit 77cb331

Please sign in to comment.