git.delta.rocks / unique-network / refs/commits / 0335e511ccbf

difftreelog

tests: adminTransferAndBurn migrated

rkv2022-09-06parent: #fc68cba.patch.diff
in: master

2 files changed

modifiedtests/package.jsondiffbeforeafterboth
--- a/tests/package.json
+++ b/tests/package.json
@@ -48,6 +48,7 @@
     "testRemoveCollectionAdmin": "mocha --timeout 9999999 -r ts-node/register ./**/removeCollectionAdmin.test.ts",
     "testRemoveCollectionSponsor": "mocha --timeout 9999999 -r ts-node/register ./**/removeCollectionSponsor.test.ts",
     "testRemoveFromAllowList": "mocha --timeout 9999999 -r ts-node/register ./**/removeFromAllowList.test.ts",
+    "testAllowLists": "mocha --timeout 9999999 -r ts-node/register ./**/allowLists.test.ts",
     "testConnection": "mocha --timeout 9999999 -r ts-node/register ./**/connection.test.ts",
     "testContracts": "mocha --timeout 9999999 -r ts-node/register ./**/contracts.test.ts",
     "testCreateItem": "mocha --timeout 9999999 -r ts-node/register ./**/createItem.test.ts",
modifiedtests/src/adminTransferAndBurn.test.tsdiffbeforeafterboth
27 burnFromExpectSuccess,27 burnFromExpectSuccess,
28 setCollectionLimitsExpectSuccess,28 setCollectionLimitsExpectSuccess,
29} from './util/helpers';29} from './util/helpers';
30import { usingPlaygrounds } from './util/playgrounds';
3031
31chai.use(chaiAsPromised);32chai.use(chaiAsPromised);
32const expect = chai.expect;33const expect = chai.expect;
34
35let donor: IKeyringPair;
36
37before(async () => {
38 await usingPlaygrounds(async (_, privateKeyWrapper) => {
39 donor = privateKeyWrapper('//Alice');
40 });
41});
3342
34describe('Integration Test: ownerCanTransfer allows admins to use only transferFrom/burnFrom:', () => {43describe('Integration Test: ownerCanTransfer allows admins to use only transferFrom/burnFrom:', () => {
35 let alice: IKeyringPair;44 let alice: IKeyringPair;
36 let bob: IKeyringPair;45 let bob: IKeyringPair;
37 let charlie: IKeyringPair;46 let charlie: IKeyringPair;
3847
39 before(async () => {48 before(async () => {
40 await usingApi(async (api, privateKeyWrapper) => {49 await usingPlaygrounds(async (helper) => {
41 alice = privateKeyWrapper('//Alice');50 [alice, bob, charlie] = await helper.arrange.createAccounts([10n, 10n, 10n], donor);
42 bob = privateKeyWrapper('//Bob');
43 charlie = privateKeyWrapper('//Charlie');
44 });51 });
45 });52 });
4653
47 it('admin transfers other user\'s token', async () => {54 it('admin transfers other user\'s token', async () => {
48 await usingApi(async () => {55 await usingPlaygrounds(async (helper) => {
49 const collectionId = await createCollectionExpectSuccess();56 const {collectionId} = await helper.nft.mintCollection(alice, {name: 'name', description: 'descr', tokenPrefix: 'COL'});
50 await setCollectionLimitsExpectSuccess(alice, collectionId, {ownerCanTransfer: true});57 const setLimitsResult = await helper.collection.setLimits(alice, collectionId, {ownerCanTransfer: true});
58 const limits = await helper.collection.getEffectiveLimits(collectionId);
59 expect(limits.ownerCanTransfer).to.be.true;
5160
52 const tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT', {Substrate: bob.address});61 const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: bob.address});
53
54 await transferExpectFailure(collectionId, tokenId, alice, charlie);62 const transferResult = async () => helper.nft.transferToken(alice, collectionId, tokenId, {Substrate: charlie.address});
63 await expect(transferResult()).to.be.rejected;
5564
56 await transferFromExpectSuccess(collectionId, tokenId, alice, bob, charlie, 1);65 const res = await helper.nft.transferTokenFrom(alice, collectionId, tokenId, {Substrate: bob.address}, {Substrate: charlie.address});
66 const newTokenOwner = await helper.nft.getTokenOwner(collectionId, tokenId);
67 expect(newTokenOwner.Substrate).to.be.equal(charlie.address);
57 });68 });
58 });69 });
5970
60 it('admin burns other user\'s token', async () => {71 it('admin burns other user\'s token', async () => {
61 await usingApi(async () => {72 await usingPlaygrounds(async (helper) => {
62 const collectionId = await createCollectionExpectSuccess();73 const {collectionId} = await helper.nft.mintCollection(alice, {name: 'name', description: 'descr', tokenPrefix: 'COL'});
74
63 await setCollectionLimitsExpectSuccess(alice, collectionId, {ownerCanTransfer: true});75 const setLimitsResult = await helper.collection.setLimits(alice, collectionId, {ownerCanTransfer: true});
76 const limits = await helper.collection.getEffectiveLimits(collectionId);
77 expect(limits.ownerCanTransfer).to.be.true;
6478
65 const tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT', {Substrate: bob.address});79 const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: bob.address});
66
67 await burnItemExpectFailure(alice, collectionId, tokenId);80 const burnTxFailed = async () => helper.nft.burnToken(alice, collectionId, tokenId);
81
82 await expect(burnTxFailed()).to.be.rejected;
6883
69 await burnFromExpectSuccess(alice, bob, collectionId, tokenId);84 const burnResult = await helper.nft.burnToken(bob, collectionId, tokenId);
85 const token = await helper.nft.getToken(collectionId, tokenId);
86 expect(token).to.be.null;
70 });87 });
71 });88 });
72});89});