import std/random import pkg/stew/results import ../leopard proc randomCRCPacket*(data: var openArray[byte]) = if data.len < 16: data[0] = rand(data.len).byte for i in 1.. 0: dropRandomIdx(dataBuf, dataLosses) if parityLosses > 0: dropRandomIdx(parityBuf, parityLosses) decoder.decode(dataBuf, parityBuf, recoveredBuf).tryGet() for i, d in dataBuf: if d.len <= 0: if not checkCRCPacket(recoveredBuf[i]): return err(("Check failed for packet " & $i).cstring) ok()