Skip to content

Commit

Permalink
Add new test where only half of nodes submit transcripts
Browse files Browse the repository at this point in the history
  • Loading branch information
theref committed Aug 9, 2024
1 parent 233209f commit 09bcfe3
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/test_infraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,27 @@ def test_no_infractions(erc20, nodes, initiator, global_allow_list, infraction_c
with ape.reverts("Ritual must have failed"):
infraction_collector.reportMissingTranscript(0, nodes, sender=initiator)

def test_partial_infractions(erc20, nodes, initiator, global_allow_list, infraction_collector, coordinator, chain):
cost = coordinator.getRitualInitiationCost(nodes, DURATION)
for node in nodes:
public_key = gen_public_key()
coordinator.setProviderPublicKey(public_key, sender=node)
erc20.approve(coordinator.address, cost, sender=initiator)
coordinator.initiateRitual(
nodes, initiator, DURATION, global_allow_list.address, sender=initiator
)
transcript = os.urandom(transcript_size(len(nodes), len(nodes)))
# post transcript for half of nodes
for node in nodes[:len(nodes) // 2]:
coordinator.postTranscript(0, transcript, sender=node)
chain.pending_timestamp += TIMEOUT * 2
infraction_collector.reportMissingTranscript(0, nodes[len(nodes) // 2:], sender=initiator)
# first half of nodes should be fine, second half should be infracted
for node in nodes[:len(nodes) // 2]:
assert infraction_collector.infractions(0, node, 0) == False
for node in nodes[len(nodes) // 2:]:
assert infraction_collector.infractions(0, node, 0) == True

def test_report_infractions(erc20, nodes, initiator, global_allow_list, infraction_collector, coordinator, chain):
cost = coordinator.getRitualInitiationCost(nodes, DURATION)
for node in nodes:
Expand Down

0 comments on commit 09bcfe3

Please sign in to comment.