Skip to content

Commit

Permalink
Fix tests that parse events with a lax Kevery to now use local=true
Browse files Browse the repository at this point in the history
… in the call to parse.

Signed-off-by: pfeairheller <[email protected]>
  • Loading branch information
pfeairheller committed Dec 30, 2023
1 parent 8a112de commit 1a1bc69
Show file tree
Hide file tree
Showing 14 changed files with 149 additions and 163 deletions.
4 changes: 2 additions & 2 deletions src/keri/app/agenting.py
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,7 @@ def msgDo(self, tymth=None, tock=0.0, **opts):
Usage:
add result of doify on this method to doers list
"""
yield from self.parser.parsator() # process messages continuously
yield from self.parser.parsator(local=True) # process messages continuously

@property
def idle(self):
Expand Down Expand Up @@ -808,7 +808,7 @@ def msgDo(self, tymth=None, tock=0.0, **opts):
Usage:
add result of doify on this method to doers list
"""
yield from self.parser.parsator() # process messages continuously
yield from self.parser.parsator(local=True) # process messages continuously

@property
def idle(self):
Expand Down
4 changes: 2 additions & 2 deletions src/keri/app/directing.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ def msgDo(self, tymth=None, tock=0.0, **opts):
yield # enter context
if self.parser.ims:
logger.info("Client %s received:\n%s\n...\n", self.hab.name, self.parser.ims[:1024])
done = yield from self.parser.parsator() # process messages continuously
done = yield from self.parser.parsator(local=True) # process messages continuously
return done # should nover get here except forced close


Expand Down Expand Up @@ -585,7 +585,7 @@ def msgDo(self, tymth=None, tock=0.0, **opts):
if self.parser.ims:
logger.info("Server %s: received:\n%s\n...\n", self.hab.name,
self.parser.ims[:1024])
done = yield from self.parser.parsator() # process messages continuously
done = yield from self.parser.parsator(local=True) # process messages continuously
return done # should nover get here except forced close


Expand Down
8 changes: 4 additions & 4 deletions src/keri/app/indirecting.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ def msgDo(self, tymth=None, tock=0.0):

if self.parser.ims:
logger.info("Client %s received:\n%s\n...\n", self.kvy, self.parser.ims[:1024])
done = yield from self.parser.parsator() # process messages continuously
done = yield from self.parser.parsator(local=True) # process messages continuously
return done # should nover get here except forced close

def escrowDo(self, tymth=None, tock=0.0):
Expand Down Expand Up @@ -382,7 +382,7 @@ def msgDo(self, tymth=None, tock=0.0):

if self.parser.ims:
logger.info("Client %s received:\n%s\n...\n", self.hab.pre, self.parser.ims[:1024])
done = yield from self.parser.parsator() # process messages continuously
done = yield from self.parser.parsator(local=True) # process messages continuously
return done # should nover get here except forced close

def cueDo(self, tymth=None, tock=0.0):
Expand Down Expand Up @@ -673,7 +673,7 @@ def msgDo(self, tymth=None, tock=0.0):
self.tock = tock
_ = (yield self.tock)

done = yield from self.parser.parsator() # process messages continuously
done = yield from self.parser.parsator(local=True) # process messages continuously
return done # should nover get here except forced close

def escrowDo(self, tymth=None, tock=0.0):
Expand Down Expand Up @@ -1072,7 +1072,7 @@ def on_post(self, req, rep):
msg = bytearray(serder.raw)
msg.extend(cr.attachments.encode("utf-8"))

self.psr.parseOne(ims=msg)
self.psr.parseOne(ims=msg, local=True)

if pre in self.hab.kevers:
kever = self.hab.kevers[pre]
Expand Down
6 changes: 3 additions & 3 deletions tests/app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ def openMultiSig(prefix="test", salt=b'0123456789abcdef', temp=True, **kwa):
count=3).qb64b) # attach cnt
evt.extend(sigs)

parsing.Parser().parse(ims=bytearray(evt), kvy=kev3)
parsing.Parser().parse(ims=bytearray(evt), kvy=kev2)
parsing.Parser().parse(ims=bytearray(evt), kvy=kev1)
parsing.Parser().parse(ims=bytearray(evt), kvy=kev3, local=True)
parsing.Parser().parse(ims=bytearray(evt), kvy=kev2, local=True)
parsing.Parser().parse(ims=bytearray(evt), kvy=kev1, local=True)

assert ghab1.pre in kev1.kevers
assert ghab1.pre in kev2.kevers
Expand Down
8 changes: 4 additions & 4 deletions tests/app/test_delegating.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ def sealer_test_do(tymth=None, tock=0.0, **opts):

witDoer.cues.popleft()
msg = next(wesHab.db.clonePreIter(pre=palHab.pre))
kvy = eventing.Kevery(db=delHby.db, local=False)
parsing.Parser().parseOne(ims=bytearray(msg), kvy=kvy)
kvy = eventing.Kevery(db=delHby.db, local=True)
parsing.Parser().parseOne(ims=bytearray(msg), kvy=kvy, local=True)

while palHab.pre not in delHby.kevers:
yield tock
Expand All @@ -107,8 +107,8 @@ def sealer_test_do(tymth=None, tock=0.0, **opts):
couple = coring.Seqner(sn=palHab.kever.sn).qb64b + palHab.kever.serder.saidb

msg = next(wesHab.db.clonePreIter(pre=palHab.pre, fn=1))
kvy = eventing.Kevery(db=delHby.db, local=False)
parsing.Parser().parseOne(ims=bytearray(msg), kvy=kvy)
kvy = eventing.Kevery(db=delHby.db, local=True)
parsing.Parser().parseOne(ims=bytearray(msg), kvy=kvy, local=True)

# Wait for the anchor. If we timeout before that happens, assertion in test will fail
while delHby.db.getAes(dgkey) != couple:
Expand Down
6 changes: 3 additions & 3 deletions tests/app/test_forwarding.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ def test_postman(seeder):

recpIcp = recpHab.makeOwnEvent(sn=0)
wesKvy = eventing.Kevery(db=wesHab.db, lax=False, local=False)
parsing.Parser().parse(ims=bytearray(recpIcp), kvy=wesKvy)
parsing.Parser().parse(ims=bytearray(recpIcp), kvy=wesKvy, local=True)
assert recpHab.pre in wesKvy.kevers

serder = serdering.SerderKERI(raw=recpIcp)
rct = wesHab.receipt(serder)

kvy = eventing.Kevery(db=hab.db)
parsing.Parser().parseOne(bytearray(recpIcp), kvy=kvy)
parsing.Parser().parseOne(bytearray(rct), kvy=kvy)
parsing.Parser().parseOne(bytearray(recpIcp), kvy=kvy, local=True)
parsing.Parser().parseOne(bytearray(rct), kvy=kvy, local=True)
kvy.processEscrows()
assert recpHab.pre in kvy.kevers

Expand Down
80 changes: 40 additions & 40 deletions tests/app/test_grouping.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ def test_counselor():
kev3 = eventing.Kevery(db=hab3.db, lax=True, local=False)

icp1 = hab1.makeOwnEvent(sn=0)
parsing.Parser().parse(ims=bytearray(icp1), kvy=kev2)
parsing.Parser().parse(ims=bytearray(icp1), kvy=kev3)
parsing.Parser().parse(ims=bytearray(icp1), kvy=kev2, local=True)
parsing.Parser().parse(ims=bytearray(icp1), kvy=kev3, local=True)
icp2 = hab2.makeOwnEvent(sn=0)
parsing.Parser().parse(ims=bytearray(icp2), kvy=kev1)
parsing.Parser().parse(ims=bytearray(icp2), kvy=kev3)
parsing.Parser().parse(ims=bytearray(icp2), kvy=kev1, local=True)
parsing.Parser().parse(ims=bytearray(icp2), kvy=kev3, local=True)
icp3 = hab3.makeOwnEvent(sn=0)
parsing.Parser().parse(ims=bytearray(icp3), kvy=kev1)
parsing.Parser().parse(ims=bytearray(icp3), kvy=kev2)
parsing.Parser().parse(ims=bytearray(icp3), kvy=kev1, local=True)
parsing.Parser().parse(ims=bytearray(icp3), kvy=kev2, local=True)

smids = [hab1.pre, hab2.pre, hab3.pre]
rmids = None # need to fixe this
Expand Down Expand Up @@ -69,7 +69,7 @@ def test_counselor():
b'"a":[]}-AABBBBkMCMWP1Z2MMd6dBPlogRd1k6mv1joiHIyb8mXvp0H4kY0DHIPM'
b'9O6udZ1Bbyf3klr4uGnLs07qcCcnKGI6GsH')

parsing.Parser().parse(ims=bytearray(evt), kvy=kev1) # parse second signed group inception
parsing.Parser().parse(ims=bytearray(evt), kvy=kev1, local=True) # parse second signed group inception
kev1.processEscrows() # Run escrows for Kevery1 to process all sigs together

counselor.processEscrows()
Expand Down Expand Up @@ -118,7 +118,7 @@ def test_counselor():

# Create group rotation from second participant

parsing.Parser().parse(ims=bytearray(msg), kvy=kev1) # parse second signed group inception
parsing.Parser().parse(ims=bytearray(msg), kvy=kev1, local=True) # parse second signed group inception
kev1.processEscrows() # Run escrows for Kevery1 so he processes all sigs together

counselor.processEscrows()
Expand Down Expand Up @@ -175,7 +175,7 @@ def test_counselor():

# Create group rotation from second participant

parsing.Parser().parse(ims=bytearray(msg), kvy=kev1) # parse second signed group inception
parsing.Parser().parse(ims=bytearray(msg), kvy=kev1, local=True) # parse second signed group inception
kev1.processEscrows() # Run escrows for Kevery1 so he processes all sigs together

counselor.processEscrows()
Expand Down Expand Up @@ -229,7 +229,7 @@ def test_counselor():

# Create group rotation from second participant

parsing.Parser().parse(ims=bytearray(msg), kvy=kev1) # parse second signed group inception
parsing.Parser().parse(ims=bytearray(msg), kvy=kev1, local=True) # parse second signed group inception
kev1.processEscrows() # Run escrows for Kevery1 so he processes all sigs together

counselor.processEscrows()
Expand All @@ -250,13 +250,13 @@ def test_the_seven():

# All the Habs, this will come in handy later
# Keverys so we can process each other's inception messages.
kev1 = eventing.Kevery(db=hab1.db, lax=True, local=False)
kev2 = eventing.Kevery(db=hab2.db, lax=True, local=False)
kev3 = eventing.Kevery(db=hab3.db, lax=True, local=False)
kev4 = eventing.Kevery(db=hab4.db, lax=True, local=False)
kev5 = eventing.Kevery(db=hab5.db, lax=True, local=False)
kev6 = eventing.Kevery(db=hab6.db, lax=True, local=False)
kev7 = eventing.Kevery(db=hab7.db, lax=True, local=False)
kev1 = eventing.Kevery(db=hab1.db)
kev2 = eventing.Kevery(db=hab2.db)
kev3 = eventing.Kevery(db=hab3.db)
kev4 = eventing.Kevery(db=hab4.db)
kev5 = eventing.Kevery(db=hab5.db)
kev6 = eventing.Kevery(db=hab6.db)
kev7 = eventing.Kevery(db=hab7.db)
kevs = [kev1, kev2, kev3, kev4, kev5, kev6, kev7]

icps = [hab1.makeOwnEvent(sn=0),
Expand All @@ -271,7 +271,7 @@ def test_the_seven():
# Introduce everyone to each other by parsing each others ICP event into our keverys
for (kev, icp) in [(kev, icp) for (kdx, kev) in enumerate(kevs) for (idx, icp) in enumerate(icps) if
kdx != idx]:
parsing.Parser().parse(ims=bytearray(icp), kvy=kev)
parsing.Parser().parse(ims=bytearray(icp), kvy=kev, local=True)

smids = [hab1.pre, hab2.pre, hab3.pre, hab4.pre, hab5.pre, hab6.pre, hab7.pre]
rmids = None # need to fixe this
Expand Down Expand Up @@ -313,7 +313,7 @@ def test_the_seven():
assert evt[serd.size:] == (b'-AABBBAD108k4sWtYRv8jQaRbzX6kDebjdzFNVCh3N9cOAJqXV5IzmKdi60Cr0Eu'
b'MaACskw0FCi73V2VX8BgFlxO8VIK')
assert serd.raw == raw
parsing.Parser().parse(ims=bytearray(evt), kvy=kev1) # parse second signed group inception
parsing.Parser().parse(ims=bytearray(evt), kvy=kev1, local=True) # parse second signed group inception

ghab3 = hby3.makeGroupHab(group=f"{prefix}_group3", mhab=hab3,
smids=smids, rmids=rmids, **inits)
Expand All @@ -322,7 +322,7 @@ def test_the_seven():
assert evt[serd.size:] == (b'-AABBCD6V2UkAovhY07MrJUNb-ICddDoyLde9i0FWclxfs7jes01YUEihfgbGERF'
b'dKDR4kSr4WF3AskrZOPvMuXipAgP')
assert serd.raw == raw
parsing.Parser().parse(ims=bytearray(evt), kvy=kev1) # parse second signed group inception
parsing.Parser().parse(ims=bytearray(evt), kvy=kev1, local=True) # parse second signed group inception

ghab4 = hby4.makeGroupHab(group=f"{prefix}_group4", mhab=hab4,
smids=smids, rmids=rmids, **inits)
Expand All @@ -331,7 +331,7 @@ def test_the_seven():
assert evt[serd.size:] == (b'-AABBDBCZuZSFWy0tFshGny1pTR47GphDljd0SShmGRpUSpBX_BeHB1tdIObizaA'
b'4GMoOcZ2sOWIe6muJPF_RaoKedYE')
assert serd.raw == raw
parsing.Parser().parse(ims=bytearray(evt), kvy=kev1) # parse second signed group inception
parsing.Parser().parse(ims=bytearray(evt), kvy=kev1, local=True) # parse second signed group inception

ghab5 = hby5.makeGroupHab(group=f"{prefix}_group5", mhab=hab5,
smids=smids, rmids=rmids, **inits)
Expand All @@ -340,7 +340,7 @@ def test_the_seven():
assert evt[serd.size:] == (b'-AABBEBsR6_hPId3H8fFG8EfevQVji8MsLAC72MjkkRxJp3h9v1vyFS1hAGGGxno'
b'F5xSHOnpBpPwjMJwOCurAa3VrNAD')
assert serd.raw == raw
parsing.Parser().parse(ims=bytearray(evt), kvy=kev1) # parse second signed group inception
parsing.Parser().parse(ims=bytearray(evt), kvy=kev1, local=True) # parse second signed group inception

ghab6 = hby6.makeGroupHab(group=f"{prefix}_group6", mhab=hab6,
smids=smids, rmids=rmids, **inits)
Expand All @@ -349,7 +349,7 @@ def test_the_seven():
assert evt[serd.size:] == (b'-AABBFCi5hK6Ax4aBNsdoUkh7Q_CcSWJfpwkeF68aCO34J3BDN7k483lOxiyj6pl'
b'8TQIQ7VJLBkoRscUMi_mls9jbpcD')
assert serd.raw == raw
parsing.Parser().parse(ims=bytearray(evt), kvy=kev1) # parse second signed group inception
parsing.Parser().parse(ims=bytearray(evt), kvy=kev1, local=True) # parse second signed group inception

ghab7 = hby7.makeGroupHab(group=f"{prefix}_group7", mhab=hab7,
smids=smids, rmids=rmids, **inits)
Expand All @@ -358,7 +358,7 @@ def test_the_seven():
assert evt[serd.size:] == (b'-AABBGCtPvRj00vEfT5Po6eH50DWfBWwAcQgvBaJ7LlYT7kQswkl_r-K9Lsxi5tm'
b'Pvsb2xFtcMJkFf-BxamGhFo9OOcD')
assert serd.raw == raw
parsing.Parser().parse(ims=bytearray(evt), kvy=kev1) # parse second signed group inception
parsing.Parser().parse(ims=bytearray(evt), kvy=kev1, local=True) # parse second signed group inception

kev1.processEscrows() # Run escrows for Kevery1 to process all sigs together

Expand Down Expand Up @@ -409,15 +409,15 @@ def test_the_seven():
msg = eventing.messagize(serder=serder, sigers=sigers)
assert msg[serder.size:] == (b'-AABABAzvHN7yC3581dp9DxFXrKuXGP_62r_pzNMXL20T6RaPQASXvnBn6sKJ78z'
b'KM9o499Zaz76j940nBoMT-yb9i8N')
parsing.Parser().parse(ims=bytearray(msg), kvy=kev1) # parse second signed group inception
parsing.Parser().parse(ims=bytearray(msg), kvy=kev1, local=True) # parse second signed group inception

# Now sign the group ROT with Hab3 and parse into Kev1. This should commit the event
sigers = hab3.mgr.sign(serder.raw, verfers=hab3.kever.verfers, indexed=True, indices=[2])
msg = eventing.messagize(serder=serder, sigers=sigers)
assert msg[serder.size:] == (b'-AABACB6z6LrzBAgpnrCopgiGxuki3sE-KAfY8t_rFq-2dIcQxRF4iCqCYNPKM9D'
b'NbZbA1WDaQ72enSsR2UWMftX2kYD')

parsing.Parser().parse(ims=bytearray(msg), kvy=kev1) # parse second signed group inception
parsing.Parser().parse(ims=bytearray(msg), kvy=kev1, local=True) # parse second signed group inception
kev1.processEscrows() # Run escrows for Kevery1 so he processes all sigs together

counselor.processEscrows() # Get the rest of the way through counselor.
Expand Down Expand Up @@ -474,15 +474,15 @@ def test_the_seven():
msg = eventing.messagize(serder=serder, sigers=sigers)
assert msg[serder.size:] == (b'-AABABC4sYnDXCpO87BMXO21ofqHZKntPSdEXlBPlq1H8NOHD3KV-GHGWrXyrElK'
b'BkQNBbNr9_yg-nSnBq7N9rAxEFcK')
parsing.Parser().parse(ims=bytearray(msg), kvy=kev1) # parse second signed group inception
parsing.Parser().parse(ims=bytearray(msg), kvy=kev1, local=True) # parse second signed group inception

# Now sign the group ROT with Hab3 and parse into Kev1. This should commit the event
sigers = hab3.mgr.sign(serder.raw, verfers=hab3.kever.verfers, indexed=True, indices=[2])
msg = eventing.messagize(serder=serder, sigers=sigers)
assert msg[serder.size:] == (b'-AABACAXyUueUfXC-ccUxBZTgnyHTXOy1wUYgQrhlk8FMJGQPiaOOdAzhaW71JeF'
b'0By8Se-tKKuPP1xG41DblgXIwNkE')

parsing.Parser().parse(ims=bytearray(msg), kvy=kev1) # parse second signed group inception
parsing.Parser().parse(ims=bytearray(msg), kvy=kev1, local=True) # parse second signed group inception
kev1.processEscrows() # Run escrows for Kevery1 so he processes all sigs together

counselor.processEscrows() # Get the rest of the way through counselor.
Expand All @@ -502,7 +502,7 @@ def test_the_seven():
msgs = [hab1.replay(), hab2.replay(), hab3.replay(), ghab.replay()]
kevs = [kev4, kev5, kev6, kev7]
for (kev, msg) in [(kev, msg) for kev in kevs for msg in msgs]:
parsing.Parser().parse(ims=bytearray(msg), kvy=kev)
parsing.Parser().parse(ims=bytearray(msg), kvy=kev, local=True)

assert kev4.kevers[ghab.pre] is not None
assert kev5.kevers[ghab.pre] is not None
Expand Down Expand Up @@ -549,15 +549,15 @@ def test_the_seven():
msg = eventing.messagize(serder=serder, sigers=sigers)
assert msg[serder.size:] == (b'-AAB2AABAEDSs99oM-KOhJ8q3H8lqGqPE3EvZxCHvCjZFvWHLzhqm91YlcskGqvK'
b'8DwCg9dj8wRZP54ienzD52EIKvJWWh4J')
parsing.Parser().parse(ims=bytearray(msg), kvy=kev4) # parse second signed group inception
parsing.Parser().parse(ims=bytearray(msg), kvy=kev4, local=True) # parse second signed group inception

# Now sign the group ROT with Hab6 and parse into Kev4. This should commit the event
sigers = hab6.mgr.sign(serder.raw, verfers=hab6.kever.verfers, indexed=True, indices=[2], ondices=[5])
msg = eventing.messagize(serder=serder, sigers=sigers)
assert msg[serder.size:] == (b'-AAB2AACAFBNVTM0Gw4rSd-S5HQ_KpmBfDedi7XNvB24ijMjQaekIfKlcdguPS8p'
b'ax9ht7EE3SiTj9fSO_3f4SVUfJMPmHIK')

parsing.Parser().parse(ims=bytearray(msg), kvy=kev4) # parse second signed group inception
parsing.Parser().parse(ims=bytearray(msg), kvy=kev4, local=True) # parse second signed group inception
kev4.processEscrows() # Run escrows for Kevery1 so he processes all sigs together

counselor4.processEscrows() # Get the rest of the way through counselor.
Expand All @@ -582,14 +582,14 @@ def openMultiSig(prefix="test", salt=b'0123456789abcdef', temp=True, **kwa):
kev3 = eventing.Kevery(db=hab3.db, lax=True, local=False)

icp1 = hab1.makeOwnEvent(sn=0)
parsing.Parser().parse(ims=bytearray(icp1), kvy=kev2)
parsing.Parser().parse(ims=bytearray(icp1), kvy=kev3)
parsing.Parser().parse(ims=bytearray(icp1), kvy=kev2, local=True)
parsing.Parser().parse(ims=bytearray(icp1), kvy=kev3, local=True)
icp2 = hab2.makeOwnEvent(sn=0)
parsing.Parser().parse(ims=bytearray(icp2), kvy=kev1)
parsing.Parser().parse(ims=bytearray(icp2), kvy=kev3)
parsing.Parser().parse(ims=bytearray(icp2), kvy=kev1, local=True)
parsing.Parser().parse(ims=bytearray(icp2), kvy=kev3, local=True)
icp3 = hab3.makeOwnEvent(sn=0)
parsing.Parser().parse(ims=bytearray(icp3), kvy=kev1)
parsing.Parser().parse(ims=bytearray(icp3), kvy=kev2)
parsing.Parser().parse(ims=bytearray(icp3), kvy=kev1, local=True)
parsing.Parser().parse(ims=bytearray(icp3), kvy=kev2, local=True)

smids = [hab1.pre, hab2.pre, hab3.pre]
rmids = None
Expand Down Expand Up @@ -620,9 +620,9 @@ def openMultiSig(prefix="test", salt=b'0123456789abcdef', temp=True, **kwa):
count=3).qb64b) # attach cnt
evt.extend(sigs)

parsing.Parser().parse(ims=bytearray(evt), kvy=kev3)
parsing.Parser().parse(ims=bytearray(evt), kvy=kev2)
parsing.Parser().parse(ims=bytearray(evt), kvy=kev1)
parsing.Parser().parse(ims=bytearray(evt), kvy=kev3, local=True)
parsing.Parser().parse(ims=bytearray(evt), kvy=kev2, local=True)
parsing.Parser().parse(ims=bytearray(evt), kvy=kev1, local=True)

assert ghab1.pre in kev1.kevers
assert ghab1.pre in kev2.kevers
Expand Down
Loading

0 comments on commit 1a1bc69

Please sign in to comment.