Update and fix quickcheck fuzz test
This commit is contained in:
parent
33a1d5f4fb
commit
f7f0dfde51
@ -46,20 +46,23 @@ prop_fail_serializes() ->
|
|||||||
?FORALL(FateCode, fate_code(Failure),
|
?FORALL(FateCode, fate_code(Failure),
|
||||||
?FORALL(Binary, catch aeb_fate_code:serialize(FateCode),
|
?FORALL(Binary, catch aeb_fate_code:serialize(FateCode),
|
||||||
is_binary(Binary))))
|
is_binary(Binary))))
|
||||||
=/= true} || Failure <- [1,2,3,4, 5] ]).
|
=/= true} || Failure <- [1, 2, 3, 4, 5] ]).
|
||||||
|
|
||||||
prop_fuzz() ->
|
prop_fuzz() ->
|
||||||
in_parallel(
|
in_parallel(
|
||||||
?FORALL(Binary, ?LET(FateCode, fate_code(0), aeb_fate_code:serialize(FateCode)),
|
?FORALL(Binary, ?LET(FateCode, fate_code(0), aeb_fate_code:serialize(FateCode)),
|
||||||
?FORALL(InjectedBin, injection(Binary),
|
?FORALL(FuzzedBin, fuzz(Binary),
|
||||||
try Org = aeb_fate_code:deserialize(InjectedBin),
|
try aeb_fate_code:deserialize(FuzzedBin) of
|
||||||
NewBin = aeb_fate_code:serialize(Org),
|
Code ->
|
||||||
NewOrg = (catch aeb_fate_code:deserialize(NewBin)),
|
?WHENFAIL(eqc:format("Code:\n ~p\n", [Code]),
|
||||||
?WHENFAIL(eqc:format("Deserialize ~p gives\n~p\nSerializes to ~p\n", [InjectedBin, Org, NewOrg]),
|
begin
|
||||||
equals(NewBin, InjectedBin))
|
Bin1 = aeb_fate_code:serialize(Code),
|
||||||
catch _:_ ->
|
Code1 = aeb_fate_code:deserialize(Bin1),
|
||||||
true
|
?WHENFAIL(eqc:format("Reserialized\n ~120p\n", [Bin1]),
|
||||||
end))).
|
equals(Code, Code1))
|
||||||
|
end)
|
||||||
|
catch _:_ -> true
|
||||||
|
end))).
|
||||||
|
|
||||||
prop_opcodes() ->
|
prop_opcodes() ->
|
||||||
?FORALL(Opcode, choose(0, 16#ff),
|
?FORALL(Opcode, choose(0, 16#ff),
|
||||||
@ -128,8 +131,8 @@ bblock(Failure, Ops) ->
|
|||||||
end
|
end
|
||||||
end || Op <- Ops ].
|
end || Op <- Ops ].
|
||||||
|
|
||||||
injection(Binary) ->
|
fuzz(Binary) ->
|
||||||
?LET({N, Inj}, {choose(0, byte_size(Binary) - 1), choose(0,255)},
|
?LET({N, Inj}, {choose(0, byte_size(Binary) - 1), choose(0, 255)},
|
||||||
begin
|
begin
|
||||||
M = N * 8,
|
M = N * 8,
|
||||||
<<X:M, _:8, Z/binary>> = Binary,
|
<<X:M, _:8, Z/binary>> = Binary,
|
||||||
|
@ -161,8 +161,8 @@ ops_defs() ->
|
|||||||
, { 'MAP_TO_LIST', 16#70, false, 3, [a,a], map_to_list, {map}, list, "Arg0 := The tuple list representation of the map Arg1."}
|
, { 'MAP_TO_LIST', 16#70, false, 3, [a,a], map_to_list, {map}, list, "Arg0 := The tuple list representation of the map Arg1."}
|
||||||
, { 'STR_LENGTH', 16#71, false, 3, [a,a], str_length, {string}, integer, "Arg0 := The length of the string Arg1."}
|
, { 'STR_LENGTH', 16#71, false, 3, [a,a], str_length, {string}, integer, "Arg0 := The length of the string Arg1."}
|
||||||
|
|
||||||
, { 'ECVERIFY', 16#72, false, 1300, [a,a,a,a], ecverify, {hash, address, signature}, boolean, "Arg0 := ecverify(Hash, PubKey, Signature)"}
|
, { 'ECVERIFY', 16#72, false, 1300, [a,a,a,a], ecverify, {bytes, address, bytes}, boolean, "Arg0 := ecverify(Hash, PubKey, Signature)"}
|
||||||
, { 'ECVERIFY_SECP256K1', 16#73, false, 1300, [a,a,a,a], ecverify_secp256k1, {hash, signature, signature}, boolean, "Arg0 := ecverify_secp256k1(Hash, PubKey, Signature)"}
|
, { 'ECVERIFY_SECP256K1', 16#73, false, 1300, [a,a,a,a], ecverify_secp256k1, {bytes, bytes, bytes}, boolean, "Arg0 := ecverify_secp256k1(Hash, PubKey, Signature)"}
|
||||||
|
|
||||||
, { 'CONTRACT_TO_ADDRESS', 16#74, false, 3, [a,a], contract_to_address, {contract}, address, "Arg0 := Arg1 - A no-op type conversion"}
|
, { 'CONTRACT_TO_ADDRESS', 16#74, false, 3, [a,a], contract_to_address, {contract}, address, "Arg0 := Arg1 - A no-op type conversion"}
|
||||||
, { 'AUTH_TX_HASH', 16#75, false, 3, [a], auth_tx_hash, {}, variant, "If in GA authentication context return Some(TxHash) otherwise None."}
|
, { 'AUTH_TX_HASH', 16#75, false, 3, [a], auth_tx_hash, {}, variant, "If in GA authentication context return Some(TxHash) otherwise None."}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user