Skip to content
This repository has been archived by the owner on Oct 11, 2023. It is now read-only.

Commit

Permalink
fixup! Support multiple servers in all actors
Browse files Browse the repository at this point in the history
  • Loading branch information
nmeum committed Jul 16, 2018
1 parent 06d50cf commit b9cb809
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
9 changes: 3 additions & 6 deletions spec/observe_spec.rb
Expand Up @@ -7,13 +7,15 @@

# TODO Replace this with factory.
before do
server = supervised_server(:Host => '0.0.0.0', :Port => port)

[:@exchange1, :@exchange2].each do |var|
mid = SecureRandom.random_number(0xffff)
token = SecureRandom.random_number(0xff)
options = { uri_path: [], token: token }

message = CoAP::Message.new(:con, :get, mid, '', options)
exchange = Exchange.new('127.0.0.1', CoAP::PORT, message)
exchange = Exchange.new(server, '127.0.0.1', CoAP::PORT, message)

instance_variable_set(var, exchange)
end
Expand Down Expand Up @@ -140,8 +142,6 @@
describe '#handle_update' do
let(:port) { random_port }

let!(:server) { supervised_server(:Host => '0.0.0.0', :Port => port) }

context 'error (4.04)' do
let!(:key) { [dummy1[0].host, dummy1[0].token] }

Expand Down Expand Up @@ -176,8 +176,6 @@
describe '#tick' do
let(:port) { random_port }

let!(:server) { supervised_server(:Host => '0.0.0.0', :Port => port) }

context 'update (2.05)' do
let!(:key) { [dummy2[0].host, dummy2[0].token] }

Expand All @@ -198,7 +196,6 @@
describe 'integration' do
let(:port) { random_port }

let!(:server) { supervised_server(:Port => port) }
let!(:client) do
CoAP::Client.new(port: port, retransmit: false, recv_timeout: 0.1)
end
Expand Down
2 changes: 1 addition & 1 deletion spec/server_spec.rb
@@ -1,7 +1,7 @@
require 'spec_helper'
require 'benchmark'

describe Server do
describe Server::CoAP do
let(:port) { random_port }
let(:client) do
CoAP::Client.new(port: port, retransmit: false, recv_timeout: 0.1)
Expand Down
4 changes: 2 additions & 2 deletions spec/spec_helper.rb
Expand Up @@ -63,7 +63,7 @@ def supervised_server(options)

g = Celluloid::Supervision::Container.run!

g.supervise(as: :server, type: ::David::Server,
g.supervise(as: :server_udp, type: ::David::Server::CoAP,
args: [app, defaults.merge(options)])

g.supervise(as: :gc, type: ::David::GarbageCollector)
Expand All @@ -72,7 +72,7 @@ def supervised_server(options)
g.supervise(as: :observe, type: ::David::Observe)
end

Celluloid::Actor[:server].async.run
Celluloid::Actor[:server_udp].async.run

g
end
Expand Down

0 comments on commit b9cb809

Please sign in to comment.