1234567891011121314151617import {IKeyringPair} from '@polkadot/types/types';18import {expect, itSub, usingPlaygrounds} from '../util/playgrounds';19import {UniqueHelper, UniqueNFToken} from '../util/playgrounds/unique';202122232425262728async function buildComplexObjectGraph(helper: UniqueHelper, sender: IKeyringPair): Promise<UniqueNFToken[]> {29 const collection = await helper.nft.mintCollection(sender, {permissions: {nesting: {tokenOwner: true}}});30 const tokens = await collection.mintMultipleTokens(sender, Array(8).fill({owner: {Substrate: sender.address}}));3132 await tokens[7].nest(sender, tokens[4]);33 await tokens[6].nest(sender, tokens[5]);34 await tokens[5].nest(sender, tokens[4]);35 await tokens[4].nest(sender, tokens[1]);36 await tokens[3].nest(sender, tokens[2]);37 await tokens[2].nest(sender, tokens[1]);38 await tokens[1].nest(sender, tokens[0]);3940 return tokens;41}4243describe('Graphs', () => {44 let alice: IKeyringPair;4546 before(async () => {47 await usingPlaygrounds(async (helper, privateKey) => {48 const donor = privateKey('//Alice');49 [alice] = await helper.arrange.createAccounts([10n], donor);50 });51 });5253 itSub('Ouroboros can\'t be created in a complex graph', async ({helper}) => {54 const tokens = await buildComplexObjectGraph(helper, alice);5556 57 await expect(58 tokens[0].nest(alice, tokens[0]),59 'first transaction', 60 ).to.be.rejectedWith(/structure\.OuroborosDetected/);61 62 await expect(63 tokens[0].nest(alice, tokens[4]),64 'second transaction',65 ).to.be.rejectedWith(/structure\.OuroborosDetected/);66 await expect(67 tokens[1].transferFrom(alice, tokens[0].nestingAccount(), tokens[7].nestingAccount()),68 'third transaction',69 ).to.be.rejectedWith(/structure\.OuroborosDetected/);70 });71});