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

difftreelog

source

tests/src/rmrk/setNftProperty.seqtest.ts3.1 KiBsourcehistory
1import {getApiConnection} from '../substrate/substrate-api';2import {NftIdTuple} from './util/fetch';3import {expectTxFailure, requirePallets, Pallets} from './util/helpers';4import {createCollection, mintNft, sendNft, setNftProperty} from './util/tx';56describe('integration test: set NFT property', () => {7  let api: any;8  before(async function () {9    api = await getApiConnection();10    await requirePallets(this, [Pallets.RmrkCore]);11  });1213  const alice = '//Alice';14  const bob = '//Bob';1516  const createTestCollection = async (issuerUri: string) => {17    return await createCollection(18      api,19      issuerUri,20      'setprop-nft-collection-metadata',21      null,22      'setprop',23    );24  };2526  it('set NFT property', async () => {27    const ownerAlice = alice;2829    const collectionId = await createTestCollection(alice);30    const nftId = await mintNft(api, alice, ownerAlice, collectionId, 'prop-nft');3132    await setNftProperty(api, alice, collectionId, nftId, 'test-key', 'test-key-value');33    await setNftProperty(api, alice, collectionId, nftId, 'test-key', 'updated-key-value');34    await setNftProperty(api, alice, collectionId, nftId, 'second-test-key', 'second-test-key-value');35  });3637  it('[negative] unable to set a property of non-existing NFT', async () => {38    const collectionId = 0;39    const maxNftId = 0xFFFFFFFF;4041    const tx = setNftProperty(api, alice, collectionId, maxNftId, 'test-key', 'test-value');4243    await expectTxFailure(/rmrkCore\.NoAvailableNftId/, tx);44  });4546  it('[negative] unable to set a property by not-an-owner', async () => {47    const ownerAlice = alice;4849    const collectionId = await createTestCollection(alice);50    const nftId = await mintNft(api, alice, ownerAlice, collectionId, 'prop-nft');5152    const tx = setNftProperty(api, bob, collectionId, nftId, 'test-key', 'test-key-value');5354    await expectTxFailure(/rmrkCore\.NoPermission/, tx);55  });5657  it('set a property to nested NFT', async () => {58    const ownerAlice = alice;5960    const collectionId = await createTestCollection(alice);61    const parentNftId = await mintNft(api, alice, ownerAlice, collectionId, 'prop-parent-nft');62    const childNftId = await mintNft(api, alice, ownerAlice, collectionId, 'prop-child-nft');6364    const ownerNft: NftIdTuple = [collectionId, parentNftId];6566    await sendNft(api, 'sent', ownerAlice, collectionId, childNftId, ownerNft);6768    await setNftProperty(api, alice, collectionId, childNftId, 'test-key', 'test-key-value');69  });7071  it('[negative] set a property to nested NFT (by not-root-owner)', async () => {72    const ownerAlice = alice;7374    const collectionId = await createTestCollection(alice);75    const parentNftId = await mintNft(api, alice, ownerAlice, collectionId, 'prop-parent-nft');76    const childNftId = await mintNft(api, alice, ownerAlice, collectionId, 'prop-child-nft');7778    const ownerNft: NftIdTuple = [collectionId, parentNftId];7980    await sendNft(api, 'sent', ownerAlice, collectionId, childNftId, ownerNft);8182    const tx = setNftProperty(api, bob, collectionId, childNftId, 'test-key', 'test-key-value');8384    await expectTxFailure(/rmrkCore\.NoPermission/, tx);85  });8687  after(async() => { await api.disconnect(); });88});