Skip to content
This repository has been archived by the owner on Oct 22, 2024. It is now read-only.

Audit-3: More tests demonstrate NFT is disabled #184

Open
wants to merge 1 commit into
base: audit-polkadot-stable2409
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions bridges/snowbridge/primitives/router/src/outbound/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1163,3 +1163,66 @@ fn xcm_converter_transfer_native_token_with_invalid_location_will_fail() {
let result = converter.convert();
assert_eq!(result.err(), Some(XcmConverterError::InvalidAsset));
}

#[test]
fn xcm_converter_transfer_non_fungible_asset_fails() {
let network = BridgedNetwork::get();

let token_address: [u8; 20] = hex!("1000000000000000000000000000000000000000");
let beneficiary_address: [u8; 20] = hex!("2000000000000000000000000000000000000000");

let asset_location: Location = [AccountKey20 { network: None, key: token_address }].into();
let fee_asset = Asset { id: AssetId(asset_location.clone()), fun: NonFungible(Index(1)) };

let assets: Assets =
vec![Asset { id: AssetId(asset_location), fun: NonFungible(Index(1)) }].into();

let filter: AssetFilter = assets.clone().into();

let message: Xcm<()> = vec![
WithdrawAsset(assets.clone()),
ClearOrigin,
BuyExecution { fees: fee_asset, weight_limit: Unlimited },
DepositAsset {
assets: filter,
beneficiary: AccountKey20 { network: None, key: beneficiary_address }.into(),
},
SetTopic([0; 32]),
]
.into();
let mut converter =
XcmConverter::<MockTokenIdConvert, ()>::new(&message, network, Default::default());
let result = converter.convert();
assert_eq!(result.err(), Some(XcmConverterError::AssetResolutionFailed));
}

#[test]
fn xcm_converter_transfer_native_non_fungible_asset_will_fail() {
let network = BridgedNetwork::get();

let beneficiary_address: [u8; 20] = hex!("2000000000000000000000000000000000000000");

let amount = 1000000;
// Invalid asset location from a different consensus
let asset_location = Location { parents: 2, interior: [GlobalConsensus(Rococo)].into() };

let assets: Assets =
vec![Asset { id: AssetId(asset_location), fun: NonFungible(Index(1)) }].into();
let filter: AssetFilter = assets.clone().into();

let message: Xcm<()> = vec![
ReserveAssetDeposited(assets.clone()),
ClearOrigin,
BuyExecution { fees: assets.get(0).unwrap().clone(), weight_limit: Unlimited },
DepositAsset {
assets: filter,
beneficiary: AccountKey20 { network: None, key: beneficiary_address }.into(),
},
SetTopic([0; 32]),
]
.into();
let mut converter =
XcmConverter::<MockTokenIdConvert, ()>::new(&message, network, Default::default());
let result = converter.convert();
assert_eq!(result.err(), Some(XcmConverterError::AssetResolutionFailed));
}
Loading