Skip to content

Commit

Permalink
Address code review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
karthikiyer56 committed Dec 3, 2024
1 parent e4b3a67 commit c3fbe24
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
26 changes: 14 additions & 12 deletions services/horizon/internal/integration/change_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
8 changes: 4 additions & 4 deletions services/horizon/internal/test/integration/integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -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
Expand Down

0 comments on commit c3fbe24

Please sign in to comment.