Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
SionoiS committed Feb 6, 2025
1 parent 8b0951b commit 1002828
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
16 changes: 16 additions & 0 deletions tests/waku_store_sync/test_protocol.nim
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ suite "Waku Sync: reconciliation":
discard server.messageIngress(hash3, msg3, 1)

check:
remoteNeeds.len == 0
localWants.len == 0
remoteNeeds.contains((clientPeerInfo.peerId, hash1)) == false
remoteNeeds.contains((clientPeerInfo.peerId, hash2)) == false
remoteNeeds.contains((clientPeerInfo.peerId, hash3)) == false
Expand All @@ -101,6 +103,8 @@ suite "Waku Sync: reconciliation":
assert res.isOk(), res.error

check:
remoteNeeds.len == 3
localWants.len == 0
remoteNeeds.contains((clientPeerInfo.peerId, hash1)) == true
remoteNeeds.contains((clientPeerInfo.peerId, hash2)) == true
remoteNeeds.contains((clientPeerInfo.peerId, hash3)) == true
Expand All @@ -122,6 +126,8 @@ suite "Waku Sync: reconciliation":
discard client.messageIngress(hash3, msg3, 1)

check:
remoteNeeds.len == 0
localWants.len == 0
remoteNeeds.contains((serverPeerInfo.peerId, hash1)) == false
remoteNeeds.contains((serverPeerInfo.peerId, hash2)) == false
remoteNeeds.contains((serverPeerInfo.peerId, hash3)) == false
Expand All @@ -130,6 +136,8 @@ suite "Waku Sync: reconciliation":
assert res.isOk(), res.error

check:
remoteNeeds.len == 3
localWants.len == 0
remoteNeeds.contains((serverPeerInfo.peerId, hash1)) == true
remoteNeeds.contains((serverPeerInfo.peerId, hash2)) == true
remoteNeeds.contains((serverPeerInfo.peerId, hash3)) == true
Expand All @@ -152,6 +160,8 @@ suite "Waku Sync: reconciliation":
discard client.messageIngress(hash3, msg3, 1)

check:
remoteNeeds.len == 0
localWants.len == 0
remoteNeeds.contains((serverPeerInfo.peerId, hash3)) == false
remoteNeeds.contains((clientPeerInfo.peerId, hash2)) == false
localWants.contains((clientPeerInfo.peerId, hash3)) == false
Expand All @@ -161,6 +171,8 @@ suite "Waku Sync: reconciliation":
assert syncRes.isOk(), $syncRes.error

check:
remoteNeeds.len == 2
localWants.len == 2
remoteNeeds.contains((serverPeerInfo.peerId, hash3)) == true
remoteNeeds.contains((clientPeerInfo.peerId, hash2)) == true
localWants.contains((clientPeerInfo.peerId, hash3)) == true
Expand Down Expand Up @@ -267,13 +279,17 @@ suite "Waku Sync: reconciliation":
timestamp += Timestamp(part)

check:
remoteNeeds.len == 0
localWants.len == 0
localWants.contains((serverPeerInfo.peerId, WakuMessageHash(diff))) == false
remoteNeeds.contains((clientPeerInfo.peerId, WakuMessageHash(diff))) == false

let res = await client.storeSynchronization(some(serverPeerInfo))
assert res.isOk(), $res.error

check:
remoteNeeds.len == 1
localWants.len == 1
localWants.contains((serverPeerInfo.peerId, WakuMessageHash(diff))) == true
remoteNeeds.contains((clientPeerInfo.peerId, WakuMessageHash(diff))) == true

Expand Down
2 changes: 1 addition & 1 deletion waku/waku_store_sync/reconciliation.nim
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ proc preProcessPayload(
let selfLowerBound = timeRange.a

# for non skip ranges check if they happen before any of our ranges
# convert to skip range in that case
# convert to skip range before processing
for i in 0 ..< payload.ranges.len:
let rangeType = payload.ranges[i][1]
if rangeType != RangeType.Skip:
Expand Down
2 changes: 0 additions & 2 deletions waku/waku_store_sync/storage/seq_storage.nim
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,6 @@ proc computefingerprintFromSlice(
proc findIdxBounds(self: SeqStorage, slice: Slice[SyncID]): Option[Slice[int]] =
## Given bounds find the corresponding indices in this storage

#TODO can thoses 2 binary search be combined for efficiency ???

let lower = self.elements.lowerBound(slice.a, common.cmp)
var upper = self.elements.upperBound(slice.b, common.cmp)

Expand Down

0 comments on commit 1002828

Please sign in to comment.