include index in the nucypher-local model of participants

remotes/origin/v7.4.x
Kieran Prasch 2024-01-26 03:16:22 +01:00 committed by Derek Pierre
parent 7fa08a25ad
commit 9632f97737
5 changed files with 16 additions and 6 deletions

View File

@ -668,6 +668,7 @@ class CoordinatorAgent(EthereumContractAgent):
@dataclass
class Participant:
index: int
provider: ChecksumAddress
aggregated: bool = False
transcript: bytes = bytes()
@ -793,8 +794,9 @@ class CoordinatorAgent(EthereumContractAgent):
params += (start, end)
result = self.contract.functions.getParticipants(*params).call()
participants = list()
for r in result:
for index, r in enumerate(result, start=start):
participant = self.Ritual.Participant(
index=index,
provider=ChecksumAddress(r[0]),
aggregated=r[1],
transcript=bytes(r[2]),
@ -831,6 +833,7 @@ class CoordinatorAgent(EthereumContractAgent):
ritual_id, provider
).call()
participant = self.Ritual.Participant(
index=0,
provider=ChecksumAddress(result[0]),
aggregated=result[1],
transcript=bytes(result[2]),

View File

@ -257,6 +257,7 @@ def test_get_participation_state_start_aggregation_round_participation_not_alrea
#
def participating(*args, **kwargs):
participant = CoordinatorAgent.Ritual.Participant(
index=0,
provider=ChecksumAddress(ursula.checksum_address),
aggregated=False,
transcript=os.urandom(32),
@ -391,6 +392,7 @@ def test_get_participation_state_end_ritual_participation_not_already_tracked(
#
def participating(*args, **kwargs):
participant = CoordinatorAgent.Ritual.Participant(
index=0,
provider=ChecksumAddress(ursula.checksum_address),
aggregated=True,
transcript=os.urandom(32),
@ -420,6 +422,7 @@ def test_get_participation_state_end_ritual_participation_not_already_tracked(
#
def participating(*args, **kwargs):
participant = CoordinatorAgent.Ritual.Participant(
index=0,
provider=ChecksumAddress(ursula.checksum_address),
aggregated=False,
transcript=bytes(),
@ -453,6 +456,7 @@ def test_get_participation_state_end_ritual_participation_not_already_tracked(
#
def participating(*args, **kwargs):
participant = CoordinatorAgent.Ritual.Participant(
index=0,
provider=ChecksumAddress(ursula.checksum_address),
aggregated=False,
transcript=os.urandom(32),

View File

@ -250,7 +250,7 @@ def test_get_ritual_participant_info(ritualist, get_random_checksum_address):
# random participants
for i in range(0, 3):
participant = CoordinatorAgent.Ritual.Participant(
provider=get_random_checksum_address()
index=i, provider=get_random_checksum_address()
)
participants.append(participant)
mocked_agent.get_participants.return_value = participants

View File

@ -93,7 +93,7 @@ class MockCoordinatorAgent(MockContractAgent):
init_timestamp=init_timestamp,
end_timestamp=end_timestamp,
participants=[
self.Participant(provider=provider) for provider in providers
self.Participant(index=0, provider=provider) for provider in providers
],
dkg_size=len(providers),
threshold=self.get_threshold_for_ritual_size(len(providers)),

View File

@ -56,9 +56,10 @@ def test_initiate_ritual(
participants = [
CoordinatorAgent.Ritual.Participant(
index=i,
provider=c,
)
for c in cohort
for i, c in enumerate(cohort)
]
init_timestamp = 123456
@ -91,8 +92,9 @@ def test_perform_round_1(
get_random_checksum_address,
):
participants = dict()
for checksum_address in cohort:
for i, checksum_address in enumerate(cohort):
participants[checksum_address] = CoordinatorAgent.Ritual.Participant(
index=i,
provider=checksum_address,
)
@ -183,8 +185,9 @@ def test_perform_round_2(
get_random_checksum_address,
):
participants = dict()
for checksum_address in cohort:
for i, checksum_address in enumerate(cohort):
participant = CoordinatorAgent.Ritual.Participant(
index=i,
transcript=bytes(random_transcript),
provider=checksum_address,
)