-
Notifications
You must be signed in to change notification settings - Fork 7
Feat/foreign trait testing #273
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| from typing import List | ||
|
|
||
|
|
||
| class PythonComposer: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the FFI Composer implements the ComposerTrait why do we need another wrapper?
Implement Foreign Trait Testing Method with control flow inversion (Python manages async, Rust orchestrates test logic). - Add test fixtures and asset freeze test suite - Add register_account to TransactionSignerGetter trait - Implement Python foreign traits (PythonAlgodClient, PythonComposerFactory) - Fix HTTP error handling with HttpError.RequestError
Remove algod_client and signer_getter parameters from all ComposerTrait methods. These dependencies are now stored internally when the composer is created, eliminating redundant parameter passing throughout the API.
955c757 to
47c2512
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements cross-language FFI testing infrastructure using foreign traits to enable Python-side async test orchestration with Rust business logic. The changes establish a pattern where Python controls async execution while delegating transaction composition to Rust's FFI Composer.
Key changes:
- Add foreign trait pattern for cross-language testing with traits for composition, factory pattern, signing, and algod operations
- Implement Python wrapper (PythonComposer) that delegates to Rust FFI Composer with stateful API design
- Add comprehensive FFI test coverage for asset freeze/unfreeze workflows
Reviewed Changes
Copilot reviewed 17 out of 18 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/python/algokit_utils/tests/test_utils.py | Refactored test utilities with improved signer implementations and skipped existing tests |
| packages/python/algokit_utils/tests/test_ffi_async.py | New async FFI test for asset freeze operations using foreign trait pattern |
| packages/python/algokit_utils/algokit_utils/ffi_composer.py | Python wrapper for Rust Composer with async trait compatibility and stateful design |
| packages/python/algokit_utils/algokit_utils/ffi_algod_client.py | Python implementation of AlgodClientTrait for async algod operations |
| packages/python/algokit_utils/algokit_utils.code-workspace | New VS Code workspace configuration |
| crates/algokit_utils_ffi/src/transactions/composer.rs | Major refactor removing redundant parameters and implementing foreign trait pattern |
| crates/algokit_utils_ffi/src/transactions/common.rs | Added register_account method to TransactionSignerGetter trait |
| crates/algokit_utils_ffi/src/transactions/app_call.rs | Reorganized imports and cleaned up parameter usage |
| crates/algokit_utils_ffi/src/tests/ | New test infrastructure with fixtures, account management, and asset freeze tests |
| crates/algokit_utils_ffi/src/lib.rs | Added tests module to library |
| crates/algokit_utils_ffi/Cargo.toml | Added dependencies for testing infrastructure |
Comments suppressed due to low confidence (1)
packages/python/algokit_utils/tests/test_utils.py:1
- The variable
bool_typeis used but not defined in this diff. This will cause a NameError at runtime.
from typing import override
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
joe-p
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Some things we definitely want to change before prod but shouldn't block this PR.
Also question: Do we want to keep the test_utils.py file now that we have the trait-based testing?
|
🎉 This PR is included in version 1.0.0-alpha.74 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Foreign Trait Testing
Implements cross-language FFI testing infrastructure using foreign traits to enable Python-side async test orchestration with Rust business logic. This allows Python tests to control async execution while delegating transaction composition to Rust's FFI Composer.
Key changes:
ComposerTrait- transaction composition with all transaction typesComposerFactory- factory pattern for creating fresh composer instancesTransactionSigner- async transaction signing interfaceTransactionSignerGetter- retrieve signers by addressAlgodClientTrait- algod client operationsPythonComposer) that delegates to Rust FFIComposerTests Passing