diff --git a/services/horizon/internal/integration/change_test.go b/services/horizon/internal/integration/change_test.go index e533408a06..bf2df266eb 100644 --- a/services/horizon/internal/integration/change_test.go +++ b/services/horizon/internal/integration/change_test.go @@ -147,11 +147,10 @@ func getChangesFromLedger(itest *integration.Test, ledger xdr.LedgerCloseMeta) [ func getLedgers(itest *integration.Test, startingLedger uint32, endLedger uint32) map[uint32]xdr.LedgerCloseMeta { t := itest.CurrentTest() - ccConfig, cleanupFn, err := itest.CreateCaptiveCoreConfig() + ccConfig, err := itest.CreateCaptiveCoreConfig() if err != nil { t.Fatalf("unable to create captive core config: %v", err) } - defer cleanupFn() captiveCore, err := ledgerbackend.NewCaptive(*ccConfig) if err != nil { @@ -200,17 +199,20 @@ func waitForLedgerInArchive(t *testing.T, waitTime time.Duration, ledgerSeq uint } var latestCheckpoint uint32 - var f = func() bool { - has, requestErr := archive.GetRootHAS() - if requestErr != nil { - t.Logf("Request to fetch checkpoint failed: %v", requestErr) - return false - } - latestCheckpoint = has.CurrentLedger - return latestCheckpoint >= ledgerSeq - } - assert.Eventually(t, f, waitTime, 1*time.Second) + assert.Eventually(t, + func() bool { + has, requestErr := archive.GetRootHAS() + if requestErr != nil { + t.Logf("Request to fetch checkpoint failed: %v", requestErr) + return false + } + latestCheckpoint = has.CurrentLedger + return latestCheckpoint >= ledgerSeq + + }, + waitTime, + 1*time.Second) } func getExactUpgradedLedgerSeq(ledgerMap map[uint32]xdr.LedgerCloseMeta, version uint32) uint32 { diff --git a/services/horizon/internal/test/integration/integration.go b/services/horizon/internal/test/integration/integration.go index 5d2b368afa..f90eece01f 100644 --- a/services/horizon/internal/test/integration/integration.go +++ b/services/horizon/internal/test/integration/integration.go @@ -614,9 +614,9 @@ func CreateCaptiveCoreConfig(contents string) (string, string, func()) { } } -func (i *Test) CreateCaptiveCoreConfig() (*ledgerbackend.CaptiveCoreConfig, func(), error) { - +func (i *Test) CreateCaptiveCoreConfig() (*ledgerbackend.CaptiveCoreConfig, error) { confName, storagePath, cleanupFn := CreateCaptiveCoreConfig(SimpleCaptiveCoreToml) + i.t.Cleanup(cleanupFn) i.t.Logf("Creating Captive Core config files, ConfName: %v, storagePath: %v", confName, storagePath) captiveCoreConfig := ledgerbackend.CaptiveCoreConfig{ @@ -636,11 +636,11 @@ func (i *Test) CreateCaptiveCoreConfig() (*ledgerbackend.CaptiveCoreConfig, func toml, err := ledgerbackend.NewCaptiveCoreTomlFromData([]byte(SimpleCaptiveCoreToml), tomlParams) if err != nil { - return nil, func() {}, err + return nil, err } captiveCoreConfig.Toml = toml - return &captiveCoreConfig, cleanupFn, nil + return &captiveCoreConfig, nil } const maxWaitForCoreStartup = 30 * time.Second