test: add security, gas benchmark, cross-contract, and event emission tests (#286, #287, #288, #289) - #383
Merged
DeFiVC merged 4 commits intoAug 31, 2026
Conversation
…ficial#289) Verifies that double-spending is impossible across all contracts: - Double-claim reward is prevented with clear error message - Double-mint credential is prevented with clear error message - Double-enroll is prevented with clear error message - Double-complete module and double-submit quiz are prevented - Double-revoke credential is prevented - State is not corrupted after failed double-spend attempts - Cross-contract operations (claim + mint) are independent All error messages are clear and specific.
Tests verify learn-token -> progress-tracker cross-contract calls: - claim_reward correctly fetches score and calculates reward - Score 0 (unsubmitted quiz) causes cross-contract call failure - Non-existent quiz and course produce clear error messages - Failed cross-contract calls do not corrupt token state - batch_claim_reward handles mixed success and failure gracefully - Progress-tracker state is unaffected by token claims - Cross-contract calls are isolated per learner
…fficial#288) Measures CPU instruction costs via env.budget() for each contract function: - ProgressTracker: create_course, enroll, complete_module, submit_quiz_score, get_progress - LearnToken: claim_reward, transfer, approve, transfer_from, mint, burn - CredentialNft: mint_credential, verify_credential, revoke_credential Includes: - Regression detection comparing batch vs individual claim costs - Full end-to-end flow benchmark (enroll→complete→claim→mint) - Results are repeatable with fresh environments per test - Ratios are relative (not absolute) for cross-host stability
Verifies all events are emitted with correct topics and data: ProgressTracker events: - course_created, enrolled (with timestamp), module_completed, quiz_submitted, credential_eligible, quiz_retaken, course_archived LearnToken events: - mint, transfer (indexed topics), burn, approve, reward_claimed, role_granted, role_revoked, max_supply_updated, vesting_created CredentialNft events: - credential_minted (with metadata_uri), credential_revoked (indexed, with audit details) All event topics and data payloads are verified for correctness.
|
@markdavid000 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
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.
Resolves
closes #286
closes #287
closes #288
closes #289
Changes
tests/integration/security_double_spending_tests.rs
. Add gas benchmark tests #288 — Gas benchmark tests
tests/benchmarks/gas_benchmarks.rs
. Add unit test for cross-contract calls #287 — Cross-contract call unit tests
tests/unit/xcontract_call_tests.rs
. Add unit test for event emissions #286 — Event emission unit tests
tests/unit/event_emission_tests.rs