Skip to content

Commit

Permalink
Update tests to new env behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
Shaptic committed Feb 27, 2025
1 parent aa24fe2 commit 69a7aba
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
2 changes: 1 addition & 1 deletion cmd/stellar-rpc/internal/methods/get_latest_ledger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (

const (
expectedLatestLedgerSequence uint32 = 960
expectedLatestLedgerProtocolVersion uint32 = 20
expectedLatestLedgerProtocolVersion uint32 = 21
expectedLatestLedgerHashBytes byte = 42
)

Expand Down
14 changes: 5 additions & 9 deletions cmd/stellar-rpc/internal/preflight/preflight_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,11 +349,7 @@ func getPreflightParameters(t testing.TB, dbConfig *preflightParametersDBConfig)
if dbConfig != nil {
entryReader := db.NewLedgerEntryReader(dbConfig.dbInstance)
var err error
if dbConfig.disableCache {
ledgerEntryReadTx, err = entryReader.NewTx(context.Background(), false)
} else {
ledgerEntryReadTx, err = entryReader.NewTx(context.Background(), true)
}
ledgerEntryReadTx, err = entryReader.NewTx(context.Background(), !dbConfig.disableCache)
require.NoError(t, err)
} else {
var err error
Expand Down Expand Up @@ -390,7 +386,7 @@ func getPreflightParameters(t testing.TB, dbConfig *preflightParametersDBConfig)
LedgerEntryReadTx: ledgerEntryReadTx,
BucketListSize: 200,
// TODO: test with multiple protocol versions
ProtocolVersion: 20,
ProtocolVersion: 22,
}
return params
}
Expand All @@ -403,7 +399,7 @@ func TestGetPreflight(t *testing.T) {
require.Empty(t, result.Error)
require.NoError(t, params.LedgerEntryReadTx.Done())

// using a restarted db with caching and
// using a restarted db with caching
getDB(t, true)
dbConfig := &preflightParametersDBConfig{
dbInstance: getDB(t, true),
Expand All @@ -419,13 +415,13 @@ func TestGetPreflight(t *testing.T) {

func TestGetPreflightDebug(t *testing.T) {
params := getPreflightParameters(t, nil)
// Cause an error
// Cause an error with a specific error code
params.OpBody.InvokeHostFunctionOp.HostFunction.InvokeContract.FunctionName = "bar"

resultWithDebug, err := GetPreflight(context.Background(), params)
require.NoError(t, err)
require.NotZero(t, resultWithDebug.Error)
require.Contains(t, resultWithDebug.Error, "Backtrace")
require.Contains(t, resultWithDebug.Error, "MissingValue")
require.Contains(t, resultWithDebug.Error, "Event log")
require.NotContains(t, resultWithDebug.Error, "DebugInfo not available")

Expand Down

0 comments on commit 69a7aba

Please sign in to comment.