git.delta.rocks / unique-network / refs/commits / 5ef5e6b4aa6d

difftreelog

source

tests/src/.outdated/collision-tests/sponsorPayments.test.ts3.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.89// 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/>.1617/* broken by design18// substrate transactions are sequential, not parallel19// the order of execution is indeterminate2021import { IKeyringPair } from '@polkadot/types/types';22import chai from 'chai';23import chaiAsPromised from 'chai-as-promised';24import { alicesPublicKey, bobsPublicKey } from '../accounts';25import getBalance from '../substrate/get-balance';26import privateKey from '../substrate/privateKey';27import usingApi, { submitTransactionAsync } from '../substrate/substrate-api';28import {29  confirmSponsorshipExpectSuccess,30  createCollectionExpectSuccess,31  createItemExpectSuccess,32  setCollectionSponsorExpectSuccess,33  normalizeAccountId,34  waitNewBlocks,35} from '../util/helpers';3637chai.use(chaiAsPromised);38const expect = chai.expect;39let Alice: IKeyringPair;40let Bob: IKeyringPair;4142before(async () => {43  await usingApi(async () => {44    Alice = privateKey('//Alice');45    Bob = privateKey('//Bob');46  });47});4849describe('Payment of commission if one block: ', () => {50  // tslint:disable-next-line: max-line-length51  it('Payment of commission if one block contains transactions for payment from the sponsor\'s balance and his (sponsor\'s) exclusion from the collection ', async () => {52    await usingApi(async (api) => {53      const collectionId = await createCollectionExpectSuccess();54      const changeAdminTxBob = api.tx.unique.addCollectionAdmin(collectionId, normalizeAccountId(Bob.address));55      await submitTransactionAsync(Alice, changeAdminTxBob);56      const itemId = await createItemExpectSuccess(Bob, collectionId, 'NFT');57      await setCollectionSponsorExpectSuccess(collectionId, Bob.address);58      await confirmSponsorshipExpectSuccess(collectionId, '//Bob');5960      const [alicesBalanceBefore, bobsBalanceBefore] = await getBalance(api, [alicesPublicKey, bobsPublicKey]);61      const sendItem = api.tx.unique.transfer(normalizeAccountId(Alice.address), collectionId, itemId, 1);62      const revokeSponsor = api.tx.unique.removeCollectionSponsor(collectionId);63      await Promise.all([64        sendItem.signAndSend(Bob),65        revokeSponsor.signAndSend(Alice),66      ]);67      const [alicesBalanceAfter, bobsBalanceAfter] = await getBalance(api, [alicesPublicKey, bobsPublicKey]);68      // tslint:disable-next-line:no-unused-expression69      expect(alicesBalanceAfter === alicesBalanceBefore).to.be.true;70      // tslint:disable-next-line:no-unused-expression71      expect(bobsBalanceAfter === bobsBalanceBefore).to.be.true;72      await waitNewBlocks(2);73    });74  });75});76*/