Showdown Function Test#200
Merged
Birdmannn merged 6 commits intoPrometheus-A:v1from Sep 14, 2025
truthixify:fix-169
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR significantly enhances the test coverage for the
showdownfunction within theactions.cairocontract. Previously, theshowdownfunction, which is critical for verifying the fairness and integrity of poker rounds, lacked dedicated tests.This update introduces a suite of tests that cover a valid end-to-end showdown scenario and various edge cases, including invalid parameters, incorrect nonces (to simulate replay attacks), and mismatched signature lengths. During the development of these tests, a minor bug related to the
verify_gamefunction's expected proof lengths was identified and fixed. Additionally, a helper functionsetup_valid_showdownwas extracted to reduce code repetition across tests.Related Issues
Closes #169
Changes Made - [ ]
test_showdown_valid_caseto verify successful execution with correct parameters and signatures.test_showdown_replay_attack_invalid_nonceto ensure the contract correctly rejects transactions with an incorrect nonce, preventing replay attacks.test_showdown_invalid_salt_lengthto validate proper error handling when incorrect salt lengths are provided.test_showdown_signature_length_mismatchto check for robust input validation on signature array lengths.test_showdown_game_not_in_showdown_stateto confirm the function fails if the game is not in the appropriate state.test_showdown_insufficient_community_cardsto test scenarios where the community cards array is not fully populated.test_showdown_player_not_in_roundto ensure only active players can participate in showdown.test_showdown_invalid_signature_recoveryto test failure when signature components are malformed leading to failed public key recovery.test_showdown_multiple_hands_validto test the scenario with multiple players submitting valid hands.setup_valid_showdownto improve test readability and maintainability.verify_gameutility that incorrectly assumed the total number of game proofs and dealt card proofs, instead of dynamically checking based on the number of hands. The fix ensuresverify_gameexpectshands.len() * 2proofs for bothgame_proofsanddealt_card_proofs.How to Test
Screenshots (if applicable)
Checklist