From 09bcfe38e4026b9c4529e7e98f84296512434242 Mon Sep 17 00:00:00 2001 From: James Campbell Date: Fri, 9 Aug 2024 17:11:32 +0200 Subject: [PATCH] Add new test where only half of nodes submit transcripts --- tests/test_infraction.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/test_infraction.py b/tests/test_infraction.py index 310ad382..cf817e4c 100644 --- a/tests/test_infraction.py +++ b/tests/test_infraction.py @@ -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: