rename newFilter to initFilter for correctness

This commit is contained in:
kdeme 2020-01-14 15:33:21 +01:00
parent 3527d47cb5
commit cb2bc388f1
No known key found for this signature in database
GPG Key ID: 4E8DD21420AF43F5
6 changed files with 27 additions and 27 deletions

View File

@ -572,7 +572,7 @@ proc add*(self: var Queue, msg: Message): bool =
return true return true
# Filters ---------------------------------------------------------------------- # Filters ----------------------------------------------------------------------
proc newFilter*(src = none[PublicKey](), privateKey = none[PrivateKey](), proc initFilter*(src = none[PublicKey](), privateKey = none[PrivateKey](),
symKey = none[SymKey](), topics: seq[Topic] = @[], symKey = none[SymKey](), topics: seq[Topic] = @[],
powReq = 0.0, allowP2P = false): Filter = powReq = 0.0, allowP2P = false): Filter =
# Zero topics will give an empty bloom filter which is fine as this bloom # Zero topics will give an empty bloom filter which is fine as this bloom

View File

@ -117,20 +117,20 @@ if config.watch:
echo msg.decoded.payload.repr echo msg.decoded.payload.repr
# filter encrypted asym # filter encrypted asym
discard node.subscribeFilter(newFilter(privateKey = some(encPrivateKey), discard node.subscribeFilter(initFilter(privateKey = some(encPrivateKey),
topics = @[topic]), topics = @[topic]),
handler) handler)
# filter encrypted asym + signed # filter encrypted asym + signed
discard node.subscribeFilter(newFilter(some(signPublicKey), discard node.subscribeFilter(initFilter(some(signPublicKey),
privateKey = some(encPrivateKey), privateKey = some(encPrivateKey),
topics = @[topic]), topics = @[topic]),
handler) handler)
# filter encrypted sym # filter encrypted sym
discard node.subscribeFilter(newFilter(symKey = some(symKey), discard node.subscribeFilter(initFilter(symKey = some(symKey),
topics = @[topic]), topics = @[topic]),
handler) handler)
# filter encrypted sym + signed # filter encrypted sym + signed
discard node.subscribeFilter(newFilter(some(signPublicKey), discard node.subscribeFilter(initFilter(some(signPublicKey),
symKey = some(symKey), symKey = some(symKey),
topics = @[topic]), topics = @[topic]),
handler) handler)

View File

@ -269,7 +269,7 @@ suite "Whisper filter":
let msg = prepFilterTestMsg(symKey = some(symKey), topic = topic) let msg = prepFilterTestMsg(symKey = some(symKey), topic = topic)
var filters = initTable[string, Filter]() var filters = initTable[string, Filter]()
let filter = newFilter(symKey = some(symKey), topics = @[topic]) let filter = initFilter(symKey = some(symKey), topics = @[topic])
let filterId = filters.subscribeFilter(filter) let filterId = filters.subscribeFilter(filter)
notify(filters, msg) notify(filters, msg)
@ -287,7 +287,7 @@ suite "Whisper filter":
topic = topic) topic = topic)
var filters = initTable[string, Filter]() var filters = initTable[string, Filter]()
let filter = newFilter(privateKey = some(privKey), topics = @[topic]) let filter = initFilter(privateKey = some(privKey), topics = @[topic])
let filterId = filters.subscribeFilter(filter) let filterId = filters.subscribeFilter(filter)
notify(filters, msg) notify(filters, msg)
@ -304,7 +304,7 @@ suite "Whisper filter":
let msg = prepFilterTestMsg(src = some(privKey), topic = topic) let msg = prepFilterTestMsg(src = some(privKey), topic = topic)
var filters = initTable[string, Filter]() var filters = initTable[string, Filter]()
let filter = newFilter(src = some(privKey.getPublicKey()), let filter = initFilter(src = some(privKey.getPublicKey()),
topics = @[topic]) topics = @[topic])
let filterId = filters.subscribeFilter(filter) let filterId = filters.subscribeFilter(filter)
@ -328,9 +328,9 @@ suite "Whisper filter":
var filters = initTable[string, Filter]() var filters = initTable[string, Filter]()
let let
filterId1 = filters.subscribeFilter( filterId1 = filters.subscribeFilter(
newFilter(topics = @[topic], powReq = 0.014492753623188406)) initFilter(topics = @[topic], powReq = 0.014492753623188406))
filterId2 = filters.subscribeFilter( filterId2 = filters.subscribeFilter(
newFilter(topics = @[topic], powReq = 0.014492753623188407)) initFilter(topics = @[topic], powReq = 0.014492753623188407))
notify(filters, msg) notify(filters, msg)
@ -347,8 +347,8 @@ suite "Whisper filter":
var filters = initTable[string, Filter]() var filters = initTable[string, Filter]()
let let
filterId1 = filters.subscribeFilter(newFilter(topics = @[topic1])) filterId1 = filters.subscribeFilter(initFilter(topics = @[topic1]))
filterId2 = filters.subscribeFilter(newFilter(topics = @[topic2])) filterId2 = filters.subscribeFilter(initFilter(topics = @[topic2]))
notify(filters, msg) notify(filters, msg)

View File

@ -59,17 +59,17 @@ suite "Whisper connections":
# Filters # Filters
# filter for encrypted asym # filter for encrypted asym
filters.add(node1.subscribeFilter(newFilter(privateKey = some(encryptKeyPair.seckey), filters.add(node1.subscribeFilter(initFilter(privateKey = some(encryptKeyPair.seckey),
topics = @[topic]), handler1)) topics = @[topic]), handler1))
# filter for encrypted asym + signed # filter for encrypted asym + signed
filters.add(node1.subscribeFilter(newFilter(some(signKeyPair.pubkey), filters.add(node1.subscribeFilter(initFilter(some(signKeyPair.pubkey),
privateKey = some(encryptKeyPair.seckey), privateKey = some(encryptKeyPair.seckey),
topics = @[topic]), handler2)) topics = @[topic]), handler2))
# filter for encrypted sym # filter for encrypted sym
filters.add(node1.subscribeFilter(newFilter(symKey = some(symKey), filters.add(node1.subscribeFilter(initFilter(symKey = some(symKey),
topics = @[topic]), handler3)) topics = @[topic]), handler3))
# filter for encrypted sym + signed # filter for encrypted sym + signed
filters.add(node1.subscribeFilter(newFilter(some(signKeyPair.pubkey), filters.add(node1.subscribeFilter(initFilter(some(signKeyPair.pubkey),
symKey = some(symKey), symKey = some(symKey),
topics = @[topic]), handler4)) topics = @[topic]), handler4))
# Messages # Messages
@ -113,8 +113,8 @@ suite "Whisper connections":
check msg.decoded.payload == payloads[1] check msg.decoded.payload == payloads[1]
futures[1].complete(1) futures[1].complete(1)
var filter1 = node1.subscribeFilter(newFilter(topics = @[topic1]), handler1) var filter1 = node1.subscribeFilter(initFilter(topics = @[topic1]), handler1)
var filter2 = node1.subscribeFilter(newFilter(topics = @[topic2]), handler2) var filter2 = node1.subscribeFilter(initFilter(topics = @[topic2]), handler2)
check: check:
node2.postMessage(ttl = safeTTL + 1, topic = topic1, node2.postMessage(ttl = safeTTL + 1, topic = topic1,
@ -142,9 +142,9 @@ suite "Whisper connections":
check msg.decoded.payload == payload check msg.decoded.payload == payload
futures[1].complete(1) futures[1].complete(1)
var filter1 = node1.subscribeFilter(newFilter(topics = @[topic], powReq = 0), var filter1 = node1.subscribeFilter(initFilter(topics = @[topic], powReq = 0),
handler1) handler1)
var filter2 = node1.subscribeFilter(newFilter(topics = @[topic], var filter2 = node1.subscribeFilter(initFilter(topics = @[topic],
powReq = 1_000_000), handler2) powReq = 1_000_000), handler2)
check: check:
@ -163,7 +163,7 @@ suite "Whisper connections":
let topic = [byte 0, 0, 0, 0] let topic = [byte 0, 0, 0, 0]
let payload = repeat(byte 0, 10) let payload = repeat(byte 0, 10)
var filter = node1.subscribeFilter(newFilter(topics = @[topic])) var filter = node1.subscribeFilter(initFilter(topics = @[topic]))
for i in countdown(10, 1): for i in countdown(10, 1):
check node2.postMessage(ttl = safeTTL, topic = topic, check node2.postMessage(ttl = safeTTL, topic = topic,
payload = payload) == true payload = payload) == true
@ -179,7 +179,7 @@ suite "Whisper connections":
asyncTest "Local filter notify": asyncTest "Local filter notify":
let topic = [byte 0, 0, 0, 0] let topic = [byte 0, 0, 0, 0]
var filter = node1.subscribeFilter(newFilter(topics = @[topic])) var filter = node1.subscribeFilter(initFilter(topics = @[topic]))
check: check:
node1.postMessage(ttl = safeTTL, topic = topic, node1.postMessage(ttl = safeTTL, topic = topic,
payload = repeat(byte 4, 10)) == true payload = repeat(byte 4, 10)) == true
@ -198,7 +198,7 @@ suite "Whisper connections":
proc handler(msg: ReceivedMessage) = proc handler(msg: ReceivedMessage) =
check msg.decoded.payload == payload check msg.decoded.payload == payload
f.complete(1) f.complete(1)
var filter = node1.subscribeFilter(newFilter(topics = filterTopics), handler) var filter = node1.subscribeFilter(initFilter(topics = filterTopics), handler)
await node1.setBloomFilter(node1.filtersToBloom()) await node1.setBloomFilter(node1.filtersToBloom())
check: check:
@ -279,7 +279,7 @@ suite "Whisper connections":
check msg.decoded.payload == repeat(byte 4, 10) check msg.decoded.payload == repeat(byte 4, 10)
f.complete(1) f.complete(1)
var filter = node1.subscribeFilter(newFilter(topics = @[topic], var filter = node1.subscribeFilter(initFilter(topics = @[topic],
allowP2P = true), handler) allowP2P = true), handler)
check: check:
node1.setPeerTrusted(toNodeId(node2.keys.pubkey)) == true node1.setPeerTrusted(toNodeId(node2.keys.pubkey)) == true

View File

@ -54,9 +54,9 @@ suite "Waku - Whisper bridge tests":
futures[1].complete(1) futures[1].complete(1)
var filter1 = whisper.subscribeFilter(nodeWhisper, var filter1 = whisper.subscribeFilter(nodeWhisper,
whisper.newFilter(topics = @[topic1]), handler1) whisper.initFilter(topics = @[topic1]), handler1)
var filter2 = waku.subscribeFilter(nodeWaku, var filter2 = waku.subscribeFilter(nodeWaku,
waku.newFilter(topics = @[topic2]), handler2) waku.initFilter(topics = @[topic2]), handler2)
check: check:
# Message should also end up in the Whisper node its queue via the bridge # Message should also end up in the Whisper node its queue via the bridge

View File

@ -73,7 +73,7 @@ suite "Waku Mail Client":
f.complete(1) f.complete(1)
let filter = subscribeFilter(client, let filter = subscribeFilter(client,
newFilter(topics = @[topic], allowP2P = true), handler) initFilter(topics = @[topic], allowP2P = true), handler)
check: check:
client.setPeerTrusted(simpleServerNode.id) client.setPeerTrusted(simpleServerNode.id)