Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tamirms committed Dec 24, 2024
1 parent e32727f commit 6ad52b5
Show file tree
Hide file tree
Showing 14 changed files with 230 additions and 296 deletions.
19 changes: 0 additions & 19 deletions services/horizon/docker/captive-core-integration-tests.cfg

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

29 changes: 16 additions & 13 deletions services/horizon/docker/docker-compose.integration-tests.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,11 @@
version: '3'
services:
core-postgres:
image: postgres:9.6.17-alpine
restart: on-failure
environment:
- POSTGRES_PASSWORD=mysecretpassword
- POSTGRES_DB=stellar
ports:
- "5641:5641"
command: ["-p", "5641"]
core:
platform: linux/amd64
# Note: Please keep the image pinned to an immutable tag matching the Captive Core version.
# This avoid implicit updates which break compatibility between
# the Core container and captive core.
image: ${CORE_IMAGE:-stellar/stellar-core:19.13.1-1481.3acf6dd26.focal}

depends_on:
- core-postgres
restart: on-failure
environment:
- TRACY_NO_INVARIANT_CHECK=1
Expand All @@ -29,5 +17,20 @@ services:
entrypoint: /usr/bin/env
command: /start standalone
volumes:
- ./${CORE_CONFIG_FILE:-stellar-core-integration-tests.cfg}:/stellar-core.cfg
- ${CORE_CONFIG_FILE:-stellar-core.cfg}:/stellar-core.cfg
- ./core-start.sh:/start
soroban-rpc:
platform: linux/amd64
image: ${SOROBAN_RPC_IMAGE:-stellar/soroban-rpc}
restart: on-failure
ports:
- "8080:8080"
environment:
- ENDPOINT=:8080
- NETWORK_PASSPHRASE=Standalone Network ; February 2017
- CAPTIVE_CORE_CONFIG_PATH=/captive-core.cfg
- HISTORY_ARCHIVE_URLS=http://core:1570
- CHECKPOINT_FREQUENCY=8
- LOG_LEVEL=debug
volumes:
- ${CAPTIVE_CORE_CONFIG_FILE:-stellar-core.cfg}:/captive-core.cfg
25 changes: 0 additions & 25 deletions services/horizon/docker/stellar-core-classic-integration-tests.cfg

This file was deleted.

30 changes: 0 additions & 30 deletions services/horizon/docker/stellar-core-integration-tests.cfg

This file was deleted.

10 changes: 0 additions & 10 deletions services/horizon/internal/integration/db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -531,11 +531,6 @@ func TestReingestDB(t *testing.T) {
// subprocesses to conflict.
itest.StopHorizon()

horizonConfig.CaptiveCoreConfigPath = filepath.Join(
filepath.Dir(horizonConfig.CaptiveCoreConfigPath),
"captive-core-reingest-range-integration-tests.cfg",
)

var rootCmd = horizoncmd.NewRootCmd()
rootCmd.SetArgs(command(t, horizonConfig, "db",
"reingest",
Expand Down Expand Up @@ -909,11 +904,6 @@ func TestFillGaps(t *testing.T) {
_, err = historyQ.DeleteRangeAll(context.Background(), oldestLedger, latestLedger)
tt.NoError(err)

horizonConfig.CaptiveCoreConfigPath = filepath.Join(
filepath.Dir(horizonConfig.CaptiveCoreConfigPath),
"captive-core-reingest-range-integration-tests.cfg",
)

rootCmd := horizoncmd.NewRootCmd()
rootCmd.SetArgs(command(t, horizonConfig, "db", "fill-gaps", "--parallel-workers=1"))
tt.NoError(rootCmd.Execute())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ func TestExtendFootprintTtl(t *testing.T) {

itest := integration.NewTest(t, integration.Config{
EnableSorobanRPC: true,
QuickExpiration: true,
})

// establish which account will be contract owner, and load it's current seq
Expand Down
4 changes: 2 additions & 2 deletions services/horizon/internal/integration/load_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ type sorobanTransaction struct {

func TestLoad(t *testing.T) {
var transactionsPerLedger, ledgers int
flag.IntVar(&transactionsPerLedger, "transactions-per-ledger", 4000, "number of transactions per ledger")
flag.IntVar(&ledgers, "ledgers", 10, "number of ledgers to generate")
flag.IntVar(&transactionsPerLedger, "transactions-per-ledger", 100, "number of transactions per ledger")
flag.IntVar(&ledgers, "ledgers", 2, "number of ledgers to generate")
flag.Parse()

itest := integration.NewTest(t, integration.Config{
Expand Down
53 changes: 3 additions & 50 deletions services/horizon/internal/integration/parameters_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,6 @@ import (
"github.com/stretchr/testify/assert"
)

var defaultCaptiveCoreParameters = map[string]string{
horizon.StellarCoreBinaryPathName: os.Getenv("CAPTIVE_CORE_BIN"),
horizon.StellarCoreURLFlagName: "",
}

var networkParamArgs = map[string]string{
horizon.CaptiveCoreConfigPathName: "",
horizon.CaptiveCoreHTTPPortFlagName: "",
Expand All @@ -41,29 +36,6 @@ var networkParamArgs = map[string]string{
horizon.NetworkPassphraseFlagName: "",
}

var (
CaptiveCoreConfigErrMsg = "error generating captive core configuration: invalid config: "
)

// Ensures that BUCKET_DIR_PATH is not an allowed value for Captive Core.
func TestBucketDirDisallowed(t *testing.T) {
config := `BUCKET_DIR_PATH="/tmp"
` + integration.SimpleCaptiveCoreToml

confName, _, cleanup := integration.CreateCaptiveCoreConfig(config)
defer cleanup()
testConfig := integration.GetTestConfig()
testConfig.HorizonIngestParameters = map[string]string{
horizon.CaptiveCoreConfigPathName: confName,
horizon.StellarCoreBinaryPathName: os.Getenv("CAPTIVE_CORE_BIN"),
}
test := integration.NewTest(t, *testConfig)
err := test.StartHorizon(true)
assert.Equal(t, err.Error(), integration.HorizonInitErrStr+": error generating captive core configuration:"+
" invalid captive core toml file: could not unmarshal captive core toml: setting BUCKET_DIR_PATH is disallowed"+
" for Captive Core, use CAPTIVE_CORE_STORAGE_PATH instead")
}

func TestEnvironmentPreserved(t *testing.T) {
// Who tests the tests? This test.
//
Expand Down Expand Up @@ -234,28 +206,9 @@ func TestNetworkEnvironmentVariable(t *testing.T) {

// Ensures that the filesystem ends up in the correct state with Captive Core.
func TestCaptiveCoreConfigFilesystemState(t *testing.T) {
confName, storagePath, cleanup := integration.CreateCaptiveCoreConfig(integration.SimpleCaptiveCoreToml)
defer cleanup()

localParams := integration.MergeMaps(defaultCaptiveCoreParameters, map[string]string{
"captive-core-storage-path": storagePath,
horizon.CaptiveCoreConfigPathName: confName,
})
testConfig := integration.GetTestConfig()
testConfig.HorizonIngestParameters = localParams
test := integration.NewTest(t, *testConfig)

err := test.StartHorizon(true)
assert.NoError(t, err)
test.WaitForHorizonIngest()

t.Run("disk state", func(t *testing.T) {
validateCaptiveCoreDiskState(test, storagePath)
})

t.Run("no bucket dir", func(t *testing.T) {
validateNoBucketDirPath(test, storagePath)
})
test := integration.NewTest(t, integration.Config{})
validateCaptiveCoreDiskState(test, test.CaptiveCoreStoragePath())
validateNoBucketDirPath(test, test.CaptiveCoreStoragePath())
}

func TestMaxAssetsForPathRequests(t *testing.T) {
Expand Down
10 changes: 10 additions & 0 deletions services/horizon/internal/integration/sac_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ func TestContractMintToAccount(t *testing.T) {
itest := integration.NewTest(t, integration.Config{
HorizonEnvironment: map[string]string{"INGEST_DISABLE_STATE_VERIFICATION": "true", "CONNECTION_TIMEOUT": "360000"},
EnableSorobanRPC: true,
QuickExpiration: true,
})

issuer := itest.Master().Address()
Expand Down Expand Up @@ -145,6 +146,7 @@ func TestContractMintToContract(t *testing.T) {

itest := integration.NewTest(t, integration.Config{
EnableSorobanRPC: true,
QuickExpiration: true,
})

issuer := itest.Master().Address()
Expand Down Expand Up @@ -230,6 +232,7 @@ func TestExpirationAndRestoration(t *testing.T) {
// want state verification to detect this
"ingest-disable-state-verification": "true",
},
QuickExpiration: true,
})

issuer := itest.Master().Address()
Expand Down Expand Up @@ -502,6 +505,7 @@ func TestContractTransferBetweenAccounts(t *testing.T) {

itest := integration.NewTest(t, integration.Config{
EnableSorobanRPC: true,
QuickExpiration: true,
})

issuer := itest.Master().Address()
Expand Down Expand Up @@ -576,6 +580,7 @@ func TestContractTransferBetweenAccountAndContract(t *testing.T) {

itest := integration.NewTest(t, integration.Config{
EnableSorobanRPC: true,
QuickExpiration: true,
})

issuer := itest.Master().Address()
Expand Down Expand Up @@ -696,6 +701,7 @@ func TestContractTransferBetweenContracts(t *testing.T) {

itest := integration.NewTest(t, integration.Config{
EnableSorobanRPC: true,
QuickExpiration: true,
})

issuer := itest.Master().Address()
Expand Down Expand Up @@ -777,6 +783,7 @@ func TestContractBurnFromAccount(t *testing.T) {

itest := integration.NewTest(t, integration.Config{
EnableSorobanRPC: true,
QuickExpiration: true,
})

issuer := itest.Master().Address()
Expand Down Expand Up @@ -852,6 +859,7 @@ func TestContractBurnFromContract(t *testing.T) {

itest := integration.NewTest(t, integration.Config{
EnableSorobanRPC: true,
QuickExpiration: true,
})

issuer := itest.Master().Address()
Expand Down Expand Up @@ -919,6 +927,7 @@ func TestContractClawbackFromAccount(t *testing.T) {

itest := integration.NewTest(t, integration.Config{
EnableSorobanRPC: true,
QuickExpiration: true,
})

// Give the master account the revocable flag (needed to set the clawback flag)
Expand Down Expand Up @@ -996,6 +1005,7 @@ func TestContractClawbackFromContract(t *testing.T) {

itest := integration.NewTest(t, integration.Config{
EnableSorobanRPC: true,
QuickExpiration: true,
})

// Give the master account the revocable flag (needed to set the clawback flag)
Expand Down
Loading

0 comments on commit 6ad52b5

Please sign in to comment.