|
|
@@ -91,11 +91,10 @@ t_chan_info(_) ->
|
|
|
} = emqx_channel:info(channel()),
|
|
|
?assertEqual(clientinfo(), ClientInfo).
|
|
|
|
|
|
-t_chan_attrs(_) ->
|
|
|
- #{conn_state := connected} = emqx_channel:attrs(channel()).
|
|
|
-
|
|
|
t_chan_caps(_) ->
|
|
|
- _Caps = emqx_channel:caps(channel()).
|
|
|
+ Caps = emqx_mqtt_caps:default(),
|
|
|
+ ?assertEqual(Caps#{max_packet_size => 1048576},
|
|
|
+ emqx_channel:caps(channel())).
|
|
|
|
|
|
%%--------------------------------------------------------------------
|
|
|
%% Test cases for channel init
|
|
|
@@ -114,8 +113,9 @@ t_handle_in_connect_packet_sucess(_) ->
|
|
|
fun(true, _ClientInfo, _ConnInfo) ->
|
|
|
{ok, #{session => session(), present => false}}
|
|
|
end),
|
|
|
- {ok, [{connack, ?CONNACK_PACKET(?RC_SUCCESS, 0)}], Channel}
|
|
|
- = emqx_channel:handle_in(?CONNECT_PACKET(connpkt()), channel(#{conn_state => idle})),
|
|
|
+ IdleChannel = channel(#{conn_state => idle}),
|
|
|
+ {ok, [{event, connected}, {connack, ?CONNACK_PACKET(?RC_SUCCESS, 0, _)}], Channel}
|
|
|
+ = emqx_channel:handle_in(?CONNECT_PACKET(connpkt()), IdleChannel),
|
|
|
ClientInfo = emqx_channel:info(clientinfo, Channel),
|
|
|
?assertMatch(#{clientid := <<"clientid">>,
|
|
|
username := <<"username">>
|
|
|
@@ -124,8 +124,9 @@ t_handle_in_connect_packet_sucess(_) ->
|
|
|
|
|
|
t_handle_in_unexpected_connect_packet(_) ->
|
|
|
Channel = emqx_channel:set_field(conn_state, connected, channel()),
|
|
|
- {shutdown, protocol_error, ?DISCONNECT_PACKET(?RC_PROTOCOL_ERROR), Channel}
|
|
|
- = emqx_channel:handle_in(?CONNECT_PACKET(connpkt()), Channel).
|
|
|
+ Packet = ?DISCONNECT_PACKET(?RC_PROTOCOL_ERROR),
|
|
|
+ {ok, [{outgoing, Packet}, {close, protocol_error}], Channel}
|
|
|
+ = emqx_channel:handle_in(?CONNECT_PACKET(connpkt()), Channel).
|
|
|
|
|
|
t_handle_in_qos0_publish(_) ->
|
|
|
ok = meck:expect(emqx_broker, publish, fun(_) -> ok end),
|
|
|
@@ -144,7 +145,7 @@ t_handle_in_qos1_publish(_) ->
|
|
|
|
|
|
t_handle_in_qos2_publish(_) ->
|
|
|
ok = meck:expect(emqx_session, publish, fun(_, _Msg, Session) -> {ok, [], Session} end),
|
|
|
- ok = meck:expect(emqx_session, info, fun(awaiting_rel_timeout, _Session) -> 300000 end),
|
|
|
+ ok = meck:expect(emqx_session, info, fun(await_rel_timeout, _Session) -> 300 end),
|
|
|
Channel = channel(#{conn_state => connected}),
|
|
|
Publish = ?PUBLISH_PACKET(?QOS_2, <<"topic">>, 1, <<"payload">>),
|
|
|
{ok, ?PUBREC_PACKET(1, RC), _NChannel} = emqx_channel:handle_in(Publish, Channel),
|
|
|
@@ -236,13 +237,12 @@ t_handle_in_pubcomp_not_found_error(_) ->
|
|
|
|
|
|
t_handle_in_subscribe(_) ->
|
|
|
ok = meck:expect(emqx_session, subscribe,
|
|
|
- fun(_, _, _, Session) ->
|
|
|
- {ok, Session}
|
|
|
- end),
|
|
|
+ fun(_, _, _, Session) -> {ok, Session} end),
|
|
|
Channel = channel(#{conn_state => connected}),
|
|
|
TopicFilters = [{<<"+">>, ?DEFAULT_SUBOPTS}],
|
|
|
Subscribe = ?SUBSCRIBE_PACKET(1, #{}, TopicFilters),
|
|
|
- {ok, ?SUBACK_PACKET(1, [?QOS_0]), _} = emqx_channel:handle_in(Subscribe, Channel).
|
|
|
+ Replies = [{outgoing, ?SUBACK_PACKET(1, [?QOS_0])}, {event, updated}],
|
|
|
+ {ok, Replies, _Chan} = emqx_channel:handle_in(Subscribe, Channel).
|
|
|
|
|
|
t_handle_in_unsubscribe(_) ->
|
|
|
ok = meck:expect(emqx_session, unsubscribe,
|
|
|
@@ -250,61 +250,65 @@ t_handle_in_unsubscribe(_) ->
|
|
|
{ok, Session}
|
|
|
end),
|
|
|
Channel = channel(#{conn_state => connected}),
|
|
|
- UnsubPkt = ?UNSUBSCRIBE_PACKET(1, #{}, [<<"+">>]),
|
|
|
- {ok, ?UNSUBACK_PACKET(1), _} = emqx_channel:handle_in(UnsubPkt, Channel).
|
|
|
+ {ok, [{outgoing, ?UNSUBACK_PACKET(1)}, {event, updated}], _Chan}
|
|
|
+ = emqx_channel:handle_in(?UNSUBSCRIBE_PACKET(1, #{}, [<<"+">>]), Channel).
|
|
|
|
|
|
t_handle_in_pingreq(_) ->
|
|
|
{ok, ?PACKET(?PINGRESP), _Channel}
|
|
|
= emqx_channel:handle_in(?PACKET(?PINGREQ), channel()).
|
|
|
|
|
|
t_handle_in_disconnect(_) ->
|
|
|
+ Packet = ?DISCONNECT_PACKET(?RC_SUCCESS),
|
|
|
Channel = channel(#{conn_state => connected}),
|
|
|
- {shutdown, normal, Channel1} = emqx_channel:handle_in(?DISCONNECT_PACKET(?RC_SUCCESS), Channel),
|
|
|
+ {ok, {close, normal}, Channel1} = emqx_channel:handle_in(Packet, Channel),
|
|
|
?assertEqual(undefined, emqx_channel:info(will_msg, Channel1)).
|
|
|
|
|
|
t_handle_in_auth(_) ->
|
|
|
Channel = channel(#{conn_state => connected}),
|
|
|
Packet = ?DISCONNECT_PACKET(?RC_IMPLEMENTATION_SPECIFIC_ERROR),
|
|
|
- {shutdown, implementation_specific_error, Packet, Channel}
|
|
|
- = emqx_channel:handle_in(?AUTH_PACKET(), Channel).
|
|
|
+ {ok, [{outgoing, Packet},
|
|
|
+ {close, implementation_specific_error}], Channel}
|
|
|
+ = emqx_channel:handle_in(?AUTH_PACKET(), Channel).
|
|
|
|
|
|
t_handle_in_frame_error(_) ->
|
|
|
IdleChannel = channel(#{conn_state => idle}),
|
|
|
{shutdown, frame_too_large, _}
|
|
|
- = emqx_channel:handle_in({frame_error, frame_too_large}, IdleChannel),
|
|
|
+ = emqx_channel:handle_in({frame_error, frame_too_large}, IdleChannel),
|
|
|
ConnectingChan = channel(#{conn_state => connecting}),
|
|
|
- {shutdown, frame_too_large, ?CONNACK_PACKET(?RC_MALFORMED_PACKET), _}
|
|
|
- = emqx_channel:handle_in({frame_error, frame_too_large}, ConnectingChan),
|
|
|
+ ConnackPacket = ?CONNACK_PACKET(?RC_MALFORMED_PACKET),
|
|
|
+ {shutdown, frame_too_large, ConnackPacket, _}
|
|
|
+ = emqx_channel:handle_in({frame_error, frame_too_large}, ConnectingChan),
|
|
|
+ DisconnectPacket = ?DISCONNECT_PACKET(?RC_MALFORMED_PACKET),
|
|
|
ConnectedChan = channel(#{conn_state => connected}),
|
|
|
- {shutdown, malformed_Packet, ?DISCONNECT_PACKET(?RC_MALFORMED_PACKET), _}
|
|
|
- = emqx_channel:handle_in({frame_error, frame_too_large}, ConnectedChan),
|
|
|
+ {ok, [{outgoing, DisconnectPacket}, {close, frame_too_large}], _}
|
|
|
+ = emqx_channel:handle_in({frame_error, frame_too_large}, ConnectedChan),
|
|
|
DisconnectedChan = channel(#{conn_state => disconnected}),
|
|
|
{ok, DisconnectedChan}
|
|
|
- = emqx_channel:handle_in({frame_error, frame_too_large}, DisconnectedChan).
|
|
|
+ = emqx_channel:handle_in({frame_error, frame_too_large}, DisconnectedChan).
|
|
|
|
|
|
-%% TODO:
|
|
|
t_handle_in_expected_packet(_) ->
|
|
|
- {shutdown, protocol_error, ?DISCONNECT_PACKET(?RC_PROTOCOL_ERROR), _Chan}
|
|
|
- = emqx_channel:handle_in(packet, channel()).
|
|
|
+ Packet = ?DISCONNECT_PACKET(?RC_PROTOCOL_ERROR),
|
|
|
+ {ok, [{outgoing, Packet}, {close, protocol_error}], _Chan}
|
|
|
+ = emqx_channel:handle_in(packet, channel()).
|
|
|
|
|
|
t_process_connect(_) ->
|
|
|
ok = meck:expect(emqx_cm, open_session,
|
|
|
fun(true, _ClientInfo, _ConnInfo) ->
|
|
|
{ok, #{session => session(), present => false}}
|
|
|
end),
|
|
|
- {ok, [{connack, ?CONNACK_PACKET(?RC_SUCCESS)}], _Channel}
|
|
|
- = emqx_channel:process_connect(connpkt(), channel(#{conn_state => idle})).
|
|
|
+ {ok, [{event, connected}, {connack, ?CONNACK_PACKET(?RC_SUCCESS)}], _Chan}
|
|
|
+ = emqx_channel:process_connect(connpkt(), channel(#{conn_state => idle})).
|
|
|
|
|
|
-t_handle_publish_qos0(_) ->
|
|
|
+t_process_publish_qos0(_) ->
|
|
|
ok = meck:expect(emqx_broker, publish, fun(_) -> [] end),
|
|
|
Publish = ?PUBLISH_PACKET(?QOS_0, <<"t">>, 1, <<"payload">>),
|
|
|
- {ok, _Channel} = emqx_channel:handle_publish(Publish, channel()).
|
|
|
+ {ok, _Channel} = emqx_channel:process_publish(Publish, channel()).
|
|
|
|
|
|
t_process_publish_qos1(_) ->
|
|
|
ok = meck:expect(emqx_broker, publish, fun(_) -> [] end),
|
|
|
- Msg = emqx_message:make(test, ?QOS_1, <<"t">>, <<"payload">>),
|
|
|
+ Publish = ?PUBLISH_PACKET(?QOS_1, <<"t">>, 1, <<"payload">>),
|
|
|
{ok, ?PUBACK_PACKET(1, ?RC_NO_MATCHING_SUBSCRIBERS), _Channel}
|
|
|
- = emqx_channel:process_publish(1, Msg, channel()).
|
|
|
+ = emqx_channel:process_publish(Publish, channel()).
|
|
|
|
|
|
t_process_subscribe(_) ->
|
|
|
ok = meck:expect(emqx_session, subscribe, fun(_, _, _, Session) -> {ok, Session} end),
|
|
|
@@ -317,55 +321,57 @@ t_process_unsubscribe(_) ->
|
|
|
{[?RC_SUCCESS], _Channel} = emqx_channel:process_unsubscribe(TopicFilters, channel()).
|
|
|
|
|
|
%%--------------------------------------------------------------------
|
|
|
-%% Test cases for handle_out
|
|
|
+%% Test cases for handle_deliver
|
|
|
%%--------------------------------------------------------------------
|
|
|
|
|
|
-t_handle_out_delivers(_) ->
|
|
|
+t_handle_deliver(_) ->
|
|
|
WithPacketId = fun(Msgs) ->
|
|
|
lists:zip(lists:seq(1, length(Msgs)), Msgs)
|
|
|
end,
|
|
|
ok = meck:expect(emqx_session, deliver,
|
|
|
fun(Delivers, Session) ->
|
|
|
- Msgs = [Msg || {deliver, _, Msg} <- Delivers],
|
|
|
- Publishes = [{publish, PacketId, Msg}
|
|
|
- || {PacketId, Msg} <- WithPacketId(Msgs)],
|
|
|
+ Publishes = WithPacketId([Msg || {deliver, _, Msg} <- Delivers]),
|
|
|
{ok, Publishes, Session}
|
|
|
end),
|
|
|
- ok = meck:expect(emqx_session, info, fun(retry_interval, _Session) -> 20000 end),
|
|
|
+ ok = meck:expect(emqx_session, info, fun(retry_interval, _Session) -> 20 end),
|
|
|
Msg0 = emqx_message:make(test, ?QOS_1, <<"t1">>, <<"qos1">>),
|
|
|
Msg1 = emqx_message:make(test, ?QOS_2, <<"t2">>, <<"qos2">>),
|
|
|
Delivers = [{deliver, <<"+">>, Msg0}, {deliver, <<"+">>, Msg1}],
|
|
|
- {ok, {outgoing, Packets}, _Ch} = emqx_channel:handle_out(Delivers, channel()),
|
|
|
+ {ok, {outgoing, Packets}, _Ch} = emqx_channel:handle_deliver(Delivers, channel()),
|
|
|
?assertEqual([?QOS_1, ?QOS_2], [emqx_packet:qos(Pkt)|| Pkt <- Packets]).
|
|
|
|
|
|
-t_handle_out_publishes(_) ->
|
|
|
+%%--------------------------------------------------------------------
|
|
|
+%% Test cases for handle_out
|
|
|
+%%--------------------------------------------------------------------
|
|
|
+
|
|
|
+t_handle_out_publish(_) ->
|
|
|
Channel = channel(#{conn_state => connected}),
|
|
|
- Pub0 = {publish, undefined, emqx_message:make(<<"t">>, <<"qos0">>)},
|
|
|
- Pub1 = {publish, 1, emqx_message:make(<<"c">>, ?QOS_1, <<"t">>, <<"qos1">>)},
|
|
|
+ Pub0 = {undefined, emqx_message:make(<<"t">>, <<"qos0">>)},
|
|
|
+ Pub1 = {1, emqx_message:make(<<"c">>, ?QOS_1, <<"t">>, <<"qos1">>)},
|
|
|
{ok, {outgoing, Packets}, _NChannel}
|
|
|
- = emqx_channel:handle_out({publish, [Pub0, Pub1]}, Channel),
|
|
|
+ = emqx_channel:handle_out(publish, [Pub0, Pub1], Channel),
|
|
|
?assertEqual(2, length(Packets)).
|
|
|
- % ?assertEqual(#{publish_out => 2}, emqx_channel:info(pub_stats, NChannel)).
|
|
|
|
|
|
-t_handle_out_publish(_) ->
|
|
|
+t_handle_out_publish_1(_) ->
|
|
|
Msg = emqx_message:make(<<"clientid">>, ?QOS_1, <<"t">>, <<"payload">>),
|
|
|
{ok, ?PUBLISH_PACKET(?QOS_1, <<"t">>, 1, <<"payload">>), _Chan}
|
|
|
- = emqx_channel:handle_out({publish, 1, Msg}, channel()).
|
|
|
+ = emqx_channel:handle_out(publish, [{1, Msg}], channel()).
|
|
|
|
|
|
t_handle_out_publish_nl(_) ->
|
|
|
ClientInfo = clientinfo(#{clientid => <<"clientid">>}),
|
|
|
Channel = channel(#{clientinfo => ClientInfo}),
|
|
|
Msg = emqx_message:make(<<"clientid">>, ?QOS_1, <<"t1">>, <<"qos1">>),
|
|
|
- Publish = {publish, 1, emqx_message:set_flag(nl, Msg)},
|
|
|
- {ok, Channel} = emqx_channel:handle_out(Publish, Channel).
|
|
|
+ Pubs = [{1, emqx_message:set_flag(nl, Msg)}],
|
|
|
+ {ok, Channel} = emqx_channel:handle_out(publish, Pubs, Channel).
|
|
|
|
|
|
t_handle_out_connack_sucess(_) ->
|
|
|
- {ok, [{connack, ?CONNACK_PACKET(?RC_SUCCESS, _SP, _)}], _Chan}
|
|
|
- = emqx_channel:handle_out(connack, {?RC_SUCCESS, 0, connpkt()}, channel()).
|
|
|
+ {ok, [{event, connected}, {connack, ?CONNACK_PACKET(?RC_SUCCESS, 0, _)}], Channel}
|
|
|
+ = emqx_channel:handle_out(connack, {?RC_SUCCESS, 0, connpkt()}, channel()),
|
|
|
+ ?assertEqual(connected, emqx_channel:info(conn_state, Channel)).
|
|
|
|
|
|
t_handle_out_connack_failure(_) ->
|
|
|
{shutdown, not_authorized, ?CONNACK_PACKET(?RC_NOT_AUTHORIZED), _Chan}
|
|
|
- = emqx_channel:handle_out(connack, {?RC_NOT_AUTHORIZED, connpkt()}, channel()).
|
|
|
+ = emqx_channel:handle_out(connack, {?RC_NOT_AUTHORIZED, connpkt()}, channel()).
|
|
|
|
|
|
t_handle_out_puback(_) ->
|
|
|
Channel = channel(#{conn_state => connected}),
|
|
|
@@ -376,33 +382,33 @@ t_handle_out_puback(_) ->
|
|
|
t_handle_out_pubrec(_) ->
|
|
|
Channel = channel(#{conn_state => connected}),
|
|
|
{ok, ?PUBREC_PACKET(1, ?RC_SUCCESS), _NChannel}
|
|
|
- = emqx_channel:handle_out(pubrec, {1, ?RC_SUCCESS}, Channel).
|
|
|
- % ?assertEqual(#{pubrec_out => 1}, emqx_channel:info(pub_stats, NChannel)).
|
|
|
+ = emqx_channel:handle_out(pubrec, {1, ?RC_SUCCESS}, Channel).
|
|
|
|
|
|
t_handle_out_pubrel(_) ->
|
|
|
Channel = channel(#{conn_state => connected}),
|
|
|
{ok, ?PUBREL_PACKET(1), Channel1}
|
|
|
- = emqx_channel:handle_out(pubrel, {1, ?RC_SUCCESS}, Channel),
|
|
|
+ = emqx_channel:handle_out(pubrel, {1, ?RC_SUCCESS}, Channel),
|
|
|
{ok, ?PUBREL_PACKET(2, ?RC_SUCCESS), _Channel2}
|
|
|
- = emqx_channel:handle_out(pubrel, {2, ?RC_SUCCESS}, Channel1).
|
|
|
- % ?assertEqual(#{pubrel_out => 2}, emqx_channel:info(pub_stats, Channel2)).
|
|
|
+ = emqx_channel:handle_out(pubrel, {2, ?RC_SUCCESS}, Channel1).
|
|
|
|
|
|
t_handle_out_pubcomp(_) ->
|
|
|
{ok, ?PUBCOMP_PACKET(1, ?RC_SUCCESS), _Channel}
|
|
|
- = emqx_channel:handle_out(pubcomp, {1, ?RC_SUCCESS}, channel()).
|
|
|
- % ?assertEqual(#{pubcomp_out => 1}, emqx_channel:info(pub_stats, Channel)).
|
|
|
+ = emqx_channel:handle_out(pubcomp, {1, ?RC_SUCCESS}, channel()).
|
|
|
|
|
|
t_handle_out_suback(_) ->
|
|
|
- {ok, ?SUBACK_PACKET(1, [?QOS_2]), _Channel}
|
|
|
- = emqx_channel:handle_out(suback, {1, [?QOS_2]}, channel()).
|
|
|
+ Replies = [{outgoing, ?SUBACK_PACKET(1, [?QOS_2])}, {event, updated}],
|
|
|
+ {ok, Replies, _Channel}
|
|
|
+ = emqx_channel:handle_out(suback, {1, [?QOS_2]}, channel()).
|
|
|
|
|
|
t_handle_out_unsuback(_) ->
|
|
|
- {ok, ?UNSUBACK_PACKET(1, [?RC_SUCCESS]), _Channel}
|
|
|
- = emqx_channel:handle_out(unsuback, {1, [?RC_SUCCESS]}, channel()).
|
|
|
+ Replies = [{outgoing, ?UNSUBACK_PACKET(1, [?RC_SUCCESS])}, {event, updated}],
|
|
|
+ {ok, Replies, _Channel}
|
|
|
+ = emqx_channel:handle_out(unsuback, {1, [?RC_SUCCESS]}, channel()).
|
|
|
|
|
|
t_handle_out_disconnect(_) ->
|
|
|
- {shutdown, normal, ?DISCONNECT_PACKET(?RC_SUCCESS), _Chan}
|
|
|
- = emqx_channel:handle_out(disconnect, ?RC_SUCCESS, channel()).
|
|
|
+ Packet = ?DISCONNECT_PACKET(?RC_SUCCESS),
|
|
|
+ {ok, [{outgoing, Packet}, {close, normal}], _Chan}
|
|
|
+ = emqx_channel:handle_out(disconnect, ?RC_SUCCESS, channel()).
|
|
|
|
|
|
t_handle_out_unexpected(_) ->
|
|
|
{ok, _Channel} = emqx_channel:handle_out(unexpected, <<"data">>, channel()).
|
|
|
@@ -444,33 +450,33 @@ t_handle_info_unsubscribe(_) ->
|
|
|
{ok, _Chan} = emqx_channel:handle_info({unsubscribe, topic_filters()}, channel()).
|
|
|
|
|
|
t_handle_info_sock_closed(_) ->
|
|
|
- {ok, _Chan} = emqx_channel:handle_out({sock_closed, reason},
|
|
|
- channel(#{conn_state => disconnected})).
|
|
|
+ Channel = channel(#{conn_state => disconnected}),
|
|
|
+ {ok, Channel} = emqx_channel:handle_info({sock_closed, reason}, Channel).
|
|
|
|
|
|
%%--------------------------------------------------------------------
|
|
|
%% Test cases for handle_timeout
|
|
|
%%--------------------------------------------------------------------
|
|
|
|
|
|
t_handle_timeout_emit_stats(_) ->
|
|
|
- ok = meck:expect(emqx_cm, set_chan_stats, fun(_, _) -> ok end),
|
|
|
TRef = make_ref(),
|
|
|
+ ok = meck:expect(emqx_cm, set_chan_stats, fun(_, _) -> ok end),
|
|
|
Channel = emqx_channel:set_field(timers, #{stats_timer => TRef}, channel()),
|
|
|
{ok, _Chan} = emqx_channel:handle_timeout(TRef, {emit_stats, []}, Channel).
|
|
|
|
|
|
t_handle_timeout_keepalive(_) ->
|
|
|
TRef = make_ref(),
|
|
|
- _Channel = emqx_channel:set_field(timers, #{alive_timer => TRef}, channel()),
|
|
|
- {ok, _Chan} = emqx_channel:handle_timeout(make_ref(), {keepalive, 10}, channel()).
|
|
|
+ Channel = emqx_channel:set_field(timers, #{alive_timer => TRef}, channel()),
|
|
|
+ {ok, _Chan} = emqx_channel:handle_timeout(make_ref(), {keepalive, 10}, Channel).
|
|
|
|
|
|
t_handle_timeout_retry_delivery(_) ->
|
|
|
- ok = meck:expect(emqx_session, retry, fun(Session) -> {ok, Session} end),
|
|
|
TRef = make_ref(),
|
|
|
- _Channel = emqx_channel:set_field(timers, #{retry_timer => TRef}, channel()),
|
|
|
- {ok, _Chan} = emqx_channel:handle_timeout(TRef, retry_delivery, channel()).
|
|
|
+ ok = meck:expect(emqx_session, retry, fun(Session) -> {ok, Session} end),
|
|
|
+ Channel = emqx_channel:set_field(timers, #{retry_timer => TRef}, channel()),
|
|
|
+ {ok, _Chan} = emqx_channel:handle_timeout(TRef, retry_delivery, Channel).
|
|
|
|
|
|
t_handle_timeout_expire_awaiting_rel(_) ->
|
|
|
- ok = meck:expect(emqx_session, expire, fun(_, Session) -> {ok, Session} end),
|
|
|
TRef = make_ref(),
|
|
|
+ ok = meck:expect(emqx_session, expire, fun(_, Session) -> {ok, Session} end),
|
|
|
Channel = emqx_channel:set_field(timers, #{await_timer => TRef}, channel()),
|
|
|
{ok, _Chan} = emqx_channel:handle_timeout(TRef, expire_awaiting_rel, Channel).
|
|
|
|
|
|
@@ -522,7 +528,7 @@ t_check_subscribe(_) ->
|
|
|
ok = emqx_channel:check_subscribe(<<"t">>, ?DEFAULT_SUBOPTS, channel()),
|
|
|
ok = meck:unload(emqx_zone).
|
|
|
|
|
|
-t_enrich_caps(_) ->
|
|
|
+t_enrich_connack_caps(_) ->
|
|
|
ok = meck:new(emqx_mqtt_caps, [passthrough, no_history]),
|
|
|
ok = meck:expect(emqx_mqtt_caps, get_caps,
|
|
|
fun(_Zone) ->
|
|
|
@@ -534,7 +540,7 @@ t_enrich_caps(_) ->
|
|
|
wildcard_subscription => true
|
|
|
}
|
|
|
end),
|
|
|
- AckProps = emqx_channel:enrich_caps(#{}, channel()),
|
|
|
+ AckProps = emqx_channel:enrich_connack_caps(#{}, channel()),
|
|
|
?assertMatch(#{'Retain-Available' := 1,
|
|
|
'Maximum-Packet-Size' := 1024,
|
|
|
'Topic-Alias-Maximum' := 10,
|