difftreelog
test remove .only
in: master
14 files changed
tests/src/benchmarks/utils/common.tsdiffbeforeafterboth--- a/tests/src/benchmarks/utils/common.ts
+++ b/tests/src/benchmarks/utils/common.ts
@@ -91,4 +91,4 @@
await collection.setTokenPropertyPermissions(donor, permissions);
return collection;
-}
\ No newline at end of file
+}
tests/src/creditFeesToTreasury.seqtest.tsdiffbeforeafterboth--- a/tests/src/creditFeesToTreasury.seqtest.ts
+++ b/tests/src/creditFeesToTreasury.seqtest.ts
@@ -88,7 +88,7 @@
expect(treasuryIncrease).to.be.equal(fee);
});
- itSub.only('Treasury balance increased by failed tx fee', async ({helper}) => {
+ itSub('Treasury balance increased by failed tx fee', async ({helper}) => {
const api = helper.getApi();
await helper.wait.newBlocks(1);
tests/src/eth/collectionSponsoring.test.tsdiffbeforeafterboth--- a/tests/src/eth/collectionSponsoring.test.ts
+++ b/tests/src/eth/collectionSponsoring.test.ts
@@ -18,7 +18,7 @@
import {Pallets, requirePalletsOrSkip, usingPlaygrounds} from '../util/index';
import {itEth, expect} from './util';
-describe.only('evm nft collection sponsoring', () => {
+describe('evm nft collection sponsoring', () => {
let donor: IKeyringPair;
let alice: IKeyringPair;
let nominal: bigint;
@@ -319,7 +319,7 @@
});
});
-describe.only('evm RFT collection sponsoring', () => {
+describe('evm RFT collection sponsoring', () => {
let donor: IKeyringPair;
let alice: IKeyringPair;
let nominal: bigint;
tests/src/eth/createFTCollection.seqtest.tsdiffbeforeafterboth--- a/tests/src/eth/createFTCollection.seqtest.ts
+++ b/tests/src/eth/createFTCollection.seqtest.ts
@@ -20,7 +20,7 @@
const DECIMALS = 18;
-describe.only('Create FT collection from EVM', () => {
+describe('Create FT collection from EVM', () => {
let donor: IKeyringPair;
before(async function() {
tests/src/eth/createFTCollection.test.tsdiffbeforeafterboth--- a/tests/src/eth/createFTCollection.test.ts
+++ b/tests/src/eth/createFTCollection.test.ts
@@ -22,7 +22,7 @@
const DECIMALS = 18;
-describe.only('Create FT collection from EVM', () => {
+describe('Create FT collection from EVM', () => {
let donor: IKeyringPair;
before(async function() {
@@ -129,7 +129,7 @@
});
});
-describe.only('(!negative tests!) Create FT collection from EVM', () => {
+describe('(!negative tests!) Create FT collection from EVM', () => {
let donor: IKeyringPair;
let nominal: bigint;
tests/src/eth/createNFTCollection.test.tsdiffbeforeafterboth--- a/tests/src/eth/createNFTCollection.test.ts
+++ b/tests/src/eth/createNFTCollection.test.ts
@@ -21,7 +21,7 @@
import {COLLECTION_HELPER} from '../util';
-describe.only('Create NFT collection from EVM', () => {
+describe('Create NFT collection from EVM', () => {
let donor: IKeyringPair;
before(async function () {
@@ -143,7 +143,7 @@
});
});
-describe.only('(!negative tests!) Create NFT collection from EVM', () => {
+describe('(!negative tests!) Create NFT collection from EVM', () => {
let donor: IKeyringPair;
let nominal: bigint;
tests/src/eth/createRFTCollection.test.tsdiffbeforeafterboth--- a/tests/src/eth/createRFTCollection.test.ts
+++ b/tests/src/eth/createRFTCollection.test.ts
@@ -21,7 +21,7 @@
import {CollectionLimitField} from './util/playgrounds/types';
-describe.only('Create RFT collection from EVM', () => {
+describe('Create RFT collection from EVM', () => {
let donor: IKeyringPair;
before(async function() {
@@ -154,7 +154,7 @@
});
});
-describe.only('(!negative tests!) Create RFT collection from EVM', () => {
+describe('(!negative tests!) Create RFT collection from EVM', () => {
let donor: IKeyringPair;
let nominal: bigint;
tests/src/eth/fractionalizer/fractionalizer.test.tsdiffbeforeafterboth1// 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/>.161718import {readFile} from 'fs/promises';1920import {IKeyringPair} from '@polkadot/types/types';21import {evmToAddress} from '@polkadot/util-crypto';2223import {Contract} from 'web3-eth-contract';2425import {usingEthPlaygrounds, expect, itEth, EthUniqueHelper} from '../util';26import {CompiledContract} from '../util/playgrounds/types';27import {requirePalletsOrSkip, Pallets, makeNames} from '../../util';2829const {dirname} = makeNames(import.meta.url);3031let compiledFractionalizer: CompiledContract;3233const compileContract = async (helper: EthUniqueHelper): Promise<CompiledContract> => {34 if(!compiledFractionalizer) {35 compiledFractionalizer = await helper.ethContract.compile('Fractionalizer', (await readFile(`${dirname}/Fractionalizer.sol`)).toString(), [36 {solPath: 'api/CollectionHelpers.sol', fsPath: `${dirname}/../api/CollectionHelpers.sol`},37 {solPath: 'api/ContractHelpers.sol', fsPath: `${dirname}/../api/ContractHelpers.sol`},38 {solPath: 'api/UniqueRefungibleToken.sol', fsPath: `${dirname}/../api/UniqueRefungibleToken.sol`},39 {solPath: 'api/UniqueRefungible.sol', fsPath: `${dirname}/../api/UniqueRefungible.sol`},40 {solPath: 'api/UniqueNFT.sol', fsPath: `${dirname}/../api/UniqueNFT.sol`},41 ]);42 }43 return compiledFractionalizer;44};454647const deployContract = async (helper: EthUniqueHelper, owner: string): Promise<Contract> => {48 const compiled = await compileContract(helper);49 return await helper.ethContract.deployByAbi(owner, compiled.abi, compiled.object);50};515253const initContract = async (helper: EthUniqueHelper, owner: string): Promise<{contract: Contract, rftCollectionAddress: string}> => {54 const fractionalizer = await deployContract(helper, owner);55 const amount = 10n * helper.balance.getOneTokenNominal();56 const web3 = helper.getWeb3();57 await web3.eth.sendTransaction({from: owner, to: fractionalizer.options.address, value: `${amount}`, gas: helper.eth.DEFAULT_GAS});58 const result = await fractionalizer.methods.createAndSetRFTCollection('A', 'B', 'C').send({value: Number(2n * helper.balance.getOneTokenNominal())});59 const rftCollectionAddress = result.events.RFTCollectionSet.returnValues._collection;60 return {contract: fractionalizer, rftCollectionAddress};61};6263const mintRFTToken = async (helper: EthUniqueHelper, owner: string, fractionalizer: Contract, amount: bigint): Promise<{64 nftCollectionAddress: string, nftTokenId: number, rftTokenAddress: string65}> => {66 const nftCollection = await helper.eth.createNFTCollection(owner, 'nft', 'NFT collection', 'NFT');67 const nftContract = await helper.ethNativeContract.collection(nftCollection.collectionAddress, 'nft', owner);68 const mintResult = await nftContract.methods.mint(owner).send({from: owner});69 const nftTokenId = mintResult.events.Transfer.returnValues.tokenId;7071 await fractionalizer.methods.setNftCollectionIsAllowed(nftCollection.collectionAddress, true).send({from: owner});72 await nftContract.methods.approve(fractionalizer.options.address, nftTokenId).send({from: owner});73 const result = await fractionalizer.methods.nft2rft(nftCollection.collectionAddress, nftTokenId, amount).send({from: owner});74 const {_collection, _tokenId, _rftToken} = result.events.Fractionalized.returnValues;75 return {76 nftCollectionAddress: _collection,77 nftTokenId: _tokenId,78 rftTokenAddress: _rftToken,79 };80};818283describe.only('Fractionalizer contract usage', () => {84 let donor: IKeyringPair;8586 before(async function() {87 await usingEthPlaygrounds(async (helper: EthUniqueHelper, privateKey) => {88 requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);89 donor = await privateKey({url: import.meta.url});90 });91 });9293 itEth('Set RFT collection', async ({helper}) => {94 const owner = await helper.eth.createAccountWithBalance(donor);95 const fractionalizer = await deployContract(helper, owner);96 const rftCollection = await helper.eth.createRFTCollection(owner, 'rft', 'RFT collection', 'RFT');97 const rftContract = await helper.ethNativeContract.collection(rftCollection.collectionAddress, 'rft', owner);9899 const fractionalizerAddressCross = helper.ethCrossAccount.fromAddress(fractionalizer.options.address);100 await rftContract.methods.addCollectionAdminCross(fractionalizerAddressCross).send({from: owner});101 const result = await fractionalizer.methods.setRFTCollection(rftCollection.collectionAddress).send({from: owner});102 expect(result.events).to.be.like({103 RFTCollectionSet: {104 returnValues: {105 _collection: rftCollection.collectionAddress,106 },107 },108 });109 });110111 itEth('Mint RFT collection', async ({helper}) => {112 const owner = await helper.eth.createAccountWithBalance(donor);113 const fractionalizer = await deployContract(helper, owner);114 await helper.balance.transferToSubstrate(donor, evmToAddress(fractionalizer.options.address), 10n * helper.balance.getOneTokenNominal());115116 const result = await fractionalizer.methods.createAndSetRFTCollection('A', 'B', 'C').send({from: owner, value: Number(2n * helper.balance.getOneTokenNominal())});117 expect(result.events).to.be.like({118 RFTCollectionSet: {},119 });120 expect(result.events.RFTCollectionSet.returnValues._collection).to.be.ok;121 });122123 itEth('Set Allowlist', async ({helper}) => {124 const owner = await helper.eth.createAccountWithBalance(donor);125 const {contract: fractionalizer} = await initContract(helper, owner);126 const nftCollection = await helper.eth.createNFTCollection(owner, 'nft', 'NFT collection', 'NFT');127128 const result1 = await fractionalizer.methods.setNftCollectionIsAllowed(nftCollection.collectionAddress, true).send({from: owner});129 expect(result1.events).to.be.like({130 AllowListSet: {131 returnValues: {132 _collection: nftCollection.collectionAddress,133 _status: true,134 },135 },136 });137 const result2 = await fractionalizer.methods.setNftCollectionIsAllowed(nftCollection.collectionAddress, false).send({from: owner});138 expect(result2.events).to.be.like({139 AllowListSet: {140 returnValues: {141 _collection: nftCollection.collectionAddress,142 _status: false,143 },144 },145 });146 });147148 itEth('NFT to RFT', async ({helper}) => {149 const owner = await helper.eth.createAccountWithBalance(donor);150151 const nftCollection = await helper.eth.createNFTCollection(owner, 'nft', 'NFT collection', 'NFT');152 const nftContract = await helper.ethNativeContract.collection(nftCollection.collectionAddress, 'nft', owner);153 const mintResult = await nftContract.methods.mint(owner).send({from: owner});154 const nftTokenId = mintResult.events.Transfer.returnValues.tokenId;155156 const {contract: fractionalizer} = await initContract(helper, owner);157158 await fractionalizer.methods.setNftCollectionIsAllowed(nftCollection.collectionAddress, true).send({from: owner});159 await nftContract.methods.approve(fractionalizer.options.address, nftTokenId).send({from: owner});160 const result = await fractionalizer.methods.nft2rft(nftCollection.collectionAddress, nftTokenId, 100).send({from: owner});161 expect(result.events).to.be.like({162 Fractionalized: {163 returnValues: {164 _collection: nftCollection.collectionAddress,165 _tokenId: nftTokenId,166 _amount: '100',167 },168 },169 });170 const rftTokenAddress = result.events.Fractionalized.returnValues._rftToken;171172 // FIXME: should work without the caller173 const rftTokenContract = await helper.ethNativeContract.rftToken(rftTokenAddress, owner);174 expect(await rftTokenContract.methods.balanceOf(owner).call()).to.equal('100');175 });176177 itEth('RFT to NFT', async ({helper}) => {178 const owner = await helper.eth.createAccountWithBalance(donor);179180 const {contract: fractionalizer, rftCollectionAddress} = await initContract(helper, owner);181 const {rftTokenAddress, nftCollectionAddress, nftTokenId} = await mintRFTToken(helper, owner, fractionalizer, 100n);182183 const {collectionId, tokenId} = helper.ethAddress.extractTokenId(rftTokenAddress);184 const refungibleAddress = helper.ethAddress.fromCollectionId(collectionId);185 expect(rftCollectionAddress).to.be.equal(refungibleAddress);186 const refungibleTokenContract = await helper.ethNativeContract.rftToken(rftTokenAddress, owner);187 await refungibleTokenContract.methods.approve(fractionalizer.options.address, 100).send({from: owner});188 const result = await fractionalizer.methods.rft2nft(refungibleAddress, tokenId).send({from: owner});189 expect(result.events).to.be.like({190 Defractionalized: {191 returnValues: {192 _rftToken: rftTokenAddress,193 _nftCollection: nftCollectionAddress,194 _nftTokenId: nftTokenId,195 },196 },197 });198 });199200 itEth('Test fractionalizer NFT <-> RFT mapping ', async ({helper}) => {201 const owner = await helper.eth.createAccountWithBalance(donor);202203 const {contract: fractionalizer, rftCollectionAddress} = await initContract(helper, owner);204 const {rftTokenAddress, nftCollectionAddress, nftTokenId} = await mintRFTToken(helper, owner, fractionalizer, 100n);205206 const {collectionId, tokenId} = helper.ethAddress.extractTokenId(rftTokenAddress);207 const refungibleAddress = helper.ethAddress.fromCollectionId(collectionId);208 expect(rftCollectionAddress).to.be.equal(refungibleAddress);209 const refungibleTokenContract = await helper.ethNativeContract.rftToken(rftTokenAddress, owner);210 await refungibleTokenContract.methods.approve(fractionalizer.options.address, 100).send({from: owner});211212 const rft2nft = await fractionalizer.methods.rft2nftMapping(rftTokenAddress).call();213 expect(rft2nft).to.be.like({214 _collection: nftCollectionAddress,215 _tokenId: nftTokenId,216 });217218 const nft2rft = await fractionalizer.methods.nft2rftMapping(nftCollectionAddress, nftTokenId).call();219 expect(nft2rft).to.be.eq(tokenId.toString());220 });221});222223224225describe('Negative Integration Tests for fractionalizer', () => {226 let donor: IKeyringPair;227228 before(async function() {229 await usingEthPlaygrounds(async (helper: EthUniqueHelper, privateKey) => {230 requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);231 donor = await privateKey({url: import.meta.url});232 });233 });234235 itEth('call setRFTCollection twice', async ({helper}) => {236 const owner = await helper.eth.createAccountWithBalance(donor);237 const rftCollection = await helper.eth.createRFTCollection(owner, 'rft', 'RFT collection', 'RFT');238 const refungibleContract = await helper.ethNativeContract.collection(rftCollection.collectionAddress, 'rft', owner);239240 const fractionalizer = await deployContract(helper, owner);241 const fractionalizerAddressCross = helper.ethCrossAccount.fromAddress(fractionalizer.options.address);242 await refungibleContract.methods.addCollectionAdminCross(fractionalizerAddressCross).send({from: owner});243 await fractionalizer.methods.setRFTCollection(rftCollection.collectionAddress).send({from: owner});244245 await expect(fractionalizer.methods.setRFTCollection(rftCollection.collectionAddress).call())246 .to.be.rejectedWith(/RFT collection is already set$/g);247 });248249 itEth('call setRFTCollection with NFT collection', async ({helper}) => {250 const owner = await helper.eth.createAccountWithBalance(donor);251 const nftCollection = await helper.eth.createNFTCollection(owner, 'nft', 'NFT collection', 'NFT');252 const nftContract = await helper.ethNativeContract.collection(nftCollection.collectionAddress, 'nft', owner);253254 const fractionalizer = await deployContract(helper, owner);255 const fractionalizerAddressCross = helper.ethCrossAccount.fromAddress(fractionalizer.options.address);256 await nftContract.methods.addCollectionAdminCross(fractionalizerAddressCross).send({from: owner});257258 await expect(fractionalizer.methods.setRFTCollection(nftCollection.collectionAddress).call())259 .to.be.rejectedWith(/Wrong collection type. Collection is not refungible.$/g);260 });261262 itEth('call setRFTCollection while not collection admin', async ({helper}) => {263 const owner = await helper.eth.createAccountWithBalance(donor);264 const fractionalizer = await deployContract(helper, owner);265 const rftCollection = await helper.eth.createRFTCollection(owner, 'rft', 'RFT collection', 'RFT');266267 await expect(fractionalizer.methods.setRFTCollection(rftCollection.collectionAddress).call())268 .to.be.rejectedWith(/Fractionalizer contract should be an admin of the collection$/g);269 });270271 itEth('call setRFTCollection after createAndSetRFTCollection', async ({helper}) => {272 const owner = await helper.eth.createAccountWithBalance(donor);273 const fractionalizer = await deployContract(helper, owner);274 await helper.balance.transferToSubstrate(donor, evmToAddress(fractionalizer.options.address), 10n * helper.balance.getOneTokenNominal());275276 const result = await fractionalizer.methods.createAndSetRFTCollection('A', 'B', 'C').send({from: owner, value: Number(2n * helper.balance.getOneTokenNominal())});277 const collectionIdAddress = result.events.RFTCollectionSet.returnValues._collection;278279 await expect(fractionalizer.methods.setRFTCollection(collectionIdAddress).call())280 .to.be.rejectedWith(/RFT collection is already set$/g);281 });282283 itEth('call nft2rft without setting RFT collection for contract', async ({helper}) => {284 const owner = await helper.eth.createAccountWithBalance(donor);285286 const nftCollection = await helper.eth.createNFTCollection(owner, 'nft', 'NFT collection', 'NFT');287 const nftContract = await helper.ethNativeContract.collection(nftCollection.collectionAddress, 'nft', owner);288 const mintResult = await nftContract.methods.mint(owner).send({from: owner});289 const nftTokenId = mintResult.events.Transfer.returnValues.tokenId;290291 const fractionalizer = await deployContract(helper, owner);292293 await expect(fractionalizer.methods.nft2rft(nftCollection.collectionAddress, nftTokenId, 100).call())294 .to.be.rejectedWith(/RFT collection is not set$/g);295 });296297 itEth('call nft2rft while not owner of NFT token', async ({helper}) => {298 const owner = await helper.eth.createAccountWithBalance(donor);299 const nftOwner = await helper.eth.createAccountWithBalance(donor);300301 const nftCollection = await helper.eth.createNFTCollection(owner, 'nft', 'NFT collection', 'NFT');302 const nftContract = await helper.ethNativeContract.collection(nftCollection.collectionAddress, 'nft', owner);303 const mintResult = await nftContract.methods.mint(owner).send({from: owner});304 const nftTokenId = mintResult.events.Transfer.returnValues.tokenId;305 await nftContract.methods.transfer(nftOwner, 1).send({from: owner});306307308 const {contract: fractionalizer} = await initContract(helper, owner);309 await fractionalizer.methods.setNftCollectionIsAllowed(nftCollection.collectionAddress, true).send({from: owner});310311 await expect(fractionalizer.methods.nft2rft(nftCollection.collectionAddress, nftTokenId, 100).call({from: owner}))312 .to.be.rejectedWith(/Only token owner could fractionalize it$/g);313 });314315 itEth('call nft2rft while not in list of allowed accounts', async ({helper}) => {316 const owner = await helper.eth.createAccountWithBalance(donor);317318 const nftCollection = await helper.eth.createNFTCollection(owner, 'nft', 'NFT collection', 'NFT');319 const nftContract = await helper.ethNativeContract.collection(nftCollection.collectionAddress, 'nft', owner);320 const mintResult = await nftContract.methods.mint(owner).send({from: owner});321 const nftTokenId = mintResult.events.Transfer.returnValues.tokenId;322323 const {contract: fractionalizer} = await initContract(helper, owner);324325 await nftContract.methods.approve(fractionalizer.options.address, nftTokenId).send({from: owner});326 await expect(fractionalizer.methods.nft2rft(nftCollection.collectionAddress, nftTokenId, 100).call())327 .to.be.rejectedWith(/Fractionalization of this collection is not allowed by admin$/g);328 });329330 itEth('call nft2rft while fractionalizer doesnt have approval for nft token', async ({helper}) => {331 const owner = await helper.eth.createAccountWithBalance(donor);332333 const nftCollection = await helper.eth.createNFTCollection(owner, 'nft', 'NFT collection', 'NFT');334 const nftContract = await helper.ethNativeContract.collection(nftCollection.collectionAddress, 'nft', owner);335 const mintResult = await nftContract.methods.mint(owner).send({from: owner});336 const nftTokenId = mintResult.events.Transfer.returnValues.tokenId;337338 const {contract: fractionalizer} = await initContract(helper, owner);339340 await fractionalizer.methods.setNftCollectionIsAllowed(nftCollection.collectionAddress, true).send({from: owner});341 await expect(fractionalizer.methods.nft2rft(nftCollection.collectionAddress, nftTokenId, 100).call())342 .to.be.rejectedWith(/ApprovedValueTooLow$/g);343 });344345 itEth('call rft2nft without setting RFT collection for contract', async ({helper}) => {346 const owner = await helper.eth.createAccountWithBalance(donor);347348 const fractionalizer = await deployContract(helper, owner);349 const rftCollection = await helper.eth.createRFTCollection(owner, 'rft', 'RFT collection', 'RFT');350 const refungibleContract = await helper.ethNativeContract.collection(rftCollection.collectionAddress, 'rft', owner);351 const mintResult = await refungibleContract.methods.mint(owner).send({from: owner});352 const rftTokenId = mintResult.events.Transfer.returnValues.tokenId;353354 await expect(fractionalizer.methods.rft2nft(rftCollection.collectionAddress, rftTokenId).call({from: owner}))355 .to.be.rejectedWith(/RFT collection is not set$/g);356 });357358 itEth('call rft2nft for RFT token that is not from configured RFT collection', async ({helper}) => {359 const owner = await helper.eth.createAccountWithBalance(donor);360361 const {contract: fractionalizer} = await initContract(helper, owner);362 const rftCollection = await helper.eth.createRFTCollection(owner, 'rft', 'RFT collection', 'RFT');363 const refungibleContract = await helper.ethNativeContract.collection(rftCollection.collectionAddress, 'rft', owner);364 const mintResult = await refungibleContract.methods.mint(owner).send({from: owner});365 const rftTokenId = mintResult.events.Transfer.returnValues.tokenId;366367 await expect(fractionalizer.methods.rft2nft(rftCollection.collectionAddress, rftTokenId).call())368 .to.be.rejectedWith(/Wrong RFT collection$/g);369 });370371 itEth('call rft2nft for RFT token that was not minted by fractionalizer contract', async ({helper}) => {372 const owner = await helper.eth.createAccountWithBalance(donor);373 const rftCollection = await helper.eth.createRFTCollection(owner, 'rft', 'RFT collection', 'RFT');374 const refungibleContract = await helper.ethNativeContract.collection(rftCollection.collectionAddress, 'rft', owner);375376 const fractionalizer = await deployContract(helper, owner);377378 const fractionalizerAddressCross = helper.ethCrossAccount.fromAddress(fractionalizer.options.address);379 await refungibleContract.methods.addCollectionAdminCross(fractionalizerAddressCross).send({from: owner});380 await fractionalizer.methods.setRFTCollection(rftCollection.collectionAddress).send({from: owner});381382 const mintResult = await refungibleContract.methods.mint(owner).send({from: owner});383 const rftTokenId = mintResult.events.Transfer.returnValues.tokenId;384385 await expect(fractionalizer.methods.rft2nft(rftCollection.collectionAddress, rftTokenId).call())386 .to.be.rejectedWith(/No corresponding NFT token found$/g);387 });388389 itEth('call rft2nft without owning all RFT pieces', async ({helper}) => {390 const owner = await helper.eth.createAccountWithBalance(donor);391 const receiver = await helper.eth.createAccountWithBalance(donor);392393 const {contract: fractionalizer, rftCollectionAddress} = await initContract(helper, owner);394 const {rftTokenAddress} = await mintRFTToken(helper, owner, fractionalizer, 100n);395396 const {tokenId} = helper.ethAddress.extractTokenId(rftTokenAddress);397 const refungibleTokenContract = await helper.ethNativeContract.rftToken(rftTokenAddress, owner);398 await refungibleTokenContract.methods.transfer(receiver, 50).send({from: owner});399 await refungibleTokenContract.methods.approve(fractionalizer.options.address, 50).send({from: receiver});400 await expect(fractionalizer.methods.rft2nft(rftCollectionAddress, tokenId).call({from: receiver}))401 .to.be.rejectedWith(/Not all pieces are owned by the caller$/g);402 });403404 itEth('send QTZ/UNQ to contract from non owner', async ({helper}) => {405 const owner = await helper.eth.createAccountWithBalance(donor);406 const payer = await helper.eth.createAccountWithBalance(donor);407408 const fractionalizer = await deployContract(helper, owner);409 const amount = 10n * helper.balance.getOneTokenNominal();410 const web3 = helper.getWeb3();411 await expect(web3.eth.sendTransaction({from: payer, to: fractionalizer.options.address, value: `${amount}`, gas: helper.eth.DEFAULT_GAS})).to.be.rejected;412 });413414 itEth('fractionalize NFT with NFT transfers disallowed', async ({helper}) => {415 const nftCollection = await helper.nft.mintCollection(donor, {name: 'A', description: 'B', tokenPrefix: 'C'});416417 const owner = await helper.eth.createAccountWithBalance(donor);418 const nftToken = await nftCollection.mintToken(donor, {Ethereum: owner});419 await helper.executeExtrinsic(donor, 'api.tx.unique.setTransfersEnabledFlag', [nftCollection.collectionId, false], true);420 const nftCollectionAddress = helper.ethAddress.fromCollectionId(nftCollection.collectionId);421 const {contract: fractionalizer} = await initContract(helper, owner);422 await fractionalizer.methods.setNftCollectionIsAllowed(nftCollectionAddress, true).send({from: owner});423424 const nftContract = await helper.ethNativeContract.collection(nftCollectionAddress, 'nft', owner);425 await nftContract.methods.approve(fractionalizer.options.address, nftToken.tokenId).send({from: owner});426 await expect(fractionalizer.methods.nft2rft(nftCollectionAddress, nftToken.tokenId, 100).call())427 .to.be.rejectedWith(/TransferNotAllowed$/g);428 });429430 itEth('fractionalize NFT with RFT transfers disallowed', async ({helper}) => {431 const owner = await helper.eth.createAccountWithBalance(donor);432433 const rftCollection = await helper.rft.mintCollection(donor, {name: 'A', description: 'B', tokenPrefix: 'C'});434 const rftCollectionAddress = helper.ethAddress.fromCollectionId(rftCollection.collectionId);435 const fractionalizer = await deployContract(helper, owner);436 await rftCollection.addAdmin(donor, {Ethereum: fractionalizer.options.address});437438 await fractionalizer.methods.setRFTCollection(rftCollectionAddress).send({from: owner});439 await helper.executeExtrinsic(donor, 'api.tx.unique.setTransfersEnabledFlag', [rftCollection.collectionId, false], true);440441 const nftCollection = await helper.eth.createNFTCollection(owner, 'nft', 'NFT collection', 'NFT');442 const nftContract = await helper.ethNativeContract.collection(nftCollection.collectionAddress, 'nft', owner);443 const mintResult = await nftContract.methods.mint(owner).send({from: owner});444 const nftTokenId = mintResult.events.Transfer.returnValues.tokenId;445446 await fractionalizer.methods.setNftCollectionIsAllowed(nftCollection.collectionAddress, true).send({from: owner});447 await nftContract.methods.approve(fractionalizer.options.address, nftTokenId).send({from: owner});448449 await expect(fractionalizer.methods.nft2rft(nftCollection.collectionAddress, nftTokenId, 100n).call())450 .to.be.rejectedWith(/TransferNotAllowed$/g);451 });452});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/>.161718import {readFile} from 'fs/promises';1920import {IKeyringPair} from '@polkadot/types/types';21import {evmToAddress} from '@polkadot/util-crypto';2223import {Contract} from 'web3-eth-contract';2425import {usingEthPlaygrounds, expect, itEth, EthUniqueHelper} from '../util';26import {CompiledContract} from '../util/playgrounds/types';27import {requirePalletsOrSkip, Pallets, makeNames} from '../../util';2829const {dirname} = makeNames(import.meta.url);3031let compiledFractionalizer: CompiledContract;3233const compileContract = async (helper: EthUniqueHelper): Promise<CompiledContract> => {34 if(!compiledFractionalizer) {35 compiledFractionalizer = await helper.ethContract.compile('Fractionalizer', (await readFile(`${dirname}/Fractionalizer.sol`)).toString(), [36 {solPath: 'api/CollectionHelpers.sol', fsPath: `${dirname}/../api/CollectionHelpers.sol`},37 {solPath: 'api/ContractHelpers.sol', fsPath: `${dirname}/../api/ContractHelpers.sol`},38 {solPath: 'api/UniqueRefungibleToken.sol', fsPath: `${dirname}/../api/UniqueRefungibleToken.sol`},39 {solPath: 'api/UniqueRefungible.sol', fsPath: `${dirname}/../api/UniqueRefungible.sol`},40 {solPath: 'api/UniqueNFT.sol', fsPath: `${dirname}/../api/UniqueNFT.sol`},41 ]);42 }43 return compiledFractionalizer;44};454647const deployContract = async (helper: EthUniqueHelper, owner: string): Promise<Contract> => {48 const compiled = await compileContract(helper);49 return await helper.ethContract.deployByAbi(owner, compiled.abi, compiled.object);50};515253const initContract = async (helper: EthUniqueHelper, owner: string): Promise<{contract: Contract, rftCollectionAddress: string}> => {54 const fractionalizer = await deployContract(helper, owner);55 const amount = 10n * helper.balance.getOneTokenNominal();56 const web3 = helper.getWeb3();57 await web3.eth.sendTransaction({from: owner, to: fractionalizer.options.address, value: `${amount}`, gas: helper.eth.DEFAULT_GAS});58 const result = await fractionalizer.methods.createAndSetRFTCollection('A', 'B', 'C').send({value: Number(2n * helper.balance.getOneTokenNominal())});59 const rftCollectionAddress = result.events.RFTCollectionSet.returnValues._collection;60 return {contract: fractionalizer, rftCollectionAddress};61};6263const mintRFTToken = async (helper: EthUniqueHelper, owner: string, fractionalizer: Contract, amount: bigint): Promise<{64 nftCollectionAddress: string, nftTokenId: number, rftTokenAddress: string65}> => {66 const nftCollection = await helper.eth.createNFTCollection(owner, 'nft', 'NFT collection', 'NFT');67 const nftContract = await helper.ethNativeContract.collection(nftCollection.collectionAddress, 'nft', owner);68 const mintResult = await nftContract.methods.mint(owner).send({from: owner});69 const nftTokenId = mintResult.events.Transfer.returnValues.tokenId;7071 await fractionalizer.methods.setNftCollectionIsAllowed(nftCollection.collectionAddress, true).send({from: owner});72 await nftContract.methods.approve(fractionalizer.options.address, nftTokenId).send({from: owner});73 const result = await fractionalizer.methods.nft2rft(nftCollection.collectionAddress, nftTokenId, amount).send({from: owner});74 const {_collection, _tokenId, _rftToken} = result.events.Fractionalized.returnValues;75 return {76 nftCollectionAddress: _collection,77 nftTokenId: _tokenId,78 rftTokenAddress: _rftToken,79 };80};818283describe('Fractionalizer contract usage', () => {84 let donor: IKeyringPair;8586 before(async function() {87 await usingEthPlaygrounds(async (helper: EthUniqueHelper, privateKey) => {88 requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);89 donor = await privateKey({url: import.meta.url});90 });91 });9293 itEth('Set RFT collection', async ({helper}) => {94 const owner = await helper.eth.createAccountWithBalance(donor);95 const fractionalizer = await deployContract(helper, owner);96 const rftCollection = await helper.eth.createRFTCollection(owner, 'rft', 'RFT collection', 'RFT');97 const rftContract = await helper.ethNativeContract.collection(rftCollection.collectionAddress, 'rft', owner);9899 const fractionalizerAddressCross = helper.ethCrossAccount.fromAddress(fractionalizer.options.address);100 await rftContract.methods.addCollectionAdminCross(fractionalizerAddressCross).send({from: owner});101 const result = await fractionalizer.methods.setRFTCollection(rftCollection.collectionAddress).send({from: owner});102 expect(result.events).to.be.like({103 RFTCollectionSet: {104 returnValues: {105 _collection: rftCollection.collectionAddress,106 },107 },108 });109 });110111 itEth('Mint RFT collection', async ({helper}) => {112 const owner = await helper.eth.createAccountWithBalance(donor);113 const fractionalizer = await deployContract(helper, owner);114 await helper.balance.transferToSubstrate(donor, evmToAddress(fractionalizer.options.address), 10n * helper.balance.getOneTokenNominal());115116 const result = await fractionalizer.methods.createAndSetRFTCollection('A', 'B', 'C').send({from: owner, value: Number(2n * helper.balance.getOneTokenNominal())});117 expect(result.events).to.be.like({118 RFTCollectionSet: {},119 });120 expect(result.events.RFTCollectionSet.returnValues._collection).to.be.ok;121 });122123 itEth('Set Allowlist', async ({helper}) => {124 const owner = await helper.eth.createAccountWithBalance(donor);125 const {contract: fractionalizer} = await initContract(helper, owner);126 const nftCollection = await helper.eth.createNFTCollection(owner, 'nft', 'NFT collection', 'NFT');127128 const result1 = await fractionalizer.methods.setNftCollectionIsAllowed(nftCollection.collectionAddress, true).send({from: owner});129 expect(result1.events).to.be.like({130 AllowListSet: {131 returnValues: {132 _collection: nftCollection.collectionAddress,133 _status: true,134 },135 },136 });137 const result2 = await fractionalizer.methods.setNftCollectionIsAllowed(nftCollection.collectionAddress, false).send({from: owner});138 expect(result2.events).to.be.like({139 AllowListSet: {140 returnValues: {141 _collection: nftCollection.collectionAddress,142 _status: false,143 },144 },145 });146 });147148 itEth('NFT to RFT', async ({helper}) => {149 const owner = await helper.eth.createAccountWithBalance(donor);150151 const nftCollection = await helper.eth.createNFTCollection(owner, 'nft', 'NFT collection', 'NFT');152 const nftContract = await helper.ethNativeContract.collection(nftCollection.collectionAddress, 'nft', owner);153 const mintResult = await nftContract.methods.mint(owner).send({from: owner});154 const nftTokenId = mintResult.events.Transfer.returnValues.tokenId;155156 const {contract: fractionalizer} = await initContract(helper, owner);157158 await fractionalizer.methods.setNftCollectionIsAllowed(nftCollection.collectionAddress, true).send({from: owner});159 await nftContract.methods.approve(fractionalizer.options.address, nftTokenId).send({from: owner});160 const result = await fractionalizer.methods.nft2rft(nftCollection.collectionAddress, nftTokenId, 100).send({from: owner});161 expect(result.events).to.be.like({162 Fractionalized: {163 returnValues: {164 _collection: nftCollection.collectionAddress,165 _tokenId: nftTokenId,166 _amount: '100',167 },168 },169 });170 const rftTokenAddress = result.events.Fractionalized.returnValues._rftToken;171172 // FIXME: should work without the caller173 const rftTokenContract = await helper.ethNativeContract.rftToken(rftTokenAddress, owner);174 expect(await rftTokenContract.methods.balanceOf(owner).call()).to.equal('100');175 });176177 itEth('RFT to NFT', async ({helper}) => {178 const owner = await helper.eth.createAccountWithBalance(donor);179180 const {contract: fractionalizer, rftCollectionAddress} = await initContract(helper, owner);181 const {rftTokenAddress, nftCollectionAddress, nftTokenId} = await mintRFTToken(helper, owner, fractionalizer, 100n);182183 const {collectionId, tokenId} = helper.ethAddress.extractTokenId(rftTokenAddress);184 const refungibleAddress = helper.ethAddress.fromCollectionId(collectionId);185 expect(rftCollectionAddress).to.be.equal(refungibleAddress);186 const refungibleTokenContract = await helper.ethNativeContract.rftToken(rftTokenAddress, owner);187 await refungibleTokenContract.methods.approve(fractionalizer.options.address, 100).send({from: owner});188 const result = await fractionalizer.methods.rft2nft(refungibleAddress, tokenId).send({from: owner});189 expect(result.events).to.be.like({190 Defractionalized: {191 returnValues: {192 _rftToken: rftTokenAddress,193 _nftCollection: nftCollectionAddress,194 _nftTokenId: nftTokenId,195 },196 },197 });198 });199200 itEth('Test fractionalizer NFT <-> RFT mapping ', async ({helper}) => {201 const owner = await helper.eth.createAccountWithBalance(donor);202203 const {contract: fractionalizer, rftCollectionAddress} = await initContract(helper, owner);204 const {rftTokenAddress, nftCollectionAddress, nftTokenId} = await mintRFTToken(helper, owner, fractionalizer, 100n);205206 const {collectionId, tokenId} = helper.ethAddress.extractTokenId(rftTokenAddress);207 const refungibleAddress = helper.ethAddress.fromCollectionId(collectionId);208 expect(rftCollectionAddress).to.be.equal(refungibleAddress);209 const refungibleTokenContract = await helper.ethNativeContract.rftToken(rftTokenAddress, owner);210 await refungibleTokenContract.methods.approve(fractionalizer.options.address, 100).send({from: owner});211212 const rft2nft = await fractionalizer.methods.rft2nftMapping(rftTokenAddress).call();213 expect(rft2nft).to.be.like({214 _collection: nftCollectionAddress,215 _tokenId: nftTokenId,216 });217218 const nft2rft = await fractionalizer.methods.nft2rftMapping(nftCollectionAddress, nftTokenId).call();219 expect(nft2rft).to.be.eq(tokenId.toString());220 });221});222223224225describe('Negative Integration Tests for fractionalizer', () => {226 let donor: IKeyringPair;227228 before(async function() {229 await usingEthPlaygrounds(async (helper: EthUniqueHelper, privateKey) => {230 requirePalletsOrSkip(this, helper, [Pallets.ReFungible]);231 donor = await privateKey({url: import.meta.url});232 });233 });234235 itEth('call setRFTCollection twice', async ({helper}) => {236 const owner = await helper.eth.createAccountWithBalance(donor);237 const rftCollection = await helper.eth.createRFTCollection(owner, 'rft', 'RFT collection', 'RFT');238 const refungibleContract = await helper.ethNativeContract.collection(rftCollection.collectionAddress, 'rft', owner);239240 const fractionalizer = await deployContract(helper, owner);241 const fractionalizerAddressCross = helper.ethCrossAccount.fromAddress(fractionalizer.options.address);242 await refungibleContract.methods.addCollectionAdminCross(fractionalizerAddressCross).send({from: owner});243 await fractionalizer.methods.setRFTCollection(rftCollection.collectionAddress).send({from: owner});244245 await expect(fractionalizer.methods.setRFTCollection(rftCollection.collectionAddress).call())246 .to.be.rejectedWith(/RFT collection is already set$/g);247 });248249 itEth('call setRFTCollection with NFT collection', async ({helper}) => {250 const owner = await helper.eth.createAccountWithBalance(donor);251 const nftCollection = await helper.eth.createNFTCollection(owner, 'nft', 'NFT collection', 'NFT');252 const nftContract = await helper.ethNativeContract.collection(nftCollection.collectionAddress, 'nft', owner);253254 const fractionalizer = await deployContract(helper, owner);255 const fractionalizerAddressCross = helper.ethCrossAccount.fromAddress(fractionalizer.options.address);256 await nftContract.methods.addCollectionAdminCross(fractionalizerAddressCross).send({from: owner});257258 await expect(fractionalizer.methods.setRFTCollection(nftCollection.collectionAddress).call())259 .to.be.rejectedWith(/Wrong collection type. Collection is not refungible.$/g);260 });261262 itEth('call setRFTCollection while not collection admin', async ({helper}) => {263 const owner = await helper.eth.createAccountWithBalance(donor);264 const fractionalizer = await deployContract(helper, owner);265 const rftCollection = await helper.eth.createRFTCollection(owner, 'rft', 'RFT collection', 'RFT');266267 await expect(fractionalizer.methods.setRFTCollection(rftCollection.collectionAddress).call())268 .to.be.rejectedWith(/Fractionalizer contract should be an admin of the collection$/g);269 });270271 itEth('call setRFTCollection after createAndSetRFTCollection', async ({helper}) => {272 const owner = await helper.eth.createAccountWithBalance(donor);273 const fractionalizer = await deployContract(helper, owner);274 await helper.balance.transferToSubstrate(donor, evmToAddress(fractionalizer.options.address), 10n * helper.balance.getOneTokenNominal());275276 const result = await fractionalizer.methods.createAndSetRFTCollection('A', 'B', 'C').send({from: owner, value: Number(2n * helper.balance.getOneTokenNominal())});277 const collectionIdAddress = result.events.RFTCollectionSet.returnValues._collection;278279 await expect(fractionalizer.methods.setRFTCollection(collectionIdAddress).call())280 .to.be.rejectedWith(/RFT collection is already set$/g);281 });282283 itEth('call nft2rft without setting RFT collection for contract', async ({helper}) => {284 const owner = await helper.eth.createAccountWithBalance(donor);285286 const nftCollection = await helper.eth.createNFTCollection(owner, 'nft', 'NFT collection', 'NFT');287 const nftContract = await helper.ethNativeContract.collection(nftCollection.collectionAddress, 'nft', owner);288 const mintResult = await nftContract.methods.mint(owner).send({from: owner});289 const nftTokenId = mintResult.events.Transfer.returnValues.tokenId;290291 const fractionalizer = await deployContract(helper, owner);292293 await expect(fractionalizer.methods.nft2rft(nftCollection.collectionAddress, nftTokenId, 100).call())294 .to.be.rejectedWith(/RFT collection is not set$/g);295 });296297 itEth('call nft2rft while not owner of NFT token', async ({helper}) => {298 const owner = await helper.eth.createAccountWithBalance(donor);299 const nftOwner = await helper.eth.createAccountWithBalance(donor);300301 const nftCollection = await helper.eth.createNFTCollection(owner, 'nft', 'NFT collection', 'NFT');302 const nftContract = await helper.ethNativeContract.collection(nftCollection.collectionAddress, 'nft', owner);303 const mintResult = await nftContract.methods.mint(owner).send({from: owner});304 const nftTokenId = mintResult.events.Transfer.returnValues.tokenId;305 await nftContract.methods.transfer(nftOwner, 1).send({from: owner});306307308 const {contract: fractionalizer} = await initContract(helper, owner);309 await fractionalizer.methods.setNftCollectionIsAllowed(nftCollection.collectionAddress, true).send({from: owner});310311 await expect(fractionalizer.methods.nft2rft(nftCollection.collectionAddress, nftTokenId, 100).call({from: owner}))312 .to.be.rejectedWith(/Only token owner could fractionalize it$/g);313 });314315 itEth('call nft2rft while not in list of allowed accounts', async ({helper}) => {316 const owner = await helper.eth.createAccountWithBalance(donor);317318 const nftCollection = await helper.eth.createNFTCollection(owner, 'nft', 'NFT collection', 'NFT');319 const nftContract = await helper.ethNativeContract.collection(nftCollection.collectionAddress, 'nft', owner);320 const mintResult = await nftContract.methods.mint(owner).send({from: owner});321 const nftTokenId = mintResult.events.Transfer.returnValues.tokenId;322323 const {contract: fractionalizer} = await initContract(helper, owner);324325 await nftContract.methods.approve(fractionalizer.options.address, nftTokenId).send({from: owner});326 await expect(fractionalizer.methods.nft2rft(nftCollection.collectionAddress, nftTokenId, 100).call())327 .to.be.rejectedWith(/Fractionalization of this collection is not allowed by admin$/g);328 });329330 itEth('call nft2rft while fractionalizer doesnt have approval for nft token', async ({helper}) => {331 const owner = await helper.eth.createAccountWithBalance(donor);332333 const nftCollection = await helper.eth.createNFTCollection(owner, 'nft', 'NFT collection', 'NFT');334 const nftContract = await helper.ethNativeContract.collection(nftCollection.collectionAddress, 'nft', owner);335 const mintResult = await nftContract.methods.mint(owner).send({from: owner});336 const nftTokenId = mintResult.events.Transfer.returnValues.tokenId;337338 const {contract: fractionalizer} = await initContract(helper, owner);339340 await fractionalizer.methods.setNftCollectionIsAllowed(nftCollection.collectionAddress, true).send({from: owner});341 await expect(fractionalizer.methods.nft2rft(nftCollection.collectionAddress, nftTokenId, 100).call())342 .to.be.rejectedWith(/ApprovedValueTooLow$/g);343 });344345 itEth('call rft2nft without setting RFT collection for contract', async ({helper}) => {346 const owner = await helper.eth.createAccountWithBalance(donor);347348 const fractionalizer = await deployContract(helper, owner);349 const rftCollection = await helper.eth.createRFTCollection(owner, 'rft', 'RFT collection', 'RFT');350 const refungibleContract = await helper.ethNativeContract.collection(rftCollection.collectionAddress, 'rft', owner);351 const mintResult = await refungibleContract.methods.mint(owner).send({from: owner});352 const rftTokenId = mintResult.events.Transfer.returnValues.tokenId;353354 await expect(fractionalizer.methods.rft2nft(rftCollection.collectionAddress, rftTokenId).call({from: owner}))355 .to.be.rejectedWith(/RFT collection is not set$/g);356 });357358 itEth('call rft2nft for RFT token that is not from configured RFT collection', async ({helper}) => {359 const owner = await helper.eth.createAccountWithBalance(donor);360361 const {contract: fractionalizer} = await initContract(helper, owner);362 const rftCollection = await helper.eth.createRFTCollection(owner, 'rft', 'RFT collection', 'RFT');363 const refungibleContract = await helper.ethNativeContract.collection(rftCollection.collectionAddress, 'rft', owner);364 const mintResult = await refungibleContract.methods.mint(owner).send({from: owner});365 const rftTokenId = mintResult.events.Transfer.returnValues.tokenId;366367 await expect(fractionalizer.methods.rft2nft(rftCollection.collectionAddress, rftTokenId).call())368 .to.be.rejectedWith(/Wrong RFT collection$/g);369 });370371 itEth('call rft2nft for RFT token that was not minted by fractionalizer contract', async ({helper}) => {372 const owner = await helper.eth.createAccountWithBalance(donor);373 const rftCollection = await helper.eth.createRFTCollection(owner, 'rft', 'RFT collection', 'RFT');374 const refungibleContract = await helper.ethNativeContract.collection(rftCollection.collectionAddress, 'rft', owner);375376 const fractionalizer = await deployContract(helper, owner);377378 const fractionalizerAddressCross = helper.ethCrossAccount.fromAddress(fractionalizer.options.address);379 await refungibleContract.methods.addCollectionAdminCross(fractionalizerAddressCross).send({from: owner});380 await fractionalizer.methods.setRFTCollection(rftCollection.collectionAddress).send({from: owner});381382 const mintResult = await refungibleContract.methods.mint(owner).send({from: owner});383 const rftTokenId = mintResult.events.Transfer.returnValues.tokenId;384385 await expect(fractionalizer.methods.rft2nft(rftCollection.collectionAddress, rftTokenId).call())386 .to.be.rejectedWith(/No corresponding NFT token found$/g);387 });388389 itEth('call rft2nft without owning all RFT pieces', async ({helper}) => {390 const owner = await helper.eth.createAccountWithBalance(donor);391 const receiver = await helper.eth.createAccountWithBalance(donor);392393 const {contract: fractionalizer, rftCollectionAddress} = await initContract(helper, owner);394 const {rftTokenAddress} = await mintRFTToken(helper, owner, fractionalizer, 100n);395396 const {tokenId} = helper.ethAddress.extractTokenId(rftTokenAddress);397 const refungibleTokenContract = await helper.ethNativeContract.rftToken(rftTokenAddress, owner);398 await refungibleTokenContract.methods.transfer(receiver, 50).send({from: owner});399 await refungibleTokenContract.methods.approve(fractionalizer.options.address, 50).send({from: receiver});400 await expect(fractionalizer.methods.rft2nft(rftCollectionAddress, tokenId).call({from: receiver}))401 .to.be.rejectedWith(/Not all pieces are owned by the caller$/g);402 });403404 itEth('send QTZ/UNQ to contract from non owner', async ({helper}) => {405 const owner = await helper.eth.createAccountWithBalance(donor);406 const payer = await helper.eth.createAccountWithBalance(donor);407408 const fractionalizer = await deployContract(helper, owner);409 const amount = 10n * helper.balance.getOneTokenNominal();410 const web3 = helper.getWeb3();411 await expect(web3.eth.sendTransaction({from: payer, to: fractionalizer.options.address, value: `${amount}`, gas: helper.eth.DEFAULT_GAS})).to.be.rejected;412 });413414 itEth('fractionalize NFT with NFT transfers disallowed', async ({helper}) => {415 const nftCollection = await helper.nft.mintCollection(donor, {name: 'A', description: 'B', tokenPrefix: 'C'});416417 const owner = await helper.eth.createAccountWithBalance(donor);418 const nftToken = await nftCollection.mintToken(donor, {Ethereum: owner});419 await helper.executeExtrinsic(donor, 'api.tx.unique.setTransfersEnabledFlag', [nftCollection.collectionId, false], true);420 const nftCollectionAddress = helper.ethAddress.fromCollectionId(nftCollection.collectionId);421 const {contract: fractionalizer} = await initContract(helper, owner);422 await fractionalizer.methods.setNftCollectionIsAllowed(nftCollectionAddress, true).send({from: owner});423424 const nftContract = await helper.ethNativeContract.collection(nftCollectionAddress, 'nft', owner);425 await nftContract.methods.approve(fractionalizer.options.address, nftToken.tokenId).send({from: owner});426 await expect(fractionalizer.methods.nft2rft(nftCollectionAddress, nftToken.tokenId, 100).call())427 .to.be.rejectedWith(/TransferNotAllowed$/g);428 });429430 itEth('fractionalize NFT with RFT transfers disallowed', async ({helper}) => {431 const owner = await helper.eth.createAccountWithBalance(donor);432433 const rftCollection = await helper.rft.mintCollection(donor, {name: 'A', description: 'B', tokenPrefix: 'C'});434 const rftCollectionAddress = helper.ethAddress.fromCollectionId(rftCollection.collectionId);435 const fractionalizer = await deployContract(helper, owner);436 await rftCollection.addAdmin(donor, {Ethereum: fractionalizer.options.address});437438 await fractionalizer.methods.setRFTCollection(rftCollectionAddress).send({from: owner});439 await helper.executeExtrinsic(donor, 'api.tx.unique.setTransfersEnabledFlag', [rftCollection.collectionId, false], true);440441 const nftCollection = await helper.eth.createNFTCollection(owner, 'nft', 'NFT collection', 'NFT');442 const nftContract = await helper.ethNativeContract.collection(nftCollection.collectionAddress, 'nft', owner);443 const mintResult = await nftContract.methods.mint(owner).send({from: owner});444 const nftTokenId = mintResult.events.Transfer.returnValues.tokenId;445446 await fractionalizer.methods.setNftCollectionIsAllowed(nftCollection.collectionAddress, true).send({from: owner});447 await nftContract.methods.approve(fractionalizer.options.address, nftTokenId).send({from: owner});448449 await expect(fractionalizer.methods.nft2rft(nftCollection.collectionAddress, nftTokenId, 100n).call())450 .to.be.rejectedWith(/TransferNotAllowed$/g);451 });452});tests/src/eth/nonFungible.test.tsdiffbeforeafterboth--- a/tests/src/eth/nonFungible.test.ts
+++ b/tests/src/eth/nonFungible.test.ts
@@ -929,7 +929,7 @@
});
});
- itEth.only('Returns collection name', async ({helper}) => {
+ itEth('Returns collection name', async ({helper}) => {
// FIXME: should not have balance to use .call()
const caller = await helper.eth.createAccountWithBalance(donor);
const tokenPropertyPermissions = [{
tests/src/eth/payable.test.tsdiffbeforeafterboth--- a/tests/src/eth/payable.test.ts
+++ b/tests/src/eth/payable.test.ts
@@ -41,7 +41,7 @@
expect(await contract.methods.getCollected().call()).to.be.equal('10000');
});
- itEth.only('Evm contract can receive wei from substrate account', async ({helper}) => {
+ itEth('Evm contract can receive wei from substrate account', async ({helper}) => {
const deployer = await helper.eth.createAccountWithBalance(donor);
const contract = await helper.eth.deployCollectorContract(deployer);
const [alice] = await helper.arrange.createAccounts([40n], donor);
tests/src/eth/reFungible.test.tsdiffbeforeafterboth--- a/tests/src/eth/reFungible.test.ts
+++ b/tests/src/eth/reFungible.test.ts
@@ -679,7 +679,7 @@
});
});
- itEth.only('Returns collection name', async ({helper}) => {
+ itEth('Returns collection name', async ({helper}) => {
// FIXME: should not have balance to use .call()
const caller = await helper.eth.createAccountWithBalance(alice);
const tokenPropertyPermissions = [{
tests/src/eth/tokenProperties.test.tsdiffbeforeafterboth--- a/tests/src/eth/tokenProperties.test.ts
+++ b/tests/src/eth/tokenProperties.test.ts
@@ -314,7 +314,7 @@
expect(result.length).to.equal(0);
}));
- itEth.only('Can be read', async({helper}) => {
+ itEth('Can be read', async({helper}) => {
// FIXME: User with no balance should be able to call
const caller = await helper.eth.createAccountWithBalance(alice);
const collection = await helper.nft.mintCollection(alice, {
tests/src/maintenance.seqtest.tsdiffbeforeafterboth--- a/tests/src/maintenance.seqtest.ts
+++ b/tests/src/maintenance.seqtest.ts
@@ -325,7 +325,7 @@
expect(await helper.preimage.getPreimageInfo(preimageHashes[0])).to.have.property('unrequested');
});
- itSub.only('Does not allow execution of a preimage that would fail', async ({helper}) => {
+ itSub('Does not allow execution of a preimage that would fail', async ({helper}) => {
const [zeroAccount] = await helper.arrange.createAccounts([0n], superuser);
const preimage = helper.constructApiCall('api.tx.balances.forceTransfer', [
tests/src/vesting.test.tsdiffbeforeafterboth--- a/tests/src/vesting.test.ts
+++ b/tests/src/vesting.test.ts
@@ -103,7 +103,7 @@
expect(balanceSender.reserved).to.eq(0n);
});
- itSub.only('cannot send more tokens than have', async ({helper}) => {
+ itSub('cannot send more tokens than have', async ({helper}) => {
const [sender, receiver] = await helper.arrange.createAccounts([1000n, 1n], donor);
const schedule = {start: 0n, period: 1n, periodCount: 1n, perPeriod: 100n * nominal};
const manyPeriodsSchedule = {start: 0n, period: 1n, periodCount: 100n, perPeriod: 10n * nominal};