Skip to content

Commit

Permalink
fix(MultiAddress): GetHashCode and null protocol value, fixes #103
Browse files Browse the repository at this point in the history
  • Loading branch information
richardschneider committed Aug 21, 2019
1 parent 5bb6dcf commit 06cc4c2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/MultiAddress.cs
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ public override int GetHashCode()
foreach (var p in Protocols)
{
code += p.Code.GetHashCode();
code += p.Value.GetHashCode();
code += p.Value?.GetHashCode() ?? 0;
}
return code;
}
Expand Down
7 changes: 7 additions & 0 deletions test/MultiAddressTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,13 @@ public void Alias_Equality()
Assert.IsTrue(a == b);
Assert.AreEqual(a.GetHashCode(), b.GetHashCode());
}

[TestMethod]
public void GetHashCode_NullValue()
{
var a = new MultiAddress("/ip4/139.178.69.3/udp/4001/quic/p2p/QmdGQoGuK3pao6bRDqGSDvux5SFHa4kC2XNFfHFcvcbydY/p2p-circuit/ipfs/QmPJkpfUedzahgVAj6tTUa3DHKVkfTSyvUmnn1USFpiCaF");
var _ = a.GetHashCode();
}
}
}

0 comments on commit 06cc4c2

Please sign in to comment.