Using ip in connection

This commit is contained in:
Shorssaud 2023-02-23 16:20:15 +01:00
parent 84b262974a
commit f3ab6e9185
2 changed files with 9 additions and 7 deletions

3
go.sum
View File

@ -157,7 +157,6 @@ github.com/ettle/strcase v0.1.1/go.mod h1:hzDLsPC7/lwKyBOywSHEP89nt2pDgdy+No1NBA
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU=
github.com/fatih/color v1.10.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM=
github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w=
github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=
github.com/fatih/color v1.14.1 h1:qfhVLaG5s+nCROl1zJsZRxFeYrHLqWroPOQ8BWiNb4w=
github.com/fatih/color v1.14.1/go.mod h1:2oHN61fhTpgcxD3TSWCgKDiH1+x4OiDVVGH8WlgGZGg=
@ -458,7 +457,6 @@ github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVc
github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
github.com/mattn/go-colorable v0.1.11 h1:nQ+aFkoE2TMGc0b68U2OKSexC+eq46+XwZzWXHRmPYs=
github.com/mattn/go-colorable v0.1.11/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
@ -469,7 +467,6 @@ github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcME
github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE=
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
github.com/mattn/go-isatty v0.0.16 h1:bq3VjFmv/sOjHtdEhmkEV4x1AJtvUvOJ2PFAZ5+peKQ=
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng=
github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=

View File

@ -48,8 +48,9 @@ func TestDownload1(t *testing.T) {
runerr := &bytes.Buffer{}
_, err = node.StartProc(cluster.StartProcRequest{
Command: "./build/codex",
Args: []string{"--metrics", "--api-port=8090", "--data-dir=`pwd`/Codex1", "--disc-port=8070", "--log-level=TRACE"},
Args: []string{"--metrics", "--api-port=8090", "--data-dir=`pwd`/Codex1", "--disc-port=8070", "--log-level=TRACE", "-e=" + ip[:len(ip)-2]},
Stdout: stdout,
Stderr: stderr,
})
if err != nil {
@ -62,9 +63,13 @@ func TestDownload1(t *testing.T) {
if err != nil {
t.Error(Fatal("failed to get debug info: %s", err))
}
t.Error(Fatal("NOPE", stderr.String()))
temp := strings.Split(out, "\"spr\":")
if len(temp) < 2 {
t.Error(Fatal("failed to get spr: ", temp))
}
t.Log(Info("debug info: ", out))
t.Log(Info("debug info: ", temp[1][1:len(temp[1])-2]))
t.Log(Info("debug info: ", temp[1][1:len(temp[1])-1]))
spr = temp[1][1 : len(temp[1])-2]
node.SendFile("tests/dog1.txt", bytes.NewBuffer([]byte("hello my dog")))
proc, err := node.StartProc(cluster.StartProcRequest{
@ -91,7 +96,7 @@ func TestDownload1(t *testing.T) {
stderr := &bytes.Buffer{}
runout := &bytes.Buffer{}
runerr := &bytes.Buffer{}
_, err = node.StartProc(cluster.StartProcRequest{
_, err := node.StartProc(cluster.StartProcRequest{
Command: "./build/codex",
Args: []string{"--metrics", "--api-port=8091", "--data-dir=`pwd`/Codex1", "--disc-port=8071", "--log-level=TRACE", "--bootstrap-node=" + spr},
Stdout: stdout,
@ -108,7 +113,7 @@ func TestDownload1(t *testing.T) {
t.Log(Info("CID: " + cid))
proc, err := node.StartProc(cluster.StartProcRequest{
Command: "curl",
Args: []string{"-vvv", "http://" + addrs + ":8090/api/codex/v1/download/" + cid, "--output", "tests/dog2.txt"},
Args: []string{"-vvv", "http://" + ip + ":8090/api/codex/v1/download/" + cid, "--output", "tests/dog2.txt"},
Stdout: runout,
})
if err != nil {