Skip to content

Commit

Permalink
Testing: ignore server instance ID when comparing connection keys
Browse files Browse the repository at this point in the history
This fixes page_refresh_with_recovery
https://ably.atlassian.net/browse/RAR-712
  • Loading branch information
amnonbc committed Sep 29, 2024
1 parent 8c9ce8b commit 93c4059
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion test/browser/connection.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,24 @@ define(['shared_helper', 'chai'], function (Helper, chai) {
});
});

// strip instanceID and handleID from connectionKey */
function connectionHmac(key) {
/* connectionKey has the form <instanceID>!<hmac>-<handleID> */

/* remove the handleID from the end of key */
let k = key.split('-')[0];

/* skip the server instanceID if present, as reconnects may be routed to different frontends */
if (k.includes('!')) {
k = k.split('!')[1];
}
return k;
}

/* uses internal realtime knowledge of the format of the connection key to
* check if a connection key is the result of a successful recovery of another */
function sameConnection(keyA, keyB) {
return keyA.split('-')[0] === keyB.split('-')[0];
return connectionHmac(keyA) === connectionHmac(keyB);
}

/**
Expand Down

0 comments on commit 93c4059

Please sign in to comment.