From 302a01e28a3c05df27945012cbecc6a1daa91a13 Mon Sep 17 00:00:00 2001 From: jyyi1 Date: Tue, 6 Feb 2024 16:40:31 -0500 Subject: [PATCH] fix: cancel all outgoing requests when disconnect to prevent ANR --- Android/app/src/go/intra/doh/doh_test.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Android/app/src/go/intra/doh/doh_test.go b/Android/app/src/go/intra/doh/doh_test.go index 7ad0797a..05fc0aeb 100644 --- a/Android/app/src/go/intra/doh/doh_test.go +++ b/Android/app/src/go/intra/doh/doh_test.go @@ -19,7 +19,6 @@ import ( "encoding/binary" "errors" "io" - "io/ioutil" "net" "net/http" "net/http/httptrace" @@ -27,6 +26,7 @@ import ( "reflect" "testing" + "github.com/stretchr/testify/require" "golang.org/x/net/dns/dnsmessage" ) @@ -247,7 +247,7 @@ func TestRequest(t *testing.T) { if req.URL.String() != testURL { t.Errorf("URL mismatch: %s != %s", req.URL.String(), testURL) } - reqBody, err := ioutil.ReadAll(req.Body) + reqBody, err := io.ReadAll(req.Body) if err != nil { t.Error(err) } @@ -889,3 +889,9 @@ func TestServfail(t *testing.T) { t.Errorf("Wrong question: %v", servfail.Questions[0]) } } + +func TestQueryCanBeCancelled(t *testing.T) { + server, err := net.ListenTCP("tcp", &net.TCPAddr{IP: net.IPv4(127, 0, 0, 1)}) + require.NoError(t, err) + defer server.Close() +}