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

Commit

Permalink
More tests demonstrate NFT is disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
yrong committed Oct 18, 2024
1 parent 87971b3 commit cdfb27d
Showing 1 changed file with 63 additions and 0 deletions.
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));
}

0 comments on commit cdfb27d

Please sign in to comment.