git.delta.rocks / unique-network / refs/commits / 1a0647ecee1e

difftreelog

source

tests/src/rmrk/setEquippableList.seqtest.ts3.1 KiBsourcehistory
1import {getApiConnection} from '../substrate/substrate-api';2import {expectTxFailure, requirePallets, Pallets} from './util/helpers';3import {createCollection, createBase, setEquippableList} from './util/tx';45describe("integration test: set slot's Equippable List", () => {6  let api: any;7  before(async function () {8    api = await getApiConnection();9    await requirePallets(this, [Pallets.RmrkCore]);10  });1112  const alice = '//Alice';13  const bob = '//Bob';1415  it("set Base's slot Equippable List", async () => {16    const collectionIds = [17      await createCollection(18        api,19        alice,20        'equiplist-collection-metadata',21        null,22        'equiplist-0',23      ),24      await createCollection(25        api,26        alice,27        'equiplist-collection-metadata',28        null,29        'equiplist-1',30      ),31    ];3233    const slotId = 202;3435    const baseId = await createBase(api, alice, 'slotpartany-base-type', 'slotpartany', [36      {37        'SlotPart': {38          id: slotId,39          equippable: 'All',40          z: 1,41          src: 'some-fallback-slot-url',42        },43      },44    ]);4546    await setEquippableList(api, alice, baseId, slotId, 'All');47    await setEquippableList(api, alice, baseId, slotId, 'Empty');48    await setEquippableList(api, alice, baseId, slotId, {'Custom': collectionIds});49  });5051  it('[negative] unable to set equippable list of a slot of non-existing base', async () => {52    const maxBaseId = 0xFFFFFFFF;53    const slotId = 0;5455    const tx = setEquippableList(api, alice, maxBaseId, slotId, 'All');56    await expectTxFailure(/rmrkEquip\.BaseDoesntExist/, tx);57  });5859  it('[negative] unable to set equippable list by a not-an-owner', async () => {60    const slotId = 42;6162    const baseId = await createBase(api, alice, 'slotpartany-base-type', 'slotpartany', [63      {64        'SlotPart': {65          id: slotId,66          equippable: 'All',67          z: 1,68          src: 'some-fallback-slot-url',69        },70      },71    ]);7273    const tx = setEquippableList(api, bob, baseId, slotId, 'All');74    await expectTxFailure(/rmrkEquip\.PermissionError/, tx);75  });7677  it('[negative] unable to set equippable list to a fixed part', async () => {78    const fixedPartId = 42;7980    const baseId = await createBase(api, alice, 'fixedpart-base-type', 'fixedpart', [81      {82        'FixedPart': {83          id: fixedPartId,84          z: 0,85          src: 'fixed-part-url',86        },87      },88    ]);8990    const tx = setEquippableList(api, alice, baseId, fixedPartId, 'All');91    await expectTxFailure(/rmrkEquip\.NoEquippableOnFixedPart/, tx);92  });9394  it('[negative] unable to set equippable list to non-existing slot', async () => {95    const slotId = 777;96    const maxSlotId = 0xFFFFFFFF;9798    const baseId = await createBase(api, alice, 'slotpartany-base-type', 'slotpartany', [99      {100        'SlotPart': {101          id: slotId,102          equippable: 'All',103          z: 1,104          src: 'some-fallback-slot-url',105        },106      },107    ]);108109    const tx = setEquippableList(api, alice, baseId, maxSlotId, 'All');110    await expectTxFailure(/rmrkEquip\.PartDoesntExist/, tx);111  });112113  after(async() => { await api.disconnect(); });114});