Skip to content

Commit 292083b

Browse files
committed
fix: initialize idempotent.
1 parent a08c3d6 commit 292083b

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

aptos-move/framework/aptos-framework/sources/governed_gas_pool.move

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ module aptos_framework::governed_gas_pool {
5555
) {
5656
system_addresses::assert_aptos_framework(aptos_framework);
5757

58+
// return if the governed gas pool has already been initialized
59+
if (exists<GovernedGasPool>(signer::address_of(aptos_framework))) {
60+
return
61+
};
62+
5863
// generate a seed to be used to create the resource account hosting the delegation pool
5964
let seed = create_resource_account_seed(delegation_pool_creation_seed);
6065

@@ -348,4 +353,12 @@ module aptos_framework::governed_gas_pool {
348353
assert!(coin::balance<AptosCoin>(signer::address_of(beneficiary)) == 100, 4);
349354

350355
}
356+
357+
#[test(aptos_framework = @aptos_framework)]
358+
fun test_initialize_is_idempotent(aptos_framework: &signer) {
359+
// initialize the governed gas pool
360+
initialize_for_test(aptos_framework);
361+
// initialize the governed gas pool again, no abort
362+
initialize(aptos_framework, vector::empty<u8>());
363+
}
351364
}

0 commit comments

Comments
 (0)