Skip to content

Commit a6cce78

Browse files
committed
fix tests
1 parent 85d5e31 commit a6cce78

File tree

4 files changed

+67
-6
lines changed

4 files changed

+67
-6
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Generated file, do not edit
2+
BUCKETLIST_DB_INDEX_PAGE_SIZE_EXPONENT = 12
3+
DATABASE = "sqlite3://stellar.db"
4+
DEPRECATED_SQL_LEDGER_STATE = false
5+
FAILURE_SAFETY = -1
6+
HTTP_PORT = 11626
7+
LOG_FILE_PATH = ""
8+
NETWORK_PASSPHRASE = "Public Global Stellar Network ; September 2015"
9+
10+
[[HOME_DOMAINS]]
11+
HOME_DOMAIN = "testnet.stellar.org"
12+
QUALITY = "MEDIUM"
13+
14+
[[VALIDATORS]]
15+
ADDRESS = "localhost:123"
16+
HOME_DOMAIN = "testnet.stellar.org"
17+
NAME = "sdf_testnet_1"
18+
PUBLIC_KEY = "GDKXE2OZMJIPOSLNA6N6F2BVCI3O777I2OOC4BV7VOYUEHYX7RTRYA7Y"
19+
20+
[HISTORY.h0]
21+
get = "curl -sf http://localhost:1170/{0} -o {1}"

ingest/ledgerbackend/testdata/expected-in-mem-core.cfg

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# Generated file, do not edit
2-
BUCKETLIST_DB_MEMORY_FOR_CACHING = 0
32
DEPRECATED_SQL_LEDGER_STATE = true
43
FAILURE_SAFETY = -1
54
HTTP_PORT = 11626

ingest/ledgerbackend/toml.go

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,8 @@ type CaptiveCoreTomlParams struct {
359359
EnforceSorobanTransactionMetaExtV1 bool
360360
// Fast HTTP Query Server parameters
361361
HTTPQueryServerParams *HTTPQueryServerParams
362+
// CoreBuildVersionFn is a function that returns the build version of the stellar-core binary.
363+
CoreBuildVersionFn CoreBuildVersionFunc
362364
}
363365

364366
// NewCaptiveCoreTomlFromFile constructs a new CaptiveCoreToml instance by merging configuration
@@ -471,15 +473,20 @@ func (c coreVersion) greaterThanOrEqual(other coreVersion) bool {
471473
if c.major == 0 && c.minor == 0 {
472474
return false
473475
}
474-
return (c.major == other.major && c.minor >= other.minor) || (c.major > other.minor)
476+
return (c.major == other.major && c.minor >= other.minor) || (c.major > other.major)
475477
}
476478

477-
func (c *CaptiveCoreToml) checkCoreVersion(coreBinaryPath string) coreVersion {
478-
if coreBinaryPath == "" {
479+
func (c *CaptiveCoreToml) checkCoreVersion(params CaptiveCoreTomlParams) coreVersion {
480+
if params.CoreBinaryPath == "" {
479481
return coreVersion{}
480482
}
481483

482-
versionRaw, err := CoreBuildVersion(coreBinaryPath)
484+
getCoreVersion := params.CoreBuildVersionFn
485+
if getCoreVersion == nil {
486+
getCoreVersion = CoreBuildVersion
487+
}
488+
489+
versionRaw, err := getCoreVersion(params.CoreBinaryPath)
483490
if err != nil {
484491
return coreVersion{}
485492
}
@@ -575,7 +582,7 @@ func (c *CaptiveCoreToml) setDefaults(params CaptiveCoreTomlParams) {
575582
}
576583

577584
if !c.tree.Has("BUCKETLIST_DB_MEMORY_FOR_CACHING") &&
578-
c.checkCoreVersion(params.CoreBinaryPath).greaterThanOrEqual(minVersionForBucketlistCaching) {
585+
c.checkCoreVersion(params).greaterThanOrEqual(minVersionForBucketlistCaching) {
579586
// set BUCKETLIST_DB_MEMORY_FOR_CACHING to 0 to disable allocation of
580587
// memory for caching entries in BucketListDB.
581588
// If we do not set BUCKETLIST_DB_MEMORY_FOR_CACHING, core will apply

ingest/ledgerbackend/toml_test.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ func TestGenerateConfig(t *testing.T) {
243243
useDB bool
244244
enforceSorobanDiagnosticEvents bool
245245
enforceEmitMetaV1 bool
246+
coreVersion string
246247
}{
247248
{
248249
name: "offline config with no appendix",
@@ -253,6 +254,7 @@ func TestGenerateConfig(t *testing.T) {
253254
peerPort: newUint(12345),
254255
logPath: nil,
255256
useDB: true,
257+
coreVersion: "v22.2.0-124-ga50f3f919",
256258
},
257259
{
258260
name: "offline config with no peer port",
@@ -262,6 +264,7 @@ func TestGenerateConfig(t *testing.T) {
262264
httpPort: newUint(6789),
263265
peerPort: nil,
264266
logPath: newString("/var/stellar-core/test.log"),
267+
coreVersion: "v22.2.0-124-ga50f3f919",
265268
},
266269
{
267270
name: "online config with appendix",
@@ -271,6 +274,7 @@ func TestGenerateConfig(t *testing.T) {
271274
httpPort: newUint(6789),
272275
peerPort: newUint(12345),
273276
logPath: nil,
277+
coreVersion: "v22.2.0-124-ga50f3f919",
274278
},
275279
{
276280
name: "online config with unsupported field in appendix",
@@ -280,6 +284,7 @@ func TestGenerateConfig(t *testing.T) {
280284
httpPort: newUint(6789),
281285
peerPort: newUint(12345),
282286
logPath: nil,
287+
coreVersion: "v22.2.0-124-ga50f3f919",
283288
},
284289
{
285290
name: "online config with no peer port",
@@ -289,6 +294,7 @@ func TestGenerateConfig(t *testing.T) {
289294
httpPort: newUint(6789),
290295
peerPort: nil,
291296
logPath: newString("/var/stellar-core/test.log"),
297+
coreVersion: "v22.2.0-124-ga50f3f919",
292298
},
293299
{
294300
name: "online config with no http port",
@@ -298,6 +304,7 @@ func TestGenerateConfig(t *testing.T) {
298304
httpPort: nil,
299305
peerPort: newUint(12345),
300306
logPath: nil,
307+
coreVersion: "v22.2.0-124-ga50f3f919",
301308
},
302309
{
303310
name: "offline config with appendix",
@@ -307,6 +314,7 @@ func TestGenerateConfig(t *testing.T) {
307314
httpPort: newUint(6789),
308315
peerPort: newUint(12345),
309316
logPath: nil,
317+
coreVersion: "v22.2.0-124-ga50f3f919",
310318
},
311319
{
312320
name: "offline config with extra fields in appendix",
@@ -316,6 +324,7 @@ func TestGenerateConfig(t *testing.T) {
316324
httpPort: newUint(6789),
317325
peerPort: newUint(12345),
318326
logPath: nil,
327+
coreVersion: "v22.2.0-124-ga50f3f919",
319328
},
320329
{
321330
name: "offline config with enforce diagnostic events and metav1",
@@ -324,6 +333,7 @@ func TestGenerateConfig(t *testing.T) {
324333
logPath: nil,
325334
enforceSorobanDiagnosticEvents: true,
326335
enforceEmitMetaV1: true,
336+
coreVersion: "v22.2.0-124-ga50f3f919",
327337
},
328338
{
329339
name: "offline config disabling enforced diagnostic events and metav1",
@@ -333,6 +343,7 @@ func TestGenerateConfig(t *testing.T) {
333343
logPath: nil,
334344
enforceSorobanDiagnosticEvents: true,
335345
enforceEmitMetaV1: true,
346+
coreVersion: "v22.2.0-124-ga50f3f919",
336347
},
337348
{
338349
name: "online config with enforce diagnostic events and meta v1",
@@ -344,13 +355,15 @@ func TestGenerateConfig(t *testing.T) {
344355
logPath: nil,
345356
enforceSorobanDiagnosticEvents: true,
346357
enforceEmitMetaV1: true,
358+
coreVersion: "v22.2.0-124-ga50f3f919",
347359
},
348360
{
349361
name: "offline config with minimum persistent entry in appendix",
350362
mode: stellarCoreRunnerModeOnline,
351363
appendPath: filepath.Join("testdata", "appendix-with-minimum-persistent-entry.cfg"),
352364
expectedPath: filepath.Join("testdata", "expected-online-with-appendix-minimum-persistent-entry.cfg"),
353365
logPath: nil,
366+
coreVersion: "v22.2.0-124-ga50f3f919",
354367
},
355368
{
356369
name: "default BucketlistDB config",
@@ -359,6 +372,16 @@ func TestGenerateConfig(t *testing.T) {
359372
expectedPath: filepath.Join("testdata", "expected-default-bucketlistdb-core.cfg"),
360373
useDB: true,
361374
logPath: nil,
375+
coreVersion: "v23.0.0-127-jb50f3f919",
376+
},
377+
{
378+
name: "default BucketlistDB config with older version",
379+
mode: stellarCoreRunnerModeOnline,
380+
appendPath: filepath.Join("testdata", "sample-appendix.cfg"),
381+
expectedPath: filepath.Join("testdata", "expected-default-bucketlistdb-core-old-version.cfg"),
382+
useDB: true,
383+
logPath: nil,
384+
coreVersion: "v22.1.0-123-hb50f3f219",
362385
},
363386
{
364387
name: "BucketlistDB config in appendix",
@@ -367,6 +390,7 @@ func TestGenerateConfig(t *testing.T) {
367390
expectedPath: filepath.Join("testdata", "expected-bucketlistdb-core.cfg"),
368391
useDB: true,
369392
logPath: nil,
393+
coreVersion: "v22.2.0-124-ga50f3f919",
370394
},
371395
{
372396
name: "Query parameters in appendix",
@@ -375,6 +399,7 @@ func TestGenerateConfig(t *testing.T) {
375399
expectedPath: filepath.Join("testdata", "expected-query-params.cfg"),
376400
useDB: true,
377401
logPath: nil,
402+
coreVersion: "v22.2.0-124-ga50f3f919",
378403
},
379404
{
380405
name: "BUCKETLIST_DB_MEMORY_FOR_CACHING in appendix",
@@ -383,6 +408,7 @@ func TestGenerateConfig(t *testing.T) {
383408
expectedPath: filepath.Join("testdata", "expected-with-memory-for-bucketlist-caching.cfg"),
384409
useDB: true,
385410
logPath: nil,
411+
coreVersion: "v22.2.0-124-ga50f3f919",
386412
},
387413
} {
388414
t.Run(testCase.name, func(t *testing.T) {
@@ -398,6 +424,10 @@ func TestGenerateConfig(t *testing.T) {
398424
UseDB: testCase.useDB,
399425
EnforceSorobanDiagnosticEvents: testCase.enforceSorobanDiagnosticEvents,
400426
EnforceSorobanTransactionMetaExtV1: testCase.enforceEmitMetaV1,
427+
CoreBinaryPath: "stellar-core",
428+
CoreBuildVersionFn: func(string) (string, error) {
429+
return testCase.coreVersion, nil
430+
},
401431
}
402432
if testCase.appendPath != "" {
403433
captiveCoreToml, err = NewCaptiveCoreTomlFromFile(testCase.appendPath, params)
@@ -427,6 +457,10 @@ func TestGenerateCoreConfigInMemory(t *testing.T) {
427457
HistoryArchiveURLs: []string{"http://localhost:1170"},
428458
Strict: false,
429459
UseDB: false,
460+
CoreBinaryPath: "stellar-core",
461+
CoreBuildVersionFn: func(string) (string, error) {
462+
return "v21.9.0-124-ga50f3f919", nil
463+
},
430464
}
431465
captiveCoreToml, err = NewCaptiveCoreTomlFromFile(appendPath, params)
432466
assert.NoError(t, err)

0 commit comments

Comments
 (0)