Add minimal test suite for transaction signing and verification#55
Add minimal test suite for transaction signing and verification#55shrilakshmikakati wants to merge 4 commits intoStabilityNexus:mainfrom
Conversation
Signed-off-by: shrilakshmikakati <shrilakshmikakati@gmail.com>
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughAdds a new pytest module that verifies MiniChain Transaction signing and verification, tamper detection (amount/receiver/nonce), invalid/mismatched sender handling, unsigned transaction rejection, and nonce-based replay protection with state updates. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related issues
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@tests/test_transaction_signing.py`:
- Line 20: The test currently uses a unittest.TestCase class
(TestTransactionSigning); migrate to pytest-style by replacing the
TestTransactionSigning class and its methods with standalone test_ functions,
switch unittest assertions (e.g., self.assertEqual, self.assertTrue,
self.assertRaises) to plain assert statements and pytest.raises for exception
checks, and remove any unittest.TestCase inheritance and setUp/tearDown in favor
of fixtures or module-level setup; update imports to remove unittest and add
pytest where needed.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 6161b5ab-bd00-4b1b-8f82-88534df2f92f
📒 Files selected for processing (1)
tests/test_transaction_signing.py
Signed-off-by: shrilakshmikakati <shrilakshmikakati@gmail.com>
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@tests/test_transaction_signing.py`:
- Around line 168-184: Add an assertion that the sender's nonce advanced to 2
after applying two sequential transactions in test_sequential_nonces_accepted:
after the existing balance checks, fetch Alice's account via
funded_state.get_account(alice_pk) and assert its "nonce" field equals 2 to
ensure replay-protection bookkeeping is updated (reference:
test_sequential_nonces_accepted, funded_state.get_account).
- Around line 145-165: In both test_replay_attack_same_nonce_rejected and
test_out_of_order_nonce_rejected, snapshot Alice’s pre-call account state
(balance and nonce) from funded_state for alice_pk, call
funded_state.apply_transaction(tx) as currently done, and after the rejected
call assert that funded_state still reports the same balance and nonce for
alice_pk (i.e., no mutation occurred). Reference the Transaction instance (tx),
the funded_state.apply_transaction method, and the alice_pk key when taking and
comparing the before/after snapshots to ensure rejected submissions are
side-effect free.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 2171a8ad-ed1b-4a4b-b72f-4d620e8e4641
📒 Files selected for processing (1)
tests/test_transaction_signing.py
…ancement Signed-off-by: shrilakshmikakati <shrilakshmikakati@gmail.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@tests/test_transaction_signing.py`:
- Around line 6-11: Update the module docstring summary so bullet 3 accurately
reflects the API: instead of saying the wrong sender key "fails verification,"
state that Transaction.sign(...) raises a ValueError when the provided signing
key does not match the transaction sender; locate the header in
tests/test_transaction_signing.py and adjust the wording to mention signing-time
rejection by Transaction.sign rather than post-signature verification.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: ff082096-6caf-404b-b96a-a59f0f1f4ca7
📒 Files selected for processing (1)
tests/test_transaction_signing.py
…re for case 3 Signed-off-by: shrilakshmikakati <shrilakshmikakati@gmail.com>
Addressed Issues:
Fixes #(TODO:issue number)
Screenshots/Recordings:
TODO: If applicable, add screenshots or recordings that demonstrate the interface before and after the changes.
Additional Notes:
AI Usage Disclosure:
We encourage contributors to use AI tools responsibly when creating Pull Requests. While AI can be a valuable aid, it is essential to ensure that your contributions meet the task requirements, build successfully, include relevant tests, and pass all linters. Submissions that do not meet these standards may be closed without warning to maintain the quality and integrity of the project. Please take the time to understand the changes you are proposing and their impact. AI slop is strongly discouraged and may lead to banning and blocking. Do not spam our repos with AI slop.
Check one of the checkboxes below:
I have used the following AI models and tools: TODO
Checklist
After Adding Testcases

Summary by CodeRabbit