2020-02-07 22:15:37 +00:00
|
|
|
package tor
|
2020-02-06 00:42:32 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func getStatusCallback(progChan chan int) func(int, string) {
|
|
|
|
return func(prog int, status string) {
|
|
|
|
fmt.Printf("%v %v\n", prog, status)
|
|
|
|
progChan <- prog
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestTorProvider(t *testing.T) {
|
|
|
|
progChan := make(chan int)
|
2020-06-25 20:44:44 +00:00
|
|
|
acn, err := NewTorACNWithAuth(".", "", 9051, HashedPasswordAuthenticator{"examplehashedpassword"})
|
2020-02-06 00:42:32 +00:00
|
|
|
if err != nil {
|
|
|
|
t.Error(err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
acn.SetStatusCallback(getStatusCallback(progChan))
|
|
|
|
|
|
|
|
progress := 0
|
|
|
|
for progress < 100 {
|
|
|
|
progress = <-progChan
|
|
|
|
}
|
|
|
|
|
|
|
|
acn.Close()
|
|
|
|
}
|