openflow: Fix aggregate request

This commit is contained in:
Eishun Kondoh 2019-05-01 23:54:40 +09:00
parent c5e38155e1
commit b32cfff395
22 changed files with 71 additions and 44 deletions

View file

@ -1,73 +0,0 @@
defmodule OfpFeaturesTest do
use ExUnit.Case
doctest Openflow
describe "Openflow.read/1" do
test "with OFP_FEATURES_REQUEST packet" do
{:ok, %Openflow.Features.Request{} = features, ""} =
"test/packet_data/ofp_features_request.raw"
|> File.read!()
|> Openflow.read()
expect = Openflow.Features.Request.new(0)
assert features.version == expect.version
assert features.xid == expect.xid
end
test "with OFP_FEATURES_REPLY packet" do
{:ok, %Openflow.Features.Reply{} = features, ""} =
"test/packet_data/ofp_features_reply.raw"
|> File.read!()
|> Openflow.read()
assert features.version == 4
assert features.xid == 0
assert features.datapath_id == "0000000000000001"
assert features.n_buffers == 255
assert features.n_tables == 255
assert features.aux_id == 0
assert features.capabilities == [
:flow_stats,
:table_stats,
:port_stats,
:group_stats,
:queue_stats
]
end
end
describe "Openflow.to_binary/1" do
test "with %Openflow.Features.Request{}" do
features = %Openflow.Features.Request{
version: 4,
xid: 0
}
expect =
"test/packet_data/ofp_features_request.raw"
|> File.read!()
assert Openflow.to_binary(features) == expect
end
end
test "with %Openflow.Features.Reply{}" do
features = %Openflow.Features.Reply{
version: 4,
xid: 0,
datapath_id: "0000000000000001",
n_buffers: 255,
n_tables: 255,
aux_id: 0,
capabilities: [:flow_stats, :table_stats, :port_stats, :group_stats, :queue_stats]
}
expect =
"test/packet_data/ofp_features_reply.raw"
|> File.read!()
assert Openflow.to_binary(features) == expect
end
end