-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added IP address verification to ensure a node is reachable (discarding private IP ranges, and unreachable addresses) Added node duplication check to avoid overload of IP/Port for different nodes Fixes #108
- Loading branch information
Rohit Roy Chowdhury
committed
Nov 4, 2021
1 parent
efb057a
commit 0a22d05
Showing
7 changed files
with
203 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
defmodule ArchEthic.NetworkingTest do | ||
use ExUnit.Case, async: true | ||
use ExUnitProperties | ||
|
||
alias ArchEthic.Networking | ||
|
||
doctest ArchEthic.Networking | ||
|
||
describe "valid_ip?/1" do | ||
property "should return false for loopback address range" do | ||
ip_generator = tuple({constant(127), integer(0..255), integer(0..255), integer(0..255)}) | ||
|
||
check all(ip <- ip_generator) do | ||
refute Networking.valid_ip?(ip) | ||
end | ||
end | ||
|
||
property "should return false for Class A private address range" do | ||
ip_generator = tuple({constant(10), integer(0..255), integer(0..255), integer(0..255)}) | ||
|
||
check all(ip <- ip_generator) do | ||
refute Networking.valid_ip?(ip) | ||
end | ||
end | ||
|
||
property "should return false for Class B private address range" do | ||
ip_generator = tuple({constant(172), integer(16..31), integer(0..255), integer(0..255)}) | ||
|
||
check all(ip <- ip_generator) do | ||
refute Networking.valid_ip?(ip) | ||
end | ||
end | ||
|
||
property "should return false for Class C private address range" do | ||
ip_generator = tuple({constant(192), constant(168), integer(0..255), integer(0..255)}) | ||
|
||
check all(ip <- ip_generator) do | ||
refute Networking.valid_ip?(ip) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters