Skip to content

Commit

Permalink
test: use local IP address for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mchitre committed Sep 13, 2022
1 parent 282a495 commit e309d38
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
1 change: 1 addition & 0 deletions test/Project.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[deps]
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
Sockets = "6462fe0b-24de-5631-8697-dd941f90decc"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
20 changes: 12 additions & 8 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Test
using Dates
using UnetSockets
using Sockets: getipaddrs, IPv4

# start fjåge

Expand All @@ -11,10 +12,13 @@ sleep(5)
# tests

println("Starting tests...")
ips = string.(filter(x -> x isa IPv4, getipaddrs()))
println("IPs: $(ips)")
ip = first(ips)
try

@testset "socket" begin
s = UnetSocket("localhost", 1101)
s = UnetSocket(ip, 1101)
@test getlocaladdress(s) == 232
@test host(s, "A") == 232
@test host(s, "B") == 31
Expand All @@ -24,7 +28,7 @@ try
end

@testset "gateway" begin
s = UnetSocket("localhost", 1101)
s = UnetSocket(ip, 1101)
gw = getgateway(s)
@test gw isa Fjage.Gateway
shell = agentforservice(gw, Services.SHELL)
Expand All @@ -34,7 +38,7 @@ try
end

@testset "agents" begin
s = UnetSocket("localhost", 1101)
s = UnetSocket(ip, 1101)
node = agent(s, "node")
@test node isa AgentID
@test node.address == 232
Expand All @@ -47,7 +51,7 @@ try
end

@testset "bind/connect" begin
s = UnetSocket("localhost", 1101)
s = UnetSocket(ip, 1101)
@test getlocalprotocol(s) == -1
@test !isbound(s)
@test bind(s, 42)
Expand All @@ -71,7 +75,7 @@ try
end

@testset "timeouts" begin
s = UnetSocket("localhost", 1101)
s = UnetSocket(ip, 1101)
@test bind(s, 0)
@test gettimeout(s) == -1
settimeout(s, 1000)
Expand All @@ -90,7 +94,7 @@ try
end

@testset "cancel" begin
s = UnetSocket("localhost", 1101)
s = UnetSocket(ip, 1101)
@test bind(s, 0)
@test gettimeout(s) == -1
t1 = now().instant
Expand All @@ -105,8 +109,8 @@ try
end

@testset "communication" begin
s1 = UnetSocket("localhost", 1101)
s2 = UnetSocket("localhost", 1102)
s1 = UnetSocket(ip, 1101)
s2 = UnetSocket(ip, 1102)
@test bind(s2, Protocol.USER)
settimeout(s2, 1000)
@test !send(s1, [1,2,3])
Expand Down

2 comments on commit e309d38

@mchitre
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/68208

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.2.0 -m "<description of version>" e309d38adc03326d3a87f68885bafea6ea13c1b4
git push origin v0.2.0

Please sign in to comment.