Check validity of set of acknowledgements

This commit is contained in:
Mark Spanbroek 2021-07-08 12:42:54 +02:00
parent db1d8d3ae8
commit 338f94b6c7
2 changed files with 14 additions and 0 deletions

View File

@ -47,3 +47,9 @@ func hasValidAck*(store: TxStore, ackHash: AckHash): bool =
return false return false
true true
func hasValidAcks*(store: TxStore, hashes: varargs[AckHash]): bool =
for hash in hashes:
if not store.hasValidAck(hash):
return false
true

View File

@ -107,3 +107,11 @@ suite "Acknowledgement validation":
store.add(bad1, bad2) store.add(bad1, bad2)
check not store.hasValidAck(bad1.hash) check not store.hasValidAck(bad1.hash)
check not store.hasValidAck(bad2.hash) check not store.hasValidAck(bad2.hash)
test "checks validity of a set of acknowledgements":
var store = TxStore.init(genesis)
store.add(tx1, tx2)
store.add(ack2)
check not store.hasValidAcks(ack1.hash, ack2.hash)
store.add(ack1)
check store.hasValidAcks(ack1.hash, ack2.hash)