Skip to content

Commit 23c05de

Browse files
committed
chore: feature flag is_core_resource_address
1 parent 8d5ad3f commit 23c05de

File tree

2 files changed

+25
-7
lines changed

2 files changed

+25
-7
lines changed

aptos-move/framework/aptos-framework/sources/configs/version.move

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ module aptos_framework::version {
9292
}
9393

9494
#[test(aptos_framework = @aptos_framework, core_resources = @core_resources)]
95-
#[expected_failure(abort_code = 327681, location = system_addresses)]
9695
public entry fun test_set_version_core_resources(
9796
aptos_framework: signer,
9897
core_resources: signer,

aptos-move/framework/aptos-framework/sources/system_addresses.move

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
module aptos_framework::system_addresses {
22
use std::error;
33
use std::signer;
4+
use std::features::get_decommission_core_resources_enabled;
5+
#[test_only]
6+
use std::features::change_feature_flags_for_testing;
47

58
/// The address/account did not correspond to the core resource address
69
const ENOT_CORE_RESOURCE_ADDRESS: u64 = 1;
@@ -20,7 +23,12 @@ module aptos_framework::system_addresses {
2023
}
2124

2225
public fun is_core_resource_address(addr: address): bool {
23-
false
26+
// Check if the feature flag for decommissioning core resources is enabled.
27+
if (get_decommission_core_resources_enabled()) {
28+
false
29+
} else {
30+
addr == @core_resources
31+
}
2432
}
2533

2634
public fun assert_aptos_framework(account: &signer) {
@@ -80,10 +88,21 @@ module aptos_framework::system_addresses {
8088
is_aptos_framework_address(addr) || is_vm_address(addr)
8189
}
8290

83-
#[test(aptos_framework = @aptos_framework, core_resources = @0xA550C18)]
84-
#[expected_failure(abort_code = 327681, location = Self)]
85-
public entry fun test_core_resource_check_fails(core_resources: signer) {
86-
// This should now abort due to is_core_resource_address always returning false
87-
assert_core_resource_address(signer::address_of(&core_resources));
91+
#[test(aptos_framework = @0x1, core_resources = @0xA550C18)]
92+
public entry fun test_core_resource_check_returns_false_with_flag_enabled(aptos_framework: signer, core_resources: address) {
93+
// Enable the feature flag for testing
94+
std::features::change_feature_flags_for_testing(&aptos_framework, vector[222], vector[]);
95+
96+
// Assert that is_core_resource_address returns false
97+
assert!(!is_core_resource_address(core_resources), 0);
98+
}
99+
100+
#[test(aptos_framework = @0x1, core_resources = @0xA550C18)]
101+
public entry fun test_core_resource_check_returns_true_without_flag(aptos_framework: signer, core_resources: address) {
102+
// Disable the feature flag for testing
103+
std::features::change_feature_flags_for_testing(&aptos_framework, vector[], vector[222]);
104+
105+
// Assert that is_core_resource_address returns true
106+
assert!(is_core_resource_address(core_resources), 0);
88107
}
89108
}

0 commit comments

Comments
 (0)