Skip to content

Commit

Permalink
fix: delete old messages for gateway
Browse files Browse the repository at this point in the history
integration tests are passing!
  • Loading branch information
ilbertt committed Dec 4, 2023
1 parent e56239c commit b7c428e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
9 changes: 3 additions & 6 deletions src/Types.mo
Original file line number Diff line number Diff line change
Expand Up @@ -282,12 +282,7 @@ module {
var deleted_keys : List.List<Text> = List.nil();

label f for (_ in Iter.range(0, n - 1)) {
let message_to_delete = do {
let (m, l) = List.pop(messages_to_delete);
messages_to_delete := l;
m;
};
switch (message_to_delete) {
switch (List.get(messages_to_delete, 0)) {
case (?message_to_delete) {
if ((time - message_to_delete.timestamp) > (message_max_age_ms * 1_000_000)) {
let deleted_message = do {
Expand All @@ -308,6 +303,8 @@ module {
Prelude.unreachable();
};
};
let (_, l) = List.pop(messages_to_delete);
messages_to_delete := l;
} else {
// In this case, no messages can be deleted because
// they're all not older than `message_max_age_ms`.
Expand Down
2 changes: 1 addition & 1 deletion tests/ic-websocket-cdk-rs
Submodule ic-websocket-cdk-rs updated 27 files
+6 −0 .github/workflows/tests.yml
+1 −1 scripts/test.sh
+1 −1 src/ic-websocket-cdk/service.example.did
+109 −0 src/ic-websocket-cdk/src/errors.rs
+102 −1,047 src/ic-websocket-cdk/src/lib.rs
+0 −13 src/ic-websocket-cdk/src/logger.rs
+560 −0 src/ic-websocket-cdk/src/state.rs
+1 −7 src/ic-websocket-cdk/src/tests/common.rs
+40 −56 src/ic-websocket-cdk/src/tests/integration_tests/a_ws_open.rs
+50 −45 src/ic-websocket-cdk/src/tests/integration_tests/b_ws_message.rs
+153 −228 src/ic-websocket-cdk/src/tests/integration_tests/c_ws_get_messages.rs
+75 −10 src/ic-websocket-cdk/src/tests/integration_tests/d_ws_close.rs
+10 −9 src/ic-websocket-cdk/src/tests/integration_tests/e_ws_send.rs
+56 −67 src/ic-websocket-cdk/src/tests/integration_tests/f_messages_acknowledgement.rs
+72 −55 src/ic-websocket-cdk/src/tests/integration_tests/g_multiple_gateways.rs
+48 −19 src/ic-websocket-cdk/src/tests/integration_tests/utils/actor.rs
+16 −3 src/ic-websocket-cdk/src/tests/integration_tests/utils/clients.rs
+0 −19 src/ic-websocket-cdk/src/tests/integration_tests/utils/constants.rs
+76 −2 src/ic-websocket-cdk/src/tests/integration_tests/utils/messages.rs
+0 −1 src/ic-websocket-cdk/src/tests/integration_tests/utils/mod.rs
+18 −26 src/ic-websocket-cdk/src/tests/integration_tests/utils/test_env.rs
+486 −152 src/ic-websocket-cdk/src/tests/unit_tests/mod.rs
+146 −0 src/ic-websocket-cdk/src/timers.rs
+453 −0 src/ic-websocket-cdk/src/types.rs
+46 −0 src/ic-websocket-cdk/src/utils.rs
+1 −0 src/ic-websocket-cdk/ws_types.did
+0 −4 src/test_canister/src/lib.rs

0 comments on commit b7c428e

Please sign in to comment.