Skip to content

Commit

Permalink
Unit Test for #297 (#298)
Browse files Browse the repository at this point in the history
* update tests for unsubscribe crash

* update comments
  • Loading branch information
xiazhvera authored Jun 5, 2023
1 parent b3ac03e commit d3377e4
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tests/v3/topic_tree_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,12 @@ static int s_mqtt_topic_tree_unsubscribe_fn(struct aws_allocator *allocator, voi

ASSERT_SUCCESS(aws_mqtt_topic_tree_insert(
&tree, topic_a_a_a, AWS_MQTT_QOS_AT_MOST_ONCE, &on_publish, s_string_clean_up, topic_a_a_a));
/* At this moment, the topic_a_a was not inserted. Though the remove returns a success, the topic_a_a_a should still
* remained in the tree.
* The test is inspired by the ticket: https://github.com/awslabs/aws-crt-nodejs/issues/405. There was a crash when
* we unsubscribe from an unsubscribed parent topic.
* We fixed the issue in https://github.com/awslabs/aws-c-mqtt/pull/297 */
ASSERT_SUCCESS(aws_mqtt_topic_tree_remove(&tree, &s_topic_a_a));
ASSERT_SUCCESS(aws_mqtt_topic_tree_remove(&tree, &s_topic_a_a_a));
/* Re-create, it was nuked by remove. */
topic_a_a_a = aws_string_new_from_array(allocator, s_topic_a_a_a.ptr, s_topic_a_a_a.len);
Expand Down

0 comments on commit d3377e4

Please sign in to comment.