Skip to content
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

[Feature Request]: Support for 0x1 #[test_only] Functions in Local Testnet and for Publishing Move Modules #14647

Open
mshakeg opened this issue Sep 16, 2024 · 0 comments
Labels
enhancement New feature or request move-framework Issues related to the Framework modules/libraries stale-exempt Prevents issues from being automatically marked and closed as stale

Comments

@mshakeg
Copy link

mshakeg commented Sep 16, 2024

Motivation

Developers working with the Aptos blockchain and the Move language often need to write and test modules that include #[test_only] annotations. These annotations are crucial for creating unit tests and simulating time-dependent logic. However, the current aptos node run-local-testnet command does not publish the 0x1 modules with their #[test_only] functions, such as aptos_framework::timestamp or aptos_framework::account. This limitation restricts developers from effectively testing their Move modules in a local environment, hindering the development and testing workflow.

Example Issue: Currently, time-dependent functions like aptos_framework::timestamp::fast_forward_seconds are not available in the local testnet, making it difficult to test scenarios that rely on time manipulation, or aptos_framework::account::create_account_for_test for impersonating accounts in a local testnet.

Pitch

Introduce a --include-test-only flag to both the aptos node run-local-testnet and aptos move publish commands. This flag would enable the publishing of 0x1 modules along with their #[test_only] functions in a local testnet environment. Specifically:

  1. For aptos node run-local-testnet:

    • Flag: --include-test-only
    • Functionality: When this flag is used, the local testnet will publish the 0x1 modules along with their #[test_only] functions, allowing developers to test time-sensitive and other test-specific logic locally.
    • Usage Example:
      aptos node run-local-testnet --include-test-only
  2. For aptos move publish:

    • Flag: --include-test-only
    • Functionality: This flag allows developers to publish their Move modules to the local testnet with #[test_only] functions included, facilitating the deployment and testing of modules that contain test-specific logic.
    • Usage Example:
      aptos move publish --profile local --include-test-only

Describe alternatives you've considered

  • Manual Module Publishing: Developers could manually modify and publish 0x1 modules with #[test_only] functions, but this approach is error-prone and not streamlined.

Additional context

The ability to include #[test_only] annotations in the local testnet environment is essential for comprehensive testing of Move modules. By enabling these test-only functions, developers can simulate various scenarios, including time manipulation and other test-specific logic, without affecting the production environment. This enhancement would streamline the development workflow, reduce potential bugs, and improve the overall quality and reliability of Move modules deployed on the Aptos blockchain.

Implementing the --include-test-only flag in both the run-local-testnet and move publish commands ensures consistency and ease of use, allowing developers to effortlessly toggle test-specific functionalities during development and testing phases.

@mshakeg mshakeg added the enhancement New feature or request label Sep 16, 2024
@sausagee sausagee added move-framework Issues related to the Framework modules/libraries stale-exempt Prevents issues from being automatically marked and closed as stale labels Sep 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request move-framework Issues related to the Framework modules/libraries stale-exempt Prevents issues from being automatically marked and closed as stale
Projects
None yet
Development

No branches or pull requests

2 participants