Skip to content

Feature/contract token balance equals 2x stake after both deposits#302

Open
Abdulmajeed82 wants to merge 252 commits intoStellarCheckMate:mainfrom
Abdulmajeed82:feature/contract-token-balance-equals-2x-stake-after-both-deposits
Open

Feature/contract token balance equals 2x stake after both deposits#302
Abdulmajeed82 wants to merge 252 commits intoStellarCheckMate:mainfrom
Abdulmajeed82:feature/contract-token-balance-equals-2x-stake-after-both-deposits

Conversation

@Abdulmajeed82
Copy link
Copy Markdown
Contributor

closes #177

jxsonyx and others added 30 commits March 24, 2026 22:41
The merge of upstream changes into this branch produced a mangled test
block where test_non_oracle_cannot_submit_result and
test_cancel_active_match_fails_with_invalid_state were interleaved into
a single broken function. Also, test_ttl_extended_on_submit_result was
still using the old 2-argument submit_result signature.

- Reconstruct both tests as separate, correct functions
- Update test_ttl_extended_on_submit_result to pass &oracle as caller
- All 22 tests now pass cleanly

Closes StellarCheckMate#27
- Add AllowedToken(Address) to DataKey enum
- Add TokenNotAllowed and TokenAlreadyAllowed errors
- Implement add_allowed_token() and remove_allowed_token() admin functions
- Add is_token_allowed() query function
- Validate token in create_match() against allowlist
- Add comprehensive tests for token allowlist functionality

Fixes StellarCheckMate#52
…acle-auth-submit-result

feat: enforce strict oracle authorization for submit_result
…atch-test

test: add get match match id test
eposit emits no event when match transitions to Active
…-unpause-events

fix(escrow): emit events on pause and unpause (StellarCheckMate#84)
- Added client.add_allowed_token(&token_addr) in setup() function
- This fixes CI failures where tests failed because create_match
  now requires tokens to be in the allowlist (PR StellarCheckMate#89)
- Kept our 5 new tests (non-admin pause/unpause auth, cancel refund scenarios)
- Kept main's 2 new tests (pause/unpause event emission)
- Applied main's lib.rs changes (pause/unpause now emit events)
- All 36 tests pass
Add security and refund coverage tests for escrow contract
…state

Add InvalidState guard tests and Match timestamp field
…rCheckMate#52)

- Add DataKey::AllowedToken(Address) variant to DataKey enum
- Add Error::TokenNotAllowed = 11 to the Error enum
- Add admin functions: add_allowed_token, remove_allowed_token, is_allowed_token
- Reject create_match if the token is not on the admin-managed allowlist
- Update setup() helper to register the test token as allowed
- Add 6 new tests covering allowed/disallowed token scenarios and
  non-admin access control for allowlist management
…e#65)

- test_player1_cannot_deposit_twice: player1 deposits successfully then
  calls deposit again, asserts Error::AlreadyFunded
- test_player2_cannot_deposit_twice: same coverage for player2
- Add MatchNotExpired = 11 error variant
- Add MATCH_TIMEOUT_LEDGERS constant (~24h at 5s/ledger)
- Add expire_match() — permissionless, refunds depositor(s) and
  cancels any Pending match not fully funded within the timeout window
- Add 4 tests: early expiry rejected, refund after timeout,
  expired event emitted, active match cannot be expired
yahia008 and others added 30 commits March 28, 2026 14:32
…es-not-verify-the-caller-is-the-oracle-before-state-check

submit-result-does-not-verify-the-caller-is-the-oracle-before-state-c…
…ist-all-active-matches-no-global-match-index

Fix no way to list all active matches no global match index
…-Escrow148

feature:Fix: deposit does not emit event  no way to detect partial fu…
…dress-not-validated

fix: validate token address against allowlist in create_match (StellarCheckMate#52)
…ist-validation

fix: add token allowlist validation for create_match
…-cannot-deposit-twice

test: player cannot deposit twice for the same match (StellarCheckMate#65)
…test/oracle-get-result-not-found

test: verify get_result returns ResultNotFound for unknown match id
…test/unpause-restores-create-match

test: verify unpause restores create_match functionality
…test

feat: oracle.get_result on non-existent match_id should return Result…
feat: implement player match indexing and get_player_matches getter
…it-result-pot-overflow

Fix StellarCheckMate#170: use checked_mul to prevent pot overflow in submit_result
…-169-overflow-guard-max-stake

feat: add overflow guard for pot calculation and test with i128::MAX …
…-174-is-initialized

feat: add is_initialized() helper and test (StellarCheckMate#174)
…-137-state-transition-pending-active

test: explicitly assert Pending -> Active state transition (StellarCheckMate#137)
…e-181-test-oracle-submit_result

feat: Add Test: oracle submit_result is blocked when oracle contract …
…e-187-match-never-existed

feat: distinguish MatchNotFound vs MatchStorageExpired
…ow-state-test

feat(testing): add escrow state transition tests for all winner variants
Fixes missing test for contract holding exactly 2 * stake_amount post-deposits.

Also fixed duplicate enum variants and missing DataKey variants in types.rs, lib.rs for compilation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Test: contract token balance equals 2x stake after both deposits