Skip to content

Commit

Permalink
uncommit half baked changes
Browse files Browse the repository at this point in the history
  • Loading branch information
karthikiyer56 committed Nov 25, 2024
1 parent 01b86b0 commit e363afc
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 92 deletions.
77 changes: 0 additions & 77 deletions services/horizon/internal/integration/muxed_operations_test.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
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 @@ -138,74 +131,4 @@ 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)
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)
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: 8 additions & 11 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,10 +871,7 @@ func (i *Test) WaitForHorizonIngest() {

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

i.t.Logf("Horizon ingesting...")
//i.t.Logf(string(jcart))
i.t.Logf("Horizon ingesting... %v", root)
continue
}

Expand Down

0 comments on commit e363afc

Please sign in to comment.