--- a/tests/src/nesting/nest.test.ts +++ b/tests/src/nesting/nest.test.ts @@ -15,7 +15,7 @@ // along with Unique Network. If not, see . import {IKeyringPair} from '@polkadot/types/types'; -import {expect, itSub, usingPlaygrounds} from '../util'; +import {expect, itSub, Pallets, usingPlaygrounds} from '../util'; describe('Integration Test: Composite nesting tests', () => { let alice: IKeyringPair; @@ -138,7 +138,7 @@ before(async () => { await usingPlaygrounds(async (helper, privateKey) => { const donor = await privateKey({filename: __filename}); - [alice, bob, charlie] = await helper.arrange.createAccounts([50n, 10n, 10n], donor); + [alice, bob, charlie] = await helper.arrange.createAccounts([200n, 10n, 10n], donor); }); }); @@ -288,6 +288,38 @@ await collectionFT.transfer(charlie, targetToken.nestingAccount(), 2n); expect(await collectionFT.getBalance(targetToken.nestingAccount())).to.be.equal(7n); }); + + itSub.ifWithPallets('ReFungible: getTopmostOwner works correctly with Nesting', [Pallets.ReFungible], async({helper}) => { + const collectionNFT = await helper.nft.mintCollection(alice, { + permissions: { + nesting: { + tokenOwner: true, + }, + }, + }); + const collectionRFT = await helper.rft.mintCollection(alice); + + const nft = await collectionNFT.mintToken(alice, {Substrate: alice.address}); + const rft = await collectionRFT.mintToken(alice, 100n, {Substrate: alice.address}); + + expect(await rft.getTopmostOwner()).deep.equal({Substrate: alice.address}); + + await rft.transfer(alice, nft.nestingAccount(), 40n); + + expect(await rft.getTopmostOwner()).deep.equal(null); + + await rft.transfer(alice, nft.nestingAccount(), 60n); + + expect(await rft.getTopmostOwner()).deep.equal({Substrate: alice.address}); + + await rft.transferFrom(alice, nft.nestingAccount(), {Substrate: alice.address}, 30n); + + expect(await rft.getTopmostOwner()).deep.equal(null); + + await rft.transferFrom(alice, nft.nestingAccount(), {Substrate: alice.address}, 70n); + + expect(await rft.getTopmostOwner()).deep.equal({Substrate: alice.address}); + }); }); describe('Negative Test: Nesting', () => {