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]: aptos move test Should Prioritize [dev-addresses] Over [addresses] #14882

Open
mshakeg opened this issue Oct 5, 2024 · 1 comment
Labels
enhancement New feature or request stale-exempt Prevents issues from being automatically marked and closed as stale

Comments

@mshakeg
Copy link

mshakeg commented Oct 5, 2024

Description

When running tests with aptos move test, the CLI attempts to resolve addresses from the [addresses] section of the Move.toml file, even when [dev-addresses] are defined specifically for testing. This causes address conflicts, especially when placeholder values (like _) are used in the [addresses] section for production or deployment.

The following error occurs when the same named address is used in both sections:

Error: Unable to resolve named address 'staking_contract' in package 'ExamplePackage' when resolving dependencies in dev mode: Attempted to assign a different value '0x9' to an already-assigned named address '0xabc123...'

Current Workaround:
The current way to avoid this is to either:

  • Temporarily comment out the [dev-addresses] section, or
  • Replace placeholders in [addresses] with underscores (_).

Proposed Solution

It would be more efficient if aptos move test prioritized addresses from [dev-addresses] when running in dev mode. This would allow for smooth local testing without having to temporarily adjust or remove entries from the [addresses] or [dev-addresses] sections.

This change would improve the development experience, especially since the typical workflow involves using specific addresses for local testing first and production addresses later on.

Sample Move.toml:

[package]
name = "ExamplePackage"
version = "1.0.0"
license = "MIT"
authors = ["Dev1", "Dev2"]
upgrade_policy = "immutable"

# Production addresses, using placeholders for now
[addresses]
publisher = "_"
staker_resource_account = "_"

# Dev addresses for local testing
[dev-addresses]
publisher = "0x9"
staker_resource_account = "0x8d..."

[dependencies.Framework]
git = "https://github.com/example/example-core.git"
rev = "mainnet"
subdir = "move/framework"

[dev-dependencies]

Versions:

  • aptos 4.2.2

Related Issues:

#7228

@mshakeg mshakeg added the enhancement New feature or request label Oct 5, 2024
@mshakeg
Copy link
Author

mshakeg commented Oct 7, 2024

imo there should also be a way to specify the [addresses] per live network(e.g. mainnet, testnet, devnet or even other custom networks) for example something like:

# ...

[network]
default = "mainnet" # Specify default network (optional)

[network.mainnet]
my_staking = "0x1"
my_staking_resource_account = "0x2"

[network.testnet]
my_staking = "0x4"
my_staking_resource_account = "0x5"

[network.devnet]
my_staking = "0x7"
my_staking_resource_account = "0x8"

[network.customnet]
rpc_url = "https://custom-rpc-url.com" # Custom RPC URL for non-default networks
my_staking = "0xCustom1"
my_staking_resource_account = "0xCustom2"

[dev-addresses]
my_staking = "0xDev1"
my_staking_resource_account = "0xDev2"

# ...

@brmataptos brmataptos added the stale-exempt Prevents issues from being automatically marked and closed as stale label Oct 31, 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 stale-exempt Prevents issues from being automatically marked and closed as stale
Projects
Status: 🆕 New
Development

No branches or pull requests

2 participants