git.delta.rocks / unique-network / refs/commits / 281abcbf9b51

difftreelog

source

tests/src/eth/createCollection.test.ts2.2 KiBsourcehistory
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.8//9// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617import {expect} from 'chai';18import {getCreatedCollectionCount, getDetailedCollectionInfo} from '../util/helpers';19import {collectionHelper, collectionIdFromAddress, contractHelpers, createEthAccountWithBalance, itWeb3} from './util/helpers';2021describe('Create collection from EVM', () => {22  itWeb3('Create collection', async ({api, web3}) => {23    const owner = await createEthAccountWithBalance(api, web3);24    const helpers = collectionHelper(web3, owner);25    const collectionName = 'CollectionEVM';26    const description = 'Some description';27    const tokenPrefix = 'token prefix';28  29    const collectionCountBefore = await getCreatedCollectionCount(api);30    const result = await helpers.methods31      .create721Collection(collectionName, description, tokenPrefix)32      .send();33    const collectionCountAfter = await getCreatedCollectionCount(api);34  35    const collectionId = collectionIdFromAddress(result.events[0].raw.topics[2]);36    expect(collectionCountAfter - collectionCountBefore).to.be.eq(1);37    expect(collectionId).to.be.eq(collectionCountAfter);38      39    const collection = (await getDetailedCollectionInfo(api, collectionId))!;40    expect(collection.name.map(v => String.fromCharCode(v.toNumber())).join('')).to.be.eq(collectionName);41    expect(collection.description.map(v => String.fromCharCode(v.toNumber())).join('')).to.be.eq(description);42    expect(collection.tokenPrefix.toHuman()).to.be.eq(tokenPrefix);43    expect(collection.schemaVersion.type).to.be.eq('ImageURL');44  });45});