Skip to content

Commit

Permalink
fix: tests pass
Browse files Browse the repository at this point in the history
  • Loading branch information
Godspower-Eze committed Dec 12, 2023
1 parent 814ca95 commit ecf084e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 4 additions & 2 deletions lib/spec/runners/ssz_generic.ex
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,17 @@ 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

{:ok, serialized} = SszEx.encode(real_deserialized, schema)

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
Expand Down
3 changes: 2 additions & 1 deletion lib/ssz_ex.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
<<value::size(size)-little>> |> String.pad_trailing(32, <<0>>)
pad = 256 - size
<<value::size(size)-little, 0::size(pad)>>
end

defp pack(value) when is_boolean(value) do
Expand Down

0 comments on commit ecf084e

Please sign in to comment.