Skip to content

Commit

Permalink
#8: make the test config params proper, per review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
sreuland committed Feb 12, 2024
1 parent 0600fe9 commit cdf9481
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
2 changes: 1 addition & 1 deletion cmd/soroban-rpc/internal/test/archive_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

func TestArchiveUserAgent(t *testing.T) {
userAgents := sync.Map{}
cfg := &Test{
cfg := &TestConfig{
historyArchiveProxyCallback: func(r *http.Request) {
userAgents.Store(r.Header["User-Agent"][0], "")
},
Expand Down
27 changes: 15 additions & 12 deletions cmd/soroban-rpc/internal/test/integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,22 @@ const (
StandaloneNetworkPassphrase = "Standalone Network ; February 2017"
stellarCoreProtocolVersion = 20
stellarCorePort = 11626
stellarCoreArchiveHost = "localhost:1570"
goModFile = "go.mod"
goMonorepoGithubPath = "github.com/stellar/go"
friendbotURL = "http://localhost:8000/friendbot"

friendbotURL = "http://localhost:8000/friendbot"
// Needed when Core is run with ARTIFICIALLY_ACCELERATE_TIME_FOR_TESTING=true
checkpointFrequency = 8
sorobanRPCPort = 8000
adminPort = 8080
helloWorldContractPath = "../../../../target/wasm32-unknown-unknown/test-wasms/test_hello_world.wasm"
)

type TestConfig struct {
historyArchiveProxyCallback func(*http.Request)
}

type Test struct {
t *testing.T

Expand All @@ -61,7 +67,7 @@ type Test struct {
shutdownCalls []func()
}

func NewTest(t *testing.T, i *Test) *Test {
func NewTest(t *testing.T, cfg *TestConfig) *Test {
if os.Getenv("SOROBAN_RPC_INTEGRATION_TESTS_ENABLED") == "" {
t.Skip("skipping integration test: SOROBAN_RPC_INTEGRATION_TESTS_ENABLED not set")
}
Expand All @@ -70,22 +76,19 @@ func NewTest(t *testing.T, i *Test) *Test {
t.Fatal("missing SOROBAN_RPC_INTEGRATION_TESTS_CAPTIVE_CORE_BIN")
}

if i == nil {
i = &Test{}
i := &Test{
t: t,
composePath: findDockerComposePath(),
}

i.t = t
i.composePath = findDockerComposePath()
i.masterAccount = &txnbuild.SimpleAccount{
AccountID: i.MasterKey().Address(),
Sequence: 0,
}

origin, err := url.Parse("http://localhost:1570")
if err != nil {
panic(err)
if cfg != nil {
i.historyArchiveProxyCallback = cfg.historyArchiveProxyCallback
}
proxy := httputil.NewSingleHostReverseProxy(origin)

proxy := httputil.NewSingleHostReverseProxy(&url.URL{Scheme: "http", Host: stellarCoreArchiveHost})

i.historyArchiveProxy = httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if i.historyArchiveProxyCallback != nil {
Expand Down

0 comments on commit cdf9481

Please sign in to comment.