[Feature Request]: Support for 0x1 #[test_only] Functions in Local Testnet and for Publishing Move Modules #14647
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
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 currentaptos node run-local-testnet
command does not publish the0x1
modules with their#[test_only]
functions, such asaptos_framework::timestamp
oraptos_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, oraptos_framework::account::create_account_for_test
for impersonating accounts in a local testnet.Pitch
Introduce a
--include-test-only
flag to both theaptos node run-local-testnet
andaptos move publish
commands. This flag would enable the publishing of0x1
modules along with their#[test_only]
functions in a local testnet environment. Specifically:For
aptos node run-local-testnet
:--include-test-only
0x1
modules along with their#[test_only]
functions, allowing developers to test time-sensitive and other test-specific logic locally.For
aptos move publish
:--include-test-only
#[test_only]
functions included, facilitating the deployment and testing of modules that contain test-specific logic.aptos move publish --profile local --include-test-only
Describe alternatives you've considered
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 therun-local-testnet
andmove publish
commands ensures consistency and ease of use, allowing developers to effortlessly toggle test-specific functionalities during development and testing phases.The text was updated successfully, but these errors were encountered: