1234567891011121314151617import {IKeyringPair} from '@polkadot/types/types';18import {expect, itSub, usingPlaygrounds} from '../util/playgrounds';19import {ITokenNonfungible} from '../util/playgrounds/types';20import {UniqueHelper} from '../util/playgrounds/unique';212223242526272829async function buildComplexObjectGraph(helper: UniqueHelper, sender: IKeyringPair): Promise<ITokenNonfungible[]> {30 const collection = await helper.nft.mintCollection(sender, {permissions: {nesting: {tokenOwner: true}}});31 const tokens = await collection.mintMultipleTokens(sender, Array(8).fill({owner: {Substrate: sender.address}}));3233 await tokens[7].nest(sender, tokens[4]);34 await tokens[6].nest(sender, tokens[5]);35 await tokens[5].nest(sender, tokens[4]);36 await tokens[4].nest(sender, tokens[1]);37 await tokens[3].nest(sender, tokens[2]);38 await tokens[2].nest(sender, tokens[1]);39 await tokens[1].nest(sender, tokens[0]);4041 return tokens;42}4344describe('Graphs', () => {45 let alice: IKeyringPair;4647 before(async () => {48 await usingPlaygrounds(async (helper, privateKey) => {49 const donor = privateKey('//Alice');50 [alice] = await helper.arrange.createAccounts([10n], donor);51 });52 });5354 itSub('Ouroboros can\'t be created in a complex graph', async ({helper}) => {55 const tokens = await buildComplexObjectGraph(helper, alice);5657 58 await expect(59 tokens[0].nest(alice, tokens[0]),60 'first transaction', 61 ).to.be.rejectedWith(/structure\.OuroborosDetected/);62 63 await expect(64 tokens[0].nest(alice, tokens[4]),65 'second transaction',66 ).to.be.rejectedWith(/structure\.OuroborosDetected/);67 await expect(68 tokens[1].transferFrom(alice, tokens[0].nestingAccount(), tokens[7].nestingAccount()),69 'third transaction',70 ).to.be.rejectedWith(/structure\.OuroborosDetected/);71 });72});