difftreelog
tests: adminTransferAndBurn migrated
in: master
2 files changed
tests/package.jsondiffbeforeafterboth48 "testRemoveCollectionAdmin": "mocha --timeout 9999999 -r ts-node/register ./**/removeCollectionAdmin.test.ts",48 "testRemoveCollectionAdmin": "mocha --timeout 9999999 -r ts-node/register ./**/removeCollectionAdmin.test.ts",49 "testRemoveCollectionSponsor": "mocha --timeout 9999999 -r ts-node/register ./**/removeCollectionSponsor.test.ts",49 "testRemoveCollectionSponsor": "mocha --timeout 9999999 -r ts-node/register ./**/removeCollectionSponsor.test.ts",50 "testRemoveFromAllowList": "mocha --timeout 9999999 -r ts-node/register ./**/removeFromAllowList.test.ts",50 "testRemoveFromAllowList": "mocha --timeout 9999999 -r ts-node/register ./**/removeFromAllowList.test.ts",51 "testAllowLists": "mocha --timeout 9999999 -r ts-node/register ./**/allowLists.test.ts",51 "testConnection": "mocha --timeout 9999999 -r ts-node/register ./**/connection.test.ts",52 "testConnection": "mocha --timeout 9999999 -r ts-node/register ./**/connection.test.ts",52 "testContracts": "mocha --timeout 9999999 -r ts-node/register ./**/contracts.test.ts",53 "testContracts": "mocha --timeout 9999999 -r ts-node/register ./**/contracts.test.ts",53 "testCreateItem": "mocha --timeout 9999999 -r ts-node/register ./**/createItem.test.ts",54 "testCreateItem": "mocha --timeout 9999999 -r ts-node/register ./**/createItem.test.ts",tests/src/adminTransferAndBurn.test.tsdiffbeforeafterboth--- a/tests/src/adminTransferAndBurn.test.ts
+++ b/tests/src/adminTransferAndBurn.test.ts
@@ -27,46 +27,63 @@
burnFromExpectSuccess,
setCollectionLimitsExpectSuccess,
} from './util/helpers';
+import { usingPlaygrounds } from './util/playgrounds';
chai.use(chaiAsPromised);
const expect = chai.expect;
+let donor: IKeyringPair;
+
+before(async () => {
+ await usingPlaygrounds(async (_, privateKeyWrapper) => {
+ donor = privateKeyWrapper('//Alice');
+ });
+});
+
describe('Integration Test: ownerCanTransfer allows admins to use only transferFrom/burnFrom:', () => {
let alice: IKeyringPair;
let bob: IKeyringPair;
let charlie: IKeyringPair;
before(async () => {
- await usingApi(async (api, privateKeyWrapper) => {
- alice = privateKeyWrapper('//Alice');
- bob = privateKeyWrapper('//Bob');
- charlie = privateKeyWrapper('//Charlie');
+ await usingPlaygrounds(async (helper) => {
+ [alice, bob, charlie] = await helper.arrange.createAccounts([10n, 10n, 10n], donor);
});
});
it('admin transfers other user\'s token', async () => {
- await usingApi(async () => {
- const collectionId = await createCollectionExpectSuccess();
- await setCollectionLimitsExpectSuccess(alice, collectionId, {ownerCanTransfer: true});
-
- const tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT', {Substrate: bob.address});
+ await usingPlaygrounds(async (helper) => {
+ const {collectionId} = await helper.nft.mintCollection(alice, {name: 'name', description: 'descr', tokenPrefix: 'COL'});
+ const setLimitsResult = await helper.collection.setLimits(alice, collectionId, {ownerCanTransfer: true});
+ const limits = await helper.collection.getEffectiveLimits(collectionId);
+ expect(limits.ownerCanTransfer).to.be.true;
- await transferExpectFailure(collectionId, tokenId, alice, charlie);
+ const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: bob.address});
+ const transferResult = async () => helper.nft.transferToken(alice, collectionId, tokenId, {Substrate: charlie.address});
+ await expect(transferResult()).to.be.rejected;
- await transferFromExpectSuccess(collectionId, tokenId, alice, bob, charlie, 1);
+ const res = await helper.nft.transferTokenFrom(alice, collectionId, tokenId, {Substrate: bob.address}, {Substrate: charlie.address});
+ const newTokenOwner = await helper.nft.getTokenOwner(collectionId, tokenId);
+ expect(newTokenOwner.Substrate).to.be.equal(charlie.address);
});
});
it('admin burns other user\'s token', async () => {
- await usingApi(async () => {
- const collectionId = await createCollectionExpectSuccess();
- await setCollectionLimitsExpectSuccess(alice, collectionId, {ownerCanTransfer: true});
+ await usingPlaygrounds(async (helper) => {
+ const {collectionId} = await helper.nft.mintCollection(alice, {name: 'name', description: 'descr', tokenPrefix: 'COL'});
- const tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT', {Substrate: bob.address});
+ const setLimitsResult = await helper.collection.setLimits(alice, collectionId, {ownerCanTransfer: true});
+ const limits = await helper.collection.getEffectiveLimits(collectionId);
+ expect(limits.ownerCanTransfer).to.be.true;
+
+ const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: bob.address});
+ const burnTxFailed = async () => helper.nft.burnToken(alice, collectionId, tokenId);
- await burnItemExpectFailure(alice, collectionId, tokenId);
+ await expect(burnTxFailed()).to.be.rejected;
- await burnFromExpectSuccess(alice, bob, collectionId, tokenId);
+ const burnResult = await helper.nft.burnToken(bob, collectionId, tokenId);
+ const token = await helper.nft.getToken(collectionId, tokenId);
+ expect(token).to.be.null;
});
});
});