diff --git a/lib/spec/runners/ssz_generic.ex b/lib/spec/runners/ssz_generic.ex index da0963341..28cb8a00b 100644 --- a/lib/spec/runners/ssz_generic.ex +++ b/lib/spec/runners/ssz_generic.ex @@ -78,7 +78,7 @@ defmodule SszGenericTestRunner do assert serialized == real_serialized end - defp assert_ssz("valid", schema, real_serialized, real_deserialized, hash_tree_root) do + defp assert_ssz("valid", schema, real_serialized, real_deserialized, expected_hash_tree_root) do {:ok, deserialized} = SszEx.decode(real_serialized, schema) assert deserialized == real_deserialized @@ -86,7 +86,9 @@ defmodule SszGenericTestRunner do assert serialized == real_serialized - assert hash_tree_root == SszEx.hash_tree_root!(real_deserialized, schema) + actual_hash_tree_root = SszEx.hash_tree_root!(real_deserialized, schema) + + assert actual_hash_tree_root == expected_hash_tree_root end defp assert_ssz("invalid", schema, real_serialized) do diff --git a/lib/ssz_ex.ex b/lib/ssz_ex.ex index 536385ace..7ea566ce9 100644 --- a/lib/ssz_ex.ex +++ b/lib/ssz_ex.ex @@ -392,7 +392,8 @@ defmodule LambdaEthereumConsensus.SszEx do defp variable_size?({:bytes, _}), do: false defp pack(value, size) when is_integer(value) and value >= 0 do - <> |> String.pad_trailing(32, <<0>>) + pad = 256 - size + <> end defp pack(value) when is_boolean(value) do