1
1
module aptos_framework ::system_addresses {
2
2
use std::error;
3
3
use std::signer;
4
+ use std::features::get_decommission_core_resources_enabled;
5
+ #[test_only]
6
+ use std::features::change_feature_flags_for_testing;
4
7
5
8
/// The address/account did not correspond to the core resource address
6
9
const ENOT_CORE_RESOURCE_ADDRESS : u64 = 1 ;
@@ -20,7 +23,12 @@ module aptos_framework::system_addresses {
20
23
}
21
24
22
25
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
+ }
24
32
}
25
33
26
34
public fun assert_aptos_framework (account: &signer ) {
@@ -80,10 +88,21 @@ module aptos_framework::system_addresses {
80
88
is_aptos_framework_address (addr) || is_vm_address (addr)
81
89
}
82
90
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 );
88
107
}
89
108
}
0 commit comments