git.delta.rocks / unique-network / refs/commits / f37b77adcb2f

difftreelog

Nested rft pieces burn test

Max Andreev2023-01-13parent: #483c1f0.patch.diff
in: master

1 file changed

modifiedtests/src/sub/refungible/nesting.test.tsdiffbeforeafterboth
58 });58 });
59 });59 });
6060
61 itSub('owner can unnest nested token', async ({helper}) => {61 itSub('Owner can unnest nested token', async ({helper}) => {
62 const collection = await helper.nft.mintCollection(alice, {permissions: {nesting: {tokenOwner: true}}});62 const collection = await helper.nft.mintCollection(alice, {permissions: {nesting: {tokenOwner: true}}});
63 const targetToken = await collection.mintToken(alice);63 const targetToken = await collection.mintToken(alice);
6464
77 expect(await token.getBalance(targetToken.nestingAccount())).to.be.equal(0n);77 expect(await token.getBalance(targetToken.nestingAccount())).to.be.equal(0n);
78 });78 });
7979
80 itSub('owner can burn nested token', async ({helper}) => {80 itSub('Owner can burn nested token pieces', async ({helper}) => {
81 const collection = await helper.nft.mintCollection(alice, {permissions: {nesting: {tokenOwner: true}}});81 const collection = await helper.nft.mintCollection(alice, {permissions: {nesting: {tokenOwner: true}}});
82 const targetToken = await collection.mintToken(alice);82 const targetToken = await collection.mintToken(alice);
8383
84 // Owner mints nested RFT token:84 // Owner mints nested RFT token:
85 const collectionRFT = await helper.rft.mintCollection(alice);85 const collectionRFT = await helper.rft.mintCollection(alice);
86 const token = await collectionRFT.mintToken(alice, 10n, targetToken.nestingAccount());86 const token = await collectionRFT.mintToken(alice, 100n, {Substrate: alice.address});
87 await token.transfer(alice, targetToken.nestingAccount(), 30n);
8788
88 // 1.1 Owner can partially burnFrom nested pieces:89 // 1.1 Owner can partially burnFrom nested pieces:
89 await token.burnFrom(alice, targetToken.nestingAccount(), 6n);90 await token.burnFrom(alice, targetToken.nestingAccount(), 10n);
90 expect(await token.getBalance({Substrate: alice.address})).to.be.equal(0n);91 expect(await token.getBalance({Substrate: alice.address})).to.be.equal(70n);
91 expect(await token.getBalance(targetToken.nestingAccount())).to.be.equal(4n);92 expect(await token.getBalance(targetToken.nestingAccount())).to.be.equal(20n);
92 expect(await targetToken.getChildren()).to.has.length(1);93 expect(await targetToken.getChildren()).to.has.length(1);
9394
94 // 1.1 Owner can burnFrom all nested pieces:95 // 1.1 Owner can burnFrom all nested pieces:
95 await token.burnFrom(alice, targetToken.nestingAccount(), 4n);96 await token.burnFrom(alice, targetToken.nestingAccount(), 20n);
96 expect(await token.getBalance(targetToken.nestingAccount())).to.be.equal(0n);97 expect(await token.getBalance(targetToken.nestingAccount())).to.be.equal(0n);
97 expect(await targetToken.getChildren()).to.has.length(0);98 expect(await targetToken.getChildren()).to.has.length(0);
98 expect(await token.doesExist()).to.be.false;99 expect(await token.doesExist()).to.be.true;
100
101 // 2. Target token does not contain any pieces and can be burnt:
102 await targetToken.burn(alice);
103 expect(await targetToken.doesExist()).to.be.false;
99 });104 });
100});105});
101106