If by chance the call to crypto:rand_bytes generates a random bitstring that starts with a data types tag (in the example below a bitstring that starts with the map ?TAG has been generated) then the test will fail for the wrong reason. Use quickcheck, or some deterministic method to generate bytes that are invalid from the start.
riak_dt_map: invalid_binary_test...*failed*
in function riak_dt_map:'-invalid_binary_test/0-fun-0-'/0 (src/riak_dt_map.erl, line 955)
**error:{assertMatch_failed,[{module,riak_dt_map},
{line,955},
{expression,"from_binary ( << ( crypto : rand_bytes ( 187 ) ) / binary >> )"},
{pattern,"? INVALID_BINARY"},
{value,{error,unsupported_version,226}}]}
If by chance the call to
crypto:rand_bytes
generates a random bitstring that starts with a data types tag (in the example below a bitstring that starts with the map?TAG
has been generated) then the test will fail for the wrong reason. Use quickcheck, or some deterministic method to generate bytes that are invalid from the start.