difftreelog
Skip rft tests for unique
in: master
2 files changed
tests/src/eth/tokens/callMethodsERC721.test.tsdiffbeforeafterboth--- a/tests/src/eth/tokens/callMethodsERC721.test.ts
+++ b/tests/src/eth/tokens/callMethodsERC721.test.ts
@@ -105,7 +105,7 @@
{mode: 'rft' as const, requiredPallets: [Pallets.ReFungible]},
// TODO {mode: 'nft' as const, requiredPallets: []},
].map(testCase => {
- itEth(`${testCase.mode.toUpperCase()}: ownerOf after burn`, async ({helper}) => {
+ itEth.ifWithPallets(`${testCase.mode.toUpperCase()}: ownerOf after burn`, testCase.requiredPallets, async ({helper}) => {
const caller = await helper.eth.createAccountWithBalance(donor);
const receiver = helper.eth.createAccount();
const {collection, collectionId} = await helper.eth.createCollection(testCase.mode, caller, 'OwnerOf-AfterBurn', '6', '6');
@@ -124,7 +124,7 @@
});
});
- itEth('RFT: ownerOf for partial ownership', async ({helper}) => {
+ itEth.ifWithPallets('RFT: ownerOf for partial ownership', [Pallets.ReFungible], async ({helper}) => {
const caller = await helper.eth.createAccountWithBalance(donor);
const receiver = helper.eth.createAccount();
const {collectionId, collectionAddress} = await helper.eth.createRFTCollection(caller, 'Partial-OwnerOf', '6', '6');
tests/src/eth/tokens/minting.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/>.1617import {IKeyringPair} from '@polkadot/types/types';18import {Pallets} from '../../util';19import {expect, itEth, usingEthPlaygrounds} from '../util';202122describe('Minting tokens', () => {23 let donor: IKeyringPair;24 let alice: IKeyringPair;2526 before(async function() {27 await usingEthPlaygrounds(async (helper, privateKey) => {28 donor = await privateKey({filename: __filename});29 [alice] = await helper.arrange.createAccounts([30n, 20n], donor);30 });31 });3233 [34 {mode: 'nft' as const, requiredPallets: []},35 {mode: 'rft' as const, requiredPallets: [Pallets.ReFungible]},36 {mode: 'ft' as const, requiredPallets: []},37 ].map(testCase => {38 itEth(`${testCase.mode.toUpperCase()}: Can mint() for Substrate collection`, async ({helper}) => {39 const owner = await helper.eth.createAccountWithBalance(donor);40 const receiver = helper.eth.createAccount();41 const mintingParams = testCase.mode === 'ft' ? [receiver, 100] : [receiver];4243 const collection = await helper[testCase.mode].mintCollection(alice);44 await collection.addAdmin(alice, {Ethereum: owner});4546 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);47 const contract = await helper.ethNativeContract.collection(collectionAddress, testCase.mode, owner);4849 const result = await contract.methods.mint(...mintingParams).send({from: owner});5051 // Check events:52 const event = result.events.Transfer;53 expect(event.address).to.equal(collectionAddress);54 expect(event.returnValues.from).to.equal('0x0000000000000000000000000000000000000000');55 expect(event.returnValues.to).to.equal(receiver);56 if (testCase.mode === 'ft')57 expect(event.returnValues.value).to.equal('100');5859 // Check token exist:60 if(testCase.mode === 'ft') {61 expect(await helper.ft.getBalance(collection.collectionId, {Ethereum: receiver})).to.eq(100n);62 } else {63 const tokenId = event.returnValues.tokenId;64 expect(tokenId).to.be.equal('1');65 expect(await helper.collection.getLastTokenId(collection.collectionId)).to.eq(1);66 expect(await contract.methods.crossOwnerOf(tokenId).call()).to.be.like([receiver, '0']);67 }68 });69 });7071 [72 {mode: 'nft' as const, requiredPallets: []},73 {mode: 'rft' as const, requiredPallets: [Pallets.ReFungible]},74 {mode: 'ft' as const, requiredPallets: []},75 ].map(testCase => {76 itEth(`${testCase.mode.toUpperCase()}: Can mint() for Ethereum collection`, async ({helper}) => {77 const owner = await helper.eth.createAccountWithBalance(donor);78 const receiver = helper.eth.createAccount();79 const mintingParams = testCase.mode === 'ft' ? [receiver, 100] : [receiver];8081 const {collection, collectionAddress, collectionId} = await helper.eth.createCollection(testCase.mode, owner, 'Name', 'Desc', 'Prefix');8283 const result = await collection.methods.mint(...mintingParams).send({from: owner});8485 // Check events:86 const event = result.events.Transfer;87 expect(event.address).to.equal(collectionAddress);88 expect(event.returnValues.from).to.equal('0x0000000000000000000000000000000000000000');89 expect(event.returnValues.to).to.equal(receiver);90 if (testCase.mode === 'ft')91 expect(event.returnValues.value).to.equal('100');9293 // Check token exist:94 if(testCase.mode === 'ft') {95 expect(await helper.ft.getBalance(collectionId, {Ethereum: receiver})).to.eq(100n);96 } else {97 const tokenId = event.returnValues.tokenId;98 expect(tokenId).to.be.equal('1');99 expect(await helper.collection.getLastTokenId(collectionId)).to.eq(1);100 expect(await collection.methods.crossOwnerOf(tokenId).call()).to.be.like([receiver, '0']);101 }102 });103 });104105 [106 {mode: 'nft' as const, requiredPallets: []},107 {mode: 'rft' as const, requiredPallets: [Pallets.ReFungible]},108 {mode: 'ft' as const, requiredPallets: []},109 ].map(testCase => {110 itEth(`${testCase.mode.toUpperCase()}: Can mint() for Ethereum collection`, async ({helper}) => {111 const owner = await helper.eth.createAccountWithBalance(donor);112 const receiver = helper.eth.createAccount();113 const mintingParams = testCase.mode === 'ft' ? [receiver, 100] : [receiver];114115 const {collection, collectionAddress, collectionId} = await helper.eth.createCollection(testCase.mode, owner, 'Name', 'Desc', 'Prefix');116117 const result = await collection.methods.mint(...mintingParams).send({from: owner});118119 // Check events:120 const event = result.events.Transfer;121 expect(event.address).to.equal(collectionAddress);122 expect(event.returnValues.from).to.equal('0x0000000000000000000000000000000000000000');123 expect(event.returnValues.to).to.equal(receiver);124 if (testCase.mode === 'ft')125 expect(event.returnValues.value).to.equal('100');126127 // Check token exist:128 if(testCase.mode === 'ft') {129 expect(await helper.ft.getBalance(collectionId, {Ethereum: receiver})).to.eq(100n);130 } else {131 const tokenId = event.returnValues.tokenId;132 expect(tokenId).to.be.equal('1');133 expect(await helper.collection.getLastTokenId(collectionId)).to.eq(1);134 expect(await collection.methods.crossOwnerOf(tokenId).call()).to.be.like([receiver, '0']);135 }136 });137 });138139 [140 {mode: 'nft' as const, requiredPallets: []},141 {mode: 'rft' as const, requiredPallets: [Pallets.ReFungible]},142 ].map(testCase => {143 itEth(`${testCase.mode.toUpperCase()}: Can mintWithTokenURI() for Ethereum collection`, async ({helper}) => {144 const owner = await helper.eth.createAccountWithBalance(donor);145 const receiver = helper.eth.createAccount();146147 const {collectionAddress} = await helper.eth.createERC721MetadataCompatibleNFTCollection(owner, 'Mint collection', '6', '6', '');148 const contract = await helper.ethNativeContract.collection(collectionAddress, testCase.mode, owner);149150 const result = await contract.methods.mintWithTokenURI(receiver, 'Test URI').send();151 const tokenId = result.events.Transfer.returnValues.tokenId;152 expect(tokenId).to.be.equal('1');153154 const event = result.events.Transfer;155 expect(event.address).to.be.equal(collectionAddress);156 expect(event.returnValues.from).to.be.equal('0x0000000000000000000000000000000000000000');157 expect(event.returnValues.to).to.be.equal(receiver);158159 expect(await contract.methods.tokenURI(tokenId).call()).to.be.equal('Test URI');160 expect(await contract.methods.crossOwnerOf(tokenId).call()).to.be.like([receiver, '0']);161 // TODO: this wont work right now, need release 919000 first162 // await helper.methods.setOffchainSchema(collectionIdAddress, 'https://offchain-service.local/token-info/{id}').send();163 // const tokenUri = await contract.methods.tokenURI(nextTokenId).call();164 // expect(tokenUri).to.be.equal(`https://offchain-service.local/token-info/${nextTokenId}`);165 });166 });167});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/>.1617import {IKeyringPair} from '@polkadot/types/types';18import {Pallets} from '../../util';19import {expect, itEth, usingEthPlaygrounds} from '../util';202122describe('Minting tokens', () => {23 let donor: IKeyringPair;24 let alice: IKeyringPair;2526 before(async function() {27 await usingEthPlaygrounds(async (helper, privateKey) => {28 donor = await privateKey({filename: __filename});29 [alice] = await helper.arrange.createAccounts([30n, 20n], donor);30 });31 });3233 [34 {mode: 'nft' as const, requiredPallets: []},35 {mode: 'rft' as const, requiredPallets: [Pallets.ReFungible]},36 {mode: 'ft' as const, requiredPallets: []},37 ].map(testCase => {38 itEth.ifWithPallets(`${testCase.mode.toUpperCase()}: Can mint() for Substrate collection`, testCase.requiredPallets, async ({helper}) => {39 const owner = await helper.eth.createAccountWithBalance(donor);40 const receiver = helper.eth.createAccount();41 const mintingParams = testCase.mode === 'ft' ? [receiver, 100] : [receiver];4243 const collection = await helper[testCase.mode].mintCollection(alice);44 await collection.addAdmin(alice, {Ethereum: owner});4546 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);47 const contract = await helper.ethNativeContract.collection(collectionAddress, testCase.mode, owner);4849 const result = await contract.methods.mint(...mintingParams).send({from: owner});5051 // Check events:52 const event = result.events.Transfer;53 expect(event.address).to.equal(collectionAddress);54 expect(event.returnValues.from).to.equal('0x0000000000000000000000000000000000000000');55 expect(event.returnValues.to).to.equal(receiver);56 if (testCase.mode === 'ft')57 expect(event.returnValues.value).to.equal('100');5859 // Check token exist:60 if(testCase.mode === 'ft') {61 expect(await helper.ft.getBalance(collection.collectionId, {Ethereum: receiver})).to.eq(100n);62 } else {63 const tokenId = event.returnValues.tokenId;64 expect(tokenId).to.be.equal('1');65 expect(await helper.collection.getLastTokenId(collection.collectionId)).to.eq(1);66 expect(await contract.methods.crossOwnerOf(tokenId).call()).to.be.like([receiver, '0']);67 }68 });69 });7071 [72 {mode: 'nft' as const, requiredPallets: []},73 {mode: 'rft' as const, requiredPallets: [Pallets.ReFungible]},74 {mode: 'ft' as const, requiredPallets: []},75 ].map(testCase => {76 itEth.ifWithPallets(`${testCase.mode.toUpperCase()}: Can mint() for Ethereum collection`, testCase.requiredPallets, async ({helper}) => {77 const owner = await helper.eth.createAccountWithBalance(donor);78 const receiver = helper.eth.createAccount();79 const mintingParams = testCase.mode === 'ft' ? [receiver, 100] : [receiver];8081 const {collection, collectionAddress, collectionId} = await helper.eth.createCollection(testCase.mode, owner, 'Name', 'Desc', 'Prefix');8283 const result = await collection.methods.mint(...mintingParams).send({from: owner});8485 // Check events:86 const event = result.events.Transfer;87 expect(event.address).to.equal(collectionAddress);88 expect(event.returnValues.from).to.equal('0x0000000000000000000000000000000000000000');89 expect(event.returnValues.to).to.equal(receiver);90 if (testCase.mode === 'ft')91 expect(event.returnValues.value).to.equal('100');9293 // Check token exist:94 if(testCase.mode === 'ft') {95 expect(await helper.ft.getBalance(collectionId, {Ethereum: receiver})).to.eq(100n);96 } else {97 const tokenId = event.returnValues.tokenId;98 expect(tokenId).to.be.equal('1');99 expect(await helper.collection.getLastTokenId(collectionId)).to.eq(1);100 expect(await collection.methods.crossOwnerOf(tokenId).call()).to.be.like([receiver, '0']);101 }102 });103 });104105 [106 {mode: 'nft' as const, requiredPallets: []},107 {mode: 'rft' as const, requiredPallets: [Pallets.ReFungible]},108 {mode: 'ft' as const, requiredPallets: []},109 ].map(testCase => {110 itEth.ifWithPallets(`${testCase.mode.toUpperCase()}: Can mint() for Ethereum collection`, testCase.requiredPallets, async ({helper}) => {111 const owner = await helper.eth.createAccountWithBalance(donor);112 const receiver = helper.eth.createAccount();113 const mintingParams = testCase.mode === 'ft' ? [receiver, 100] : [receiver];114115 const {collection, collectionAddress, collectionId} = await helper.eth.createCollection(testCase.mode, owner, 'Name', 'Desc', 'Prefix');116117 const result = await collection.methods.mint(...mintingParams).send({from: owner});118119 // Check events:120 const event = result.events.Transfer;121 expect(event.address).to.equal(collectionAddress);122 expect(event.returnValues.from).to.equal('0x0000000000000000000000000000000000000000');123 expect(event.returnValues.to).to.equal(receiver);124 if (testCase.mode === 'ft')125 expect(event.returnValues.value).to.equal('100');126127 // Check token exist:128 if(testCase.mode === 'ft') {129 expect(await helper.ft.getBalance(collectionId, {Ethereum: receiver})).to.eq(100n);130 } else {131 const tokenId = event.returnValues.tokenId;132 expect(tokenId).to.be.equal('1');133 expect(await helper.collection.getLastTokenId(collectionId)).to.eq(1);134 expect(await collection.methods.crossOwnerOf(tokenId).call()).to.be.like([receiver, '0']);135 }136 });137 });138139 [140 {mode: 'nft' as const, requiredPallets: []},141 {mode: 'rft' as const, requiredPallets: [Pallets.ReFungible]},142 ].map(testCase => {143 itEth.ifWithPallets(`${testCase.mode.toUpperCase()}: Can mintWithTokenURI() for Ethereum collection`, testCase.requiredPallets, async ({helper}) => {144 const owner = await helper.eth.createAccountWithBalance(donor);145 const receiver = helper.eth.createAccount();146147 const {collectionAddress} = await helper.eth.createERC721MetadataCompatibleNFTCollection(owner, 'Mint collection', '6', '6', '');148 const contract = await helper.ethNativeContract.collection(collectionAddress, testCase.mode, owner);149150 const result = await contract.methods.mintWithTokenURI(receiver, 'Test URI').send();151 const tokenId = result.events.Transfer.returnValues.tokenId;152 expect(tokenId).to.be.equal('1');153154 const event = result.events.Transfer;155 expect(event.address).to.be.equal(collectionAddress);156 expect(event.returnValues.from).to.be.equal('0x0000000000000000000000000000000000000000');157 expect(event.returnValues.to).to.be.equal(receiver);158159 expect(await contract.methods.tokenURI(tokenId).call()).to.be.equal('Test URI');160 expect(await contract.methods.crossOwnerOf(tokenId).call()).to.be.like([receiver, '0']);161 // TODO: this wont work right now, need release 919000 first162 // await helper.methods.setOffchainSchema(collectionIdAddress, 'https://offchain-service.local/token-info/{id}').send();163 // const tokenUri = await contract.methods.tokenURI(nextTokenId).call();164 // expect(tokenUri).to.be.equal(`https://offchain-service.local/token-info/${nextTokenId}`);165 });166 });167});