Skip to content

Commit

Permalink
rename fields
Browse files Browse the repository at this point in the history
  • Loading branch information
karthikiyer56 committed Nov 25, 2024
1 parent 06c515c commit 01b86b0
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 19 deletions.
2 changes: 1 addition & 1 deletion ingest/change.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ type Change struct {
Reason LedgerEntryChangeReason
OperationIndex uint32
Transaction *LedgerTransaction
LEdger *xdr.LedgerCloseMeta
Ledger *xdr.LedgerCloseMeta
LedgerUpgrade *xdr.LedgerUpgrade
}

Expand Down
4 changes: 2 additions & 2 deletions ingest/ledger_change_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ func (r *LedgerChangeReader) Read() (Change, error) {
Pre: &entry,
Post: nil,
Reason: Eviction,
Lcm: &r.lcm,
Ledger: &r.lcm,
}
}
sortChanges(changes)
Expand All @@ -207,7 +207,7 @@ func (r *LedgerChangeReader) Read() (Change, error) {
ledgerUpgrades := r.LedgerTransactionReader.lcm.UpgradesProcessing()
for _, change := range changes {
change.Reason = Upgrade
change.Lcm = &r.lcm
change.Ledger = &r.lcm
change.LedgerUpgrade = &ledgerUpgrades[r.upgradeIndex].Upgrade
}
r.pending = append(r.pending, changes...)
Expand Down
77 changes: 77 additions & 0 deletions services/horizon/internal/integration/muxed_operations_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
package integration

import (
"context"
"fmt"
"github.com/stellar/go/ingest"
"github.com/stellar/go/ingest/ledgerbackend"
"io"
"os"
"testing"
"time"

"github.com/stellar/go/clients/horizonclient"
"github.com/stellar/go/keypair"
Expand Down Expand Up @@ -131,4 +138,74 @@ func TestMuxedOperations(t *testing.T) {
assert.True(t, oneSet, "at least one of account_muxed_id, seller_muxed_id must be set")
}
}

time.Sleep(time.Second * 5)

captiveCoreConfig := ledgerbackend.CaptiveCoreConfig{}
captiveCoreConfig.BinaryPath = os.Getenv("HORIZON_INTEGRATION_TESTS_CAPTIVE_CORE_BIN")
captiveCoreConfig.HistoryArchiveURLs = []string{itest.GetDefaultArgs()["history-archive-urls"]}
captiveCoreConfig.NetworkPassphrase = integration.StandaloneNetworkPassphrase
captiveCoreConfig.CheckpointFrequency = 8
confName, _, cleanup := CreateCaptiveCoreConfig(SimpleCaptiveCoreToml)
kk := ledgerbackend.CaptiveCoreTomlParams{
NetworkPassphrase: captiveCoreConfig.NetworkPassphrase,
HistoryArchiveURLs: captiveCoreConfig.HistoryArchiveURLs,
}

captiveCoreToml, _ := ledgerbackend.NewCaptiveCoreTomlFromFile(confName, kk)
captiveCoreConfig.Toml = captiveCoreToml
defer cleanup()

var captiveCore *ledgerbackend.CaptiveStellarCore
captiveCore, err = ledgerbackend.NewCaptive(captiveCoreConfig)
if err != nil {
t.Fatal(err)
}
cc := context.Background()
err = captiveCore.PrepareRange(cc, ledgerbackend.BoundedRange(uint32(txResp.Ledger), uint32(txResp.Ledger)))
defer captiveCore.Close()

if err != nil {
t.Fatal(err)
}

ll, _ := captiveCore.GetLedger(cc, uint32(txResp.Ledger))

var successfulTransactions, failedTransactions int
var operationsInSuccessful, operationsInFailed int

txReader, _ := ingest.NewLedgerTransactionReaderFromLedgerCloseMeta(
captiveCoreConfig.NetworkPassphrase, ll,
)
//panicIf(err)
defer txReader.Close()

// Read each transaction within the ledger, extract its operations, and
// accumulate the statistics we're interested in.
for {
ltx, err := txReader.Read()
if err == io.EOF {
break
}
//panicIf(err)

envelope := ltx.Envelope
operationCount := len(envelope.Operations())
if ltx.Result.Successful() {
successfulTransactions++
operationsInSuccessful += operationCount
} else {
failedTransactions++
operationsInFailed += operationCount
}
}

fmt.Println("\nDone. Results:")
fmt.Printf(" - total transactions: %d\n", successfulTransactions+failedTransactions)
fmt.Printf(" - succeeded / failed: %d / %d\n", successfulTransactions, failedTransactions)
fmt.Printf(" - total operations: %d\n", operationsInSuccessful+operationsInFailed)
fmt.Printf(" - succeeded / failed: %d / %d\n", operationsInSuccessful, operationsInFailed)

t.Logf("----------- This is %v, %v", ll.LedgerSequence(), ll.TransactionHash(0))

}
8 changes: 4 additions & 4 deletions services/horizon/internal/integration/parameters_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func TestBucketDirDisallowed(t *testing.T) {
config := `BUCKET_DIR_PATH="/tmp"
` + SimpleCaptiveCoreToml

confName, _, cleanup := createCaptiveCoreConfig(config)
confName, _, cleanup := CreateCaptiveCoreConfig(config)

Check failure on line 71 in services/horizon/internal/integration/parameters_test.go

View workflow job for this annotation

GitHub Actions / golangci

confName declared and not used (typecheck)
defer cleanup()
testConfig := integration.GetTestConfig()
testConfig.HorizonIngestParameters = map[string]string{
Expand Down Expand Up @@ -252,7 +252,7 @@ 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 := createCaptiveCoreConfig(SimpleCaptiveCoreToml)
confName, storagePath, cleanup := CreateCaptiveCoreConfig(SimpleCaptiveCoreToml)

Check failure on line 255 in services/horizon/internal/integration/parameters_test.go

View workflow job for this annotation

GitHub Actions / golangci

confName declared and not used (typecheck)
defer cleanup()

localParams := integration.MergeMaps(defaultCaptiveCoreParameters, map[string]string{
Expand Down Expand Up @@ -672,10 +672,10 @@ func validateCaptiveCoreDiskState(itest *integration.Test, rootDir string) {
tt.FileExists(coreConf)
}

// createCaptiveCoreConfig will create a temporary TOML config with the
// CreateCaptiveCoreConfig will create a temporary TOML config with the
// specified contents as well as a temporary storage directory. You should
// `defer` the returned function to clean these up when you're done.
func createCaptiveCoreConfig(contents string) (string, string, func()) {
func CreateCaptiveCoreConfig(contents string) (string, string, func()) {
tomlFile, err := ioutil.TempFile("", "captive-core-test-*.toml")
defer tomlFile.Close()
if err != nil {
Expand Down
19 changes: 11 additions & 8 deletions services/horizon/internal/test/integration/integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,8 +362,8 @@ func (i *Test) StartHorizon(startIngestProcess bool) error {

// To facilitate custom runs of Horizon, we merge a default set of
// parameters with the tester-supplied ones (if any).
mergedWebArgs := MergeMaps(i.getDefaultWebArgs(), i.config.HorizonWebParameters)
mergedIngestArgs := MergeMaps(i.getDefaultIngestArgs(), i.config.HorizonIngestParameters)
mergedWebArgs := MergeMaps(i.GetDefaultWebArgs(), i.config.HorizonWebParameters)
mergedIngestArgs := MergeMaps(i.GetDefaultIngestArgs(), i.config.HorizonIngestParameters)

// Set up Horizon clients
i.setupHorizonClient(mergedWebArgs)
Expand Down Expand Up @@ -431,7 +431,7 @@ func (i *Test) StartHorizon(startIngestProcess bool) error {
return nil
}

func (i *Test) getDefaultArgs() map[string]string {
func (i *Test) GetDefaultArgs() map[string]string {
// TODO: Ideally, we'd be pulling host/port information from the Docker
// Compose YAML file itself rather than hardcoding it.
return map[string]string{
Expand All @@ -449,12 +449,12 @@ func (i *Test) getDefaultArgs() map[string]string {
}
}

func (i *Test) getDefaultWebArgs() map[string]string {
return MergeMaps(i.getDefaultArgs(), map[string]string{"admin-port": "0"})
func (i *Test) GetDefaultWebArgs() map[string]string {
return MergeMaps(i.GetDefaultArgs(), map[string]string{"admin-port": "0"})
}

func (i *Test) getDefaultIngestArgs() map[string]string {
return MergeMaps(i.getDefaultArgs(), map[string]string{
func (i *Test) GetDefaultIngestArgs() map[string]string {
return MergeMaps(i.GetDefaultArgs(), map[string]string{
"admin-port": strconv.Itoa(i.AdminPort()),
"port": "8001",
"db-url": i.testDB.DSN,
Expand Down Expand Up @@ -871,7 +871,10 @@ func (i *Test) WaitForHorizonIngest() {

if root.HorizonSequence < 3 ||
int(root.HorizonSequence) != int(root.IngestSequence) {
i.t.Logf("Horizon ingesting... %v", root)
//jcart, _ := json.MarshalIndent(root, "", "\t")

i.t.Logf("Horizon ingesting...")
//i.t.Logf(string(jcart))
continue
}

Expand Down
4 changes: 0 additions & 4 deletions xdr/transaction_envelope.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,10 +215,6 @@ func (e TransactionEnvelope) Preconditions() Preconditions {
// Note for fee bump transactions, Operations() returns the operations
// of the inner transaction
func (e TransactionEnvelope) Operations() []Operation {
// This is not expected to happen.
if (e == TransactionEnvelope{}) {
return []Operation{}
}
switch e.Type {
case EnvelopeTypeEnvelopeTypeTxFeeBump:
return e.FeeBump.Tx.InnerTx.V1.Tx.Operations
Expand Down

0 comments on commit 01b86b0

Please sign in to comment.