diff --git a/Cargo.lock b/Cargo.lock index 54fe331180..de9da03046 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4464,6 +4464,7 @@ dependencies = [ "frame-support", "frame-system", "hex", + "pallet-assets", "pallet-balances", "pallet-contracts", "pallet-contracts-primitives", diff --git a/tests/integration/Cargo.toml b/tests/integration/Cargo.toml index de2c2115a7..4ddc95e116 100644 --- a/tests/integration/Cargo.toml +++ b/tests/integration/Cargo.toml @@ -23,6 +23,7 @@ pallet-contracts-primitives = { workspace = true } pallet-dapps-staking = { workspace = true } pallet-proxy = { workspace = true } pallet-utility = { workspace = true } +pallet-assets = { workspace = true } sp-core = { workspace = true } sp-io = { workspace = true } sp-runtime = { workspace = true } diff --git a/tests/integration/src/assets.rs b/tests/integration/src/assets.rs index 793a3ae347..2c9967bffb 100644 --- a/tests/integration/src/assets.rs +++ b/tests/integration/src/assets.rs @@ -58,3 +58,26 @@ fn asset_create_and_destroy_work_for_evm_revert_code() { ); }); } + +#[test] +fn asset_create_fails_if_account_code_is_non_empty() { + new_test_ext().execute_with(|| { + let asset_id = 19; + let precompile_address = Runtime::asset_id_to_address(asset_id); + + // Asset registration must fail if the precompile address is not empty + pallet_evm::AccountCodes::::insert( + &precompile_address, + astar_primitives::EVM_REVERT_CODE.to_vec(), + ); + assert_noop!( + Assets::create( + RuntimeOrigin::signed(ALICE), + asset_id.into(), + ALICE.into(), + 1, + ), + pallet_assets::Error::::CallbackFailed + ); + }); +} diff --git a/tests/integration/src/setup.rs b/tests/integration/src/setup.rs index 3407614818..594ca745b0 100644 --- a/tests/integration/src/setup.rs +++ b/tests/integration/src/setup.rs @@ -19,7 +19,7 @@ //! Runtime integration tests setup & imports. pub use frame_support::{ - assert_ok, + assert_noop, assert_ok, traits::{OnFinalize, OnIdle, OnInitialize}, weights::Weight, };