Skip to content

Commit

Permalink
adds group keeper coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
m00sey committed Aug 23, 2023
1 parent 5c66777 commit 5de7668
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .codecov.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ coverage:
status:
project:
default:
target: 75
target: 80
paths: ["src"]
patch:
default:
Expand Down
3 changes: 1 addition & 2 deletions src/signify/core/keeping.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,6 @@ def incept(self, transferable):
self.nxts = [self.encrypter.encrypt(matter=signer).qb64 for signer in nsigners]
digers = [coring.Diger(ser=nsigner.verfer.qb64b, code=self.dcode).qb64 for nsigner in nsigners]
return verfers, digers
return verfers, digers

def rotate(self, ncodes, transferable, **_):
self.transferable = transferable
Expand Down Expand Up @@ -356,7 +355,7 @@ def rotate(self, states, rstates, **_):

return self.gkeys, self.gdigs

def sign(self, ser, indexed=True, rotate=False, **_):
def sign(self, ser, indexed=True, **_):
key = self.mhab['state']['k'][0]
ndig = self.mhab['state']['n'][0]

Expand Down
94 changes: 93 additions & 1 deletion tests/core/test_keeping.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,4 +371,96 @@ def test_randy_keeper_sign():
assert sigs == ['a signature']

verifyNoUnwantedInteractions()
unstub()
unstub()

def test_group_keeper():
from keri.core.coring import Salter
mock_salter = mock(spec=Salter, strict=True)

from signify.core.keeping import Manager
manager = Manager(salter=mock_salter)

from signify.core.keeping import GroupKeeper
gk = GroupKeeper(mgr=manager, mhab={'m': 'hab'}, states=[{'k': ['key 1']}], rstates=[{'n': ['n dig 1']}])

assert gk.gkeys == ['key 1']
assert gk.gdigs == ['n dig 1']
assert gk.mhab == {'m': 'hab'}

def test_group_keeper_incept():
from keri.core.coring import Salter
mock_salter = mock(spec=Salter, strict=True)

from signify.core.keeping import Manager
manager = Manager(salter=mock_salter)

from signify.core.keeping import GroupKeeper
gk = GroupKeeper(mgr=manager, mhab={'m': 'hab'}, states=[{'k': ['key 1']}], rstates=[{'n': ['n dig 1']}])

gkeys, gdigs = gk.incept()

assert gkeys == ['key 1']
assert gdigs == ['n dig 1']

verifyNoUnwantedInteractions()
unstub()

def test_group_keeper_rotate():
from keri.core.coring import Salter
mock_salter = mock(spec=Salter, strict=True)

from signify.core.keeping import Manager
manager = Manager(salter=mock_salter)

from signify.core.keeping import GroupKeeper
gk = GroupKeeper(mgr=manager, mhab={'m': 'hab'}, states=[{'k': ['key 1']}], rstates=[{'n': ['n dig 1']}])

gkeys, gdigs = gk.rotate(states=[{'k': ['key 2']}], rstates=[{'n': ['n dig 2']}])

assert gkeys == ['key 2']
assert gdigs == ['n dig 2']

verifyNoUnwantedInteractions()
unstub()

def test_group_keeper_sign():
from keri.core.coring import Salter
mock_salter = mock(spec=Salter, strict=True)

from signify.core.keeping import Manager
mock_manager = Manager(salter=mock_salter)

from signify.core.keeping import GroupKeeper
gk = GroupKeeper(mgr=mock_manager, mhab={'state': {'k': ['key 1'], 'n': ['n dig 1']}}, keys=['key 1'], ndigs=['n dig 1'])

from signify.core.keeping import BaseKeeper
mock_keeper = mock(strict=True)
expect(mock_manager, times=1).get({'state': {'k': ['key 1'], 'n': ['n dig 1']}}).thenReturn(mock_keeper)

expect(mock_keeper, times=1).sign(b'ser', indexed=True, indices=[0], ondices=[0]).thenReturn(['signatures'])

actual = gk.sign(b'ser', indexed=True)

assert actual == ['signatures']

verifyNoUnwantedInteractions()
unstub()

def test_group_keeper_params():
from keri.core.coring import Salter
mock_salter = mock(spec=Salter, strict=True)

from signify.core.keeping import Manager
mock_manager = Manager(salter=mock_salter)

from signify.core.keeping import GroupKeeper
gk = GroupKeeper(mgr=mock_manager, mhab={'state': {'k': ['key 1'], 'n': ['n dig 1']}}, keys=['key 1'], ndigs=['n dig 1'])

actual = gk.params()

assert actual['mhab'] == {'state': {'k': ['key 1'], 'n': ['n dig 1']}}
assert actual['keys'] == ['key 1']
assert actual['ndigs'] == ['n dig 1']

verifyNoUnwantedInteractions()
unstub()

0 comments on commit 5de7668

Please sign in to comment.