| 1 | package testsscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/tests`/ |
| 2 | |
| 3 | import ( |
| 4 | "contextscip-go gomod github.com/golang/go/src go1.15 context/" |
| 5 | "stringsscip-go gomod github.com/golang/go/src go1.15 strings/" |
| 6 | "testingscip-go gomod github.com/golang/go/src go1.15 testing/" |
| 7 | "timescip-go gomod github.com/golang/go/src go1.15 time/" |
| 8 | |
| 9 | "github.com/cretz/bine/controlscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/" |
| 10 | ) |
| 11 | |
| 12 | func TestHSFetchscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/tests`/TestHSFetch().(t *testingscip-go gomod github.com/golang/go/src go1.15 testing/.Tscip-go gomod github.com/golang/go/src go1.15 testing/T#) { |
| 13 | ctx := GlobalEnabledNetworkContextscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/tests`/GlobalEnabledNetworkContext().(t) |
| 14 | // Add listener |
| 15 | eventCh := make(chan controlscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/.Eventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Event#) |
| 16 | defer close(eventCh) |
| 17 | err := ctx.Controlscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/tor`/Tor#Control..AddEventListenerscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#AddEventListener().(eventCh, controlscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/.EventCodeHSDescContentscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeHSDescContent.) |
| 18 | ctx.Requirescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/tests`/TestContext#Require..NoErrorscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/require`/Assertions#NoError().(err) |
| 19 | defer ctx.Controlscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/tor`/Tor#Control..RemoveEventListenerscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#RemoveEventListener().(eventCh, controlscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/.EventCodeHSDescContentscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/EventCodeHSDescContent.) |
| 20 | // Lookup HS |
| 21 | err = ctx.Controlscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/tor`/Tor#Control..GetHiddenServiceDescriptorAsyncscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#GetHiddenServiceDescriptorAsync().("facebookcorewwwi", "") |
| 22 | ctx.Requirescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/tests`/TestContext#Require..NoErrorscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/require`/Assertions#NoError().(err) |
| 23 | // Grab events |
| 24 | eventCtx, eventCancel := contextscip-go gomod github.com/golang/go/src go1.15 context/.WithTimeoutscip-go gomod github.com/golang/go/src go1.15 context/WithTimeout().(ctx, 45*timescip-go gomod github.com/golang/go/src go1.15 time/.Secondscip-go gomod github.com/golang/go/src go1.15 time/Second.) |
| 25 | defer eventCancel() |
| 26 | errCh := make(chan error, 1) |
| 27 | go func() { errCh <- ctx.Controlscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/tor`/Tor#Control..HandleEventsscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/Conn#HandleEvents().(eventCtx) }() |
| 28 | select { |
| 29 | case <-eventCtx.Donescip-go gomod github.com/golang/go/src go1.15 context/Context#Done().(): |
| 30 | ctx.Requirescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/tests`/TestContext#Require..NoErrorscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/require`/Assertions#NoError().(eventCtx.Errscip-go gomod github.com/golang/go/src go1.15 context/Context#Err().()) |
| 31 | case err := <-errCh: |
| 32 | ctx.Requirescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/tests`/TestContext#Require..NoErrorscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/require`/Assertions#NoError().(err) |
| 33 | case event := <-eventCh: |
| 34 | hsEvent := event.(*controlscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/.HSDescContentEventscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/HSDescContentEvent#) |
| 35 | ctx.Requirescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/tests`/TestContext#Require..Equalscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/require`/Assertions#Equal().("facebookcorewwwi", hsEvent.Addressscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/HSDescContentEvent#Address.) |
| 36 | ctx.Requirescip-go gomod github.com/cretz/bine . `github.com/cretz/bine/tests`/TestContext#Require..Truescip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/require`/Assertions#True().(stringsscip-go gomod github.com/golang/go/src go1.15 strings/.HasPrefixscip-go gomod github.com/golang/go/src go1.15 strings/HasPrefix().(hsEvent.Descriptorscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/HSDescContentEvent#Descriptor., "rendezvous-service-descriptor "+hsEvent.DescIDscip-go gomod github.com/cretz/bine . `github.com/cretz/bine/control`/HSDescContentEvent#DescID.)) |
| 37 | } |
| 38 | } |