git.delta.rocks / unique-network / refs/commits / 82cba6b103c9

difftreelog

test nested rft topMostOwner

Daniel Shiposha2023-01-19parent: #e003541.patch.diff
in: master

1 file changed

modifiedtests/src/nesting/nest.test.tsdiffbeforeafterboth
15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
1616
17import {IKeyringPair} from '@polkadot/types/types';17import {IKeyringPair} from '@polkadot/types/types';
18import {expect, itSub, usingPlaygrounds} from '../util';18import {expect, itSub, Pallets, usingPlaygrounds} from '../util';
1919
20describe('Integration Test: Composite nesting tests', () => {20describe('Integration Test: Composite nesting tests', () => {
21 let alice: IKeyringPair;21 let alice: IKeyringPair;
138 before(async () => {138 before(async () => {
139 await usingPlaygrounds(async (helper, privateKey) => {139 await usingPlaygrounds(async (helper, privateKey) => {
140 const donor = await privateKey({filename: __filename});140 const donor = await privateKey({filename: __filename});
141 [alice, bob, charlie] = await helper.arrange.createAccounts([50n, 10n, 10n], donor);141 [alice, bob, charlie] = await helper.arrange.createAccounts([200n, 10n, 10n], donor);
142 });142 });
143 });143 });
144144
289 expect(await collectionFT.getBalance(targetToken.nestingAccount())).to.be.equal(7n);289 expect(await collectionFT.getBalance(targetToken.nestingAccount())).to.be.equal(7n);
290 });290 });
291
292 itSub.ifWithPallets('ReFungible: getTopmostOwner works correctly with Nesting', [Pallets.ReFungible], async({helper}) => {
293 const collectionNFT = await helper.nft.mintCollection(alice, {
294 permissions: {
295 nesting: {
296 tokenOwner: true,
297 },
298 },
299 });
300 const collectionRFT = await helper.rft.mintCollection(alice);
301
302 const nft = await collectionNFT.mintToken(alice, {Substrate: alice.address});
303 const rft = await collectionRFT.mintToken(alice, 100n, {Substrate: alice.address});
304
305 expect(await rft.getTopmostOwner()).deep.equal({Substrate: alice.address});
306
307 await rft.transfer(alice, nft.nestingAccount(), 40n);
308
309 expect(await rft.getTopmostOwner()).deep.equal(null);
310
311 await rft.transfer(alice, nft.nestingAccount(), 60n);
312
313 expect(await rft.getTopmostOwner()).deep.equal({Substrate: alice.address});
314
315 await rft.transferFrom(alice, nft.nestingAccount(), {Substrate: alice.address}, 30n);
316
317 expect(await rft.getTopmostOwner()).deep.equal(null);
318
319 await rft.transferFrom(alice, nft.nestingAccount(), {Substrate: alice.address}, 70n);
320
321 expect(await rft.getTopmostOwner()).deep.equal({Substrate: alice.address});
322 });
291});323});
292324
293describe('Negative Test: Nesting', () => {325describe('Negative Test: Nesting', () => {