From 5c2ee71c61fb9e3004003ca20b5884c8407bfa0c Mon Sep 17 00:00:00 2001 From: eldritch horrors Date: Mon, 28 Jul 2025 17:15:50 +0200 Subject: [PATCH] libstore: update exceptionAbortsDownload test the exception no longer actually matters, only that the download stream is destroyed before the download finishes does. exceptions during drain calls on the returned stream will cause the stream to be destroyed, but draining this stream is just a remnant of the old download-to-sink API. Change-Id: Ic6de40deb2ccff09d77180148afe746f29f55d23 --- tests/unit/libstore/filetransfer.cc | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/tests/unit/libstore/filetransfer.cc b/tests/unit/libstore/filetransfer.cc index b1e0b85c6..a1d584cd3 100644 --- a/tests/unit/libstore/filetransfer.cc +++ b/tests/unit/libstore/filetransfer.cc @@ -203,23 +203,16 @@ serveHTTP(std::string status, std::string headers, std::function return serveHTTP({{{status, headers, content}}}); } -TEST(FileTransfer, exceptionAbortsDownload) +TEST(FileTransfer, destructionAbortsDownload) { - struct Done : BaseException - {}; - AsyncIoRoot aio; auto ft = makeFileTransfer(); - LambdaSink broken([](auto block) { throw Done(); }); - auto [port, srv] = serveHTTP({{"200 ok", "", [](int) { return "foo"; }}}); - ASSERT_THROW( - aio.blockOn( - aio.blockOn(ft->download(fmt("http://[::1]:%d/index", port))).second->drainInto(broken) - ), - Done - ); + // discard the download stream. this must cancel the download, even when the + // remote still has data to send. we simulate this by sending the same block + // of data over and over without any content-length headers sent the client. + (void) aio.blockOn(ft->download(fmt("http://[::1]:%d/index", port))); // makeFileTransfer returns a ref<>, which cannot be cleared. since we also // can't default-construct it we'll have to overwrite it instead, but we'll