mirror of https://github.com/status-im/nim-eth.git
rename newFilter to initFilter for correctness
This commit is contained in:
parent
3527d47cb5
commit
cb2bc388f1
|
@ -572,7 +572,7 @@ proc add*(self: var Queue, msg: Message): bool =
|
|||
return true
|
||||
|
||||
# Filters ----------------------------------------------------------------------
|
||||
proc newFilter*(src = none[PublicKey](), privateKey = none[PrivateKey](),
|
||||
proc initFilter*(src = none[PublicKey](), privateKey = none[PrivateKey](),
|
||||
symKey = none[SymKey](), topics: seq[Topic] = @[],
|
||||
powReq = 0.0, allowP2P = false): Filter =
|
||||
# Zero topics will give an empty bloom filter which is fine as this bloom
|
||||
|
|
|
@ -117,20 +117,20 @@ if config.watch:
|
|||
echo msg.decoded.payload.repr
|
||||
|
||||
# filter encrypted asym
|
||||
discard node.subscribeFilter(newFilter(privateKey = some(encPrivateKey),
|
||||
discard node.subscribeFilter(initFilter(privateKey = some(encPrivateKey),
|
||||
topics = @[topic]),
|
||||
handler)
|
||||
# filter encrypted asym + signed
|
||||
discard node.subscribeFilter(newFilter(some(signPublicKey),
|
||||
discard node.subscribeFilter(initFilter(some(signPublicKey),
|
||||
privateKey = some(encPrivateKey),
|
||||
topics = @[topic]),
|
||||
handler)
|
||||
# filter encrypted sym
|
||||
discard node.subscribeFilter(newFilter(symKey = some(symKey),
|
||||
discard node.subscribeFilter(initFilter(symKey = some(symKey),
|
||||
topics = @[topic]),
|
||||
handler)
|
||||
# filter encrypted sym + signed
|
||||
discard node.subscribeFilter(newFilter(some(signPublicKey),
|
||||
discard node.subscribeFilter(initFilter(some(signPublicKey),
|
||||
symKey = some(symKey),
|
||||
topics = @[topic]),
|
||||
handler)
|
||||
|
|
|
@ -269,7 +269,7 @@ suite "Whisper filter":
|
|||
let msg = prepFilterTestMsg(symKey = some(symKey), topic = topic)
|
||||
|
||||
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)
|
||||
|
||||
notify(filters, msg)
|
||||
|
@ -287,7 +287,7 @@ suite "Whisper filter":
|
|||
topic = topic)
|
||||
|
||||
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)
|
||||
|
||||
notify(filters, msg)
|
||||
|
@ -304,7 +304,7 @@ suite "Whisper filter":
|
|||
let msg = prepFilterTestMsg(src = some(privKey), topic = topic)
|
||||
|
||||
var filters = initTable[string, Filter]()
|
||||
let filter = newFilter(src = some(privKey.getPublicKey()),
|
||||
let filter = initFilter(src = some(privKey.getPublicKey()),
|
||||
topics = @[topic])
|
||||
let filterId = filters.subscribeFilter(filter)
|
||||
|
||||
|
@ -328,9 +328,9 @@ suite "Whisper filter":
|
|||
var filters = initTable[string, Filter]()
|
||||
let
|
||||
filterId1 = filters.subscribeFilter(
|
||||
newFilter(topics = @[topic], powReq = 0.014492753623188406))
|
||||
initFilter(topics = @[topic], powReq = 0.014492753623188406))
|
||||
filterId2 = filters.subscribeFilter(
|
||||
newFilter(topics = @[topic], powReq = 0.014492753623188407))
|
||||
initFilter(topics = @[topic], powReq = 0.014492753623188407))
|
||||
|
||||
notify(filters, msg)
|
||||
|
||||
|
@ -347,8 +347,8 @@ suite "Whisper filter":
|
|||
|
||||
var filters = initTable[string, Filter]()
|
||||
let
|
||||
filterId1 = filters.subscribeFilter(newFilter(topics = @[topic1]))
|
||||
filterId2 = filters.subscribeFilter(newFilter(topics = @[topic2]))
|
||||
filterId1 = filters.subscribeFilter(initFilter(topics = @[topic1]))
|
||||
filterId2 = filters.subscribeFilter(initFilter(topics = @[topic2]))
|
||||
|
||||
notify(filters, msg)
|
||||
|
||||
|
|
|
@ -59,17 +59,17 @@ suite "Whisper connections":
|
|||
|
||||
# Filters
|
||||
# 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))
|
||||
# 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),
|
||||
topics = @[topic]), handler2))
|
||||
# filter for encrypted sym
|
||||
filters.add(node1.subscribeFilter(newFilter(symKey = some(symKey),
|
||||
filters.add(node1.subscribeFilter(initFilter(symKey = some(symKey),
|
||||
topics = @[topic]), handler3))
|
||||
# filter for encrypted sym + signed
|
||||
filters.add(node1.subscribeFilter(newFilter(some(signKeyPair.pubkey),
|
||||
filters.add(node1.subscribeFilter(initFilter(some(signKeyPair.pubkey),
|
||||
symKey = some(symKey),
|
||||
topics = @[topic]), handler4))
|
||||
# Messages
|
||||
|
@ -113,8 +113,8 @@ suite "Whisper connections":
|
|||
check msg.decoded.payload == payloads[1]
|
||||
futures[1].complete(1)
|
||||
|
||||
var filter1 = node1.subscribeFilter(newFilter(topics = @[topic1]), handler1)
|
||||
var filter2 = node1.subscribeFilter(newFilter(topics = @[topic2]), handler2)
|
||||
var filter1 = node1.subscribeFilter(initFilter(topics = @[topic1]), handler1)
|
||||
var filter2 = node1.subscribeFilter(initFilter(topics = @[topic2]), handler2)
|
||||
|
||||
check:
|
||||
node2.postMessage(ttl = safeTTL + 1, topic = topic1,
|
||||
|
@ -142,9 +142,9 @@ suite "Whisper connections":
|
|||
check msg.decoded.payload == payload
|
||||
futures[1].complete(1)
|
||||
|
||||
var filter1 = node1.subscribeFilter(newFilter(topics = @[topic], powReq = 0),
|
||||
var filter1 = node1.subscribeFilter(initFilter(topics = @[topic], powReq = 0),
|
||||
handler1)
|
||||
var filter2 = node1.subscribeFilter(newFilter(topics = @[topic],
|
||||
var filter2 = node1.subscribeFilter(initFilter(topics = @[topic],
|
||||
powReq = 1_000_000), handler2)
|
||||
|
||||
check:
|
||||
|
@ -163,7 +163,7 @@ suite "Whisper connections":
|
|||
let topic = [byte 0, 0, 0, 0]
|
||||
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):
|
||||
check node2.postMessage(ttl = safeTTL, topic = topic,
|
||||
payload = payload) == true
|
||||
|
@ -179,7 +179,7 @@ suite "Whisper connections":
|
|||
asyncTest "Local filter notify":
|
||||
let topic = [byte 0, 0, 0, 0]
|
||||
|
||||
var filter = node1.subscribeFilter(newFilter(topics = @[topic]))
|
||||
var filter = node1.subscribeFilter(initFilter(topics = @[topic]))
|
||||
check:
|
||||
node1.postMessage(ttl = safeTTL, topic = topic,
|
||||
payload = repeat(byte 4, 10)) == true
|
||||
|
@ -198,7 +198,7 @@ suite "Whisper connections":
|
|||
proc handler(msg: ReceivedMessage) =
|
||||
check msg.decoded.payload == payload
|
||||
f.complete(1)
|
||||
var filter = node1.subscribeFilter(newFilter(topics = filterTopics), handler)
|
||||
var filter = node1.subscribeFilter(initFilter(topics = filterTopics), handler)
|
||||
await node1.setBloomFilter(node1.filtersToBloom())
|
||||
|
||||
check:
|
||||
|
@ -279,7 +279,7 @@ suite "Whisper connections":
|
|||
check msg.decoded.payload == repeat(byte 4, 10)
|
||||
f.complete(1)
|
||||
|
||||
var filter = node1.subscribeFilter(newFilter(topics = @[topic],
|
||||
var filter = node1.subscribeFilter(initFilter(topics = @[topic],
|
||||
allowP2P = true), handler)
|
||||
check:
|
||||
node1.setPeerTrusted(toNodeId(node2.keys.pubkey)) == true
|
||||
|
|
|
@ -54,9 +54,9 @@ suite "Waku - Whisper bridge tests":
|
|||
futures[1].complete(1)
|
||||
|
||||
var filter1 = whisper.subscribeFilter(nodeWhisper,
|
||||
whisper.newFilter(topics = @[topic1]), handler1)
|
||||
whisper.initFilter(topics = @[topic1]), handler1)
|
||||
var filter2 = waku.subscribeFilter(nodeWaku,
|
||||
waku.newFilter(topics = @[topic2]), handler2)
|
||||
waku.initFilter(topics = @[topic2]), handler2)
|
||||
|
||||
check:
|
||||
# Message should also end up in the Whisper node its queue via the bridge
|
||||
|
|
|
@ -73,7 +73,7 @@ suite "Waku Mail Client":
|
|||
f.complete(1)
|
||||
|
||||
let filter = subscribeFilter(client,
|
||||
newFilter(topics = @[topic], allowP2P = true), handler)
|
||||
initFilter(topics = @[topic], allowP2P = true), handler)
|
||||
|
||||
check:
|
||||
client.setPeerTrusted(simpleServerNode.id)
|
||||
|
|
Loading…
Reference in New Issue