diff --git a/test/Spec.hs b/test/Spec.hs index ef4649a9e713bd00f34c60fcfba19ef3f16cf455..746fb0a687dd65600aa777b12e8e76ddf6a929ec 100644 --- a/test/Spec.hs +++ b/test/Spec.hs @@ -4,6 +4,9 @@ import Test.Tasty (TestTree, defaultMain, testGroup) import System.IO (hSetEncoding, stderr, stdout, utf8) +import qualified Codec.FEC as FEC +import Control.Exception (evaluate) +import Control.Monad (void) import qualified SpecCHK import qualified SpecCrypto import qualified SpecMerkle @@ -39,6 +42,18 @@ main = do hSetEncoding stdout utf8 hSetEncoding stderr utf8 + -- fec <= 0.1.1 has a bug under multithreaded usage where concurrent + -- implicit initialization from different threads corrupts some of its + -- internal state. fec > 0.1.1 exposes an `initialize` function to allow + -- this to be avoided but for now we can just do any initialization prior + -- to multithreaded work to avoid this. + -- + -- Use evaluate to force evaluation at this position in the IO, otherwise + -- we have no idea when `FEC.fec ...` will actually cause initialization + -- of the underlying lib. Replace this with `FEC.initialize` when + -- possible. + void $ evaluate $ FEC.fec 2 3 + testVectors <- loadTestVectorData let testVectorsTree = either