diff --git a/templates/parachain/pallets/xcnft/src/mock.rs b/templates/parachain/pallets/xcnft/src/mock.rs index b5ef74496a8b..a01ab1f39fab 100644 --- a/templates/parachain/pallets/xcnft/src/mock.rs +++ b/templates/parachain/pallets/xcnft/src/mock.rs @@ -30,7 +30,7 @@ mod test_runtime { #[runtime::pallet_index(0)] pub type System = frame_system; - #[runtime::pallet_index(1)] + #[runtime::pallet_index(5)] pub type XcNFT = crate; #[runtime::pallet_index(2)] diff --git a/templates/parachain/pallets/xcnft/src/tests.rs b/templates/parachain/pallets/xcnft/src/tests.rs index f742f6bf87c7..4e4db01db33d 100644 --- a/templates/parachain/pallets/xcnft/src/tests.rs +++ b/templates/parachain/pallets/xcnft/src/tests.rs @@ -8,10 +8,11 @@ pub mod testrelay; use frame_support::assert_noop; use pallet_nfts::{CollectionConfigFor, CollectionSettings, Event::Destroyed, MintSettings}; -use sp_runtime::{AccountId32, BoundedVec, BuildStorage}; +use sp_runtime::{traits::Bounded, AccountId32, BoundedVec, BuildStorage}; use cumulus_primitives_core::Parachain; use xcm_executor::traits::ConvertLocation; use xcm::prelude::*; +use crate::tests::testpara::XcNFT; pub const ALICE: AccountId32 = AccountId32::new([0u8; 32]); pub const BOB: AccountId32 = AccountId32::new([1u8; 32]); @@ -35,7 +36,7 @@ decl_test_parachain! { Runtime = testpara::Runtime, XcmpMessageHandler = testpara::MsgQueue, DmpMessageHandler = testpara::MsgQueue, - new_ext = para_ext(1), + new_ext = para_ext(1000), } } @@ -44,7 +45,7 @@ decl_test_parachain! { Runtime = testpara::Runtime, XcmpMessageHandler = testpara::MsgQueue, DmpMessageHandler = testpara::MsgQueue, - new_ext = para_ext(2), + new_ext = para_ext(2000), } } @@ -64,8 +65,8 @@ decl_test_network! { pub struct MockNet { relay_chain = Relay, parachains = vec![ - (1, ParaA), - (2, ParaB), + (1000, ParaA), + (2000, ParaB), ], } } @@ -114,10 +115,100 @@ pub fn relay_ext() -> sp_io::TestExternalities { ext } +#[test] +fn try_sending_collection_empty_success() { + ParaA::execute_with(|| { + testpara::System::set_block_number(1); + const COLLECTION_ID: u32 = 1; + + let def_config: CollectionConfigFor = CollectionConfigFor:: { + settings: CollectionSettings::all_enabled(), // Default settings (all enabled) + max_supply: None, /* No maximum supply defined + * initially */ + mint_settings: MintSettings::default(), // Use default mint settings + }; + + let _ = testpara::NFTs::create(testpara::RuntimeOrigin::signed(ALICE), ALICE, def_config); + + let _ = testpara::XcNFT::collection_x_transfer( + testpara::RuntimeOrigin::signed(ALICE), + 0, + Some(COLLECTION_ID), + 2000.into(), + None + ); + + testpara::System::assert_has_event(testpara::RuntimeEvent::XcNFT(Event::CollectionTransferred { origin_collection_id: 0, origin_collection_metadata: BoundedVec::new(), destination_para_id: 2000.into()})); + + }); +} + +#[test] +fn try_sending_collection_same_owner_success() { + ParaA::execute_with(|| { + testpara::System::set_block_number(1); + const COLLECTION_ID: u32 = 1; + + let def_config: CollectionConfigFor = CollectionConfigFor:: { + settings: CollectionSettings::all_enabled(), // Default settings (all enabled) + max_supply: None, /* No maximum supply defined + * initially */ + mint_settings: MintSettings::default(), // Use default mint settings + }; + + let _ = testpara::NFTs::create(testpara::RuntimeOrigin::signed(ALICE), ALICE, def_config); + let _ = testpara::NFTs::mint(testpara::RuntimeOrigin::signed(ALICE), 0, 0,ALICE, None); + let _ = testpara::NFTs::mint(testpara::RuntimeOrigin::signed(ALICE), 0, 1, ALICE, None); + + let _ = testpara::XcNFT::collection_x_transfer( + testpara::RuntimeOrigin::signed(ALICE), + 0, + Some(COLLECTION_ID), + 2000.into(), + None + ); + + let nft_ids = vec![0, 1]; + + testpara::System::assert_has_event(testpara::RuntimeEvent::XcNFT(Event::CollectionAndNFTsTransferred { origin_collection_id: 0, nft_ids, destination_para_id: 2000.into()})); + + }); +} + +#[test] +fn try_sending_collection_different_owners_success() { + ParaA::execute_with(|| { + testpara::System::set_block_number(1); + const COLLECTION_ID: u32 = 1; + + let def_config: CollectionConfigFor = CollectionConfigFor:: { + settings: CollectionSettings::all_enabled(), // Default settings (all enabled) + max_supply: None, /* No maximum supply defined + * initially */ + mint_settings: MintSettings::default(), // Use default mint settings + }; + + let _ = testpara::NFTs::create(testpara::RuntimeOrigin::signed(ALICE), ALICE, def_config); + let _ = testpara::NFTs::mint(testpara::RuntimeOrigin::signed(ALICE), 0, 0,ALICE, None); + let _ = testpara::NFTs::mint(testpara::RuntimeOrigin::signed(ALICE), 0, 1, BOB, None); + + let _ = testpara::XcNFT::collection_x_transfer( + testpara::RuntimeOrigin::signed(ALICE), + 0, + Some(COLLECTION_ID), + 2000.into(), + None + ); + + testpara::System::assert_has_event(testpara::RuntimeEvent::XcNFT(Event::CollectionTransferProposalCreated { proposal_id: 0, collection_id: 0, proposer: ALICE, destination: 2000.into()})); + + }); +} + #[test] fn try_sending_collection_that_user_doesnt_own() { - new_test_ext().execute_with(|| { - System::set_block_number(1); + ParaA::execute_with(|| { + testpara::System::set_block_number(1); const COLLECTION_ID: u32 = 1; let def_config: CollectionConfigFor = CollectionConfigFor:: { @@ -127,11 +218,11 @@ fn try_sending_collection_that_user_doesnt_own() { mint_settings: MintSettings::default(), // Use default mint settings }; - let _ = NFTs::create(RuntimeOrigin::signed(ALICE), ALICE, def_config); + let _ = testpara::NFTs::create(testpara::RuntimeOrigin::signed(ALICE), ALICE, def_config); assert_noop!( - XcNFT::collection_x_transfer( - RuntimeOrigin::signed(BOB), + testpara::XcNFT::collection_x_transfer( + testpara::RuntimeOrigin::signed(BOB), 0, Some(COLLECTION_ID), 2000.into(), @@ -142,13 +233,14 @@ fn try_sending_collection_that_user_doesnt_own() { }); } + #[test] fn try_voting_on_non_existing_proposal() { - new_test_ext().execute_with(|| { - System::set_block_number(1); + ParaA::execute_with(|| { + testpara::System::set_block_number(1); assert_noop!( - XcNFT::collection_x_transfer_vote(RuntimeOrigin::signed(ALICE), 0, crate::Vote::Aye), + testpara::XcNFT::collection_x_transfer_vote(testpara::RuntimeOrigin::signed(ALICE), 0, crate::Vote::Aye), Error::::ProposalDoesNotExist ); }); @@ -156,8 +248,8 @@ fn try_voting_on_non_existing_proposal() { #[test] fn try_voting_on_proposal_when_no_owner() { - new_test_ext().execute_with(|| { - System::set_block_number(1); + ParaA::execute_with(|| { + testpara::System::set_block_number(1); const COLLECTION_ID: u32 = 1; //Create proposal @@ -176,7 +268,7 @@ fn try_voting_on_proposal_when_no_owner() { let _ = crate::CrossChainProposals::insert(1, proposal); assert_noop!( - XcNFT::collection_x_transfer_vote(RuntimeOrigin::signed(BOB), 1, crate::Vote::Aye), + testpara::XcNFT::collection_x_transfer_vote(testpara::RuntimeOrigin::signed(BOB), 1, crate::Vote::Aye), Error::::NotNFTOwner ); }); @@ -184,8 +276,8 @@ fn try_voting_on_proposal_when_no_owner() { #[test] fn try_voting_on_proposal_expired() { - new_test_ext().execute_with(|| { - System::set_block_number(3); + ParaA::execute_with(|| { + testpara::System::set_block_number(3); const COLLECTION_ID: u32 = 1; //Create owners vector @@ -208,16 +300,16 @@ fn try_voting_on_proposal_expired() { let _ = crate::CrossChainProposals::insert(1, proposal); let _ = - XcNFT::collection_x_transfer_vote(RuntimeOrigin::signed(ALICE), 1, crate::Vote::Aye); + testpara::XcNFT::collection_x_transfer_vote(testpara::RuntimeOrigin::signed(ALICE), 1, crate::Vote::Aye); - System::assert_last_event(RuntimeEvent::XcNFT(Event::ProposalExpired { proposal_id: 1 })); + testpara::System::assert_has_event(testpara::RuntimeEvent::XcNFT(Event::ProposalExpired { proposal_id: 1 })); }); } #[test] fn try_voting_on_proposal_did_not_pass() { - new_test_ext().execute_with(|| { - System::set_block_number(3); + ParaA::execute_with(|| { + testpara::System::set_block_number(3); const COLLECTION_ID: u32 = 1; //Create owners vector @@ -240,9 +332,9 @@ fn try_voting_on_proposal_did_not_pass() { let _ = crate::CrossChainProposals::insert(1, proposal); let _ = - XcNFT::collection_x_transfer_vote(RuntimeOrigin::signed(ALICE), 1, crate::Vote::Aye); + testpara::XcNFT::collection_x_transfer_vote(testpara::RuntimeOrigin::signed(ALICE), 1, crate::Vote::Aye); - System::assert_last_event(RuntimeEvent::XcNFT(Event::ProposalDidNotPass { + testpara::System::assert_has_event(testpara::RuntimeEvent::XcNFT(Event::ProposalDidNotPass { proposal_id: 1, })); }); @@ -250,8 +342,8 @@ fn try_voting_on_proposal_did_not_pass() { #[test] fn try_voting_on_proposal_again_same_vote() { - new_test_ext().execute_with(|| { - System::set_block_number(1); + ParaA::execute_with(|| { + testpara::System::set_block_number(1); const COLLECTION_ID: u32 = 1; //Create owners vector @@ -274,10 +366,10 @@ fn try_voting_on_proposal_again_same_vote() { let _ = crate::CrossChainProposals::insert(1, proposal); let _ = - XcNFT::collection_x_transfer_vote(RuntimeOrigin::signed(ALICE), 1, crate::Vote::Aye); + testpara::XcNFT::collection_x_transfer_vote(testpara::RuntimeOrigin::signed(ALICE), 1, crate::Vote::Aye); assert_noop!( - XcNFT::collection_x_transfer_vote(RuntimeOrigin::signed(ALICE), 1, crate::Vote::Aye), + testpara::XcNFT::collection_x_transfer_vote(testpara::RuntimeOrigin::signed(ALICE), 1, crate::Vote::Aye), Error::::AlreadyVotedThis ); }); @@ -285,8 +377,8 @@ fn try_voting_on_proposal_again_same_vote() { #[test] fn vote_on_proposal_successfuly() { - new_test_ext().execute_with(|| { - System::set_block_number(1); + ParaA::execute_with(|| { + testpara::System::set_block_number(1); const COLLECTION_ID: u32 = 1; //Create owners vector @@ -309,9 +401,9 @@ fn vote_on_proposal_successfuly() { let _ = crate::CrossChainProposals::insert(1, proposal); let _ = - XcNFT::collection_x_transfer_vote(RuntimeOrigin::signed(ALICE), 1, crate::Vote::Aye); + testpara::XcNFT::collection_x_transfer_vote(testpara::RuntimeOrigin::signed(ALICE), 1, crate::Vote::Aye); - System::assert_last_event(RuntimeEvent::XcNFT(Event::CrossChainPropoposalVoteRegistered { + testpara::System::assert_has_event(testpara::RuntimeEvent::XcNFT(Event::CrossChainPropoposalVoteRegistered { proposal_id: 1, voter: ALICE, vote: crate::Vote::Aye, @@ -319,13 +411,51 @@ fn vote_on_proposal_successfuly() { }); } +#[test] +fn initiate_proposal_successfuly() { + ParaA::execute_with(|| { + testpara::System::set_block_number(1); + const COLLECTION_ID: u32 = 1; + + let def_config: CollectionConfigFor = CollectionConfigFor:: { + settings: CollectionSettings::all_enabled(), // Default settings (all enabled) + max_supply: None, /* No maximum supply defined + * initially */ + mint_settings: MintSettings::default(), // Use default mint settings + }; + + let _ = testpara::NFTs::create(testpara::RuntimeOrigin::signed(ALICE), ALICE, def_config); + let _ = testpara::NFTs::mint(testpara::RuntimeOrigin::signed(ALICE), 0, 0,ALICE, None); + let _ = testpara::NFTs::mint(testpara::RuntimeOrigin::signed(ALICE), 0, 1, BOB, None); + + let _ = testpara::XcNFT::collection_x_transfer( + testpara::RuntimeOrigin::signed(ALICE), + 0, + Some(COLLECTION_ID), + 2000.into(), + None + ); + + let _ = testpara::XcNFT::collection_x_transfer_vote(testpara::RuntimeOrigin::signed(ALICE), 0, crate::Vote::Aye); + + testpara::System::set_block_number(11); + + let _ = testpara::XcNFT::collection_x_transfer_initiate(testpara::RuntimeOrigin::signed(ALICE), 0); + + let nfts = vec![(0, ALICE, BoundedVec::new()), (1, BOB, BoundedVec::new())]; + + testpara::System::assert_has_event(testpara::RuntimeEvent::XcNFT(Event::CollectionAndNFTsDiffTransferred { origin_collection_id: 0, nfts: nfts, destination_para_id: 2000.into(), to_address: ALICE })); + + }); +} + #[test] fn try_initiating_proposal_doesnt_exist() { - new_test_ext().execute_with(|| { - System::set_block_number(1); + ParaA::execute_with(|| { + testpara::System::set_block_number(1); assert_noop!( - XcNFT::collection_x_transfer_initiate(RuntimeOrigin::signed(ALICE), 1), + testpara::XcNFT::collection_x_transfer_initiate(testpara::RuntimeOrigin::signed(ALICE), 1), Error::::ProposalDoesNotExist ); }); @@ -333,8 +463,8 @@ fn try_initiating_proposal_doesnt_exist() { #[test] fn try_initiating_proposal_collection_doesnt_exist() { - new_test_ext().execute_with(|| { - System::set_block_number(1); + ParaA::execute_with(|| { + testpara::System::set_block_number(1); const COLLECTION_ID: u32 = 1; @@ -358,7 +488,7 @@ fn try_initiating_proposal_collection_doesnt_exist() { let _ = crate::CrossChainProposals::insert(1, proposal); assert_noop!( - XcNFT::collection_x_transfer_initiate(RuntimeOrigin::signed(ALICE), 1), + testpara::XcNFT::collection_x_transfer_initiate(testpara::RuntimeOrigin::signed(ALICE), 1), Error::::CollectionDoesNotExist ); }); @@ -366,8 +496,8 @@ fn try_initiating_proposal_collection_doesnt_exist() { #[test] fn try_initiating_proposal_no_collection_owner() { - new_test_ext().execute_with(|| { - System::set_block_number(2); + ParaA::execute_with(|| { + testpara::System::set_block_number(2); let def_config: CollectionConfigFor = CollectionConfigFor:: { settings: CollectionSettings::all_enabled(), // Default settings (all enabled) max_supply: None, /* No maximum supply defined @@ -375,7 +505,7 @@ fn try_initiating_proposal_no_collection_owner() { mint_settings: MintSettings::default(), // Use default mint settings }; - let _ = NFTs::create(RuntimeOrigin::signed(BOB), ALICE, def_config); + let _ = testpara::NFTs::create(testpara::RuntimeOrigin::signed(BOB), ALICE, def_config); //Create owners vector let mut owners = BoundedVec::new(); @@ -397,7 +527,7 @@ fn try_initiating_proposal_no_collection_owner() { let _ = crate::CrossChainProposals::insert(1, proposal); assert_noop!( - XcNFT::collection_x_transfer_initiate(RuntimeOrigin::signed(ALICE), 1), + testpara::XcNFT::collection_x_transfer_initiate(testpara::RuntimeOrigin::signed(ALICE), 1), Error::::NotCollectionOwner ); }); @@ -405,8 +535,8 @@ fn try_initiating_proposal_no_collection_owner() { #[test] fn try_initiating_proposal_that_did_not_pass() { - new_test_ext().execute_with(|| { - System::set_block_number(2); + ParaA::execute_with(|| { + testpara::System::set_block_number(2); let def_config: CollectionConfigFor = CollectionConfigFor:: { settings: CollectionSettings::all_enabled(), // Default settings (all enabled) max_supply: None, /* No maximum supply defined @@ -414,7 +544,7 @@ fn try_initiating_proposal_that_did_not_pass() { mint_settings: MintSettings::default(), // Use default mint settings }; - let _ = NFTs::create(RuntimeOrigin::signed(ALICE), ALICE, def_config); + let _ = testpara::NFTs::create(testpara::RuntimeOrigin::signed(ALICE), ALICE, def_config); //Create owners vector let mut owners = BoundedVec::new(); @@ -434,19 +564,41 @@ fn try_initiating_proposal_that_did_not_pass() { }; let _ = crate::CrossChainProposals::insert(1, proposal); - let _ = XcNFT::collection_x_transfer_initiate(RuntimeOrigin::signed(ALICE), 1); + let _ = testpara::XcNFT::collection_x_transfer_initiate(testpara::RuntimeOrigin::signed(ALICE), 1); - System::assert_has_event(RuntimeEvent::XcNFT(Event::ProposalDidNotPass { proposal_id: 1 })); + testpara::System::assert_has_event(testpara::RuntimeEvent::XcNFT(Event::ProposalDidNotPass { proposal_id: 1 })); + }); +} + +#[test] +fn try_sending_nft_successful() { + + ParaA::execute_with(|| { + testpara::System::set_block_number(2); + + let def_config: CollectionConfigFor = CollectionConfigFor:: { + settings: CollectionSettings::all_enabled(), // Default settings (all enabled) + max_supply: None, /* No maximum supply defined + * initially */ + mint_settings: MintSettings::default(), // Use default mint settings + }; + + let _ = testpara::NFTs::create(testpara::RuntimeOrigin::signed(ALICE), ALICE, def_config); + let _ = testpara::NFTs::mint(testpara::RuntimeOrigin::signed(ALICE), 0, 0,ALICE, None); + + let _ = testpara::XcNFT::nft_x_transfer(testpara::RuntimeOrigin::signed(ALICE), 0, 0, 1000.into(), 1, 1); + + testpara::System::assert_has_event(testpara::RuntimeEvent::XcNFT(Event::NFTTransferred { origin_collection_id: 0, origin_asset_id: 0, destination_para_id: 1000.into(), destination_collection_id: 1, destination_asset_id: 1 })); }); } #[test] fn try_sending_nft_no_collection() { - new_test_ext().execute_with(|| { - System::set_block_number(2); + ParaA::execute_with(|| { + testpara::System::set_block_number(2); assert_noop!( - XcNFT::nft_x_transfer(RuntimeOrigin::signed(ALICE), 1, 0, 1000.into(), 1, 1), + testpara::XcNFT::nft_x_transfer(testpara::RuntimeOrigin::signed(ALICE), 1, 0, 1000.into(), 1, 1), Error::::CollectionDoesNotExist ); }); @@ -454,8 +606,8 @@ fn try_sending_nft_no_collection() { #[test] fn try_sending_nft_no_nft() { - new_test_ext().execute_with(|| { - System::set_block_number(2); + ParaA::execute_with(|| { + testpara::System::set_block_number(2); let def_config: CollectionConfigFor = CollectionConfigFor:: { settings: CollectionSettings::all_enabled(), // Default settings (all enabled) max_supply: None, /* No maximum supply defined @@ -463,10 +615,10 @@ fn try_sending_nft_no_nft() { mint_settings: MintSettings::default(), // Use default mint settings }; - let _ = NFTs::create(RuntimeOrigin::signed(ALICE), ALICE, def_config); + let _ = testpara::NFTs::create(testpara::RuntimeOrigin::signed(ALICE), ALICE, def_config); assert_noop!( - XcNFT::nft_x_transfer(RuntimeOrigin::signed(ALICE), 0, 0, 1000.into(), 1, 1), + testpara::XcNFT::nft_x_transfer(testpara::RuntimeOrigin::signed(ALICE), 0, 0, 1000.into(), 1, 1), Error::::NFTDoesNotExist ); }); @@ -474,8 +626,8 @@ fn try_sending_nft_no_nft() { #[test] fn try_sending_nft_not_nft_owner() { - new_test_ext().execute_with(|| { - System::set_block_number(2); + ParaA::execute_with(|| { + testpara::System::set_block_number(2); let def_config: CollectionConfigFor = CollectionConfigFor:: { settings: CollectionSettings::all_enabled(), // Default settings (all enabled) @@ -484,12 +636,12 @@ fn try_sending_nft_not_nft_owner() { mint_settings: MintSettings::default(), // Use default mint settings }; - let _ = NFTs::create(RuntimeOrigin::signed(ALICE), ALICE, def_config); + let _ = testpara::NFTs::create(testpara::RuntimeOrigin::signed(ALICE), ALICE, def_config); - let _ = NFTs::mint(RuntimeOrigin::signed(ALICE), 0, 0, ALICE, None); + let _ = testpara::NFTs::mint(testpara::RuntimeOrigin::signed(ALICE), 0, 0, ALICE, None); assert_noop!( - XcNFT::nft_x_transfer(RuntimeOrigin::signed(BOB), 0, 0, 1000.into(), 1, 1), + testpara::XcNFT::nft_x_transfer(testpara::RuntimeOrigin::signed(BOB), 0, 0, 1000.into(), 1, 1), Error::::NotNFTOwner ); }); @@ -497,11 +649,11 @@ fn try_sending_nft_not_nft_owner() { #[test] fn try_claiming_nft_no_collection() { - new_test_ext().execute_with(|| { - System::set_block_number(2); + ParaA::execute_with(|| { + testpara::System::set_block_number(2); assert_noop!( - XcNFT::nft_x_claim(RuntimeOrigin::signed(ALICE), 1u32, 0u32, 100u32.into(), 1u32, 1u32), + testpara::XcNFT::nft_x_claim(testpara::RuntimeOrigin::signed(ALICE), 1u32, 0u32, 100u32.into(), 1u32, 1u32), Error::::CollectionDoesNotExist ); }); @@ -509,8 +661,8 @@ fn try_claiming_nft_no_collection() { #[test] fn try_claiming_nft_no_collection_origin() { - new_test_ext().execute_with(|| { - System::set_block_number(2); + ParaA::execute_with(|| { + testpara::System::set_block_number(2); let def_config: CollectionConfigFor = CollectionConfigFor:: { settings: CollectionSettings::all_enabled(), // Default settings (all enabled) @@ -519,10 +671,10 @@ fn try_claiming_nft_no_collection_origin() { mint_settings: MintSettings::default(), // Use default mint settings }; - let _ = NFTs::create(RuntimeOrigin::signed(ALICE), ALICE, def_config); + let _ = testpara::NFTs::create(testpara::RuntimeOrigin::signed(ALICE), ALICE, def_config); assert_noop!( - XcNFT::nft_x_claim(RuntimeOrigin::signed(ALICE), 1u32, 0u32, 100u32.into(), 1u32, 1u32), + testpara::XcNFT::nft_x_claim(testpara::RuntimeOrigin::signed(ALICE), 1u32, 0u32, 100u32.into(), 1u32, 1u32), Error::::CollectionDoesNotExist ); }); @@ -530,8 +682,8 @@ fn try_claiming_nft_no_collection_origin() { #[test] fn try_claiming_nft_wrong_origin_collection() { - new_test_ext().execute_with(|| { - System::set_block_number(2); + ParaA::execute_with(|| { + testpara::System::set_block_number(2); let def_config: CollectionConfigFor = CollectionConfigFor:: { settings: CollectionSettings::all_enabled(), // Default settings (all enabled) @@ -540,7 +692,7 @@ fn try_claiming_nft_wrong_origin_collection() { mint_settings: MintSettings::default(), // Use default mint settings }; - let _ = NFTs::create(RuntimeOrigin::signed(ALICE), ALICE, def_config); + let _ = testpara::NFTs::create(testpara::RuntimeOrigin::signed(ALICE), ALICE, def_config); let collections: ReceivedCols = ReceivedCols:: { origin_para_id: 1000.into(), @@ -551,7 +703,7 @@ fn try_claiming_nft_wrong_origin_collection() { let _ = ReceivedCollections::::insert(0, collections); assert_noop!( - XcNFT::nft_x_claim(RuntimeOrigin::signed(ALICE), 0u32, 0u32, 100u32.into(), 0u32, 1u32), + testpara::XcNFT::nft_x_claim(testpara::RuntimeOrigin::signed(ALICE), 0u32, 0u32, 100u32.into(), 0u32, 1u32), Error::::WrongOriginCollectionAtOrigin ); }); @@ -559,8 +711,8 @@ fn try_claiming_nft_wrong_origin_collection() { #[test] fn try_claiming_nft_wrong_nft() { - new_test_ext().execute_with(|| { - System::set_block_number(2); + ParaA::execute_with(|| { + testpara::System::set_block_number(2); let def_config: CollectionConfigFor = CollectionConfigFor:: { settings: CollectionSettings::all_enabled(), // Default settings (all enabled) @@ -569,7 +721,7 @@ fn try_claiming_nft_wrong_nft() { mint_settings: MintSettings::default(), // Use default mint settings }; - let _ = NFTs::create(RuntimeOrigin::signed(ALICE), ALICE, def_config); + let _ = testpara::NFTs::create(testpara::RuntimeOrigin::signed(ALICE), ALICE, def_config); let collections: ReceivedCols = ReceivedCols:: { origin_para_id: 1000.into(), @@ -580,7 +732,7 @@ fn try_claiming_nft_wrong_nft() { let _ = ReceivedCollections::::insert(0, collections); assert_noop!( - XcNFT::nft_x_claim(RuntimeOrigin::signed(ALICE), 0u32, 0u32, 100u32.into(), 0u32, 0u32), + testpara::XcNFT::nft_x_claim(testpara::RuntimeOrigin::signed(ALICE), 0u32, 0u32, 100u32.into(), 0u32, 0u32), Error::::NFTNotReceived ); }); @@ -588,8 +740,8 @@ fn try_claiming_nft_wrong_nft() { #[test] fn try_claiming_nft_not_owner() { - new_test_ext().execute_with(|| { - System::set_block_number(2); + ParaA::execute_with(|| { + testpara::System::set_block_number(2); let def_config: CollectionConfigFor = CollectionConfigFor:: { settings: CollectionSettings::all_enabled(), // Default settings (all enabled) @@ -598,13 +750,13 @@ fn try_claiming_nft_not_owner() { mint_settings: MintSettings::default(), // Use default mint settings }; - let _ = NFTs::create(RuntimeOrigin::signed(ALICE), ALICE, def_config); - let _ = NFTs::mint(RuntimeOrigin::signed(ALICE), 0u32, 0u32, ALICE, None); + let _ = testpara::NFTs::create(testpara::RuntimeOrigin::signed(ALICE), ALICE, def_config); + let _ = testpara::NFTs::mint(testpara::RuntimeOrigin::signed(ALICE), 0u32, 0u32, ALICE, None); - System::set_block_number(3); + testpara::System::set_block_number(3); - let _ = NFTs::create(RuntimeOrigin::signed(ALICE), ALICE, def_config); - let _ = NFTs::mint(RuntimeOrigin::signed(ALICE), 1u32, 0u32, ALICE, None); + let _ = testpara::NFTs::create(testpara::RuntimeOrigin::signed(ALICE), ALICE, def_config); + let _ = testpara::NFTs::mint(testpara::RuntimeOrigin::signed(ALICE), 1u32, 0u32, ALICE, None); let collections: ReceivedCols = ReceivedCols:: { origin_para_id: 1000.into(), @@ -625,7 +777,7 @@ fn try_claiming_nft_not_owner() { let _ = ReceivedAssets::::insert((1, 0), nfts); assert_noop!( - XcNFT::nft_x_claim(RuntimeOrigin::signed(BOB), 0u32, 0u32, 0u32, 1u32, 0u32), + testpara::XcNFT::nft_x_claim(testpara::RuntimeOrigin::signed(BOB), 0u32, 0u32, 0u32, 1u32, 0u32), Error::::NotNFTOwner ); }); @@ -633,8 +785,8 @@ fn try_claiming_nft_not_owner() { #[test] fn try_claiming_nft_success() { - new_test_ext().execute_with(|| { - System::set_block_number(2); + ParaA::execute_with(|| { + testpara::System::set_block_number(2); let def_config: CollectionConfigFor = CollectionConfigFor:: { settings: CollectionSettings::all_enabled(), // Default settings (all enabled) @@ -643,13 +795,13 @@ fn try_claiming_nft_success() { mint_settings: MintSettings::default(), // Use default mint settings }; - let _ = NFTs::create(RuntimeOrigin::signed(ALICE), ALICE, def_config); - let _ = NFTs::mint(RuntimeOrigin::signed(ALICE), 0u32, 0u32, ALICE, None); + let _ = testpara::NFTs::create(testpara::RuntimeOrigin::signed(ALICE), ALICE, def_config); + let _ = testpara::NFTs::mint(testpara::RuntimeOrigin::signed(ALICE), 0u32, 0u32, ALICE, None); System::set_block_number(3); - let _ = NFTs::create(RuntimeOrigin::signed(ALICE), ALICE, def_config); - let _ = NFTs::mint(RuntimeOrigin::signed(ALICE), 1u32, 0u32, ALICE, None); + let _ = testpara::NFTs::create(testpara::RuntimeOrigin::signed(ALICE), ALICE, def_config); + let _ = testpara::NFTs::mint(testpara::RuntimeOrigin::signed(ALICE), 1u32, 0u32, ALICE, None); let collections: ReceivedCols = ReceivedCols:: { origin_para_id: 1000.into(), @@ -668,11 +820,11 @@ fn try_claiming_nft_success() { }; let _ = ReceivedAssets::::insert((1, 0), nfts); - System::set_block_number(3); + testpara::System::set_block_number(3); - let _ = XcNFT::nft_x_claim(RuntimeOrigin::signed(ALICE), 0u32, 0u32, 0u32, 1u32, 0u32); + let _ = testpara::XcNFT::nft_x_claim(testpara::RuntimeOrigin::signed(ALICE), 0u32, 0u32, 0u32, 1u32, 0u32); - System::assert_has_event(RuntimeEvent::XcNFT(Event::NFTClaimed { + testpara::System::assert_has_event(testpara::RuntimeEvent::XcNFT(Event::NFTClaimed { collection_claimed_from: 1, asset_removed: 0, collection_claimed_to: 0, @@ -683,18 +835,18 @@ fn try_claiming_nft_success() { #[test] fn try_collection_parse_empty_successful() { - new_test_ext().execute_with(|| { - System::set_block_number(2); + ParaA::execute_with(|| { + testpara::System::set_block_number(2); - let _ = XcNFT::parse_collection_empty( - RuntimeOrigin::signed(ALICE), + let _ = testpara::XcNFT::parse_collection_empty( + testpara::RuntimeOrigin::signed(ALICE), 1, None, BoundedVec::new(), None, ); - System::assert_has_event(RuntimeEvent::XcNFT(Event::CollectionReceived { + testpara::System::assert_has_event(testpara::RuntimeEvent::XcNFT(Event::CollectionReceived { origin_collection_id: 1, received_collection_id: 1, to_address: ALICE, @@ -704,8 +856,8 @@ fn try_collection_parse_empty_successful() { #[test] fn try_parse_collection_burn_successful() { - new_test_ext().execute_with(|| { - System::set_block_number(2); + ParaA::execute_with(|| { + testpara::System::set_block_number(2); let destroy_witness = GeneralizedDestroyWitness { item_meta: 0, item_configs: 0, attributes: 0 }; @@ -717,11 +869,11 @@ fn try_parse_collection_burn_successful() { mint_settings: MintSettings::default(), // Use default mint settings }; - let _ = NFTs::create(RuntimeOrigin::signed(ALICE), ALICE, def_config); + let _ = testpara::NFTs::create(testpara::RuntimeOrigin::signed(ALICE), ALICE, def_config); - let _ = XcNFT::parse_collection_burn(RuntimeOrigin::signed(ALICE), 0, destroy_witness); + let _ = testpara::XcNFT::parse_collection_burn(testpara::RuntimeOrigin::signed(ALICE), 0, destroy_witness); - System::assert_has_event(RuntimeEvent::NFTs(pallet_nfts::Event::Destroyed { + testpara::System::assert_has_event(testpara::RuntimeEvent::NFTs(pallet_nfts::Event::Destroyed { collection: 0, })); }); @@ -729,8 +881,8 @@ fn try_parse_collection_burn_successful() { #[test] fn try_parse_collection_metadata_successful() { - new_test_ext().execute_with(|| { - System::set_block_number(2); + ParaA::execute_with(|| { + testpara::System::set_block_number(2); let def_config: CollectionConfigFor = CollectionConfigFor:: { settings: CollectionSettings::all_enabled(), // Default settings (all enabled) @@ -739,12 +891,12 @@ fn try_parse_collection_metadata_successful() { mint_settings: MintSettings::default(), // Use default mint settings }; - let _ = NFTs::create(RuntimeOrigin::signed(ALICE), ALICE, def_config); + let _ = testpara::NFTs::create(testpara::RuntimeOrigin::signed(ALICE), ALICE, def_config); let _ = - XcNFT::parse_collection_metadata(RuntimeOrigin::signed(ALICE), 0, BoundedVec::new()); + testpara::XcNFT::parse_collection_metadata(testpara::RuntimeOrigin::signed(ALICE), 0, BoundedVec::new()); - System::assert_has_event(RuntimeEvent::NFTs(pallet_nfts::Event::CollectionMetadataSet { + testpara::System::assert_has_event(testpara::RuntimeEvent::NFTs(pallet_nfts::Event::CollectionMetadataSet { collection: 0, data: BoundedVec::new(), })); @@ -753,8 +905,8 @@ fn try_parse_collection_metadata_successful() { #[test] fn try_parse_collection_owner_successful() { - new_test_ext().execute_with(|| { - System::set_block_number(2); + ParaA::execute_with(|| { + testpara::System::set_block_number(2); let def_config: CollectionConfigFor = CollectionConfigFor:: { settings: CollectionSettings::all_enabled(), // Default settings (all enabled) @@ -763,13 +915,13 @@ fn try_parse_collection_owner_successful() { mint_settings: MintSettings::default(), // Use default mint settings }; - let _ = NFTs::create(RuntimeOrigin::signed(ALICE), ALICE, def_config); + let _ = testpara::NFTs::create(testpara::RuntimeOrigin::signed(ALICE), ALICE, def_config); pallet_nfts::OwnershipAcceptance::::insert(BOB, 0); - let _ = XcNFT::parse_collection_owner(RuntimeOrigin::signed(ALICE), BOB, 0); + let _ = testpara::XcNFT::parse_collection_owner(testpara::RuntimeOrigin::signed(ALICE), BOB, 0); - System::assert_has_event(RuntimeEvent::NFTs(pallet_nfts::Event::OwnerChanged { + testpara::System::assert_has_event(testpara::RuntimeEvent::NFTs(pallet_nfts::Event::OwnerChanged { collection: 0, new_owner: BOB, })); @@ -778,8 +930,8 @@ fn try_parse_collection_owner_successful() { #[test] fn try_parse_nft_burn_successful() { - new_test_ext().execute_with(|| { - System::set_block_number(2); + ParaA::execute_with(|| { + testpara::System::set_block_number(2); let def_config: CollectionConfigFor = CollectionConfigFor:: { settings: CollectionSettings::all_enabled(), // Default settings (all enabled) @@ -788,13 +940,13 @@ fn try_parse_nft_burn_successful() { mint_settings: MintSettings::default(), // Use default mint settings }; - let _ = NFTs::create(RuntimeOrigin::signed(ALICE), ALICE, def_config); + let _ = testpara::NFTs::create(testpara::RuntimeOrigin::signed(ALICE), ALICE, def_config); - let _ = NFTs::mint(RuntimeOrigin::signed(ALICE), 0, 0, ALICE, None); + let _ = testpara::NFTs::mint(testpara::RuntimeOrigin::signed(ALICE), 0, 0, ALICE, None); - let _ = XcNFT::parse_nft_burn(RuntimeOrigin::signed(ALICE), 0, 0); + let _ = testpara::XcNFT::parse_nft_burn(testpara::RuntimeOrigin::signed(ALICE), 0, 0); - System::assert_has_event(RuntimeEvent::NFTs(pallet_nfts::Event::Burned { + testpara::System::assert_has_event(testpara::RuntimeEvent::NFTs(pallet_nfts::Event::Burned { collection: 0, item: 0, owner: ALICE, @@ -804,8 +956,8 @@ fn try_parse_nft_burn_successful() { #[test] fn try_parse_nft_metadata_successful() { - new_test_ext().execute_with(|| { - System::set_block_number(2); + ParaA::execute_with(|| { + testpara::System::set_block_number(2); let def_config: CollectionConfigFor = CollectionConfigFor:: { settings: CollectionSettings::all_enabled(), // Default settings (all enabled) @@ -814,13 +966,13 @@ fn try_parse_nft_metadata_successful() { mint_settings: MintSettings::default(), // Use default mint settings }; - let _ = NFTs::create(RuntimeOrigin::signed(ALICE), ALICE, def_config); + let _ = testpara::NFTs::create(testpara::RuntimeOrigin::signed(ALICE), ALICE, def_config); - let _ = NFTs::mint(RuntimeOrigin::signed(ALICE), 0, 0, ALICE, None); + let _ = testpara::NFTs::mint(testpara::RuntimeOrigin::signed(ALICE), 0, 0, ALICE, None); - let _ = XcNFT::parse_nft_metadata(RuntimeOrigin::signed(ALICE), 0, 0, BoundedVec::new()); + let _ = testpara::XcNFT::parse_nft_metadata(testpara::RuntimeOrigin::signed(ALICE), 0, 0, BoundedVec::new()); - System::assert_has_event(RuntimeEvent::NFTs(pallet_nfts::Event::ItemMetadataSet { + testpara::System::assert_has_event(testpara::RuntimeEvent::NFTs(pallet_nfts::Event::ItemMetadataSet { collection: 0, item: 0, data: BoundedVec::new(), @@ -830,8 +982,8 @@ fn try_parse_nft_metadata_successful() { #[test] fn try_parse_nft_owner_successful() { - new_test_ext().execute_with(|| { - System::set_block_number(2); + ParaA::execute_with(|| { + testpara::System::set_block_number(2); let def_config: CollectionConfigFor = CollectionConfigFor:: { settings: CollectionSettings::all_enabled(), // Default settings (all enabled) @@ -840,13 +992,13 @@ fn try_parse_nft_owner_successful() { mint_settings: MintSettings::default(), // Use default mint settings }; - let _ = NFTs::create(RuntimeOrigin::signed(ALICE), ALICE, def_config); + let _ = testpara::NFTs::create(testpara::RuntimeOrigin::signed(ALICE), ALICE, def_config); - let _ = NFTs::mint(RuntimeOrigin::signed(ALICE), 0, 0, ALICE, None); + let _ = testpara::NFTs::mint(testpara::RuntimeOrigin::signed(ALICE), 0, 0, ALICE, None); - let _ = XcNFT::parse_nft_owner(RuntimeOrigin::signed(ALICE), BOB, 0, 0); + let _ = testpara::XcNFT::parse_nft_owner(testpara::RuntimeOrigin::signed(ALICE), BOB, 0, 0); - System::assert_has_event(RuntimeEvent::NFTs(pallet_nfts::Event::Transferred { + testpara::System::assert_has_event(testpara::RuntimeEvent::NFTs(pallet_nfts::Event::Transferred { collection: 0, item: 0, from: ALICE, @@ -857,12 +1009,12 @@ fn try_parse_nft_owner_successful() { #[test] fn try_parse_nft_transfer_no_collection() { - new_test_ext().execute_with(|| { - System::set_block_number(2); + ParaA::execute_with(|| { + testpara::System::set_block_number(2); assert_noop!( - XcNFT::parse_nft_transfer( - RuntimeOrigin::signed(ALICE), + testpara::XcNFT::parse_nft_transfer( + testpara::RuntimeOrigin::signed(ALICE), 0, 0, BoundedVec::new(), @@ -877,8 +1029,8 @@ fn try_parse_nft_transfer_no_collection() { #[test] fn try_parse_nft_transfer_already_received() { - new_test_ext().execute_with(|| { - System::set_block_number(2); + ParaA::execute_with(|| { + testpara::System::set_block_number(2); let def_config: CollectionConfigFor = CollectionConfigFor:: { settings: CollectionSettings::all_enabled(), // Default settings (all enabled) @@ -887,9 +1039,9 @@ fn try_parse_nft_transfer_already_received() { mint_settings: MintSettings::default(), // Use default mint settings }; - let _ = NFTs::create(RuntimeOrigin::signed(ALICE), ALICE, def_config); + let _ = testpara::NFTs::create(testpara::RuntimeOrigin::signed(ALICE), ALICE, def_config); - let _ = NFTs::mint(RuntimeOrigin::signed(ALICE), 0, 0, ALICE, None); + let _ = testpara::NFTs::mint(testpara::RuntimeOrigin::signed(ALICE), 0, 0, ALICE, None); let nfts: ReceivedStruct = ReceivedStruct:: { origin_para_id: 1000.into(), @@ -902,8 +1054,8 @@ fn try_parse_nft_transfer_already_received() { let _ = ReceivedAssets::::insert((0, 0), nfts); assert_noop!( - XcNFT::parse_nft_transfer( - RuntimeOrigin::signed(ALICE), + testpara::XcNFT::parse_nft_transfer( + testpara::RuntimeOrigin::signed(ALICE), 0, 0, BoundedVec::new(), @@ -918,8 +1070,8 @@ fn try_parse_nft_transfer_already_received() { #[test] fn try_parse_nft_transfer_not_collection_owner() { - new_test_ext().execute_with(|| { - System::set_block_number(2); + ParaA::execute_with(|| { + testpara::System::set_block_number(2); let def_config: CollectionConfigFor = CollectionConfigFor:: { settings: CollectionSettings::all_enabled(), // Default settings (all enabled) @@ -928,12 +1080,12 @@ fn try_parse_nft_transfer_not_collection_owner() { mint_settings: MintSettings::default(), // Use default mint settings }; - let _ = NFTs::create(RuntimeOrigin::signed(ALICE), ALICE, def_config); - let _ = NFTs::mint(RuntimeOrigin::signed(ALICE), 0, 0, ALICE, None); + let _ = testpara::NFTs::create(testpara::RuntimeOrigin::signed(ALICE), ALICE, def_config); + let _ = testpara::NFTs::mint(testpara::RuntimeOrigin::signed(ALICE), 0, 0, ALICE, None); assert_noop!( - XcNFT::parse_nft_transfer( - RuntimeOrigin::signed(BOB), + testpara::XcNFT::parse_nft_transfer( + testpara::RuntimeOrigin::signed(BOB), 0, 0, BoundedVec::new(), @@ -948,8 +1100,8 @@ fn try_parse_nft_transfer_not_collection_owner() { #[test] fn try_parse_nft_transfer_not_existing_nft() { - new_test_ext().execute_with(|| { - System::set_block_number(2); + ParaA::execute_with(|| { + testpara::System::set_block_number(2); let def_config: CollectionConfigFor = CollectionConfigFor:: { settings: CollectionSettings::all_enabled(), // Default settings (all enabled) @@ -958,12 +1110,12 @@ fn try_parse_nft_transfer_not_existing_nft() { mint_settings: MintSettings::default(), // Use default mint settings }; - let _ = NFTs::create(RuntimeOrigin::signed(ALICE), ALICE, def_config); - let _ = NFTs::mint(RuntimeOrigin::signed(ALICE), 0, 0, ALICE, None); + let _ = testpara::NFTs::create(testpara::RuntimeOrigin::signed(ALICE), ALICE, def_config); + let _ = testpara::NFTs::mint(testpara::RuntimeOrigin::signed(ALICE), 0, 0, ALICE, None); assert_noop!( - XcNFT::parse_nft_transfer( - RuntimeOrigin::signed(ALICE), + testpara::XcNFT::parse_nft_transfer( + testpara::RuntimeOrigin::signed(ALICE), 0, 0, BoundedVec::new(), @@ -978,8 +1130,8 @@ fn try_parse_nft_transfer_not_existing_nft() { #[test] fn try_parse_nft_transfer_successful() { - new_test_ext().execute_with(|| { - System::set_block_number(2); + ParaA::execute_with(|| { + testpara::System::set_block_number(2); let def_config: CollectionConfigFor = CollectionConfigFor:: { settings: CollectionSettings::all_enabled(), // Default settings (all enabled) @@ -988,9 +1140,9 @@ fn try_parse_nft_transfer_successful() { mint_settings: MintSettings::default(), // Use default mint settings }; - let _ = NFTs::create(RuntimeOrigin::signed(ALICE), ALICE, def_config); - let _ = XcNFT::parse_nft_transfer( - RuntimeOrigin::signed(ALICE), + let _ = testpara::NFTs::create(testpara::RuntimeOrigin::signed(ALICE), ALICE, def_config); + let _ = testpara::XcNFT::parse_nft_transfer( + testpara::RuntimeOrigin::signed(ALICE), 0, 0, BoundedVec::new(), @@ -998,7 +1150,7 @@ fn try_parse_nft_transfer_successful() { 0, 1000.into(), ); - System::assert_has_event(RuntimeEvent::XcNFT(Event::NFTReceived { + testpara::System::assert_has_event(testpara::RuntimeEvent::XcNFT(Event::NFTReceived { origin_collection_id: 0, origin_asset_id: 0, received_collection_id: 0, @@ -1010,8 +1162,8 @@ fn try_parse_nft_transfer_successful() { #[test] fn try_parse_nft_transfer_return_to_origin() { - new_test_ext().execute_with(|| { - System::set_block_number(2); + ParaA::execute_with(|| { + testpara::System::set_block_number(2); let def_config: CollectionConfigFor = CollectionConfigFor:: { settings: CollectionSettings::all_enabled(), // Default settings (all enabled) @@ -1020,7 +1172,7 @@ fn try_parse_nft_transfer_return_to_origin() { mint_settings: MintSettings::default(), // Use default mint settings }; - let _ = NFTs::create(RuntimeOrigin::signed(ALICE), ALICE, def_config); + let _ = testpara::NFTs::create(testpara::RuntimeOrigin::signed(ALICE), ALICE, def_config); let sent = SentStruct:: { origin_para_id: ParachainInfo::parachain_id(), @@ -1035,8 +1187,8 @@ fn try_parse_nft_transfer_return_to_origin() { //Set parachain id to 1000 ParachainInfo::parachain_id(); - let _ = XcNFT::parse_nft_transfer( - RuntimeOrigin::signed(ALICE), + let _ = testpara::XcNFT::parse_nft_transfer( + testpara::RuntimeOrigin::signed(ALICE), 0, 0, BoundedVec::new(), @@ -1044,7 +1196,7 @@ fn try_parse_nft_transfer_return_to_origin() { 0, ParachainInfo::parachain_id(), ); - System::assert_has_event(RuntimeEvent::XcNFT(Event::NFTReturnedToOrigin { + testpara::System::assert_has_event(testpara::RuntimeEvent::XcNFT(Event::NFTReturnedToOrigin { returned_from_collection_id: 0, returned_from_asset_id: 0, to_address: ALICE, @@ -1054,8 +1206,8 @@ fn try_parse_nft_transfer_return_to_origin() { #[test] fn parse_collection_same_owner_successful() { - new_test_ext().execute_with(|| { - System::set_block_number(2); + ParaA::execute_with(|| { + testpara::System::set_block_number(2); let def_config: CollectionConfigFor = CollectionConfigFor:: { settings: CollectionSettings::all_enabled(), // Default settings (all enabled) @@ -1064,11 +1216,11 @@ fn parse_collection_same_owner_successful() { mint_settings: MintSettings::default(), // Use default mint settings }; - let mut nfts: Vec<(u32, BoundedVec)> = Vec::new(); + let mut nfts: Vec<(u32, BoundedVec)> = Vec::new(); nfts.push((1, BoundedVec::new())); - let _ = XcNFT::parse_collection_same_owner( - RuntimeOrigin::signed(ALICE), + let _ = testpara::XcNFT::parse_collection_same_owner( + testpara::RuntimeOrigin::signed(ALICE), Some(def_config), BoundedVec::new(), nfts.clone(), @@ -1076,7 +1228,7 @@ fn parse_collection_same_owner_successful() { 0, None, ); - System::assert_has_event(RuntimeEvent::XcNFT(Event::CollectionWithNftsReceived { + testpara::System::assert_has_event(testpara::RuntimeEvent::XcNFT(Event::CollectionWithNftsReceived { collection_id: 0, items: nfts.clone(), })); @@ -1085,8 +1237,8 @@ fn parse_collection_same_owner_successful() { #[test] fn parse_collection_diff_nft_owners_successful() { - new_test_ext().execute_with(|| { - System::set_block_number(2); + ParaA::execute_with(|| { + testpara::System::set_block_number(2); let def_config: CollectionConfigFor = CollectionConfigFor:: { settings: CollectionSettings::all_enabled(), // Default settings (all enabled) @@ -1095,11 +1247,11 @@ fn parse_collection_diff_nft_owners_successful() { mint_settings: MintSettings::default(), // Use default mint settings }; - let mut nfts: Vec<(u32, AccountId32, BoundedVec)> = Vec::new(); + let mut nfts: Vec<(u32, AccountId32, BoundedVec)> = Vec::new(); nfts.push((1, BOB, BoundedVec::new())); - let _ = XcNFT::parse_collection_diff_owners( - RuntimeOrigin::signed(ALICE), + let _ = testpara::XcNFT::parse_collection_diff_owners( + testpara::RuntimeOrigin::signed(ALICE), Some(def_config), BoundedVec::new(), nfts.clone(), @@ -1107,8 +1259,76 @@ fn parse_collection_diff_nft_owners_successful() { 0, None, ); - System::assert_has_event(RuntimeEvent::XcNFT( + testpara::System::assert_has_event(testpara::RuntimeEvent::XcNFT( Event::CollectionWithNftsDiffOwnersReceived { collection_id: 0, items: nfts.clone() }, )); }); } + +#[test] +fn try_collection_metadata_success(){ + ParaA::execute_with(|| { + testpara::System::set_block_number(2); + + let _ = testpara::XcNFT::collection_x_update(testpara::RuntimeOrigin::signed(ALICE), 0, 1000.into(), BoundedVec::new()); + + testpara::System::assert_has_event(testpara::RuntimeEvent::XcNFT(Event::CollectionMetadataSent { collection_id: 0, proposed_data: BoundedVec::new(), owner: ALICE, destination: 1000.into()})); + }); +} + +#[test] +fn try_collection_owner_send_success(){ + ParaA::execute_with(|| { + testpara::System::set_block_number(2); + + let _ = testpara::XcNFT::collection_x_change_owner(testpara::RuntimeOrigin::signed(ALICE), 0, 1000.into(), BOB); + + testpara::System::assert_has_event(testpara::RuntimeEvent::XcNFT(Event::CollectionOwnershipSent { collection_id: 0, proposed_owner: BOB, destination: 1000.into() })); + }); +} + +#[test] +fn try_collection_burn_success(){ + ParaA::execute_with(|| { + testpara::System::set_block_number(2); + + let witness = GeneralizedDestroyWitness { item_meta: 0, item_configs: 0, attributes: 0 }; + + let _ = testpara::XcNFT::collection_x_burn(testpara::RuntimeOrigin::signed(ALICE), 0, 1000.into(), witness.clone()); + + testpara::System::assert_has_event(testpara::RuntimeEvent::XcNFT(Event::CollectionBurnSent { collection_id: 0, burn_data: witness.clone(), owner: ALICE, destination: 1000.into() })); + }); +} + +#[test] +fn try_nft_metadata_successful() { + ParaA::execute_with(|| { + testpara::System::set_block_number(2); + + let _ = testpara::XcNFT::nft_x_update(testpara::RuntimeOrigin::signed(ALICE), 0, 0, 1000.into(), BoundedVec::new()); + + testpara::System::assert_has_event(testpara::RuntimeEvent::XcNFT(Event::NFTMetadataSent { collection_id: 0, asset_id: 0, proposed_data: BoundedVec::new(), owner: ALICE, destination: 1000.into() })); + }); +} + +#[test] +fn try_nft_owner_successful() { + ParaA::execute_with(|| { + testpara::System::set_block_number(2); + + let _ = testpara::XcNFT::nft_x_change_owner(testpara::RuntimeOrigin::signed(ALICE), 0, 0, 1000.into(), BOB); + + testpara::System::assert_has_event(testpara::RuntimeEvent::XcNFT(Event::NFTOwnershipSent { collection_id: 0, asset_id: 0, proposed_owner: BOB, destination: 1000.into() })); + }); +} + +#[test] +fn try_nft_burn_successful() { + ParaA::execute_with(|| { + testpara::System::set_block_number(2); + + let _ = testpara::XcNFT::nft_x_burn(testpara::RuntimeOrigin::signed(ALICE), 0, 0, 1000.into()); + + testpara::System::assert_has_event(testpara::RuntimeEvent::XcNFT(Event::NFTBurnSent { collection_id: 0, asset_id: 0, owner: ALICE, destination: 1000.into() })); + }); +} \ No newline at end of file diff --git a/templates/parachain/pallets/xcnft/src/tests/testpara/xcm_config/barrier.rs b/templates/parachain/pallets/xcnft/src/tests/testpara/xcm_config/barrier.rs index 5f1e655be05e..b0ac69069cf1 100644 --- a/templates/parachain/pallets/xcnft/src/tests/testpara/xcm_config/barrier.rs +++ b/templates/parachain/pallets/xcnft/src/tests/testpara/xcm_config/barrier.rs @@ -15,6 +15,6 @@ // along with Polkadot. If not, see . use frame_support::traits::Everything; -use xcm_builder::AllowUnpaidExecutionFrom; +use xcm_builder::AllowExplicitUnpaidExecutionFrom; -pub type Barrier = AllowUnpaidExecutionFrom; \ No newline at end of file +pub type Barrier = AllowExplicitUnpaidExecutionFrom; \ No newline at end of file diff --git a/templates/parachain/pallets/xcnft/src/tests/testpara/xcm_config/mod.rs b/templates/parachain/pallets/xcnft/src/tests/testpara/xcm_config/mod.rs index f7d340d7f54f..44a7f3dc14c8 100644 --- a/templates/parachain/pallets/xcnft/src/tests/testpara/xcm_config/mod.rs +++ b/templates/parachain/pallets/xcnft/src/tests/testpara/xcm_config/mod.rs @@ -26,6 +26,7 @@ pub mod weigher; use crate::tests::testpara::{MsgQueue, PolkadotXcm, RuntimeCall}; use frame_support::traits::{Everything, Nothing}; use xcm_builder::{EnsureDecodableXcm, FixedRateOfFungible, FrameTransactionalProcessor}; +use xcm_executor::traits::WithOriginFilter; // Generated from `decl_test_network!` pub type XcmRouter = EnsureDecodableXcm>; @@ -53,7 +54,7 @@ impl xcm_executor::Config for XcmConfig { type MaxAssetsIntoHolding = constants::MaxAssetsIntoHolding; type MessageExporter = (); type UniversalAliases = Nothing; - type CallDispatcher = RuntimeCall; + type CallDispatcher = WithOriginFilter; type SafeCallFilter = Everything; type Aliasers = Everything; type TransactionalProcessor = FrameTransactionalProcessor; diff --git a/templates/parachain/pallets/xcnft/src/tests/testrelay/xcm_config/barrier.rs b/templates/parachain/pallets/xcnft/src/tests/testrelay/xcm_config/barrier.rs index 5f1e655be05e..b0ac69069cf1 100644 --- a/templates/parachain/pallets/xcnft/src/tests/testrelay/xcm_config/barrier.rs +++ b/templates/parachain/pallets/xcnft/src/tests/testrelay/xcm_config/barrier.rs @@ -15,6 +15,6 @@ // along with Polkadot. If not, see . use frame_support::traits::Everything; -use xcm_builder::AllowUnpaidExecutionFrom; +use xcm_builder::AllowExplicitUnpaidExecutionFrom; -pub type Barrier = AllowUnpaidExecutionFrom; \ No newline at end of file +pub type Barrier = AllowExplicitUnpaidExecutionFrom; \ No newline at end of file diff --git a/templates/parachain/pallets/xcnft/src/tests/testrelay/xcm_config/mod.rs b/templates/parachain/pallets/xcnft/src/tests/testrelay/xcm_config/mod.rs index 7a787e0f64be..d483a20d83a0 100644 --- a/templates/parachain/pallets/xcnft/src/tests/testrelay/xcm_config/mod.rs +++ b/templates/parachain/pallets/xcnft/src/tests/testrelay/xcm_config/mod.rs @@ -26,6 +26,7 @@ use crate::tests::testrelay::{RuntimeCall, XcmPallet}; use frame_support::traits::{Everything, Nothing}; use xcm_builder::{EnsureDecodableXcm, FixedRateOfFungible, FrameTransactionalProcessor}; use xcm_executor::Config; +use xcm_executor::traits::WithOriginFilter; // Generated from `decl_test_network!` pub type XcmRouter = EnsureDecodableXcm; @@ -53,9 +54,9 @@ impl Config for XcmConfig { type MaxAssetsIntoHolding = constants::MaxAssetsIntoHolding; type MessageExporter = (); type UniversalAliases = Nothing; - type CallDispatcher = RuntimeCall; + type CallDispatcher = WithOriginFilter; type SafeCallFilter = Everything; - type Aliasers = Nothing; + type Aliasers = Everything; type TransactionalProcessor = FrameTransactionalProcessor; type HrmpNewChannelOpenRequestHandler = (); type HrmpChannelAcceptedHandler = ();