1

I have cloned the Stellar Horizon Repo from GitHub written in Go. I thought to run the test cases first.where the test cases have been written by using GINKGO Testing Framework. I have been running the test cases using ginkgo command eg : ginkgo (package path name will be given here). This is how I run test cases. Test cases for particular package has been executing properly. But I am getting a panic in the first test file only. Which I debugged and found that the panic is occurring while running a command. Please find the below details for reference .

File name : action_accounts_test.go func name : TestAccountAction_Show() // Has been defined below

func TestAccountActions_Show(t *testing.T) {

    ht := StartHTTPTest(t, "allow_trust") **// This function is not returning anything. Its //getting panic inside this //** 
    defer ht.Finish()
    // existing account
    w := ht.Get(
        "/accounts/GCXKG6RN4ONIEPCMNFB732A436Z5PNDSRLGWK7GBLCMQLIFO4S7EYWVU",
    )

    if ht.Assert.Equal(200, w.Code) {
        var result horizon.Account
        err := json.Unmarshal(w.Body.Bytes(), &result)
        ht.Require.NoError(err)
        ht.Assert.Equal("8589934593", result.Sequence)

        ht.Assert.NotEqual(0, result.LastModifiedLedger)
        for _, balance := range result.Balances {
            if balance.Type == "native" {
                ht.Assert.Equal(uint32(0), balance.LastModifiedLedger)
            } else {
                ht.Assert.NotEqual(uint32(0), balance.LastModifiedLedger)
            }
        }
    }

    // missing account
    w = ht.Get("/accounts/GDBAPLDCAEJV6LSEDFEAUDAVFYSNFRUYZ4X75YYJJMMX5KFVUOHX46SQ")
    ht.Assert.Equal(404, w.Code)
}

I did a Debugging and found that its getting panic in the below func call which happens inside the above func StartHTTPTest()

scenarios.Load(StellarCoreDatabaseURL(), stellarCorePath)
scenarios.Load(DatabaseURL(), horizonPath)

Definition of the particular func

func Load(url string, path string) {

    log.Println("database url", url, "   Path : ", path)
    sql, err := Asset(path)
    log.Println("Print err:", err, "  sql :", sql)
    if err != nil {
        log.Panic(err)
    }

    reader := bytes.NewReader(sql)
    cmd := exec.Command("psql", url)
    cmd.Stdin = reader

    err = cmd.Run() **// Exactly here it return some error**
    log.Println("Print err", err)

    if err != nil { **// Since err is not nil .the statement will get executed .**
        **log.Panic(err)**
    }
}

The Error returned by cmd.Run() is exit status 2 I just printed the error and found this is the error exit status 2

What is the reason for the particular error?

0 Answers0