diff --git a/bc.lua b/bc.lua index ef5c4f8fea7d..306cb119cd00 100644 --- a/bc.lua +++ b/bc.lua @@ -171,7 +171,7 @@ function BaseControl:finalize(waits, timeout) if timeout ~= nil then timeout_remaining = timeout - (computer.uptime() - tstart) if timeout_remaining <= 0 then - break + error("timeout") end end -- Wait until the next register arrives diff --git a/tests/timeout.lua b/tests/timeout.lua index 6fcd245466f1..d5167391ee3b 100644 --- a/tests/timeout.lua +++ b/tests/timeout.lua @@ -50,5 +50,7 @@ end function test_timeout_finalize() local bc1 = BaseControl:new() local addr1 = network.get_scene() - bc1:finalize({"to_final1"}, 0.1) + assert_error_match("timeout", function() + bc1:finalize({"to_final1"}, 0.1) + end) end