Skip to content

Commit

Permalink
Add negative test
Browse files Browse the repository at this point in the history
  • Loading branch information
Dinonard committed Aug 10, 2023
1 parent 35050d4 commit fb1a5da
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions tests/integration/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
23 changes: 23 additions & 0 deletions tests/integration/src/assets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<Runtime>::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::<Runtime>::CallbackFailed
);
});
}
2 changes: 1 addition & 1 deletion tests/integration/src/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down

0 comments on commit fb1a5da

Please sign in to comment.