Skip to content

Commit

Permalink
Fix dyalizer issues (#355)
Browse files Browse the repository at this point in the history
Fix several dialyzer issues. Some simply break contract because they
allow a `nil`, while others were slightly more complicated (like the
supertype being a `struct()` instead of a `%{}`).
  • Loading branch information
germsvel authored and ayrat555 committed Aug 16, 2018
1 parent 8bf0e7c commit f2ca418
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion apps/ex_wire/lib/ex_wire/framing/frame.ex
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ defmodule ExWire.Framing.Frame do
MAC.mac_inst(),
ExthCrypto.Cipher.cipher(),
ExthCrypto.Key.symmetric_key(),
binary()
binary() | nil
) :: MAC.mac_inst()
defp update_mac(mac, mac_encoder, mac_secret, seed) do
final = mac |> MAC.final() |> Binary.take(16)
Expand Down
2 changes: 1 addition & 1 deletion apps/ex_wire/lib/ex_wire/handshake/struct/auth_msg_v4.ex
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ defmodule ExWire.Handshake.Struct.AuthMsgV4 do
]
end

@spec deserialize(ExRLP.t()) :: t
@spec deserialize(nonempty_maybe_improper_list()) :: t
def deserialize(rlp) do
[signature | rlp_tail] = rlp
[initiator_public_key | rlp_tail] = rlp_tail
Expand Down
2 changes: 1 addition & 1 deletion apps/ex_wire/lib/ex_wire/packet.ex
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ defmodule ExWire.Packet do

alias ExWire.Packet

@type packet :: %{}
@type packet :: struct()
@type block_identifier :: binary() | integer()
@type block_hash :: {binary(), integer()}

Expand Down
3 changes: 1 addition & 2 deletions apps/ex_wire/lib/ex_wire/packet/transactions.ex
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,8 @@ defmodule ExWire.Packet.Transactions do
...> |> ExWire.Packet.Transactions.handle()
:ok
"""
@spec handle(ExWire.Packet.packet()) :: ExWire.Packet.handle_response()
@spec handle(ExWire.Packet.packet()) :: :ok
def handle(packet = %__MODULE__{}) do
# TODO: Do.
Logger.debug(fn -> "[Packet] Peer sent #{Enum.count(packet.transactions)} transaction(s)." end)

:ok
Expand Down
2 changes: 1 addition & 1 deletion apps/exth_crypto/lib/exth_crypto/mac.ex
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ defmodule ExthCrypto.MAC do
iex> ExthCrypto.MAC.mac("The quick brown fox jumps over the lazy dog", "key", :sha256, 8)
<<247, 188, 131, 244, 48, 83, 132, 36>>
"""
@spec mac(iodata(), iodata(), Hash.hash_algorithm(), integer()) :: mac
@spec mac(iodata(), iodata(), Hash.hash_algorithm(), integer() | nil) :: mac
def mac(data, key, hash_algorithm, length \\ nil) when is_atom(hash_algorithm) do
if Enum.member?(Hash.hash_algorithms(), hash_algorithm) do
case length do
Expand Down

0 comments on commit f2ca418

Please sign in to comment.