Adding Tests for GetInfo

This commit is contained in:
Sarah Jamie Lewis 2022-01-13 13:43:27 -08:00
parent f82cf26731
commit 0c745e7691
2 changed files with 27 additions and 0 deletions

View File

@ -114,6 +114,10 @@ func (tp *torProvider) GetInfo(onion string) (map[string]string, error) {
}
}
if cirucitID == "" {
return nil, errors.New("could not find circuit")
}
var hops []string
for _, circuit := range circuits {
if circuit.Key == "circuit-status" {

View File

@ -43,6 +43,29 @@ func TestTorProvider(t *testing.T) {
t.Logf("progress: %v", progress)
}
// Test opening the OP Server
_, _, err = acn.Open("isbr2t6bflul2zyi6hjtnuezb2xvfr42svzjg2q3gyqfgg3wmnrbkkqd")
if err == nil {
info, err := acn.GetInfo("isbr2t6bflul2zyi6hjtnuezb2xvfr42svzjg2q3gyqfgg3wmnrbkkqd")
if err != nil {
t.Fatalf("could not find info for OP server %v", err)
}
cinfo, exists := info["circuit"]
if !exists {
t.Fatalf("could not find circuit info for OP server %v", err)
}
t.Logf("Found Cicurit Info %v", cinfo)
_, err = acn.GetInfo("not_a_real_onion")
if err == nil {
t.Fatalf("GetInfo for non existant onion should have errored")
}
} else {
t.Fatalf("could not connect to OP server %v", err)
}
// Should skip without blocking...
acn.Restart()
acn.Restart()