difftreelog
fix nesting depth limit tests
in: master
2 files changed
runtime/common/src/runtime_apis.rsdiffbeforeafterboth--- a/runtime/common/src/runtime_apis.rs
+++ b/runtime/common/src/runtime_apis.rs
@@ -25,7 +25,7 @@
dispatch_unique_runtime!(collection.token_owner(token))
}
fn topmost_token_owner(collection: CollectionId, token: TokenId) -> Result<Option<CrossAccountId>, DispatchError> {
- let budget = up_data_structs::budget::Value::new(5);
+ let budget = up_data_structs::budget::Value::new(10);
Ok(Some(<pallet_structure::Pallet<Runtime>>::find_topmost_owner(collection, token, &budget)?))
}
@@ -210,7 +210,7 @@
Ok(
pallet_nonfungible::TokenChildren::<Runtime>::iter_prefix((collection_id, nft_id))
- .filter_map(|(child_id, is_child)|
+ .filter_map(|(child_id, is_child)|
match is_child {
true => Some(RmrkNftChild {
collection_id: child_id.0.0,
tests/src/nesting/nest.test.tsdiffbeforeafterboth207 await setCollectionLimitsExpectSuccess(alice, collection, {nestingRule: 'Owner'});207 await setCollectionLimitsExpectSuccess(alice, collection, {nestingRule: 'Owner'});208 const targetToken = await createItemExpectSuccess(alice, collection, 'NFT');208 const targetToken = await createItemExpectSuccess(alice, collection, 'NFT');209209210 // Create a nested-token matryoshka211 const nestedToken1 = await createItemExpectSuccess(alice, collection, 'NFT', {Ethereum: tokenIdToAddress(collection, targetToken)});210 const maxNestingLevel = 5;211 let prevToken = targetToken;212213 // Create a nested-token matryoshka214 for (let i = 0; i < maxNestingLevel; i++) {212 const nestedToken2 = await createItemExpectSuccess(alice, collection, 'NFT', {Ethereum: tokenIdToAddress(collection, nestedToken1)});215 const nestedToken = await createItemExpectSuccess(216 alice,217 collection,218 'NFT',219 {Ethereum: tokenIdToAddress(collection, prevToken)},220 );221222 prevToken = nestedToken;223 }224213 // The nesting depth is limited by 2225 // The nesting depth is limited by `maxNestingLevel`214 await expect(executeTransaction(api, alice, api.tx.unique.createItem(226 await expect(executeTransaction(api, alice, api.tx.unique.createItem(215 collection, 227 collection,216 {Ethereum: tokenIdToAddress(collection, nestedToken2)}, 228 {Ethereum: tokenIdToAddress(collection, prevToken)},217 {nft: {const_data: [], variable_data: []}} as any,229 {nft: {const_data: [], variable_data: []}} as any,218 )), 'while creating nested token').to.be.rejectedWith(/^structure\.DepthLimit$/);230 )), 'while creating nested token').to.be.rejectedWith(/^structure\.DepthLimit$/);219231220 expect(await getTopmostTokenOwner(api, collection, nestedToken2)).to.be.deep.equal({Substrate: alice.address});232 expect(await getTopmostTokenOwner(api, collection, prevToken)).to.be.deep.equal({Substrate: alice.address});221 });233 });222 });234 });223235