difftreelog
fix nesting depth limit tests
in: master
2 files changed
runtime/common/src/runtime_apis.rsdiffbeforeafterboth25 dispatch_unique_runtime!(collection.token_owner(token))25 dispatch_unique_runtime!(collection.token_owner(token))26 }26 }27 fn topmost_token_owner(collection: CollectionId, token: TokenId) -> Result<Option<CrossAccountId>, DispatchError> {27 fn topmost_token_owner(collection: CollectionId, token: TokenId) -> Result<Option<CrossAccountId>, DispatchError> {28 let budget = up_data_structs::budget::Value::new(5);28 let budget = up_data_structs::budget::Value::new(10);292930 Ok(Some(<pallet_structure::Pallet<Runtime>>::find_topmost_owner(collection, token, &budget)?))30 Ok(Some(<pallet_structure::Pallet<Runtime>>::find_topmost_owner(collection, token, &budget)?))31 }31 }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