Skip to content

test: implement test helpers and initialization tests (#607)#640

Merged
yusuftomilola merged 1 commit intoDistinctCodes:mainfrom
BigBen-7:feat/test-helpers
Mar 9, 2026
Merged

test: implement test helpers and initialization tests (#607)#640
yusuftomilola merged 1 commit intoDistinctCodes:mainfrom
BigBen-7:feat/test-helpers

Conversation

@BigBen-7
Copy link
Contributor

@BigBen-7 BigBen-7 commented Mar 8, 2026

Description:
This PR establishes the foundational testing boilerplate for the workspace_booking smart contract. It introduces reusable helper functions for the test suite and verifies the core one-time initialization logic of the contract.
closes #607

Key Changes:

  • Test Module Setup: Created the contracts/workspace_booking/src/test.rs file with the #![cfg(test)] attribute and necessary Soroban SDK imports.

  • Shared Helper Functions: * setup_contract: Registers the WorkspaceBookingContract and returns its address.

  • setup_token: Registers a mock Stellar Asset Contract, mints tokens to a recipient, and returns the token address.

  • advance_time: A utility to fast-forward the ledger timestamp for time-based testing.

  • Initialization Tests:

  • test_initialize_success: Verifies that calling initialize correctly sets the admin and payment token using mock_all_auths().

  • test_initialize_twice_fails: Ensures that attempting to initialize an already initialized contract panics with the expected AlreadyInitialized = 3 error.

Acceptance Criteria Met:

  • cargo test -p workspace_booking test_initialize_success passes.
  • cargo test -p workspace_booking test_initialize_twice_fails passes.
  • All 3 helper functions (setup_contract, setup_token, advance_time) are present and functional.
  • cargo clippy -p workspace_booking -- -D warnings passes with no warnings.

@vercel
Copy link

vercel bot commented Mar 8, 2026

@BigBen-7 is attempting to deploy a commit to the naijabuz's projects Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Collaborator

@yusuftomilola yusuftomilola left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution

@yusuftomilola yusuftomilola merged commit 8fdb5f4 into DistinctCodes:main Mar 9, 2026
2 of 7 checks passed
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.

Issue #7 — Test Helpers & Initialization Tests

2 participants