difftreelog
CORE-346 Skip some evm tests
in: master
3 files changed
tests/src/eth/contractSponsoring.test.tsdiffbeforeafterboth--- a/tests/src/eth/contractSponsoring.test.ts
+++ b/tests/src/eth/contractSponsoring.test.ts
@@ -226,7 +226,8 @@
expect(await helpers.methods.getSponsoringRateLimit(flipper.options.address).call()).to.be.equals('7200');
});
- itWeb3('Sponsoring evm address from substrate collection', async ({api, web3}) => {
+ //TODO: CORE-302 add eth methods
+ itWeb3.skip('Sponsoring evm address from substrate collection', async ({api, web3}) => {
const owner = await createEthAccountWithBalance(api, web3);
const collectionHelper = evmCollectionHelper(web3, owner);
let result = await collectionHelper.methods.create721Collection('Sponsor collection', '1', '1').send();
@@ -303,9 +304,9 @@
expect(await userContract.methods.tokenURI(nextTokenId).call()).to.be.equal('Test URI');
}
});
-
- itWeb3('Check that transaction via EVM spend money from substrate address', async ({api, web3}) => {
+ //TODO: CORE-302 add eth methods
+ itWeb3.skip('Check that transaction via EVM spend money from substrate address', async ({api, web3}) => {
const owner = privateKey('//Alice');
const user = privateKey(`//User/${Date.now()}`);
const userEth = subToEth(user.address);
tests/src/eth/nonFungible.test.tsdiffbeforeafterboth--- a/tests/src/eth/nonFungible.test.ts
+++ b/tests/src/eth/nonFungible.test.ts
@@ -112,7 +112,9 @@
// const tokenUri = await contract.methods.tokenURI(nextTokenId).call();
// expect(tokenUri).to.be.equal(`https://offchain-service.local/token-info/${nextTokenId}`);
});
- itWeb3('Can perform mintBulk()', async ({web3, api}) => {
+
+ //TODO: CORE-302 add eth methods
+ itWeb3.skip('Can perform mintBulk()', async ({web3, api}) => {
const collection = await createCollectionExpectSuccess({
mode: {type: 'NFT'},
});
tests/src/eth/proxy/nonFungibleProxy.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 privateKey from '../../substrate/privateKey';18import {createCollectionExpectSuccess, createItemExpectSuccess} from '../../util/helpers';19import {collectionIdToAddress, createEthAccount, createEthAccountWithBalance, GAS_ARGS, itWeb3, normalizeEvents} from '../util/helpers';20import nonFungibleAbi from '../nonFungibleAbi.json';21import {expect} from 'chai';22import {submitTransactionAsync} from '../../substrate/substrate-api';23import Web3 from 'web3';24import {readFile} from 'fs/promises';25import {ApiPromise} from '@polkadot/api';2627async function proxyWrap(api: ApiPromise, web3: Web3, wrapped: any) {28 // Proxy owner has no special privilegies, we don't need to reuse them29 const owner = await createEthAccountWithBalance(api, web3);30 const proxyContract = new web3.eth.Contract(JSON.parse((await readFile(`${__dirname}/UniqueNFTProxy.abi`)).toString()), undefined, {31 from: owner,32 ...GAS_ARGS,33 });34 const proxy = await proxyContract.deploy({data: (await readFile(`${__dirname}/UniqueNFTProxy.bin`)).toString(), arguments: [wrapped.options.address]}).send({from: owner});35 return proxy;36}3738describe('NFT (Via EVM proxy): Information getting', () => {39 itWeb3('totalSupply', async ({api, web3}) => {40 const collection = await createCollectionExpectSuccess({41 mode: {type: 'NFT'},42 });43 const alice = privateKey('//Alice');44 const caller = await createEthAccountWithBalance(api, web3);4546 await createItemExpectSuccess(alice, collection, 'NFT', {Substrate: alice.address});4748 const address = collectionIdToAddress(collection);49 const contract = await proxyWrap(api, web3, new web3.eth.Contract(nonFungibleAbi as any, address, {from: caller, ...GAS_ARGS}));50 const totalSupply = await contract.methods.totalSupply().call();5152 expect(totalSupply).to.equal('1');53 });5455 itWeb3('balanceOf', async ({api, web3}) => {56 const collection = await createCollectionExpectSuccess({57 mode: {type: 'NFT'},58 });59 const alice = privateKey('//Alice');6061 const caller = await createEthAccountWithBalance(api, web3);62 await createItemExpectSuccess(alice, collection, 'NFT', {Ethereum: caller});63 await createItemExpectSuccess(alice, collection, 'NFT', {Ethereum: caller});64 await createItemExpectSuccess(alice, collection, 'NFT', {Ethereum: caller});6566 const address = collectionIdToAddress(collection);67 const contract = await proxyWrap(api, web3, new web3.eth.Contract(nonFungibleAbi as any, address, {from: caller, ...GAS_ARGS}));68 const balance = await contract.methods.balanceOf(caller).call();6970 expect(balance).to.equal('3');71 });7273 itWeb3('ownerOf', async ({api, web3}) => {74 const collection = await createCollectionExpectSuccess({75 mode: {type: 'NFT'},76 });77 const alice = privateKey('//Alice');7879 const caller = await createEthAccountWithBalance(api, web3);80 const tokenId = await createItemExpectSuccess(alice, collection, 'NFT', {Ethereum: caller});8182 const address = collectionIdToAddress(collection);83 const contract = await proxyWrap(api, web3, new web3.eth.Contract(nonFungibleAbi as any, address, {from: caller, ...GAS_ARGS}));84 const owner = await contract.methods.ownerOf(tokenId).call();8586 expect(owner).to.equal(caller);87 });88});8990describe('NFT (Via EVM proxy): Plain calls', () => {91 itWeb3('Can perform mint()', async ({web3, api}) => {92 const collection = await createCollectionExpectSuccess({93 mode: {type: 'NFT'},94 });95 const alice = privateKey('//Alice');96 const caller = await createEthAccountWithBalance(api, web3);97 const receiver = createEthAccount(web3);9899 const address = collectionIdToAddress(collection);100 const contract = await proxyWrap(api, web3, new web3.eth.Contract(nonFungibleAbi as any, address, {from: caller, ...GAS_ARGS}));101102 const changeAdminTx = api.tx.unique.addCollectionAdmin(collection, {Ethereum: contract.options.address});103 await submitTransactionAsync(alice, changeAdminTx);104105 {106 const nextTokenId = await contract.methods.nextTokenId().call();107 expect(nextTokenId).to.be.equal('1');108 const result = await contract.methods.mintWithTokenURI(109 receiver,110 nextTokenId,111 'Test URI',112 ).send({from: caller});113 const events = normalizeEvents(result.events);114115 expect(events).to.be.deep.equal([116 {117 address,118 event: 'Transfer',119 args: {120 from: '0x0000000000000000000000000000000000000000',121 to: receiver,122 tokenId: nextTokenId,123 },124 },125 ]);126127 expect(await contract.methods.tokenURI(nextTokenId).call()).to.be.equal('Test URI');128 }129 });130 131 itWeb3('Can perform mintBulk()', async ({web3, api}) => {132 const collection = await createCollectionExpectSuccess({133 mode: {type: 'NFT'},134 });135 const alice = privateKey('//Alice');136137 const caller = await createEthAccountWithBalance(api, web3);138 const receiver = createEthAccount(web3);139140 const address = collectionIdToAddress(collection);141 const contract = await proxyWrap(api, web3, new web3.eth.Contract(nonFungibleAbi as any, address, {from: caller, ...GAS_ARGS}));142 const changeAdminTx = api.tx.unique.addCollectionAdmin(collection, {Ethereum: contract.options.address});143 await submitTransactionAsync(alice, changeAdminTx);144145 {146 const nextTokenId = await contract.methods.nextTokenId().call();147 expect(nextTokenId).to.be.equal('1');148 const result = await contract.methods.mintBulkWithTokenURI(149 receiver,150 [151 [nextTokenId, 'Test URI 0'],152 [+nextTokenId + 1, 'Test URI 1'],153 [+nextTokenId + 2, 'Test URI 2'],154 ],155 ).send({from: caller});156 const events = normalizeEvents(result.events);157158 expect(events).to.be.deep.equal([159 {160 address,161 event: 'Transfer',162 args: {163 from: '0x0000000000000000000000000000000000000000',164 to: receiver,165 tokenId: nextTokenId,166 },167 },168 {169 address,170 event: 'Transfer',171 args: {172 from: '0x0000000000000000000000000000000000000000',173 to: receiver,174 tokenId: String(+nextTokenId + 1),175 },176 },177 {178 address,179 event: 'Transfer',180 args: {181 from: '0x0000000000000000000000000000000000000000',182 to: receiver,183 tokenId: String(+nextTokenId + 2),184 },185 },186 ]);187188 expect(await contract.methods.tokenURI(nextTokenId).call()).to.be.equal('Test URI 0');189 expect(await contract.methods.tokenURI(+nextTokenId + 1).call()).to.be.equal('Test URI 1');190 expect(await contract.methods.tokenURI(+nextTokenId + 2).call()).to.be.equal('Test URI 2');191 }192 });193194 itWeb3('Can perform burn()', async ({web3, api}) => {195 const collection = await createCollectionExpectSuccess({196 mode: {type: 'NFT'},197 });198 const alice = privateKey('//Alice');199 const caller = await createEthAccountWithBalance(api, web3);200201 const address = collectionIdToAddress(collection);202 const contract = await proxyWrap(api, web3, new web3.eth.Contract(nonFungibleAbi as any, address, {from: caller, ...GAS_ARGS}));203 const tokenId = await createItemExpectSuccess(alice, collection, 'NFT', {Ethereum: contract.options.address});204205 const changeAdminTx = api.tx.unique.addCollectionAdmin(collection, {Ethereum: contract.options.address});206 await submitTransactionAsync(alice, changeAdminTx);207208 {209 const result = await contract.methods.burn(tokenId).send({from: caller});210 const events = normalizeEvents(result.events);211212 expect(events).to.be.deep.equal([213 {214 address,215 event: 'Transfer',216 args: {217 from: contract.options.address,218 to: '0x0000000000000000000000000000000000000000',219 tokenId: tokenId.toString(),220 },221 },222 ]);223 }224 });225226 itWeb3('Can perform approve()', async ({web3, api}) => {227 const collection = await createCollectionExpectSuccess({228 mode: {type: 'NFT'},229 });230 const alice = privateKey('//Alice');231 const caller = await createEthAccountWithBalance(api, web3);232 const spender = createEthAccount(web3);233234 const address = collectionIdToAddress(collection);235 const contract = await proxyWrap(api, web3, new web3.eth.Contract(nonFungibleAbi as any, address));236 const tokenId = await createItemExpectSuccess(alice, collection, 'NFT', {Ethereum: contract.options.address});237238 {239 const result = await contract.methods.approve(spender, tokenId).send({from: caller, ...GAS_ARGS});240 const events = normalizeEvents(result.events);241242 expect(events).to.be.deep.equal([243 {244 address,245 event: 'Approval',246 args: {247 owner: contract.options.address,248 approved: spender,249 tokenId: tokenId.toString(),250 },251 },252 ]);253 }254 });255256 itWeb3('Can perform transferFrom()', async ({web3, api}) => {257 const collection = await createCollectionExpectSuccess({258 mode: {type: 'NFT'},259 });260 const alice = privateKey('//Alice');261 const caller = await createEthAccountWithBalance(api, web3);262 const owner = await createEthAccountWithBalance(api, web3);263264 const receiver = createEthAccount(web3);265266 const address = collectionIdToAddress(collection);267 const evmCollection = new web3.eth.Contract(nonFungibleAbi as any, address, {from: caller, ...GAS_ARGS});268 const contract = await proxyWrap(api, web3, evmCollection);269 const tokenId = await createItemExpectSuccess(alice, collection, 'NFT', {Ethereum: owner});270271 await evmCollection.methods.approve(contract.options.address, tokenId).send({from: owner});272273 {274 const result = await contract.methods.transferFrom(owner, receiver, tokenId).send({from: caller});275 const events = normalizeEvents(result.events);276 expect(events).to.be.deep.equal([277 {278 address,279 event: 'Transfer',280 args: {281 from: owner,282 to: receiver,283 tokenId: tokenId.toString(),284 },285 },286 ]);287 }288289 {290 const balance = await contract.methods.balanceOf(receiver).call();291 expect(+balance).to.equal(1);292 }293294 {295 const balance = await contract.methods.balanceOf(contract.options.address).call();296 expect(+balance).to.equal(0);297 }298 });299300 itWeb3('Can perform transfer()', async ({web3, api}) => {301 const collection = await createCollectionExpectSuccess({302 mode: {type: 'NFT'},303 });304 const alice = privateKey('//Alice');305 const caller = await createEthAccountWithBalance(api, web3);306 const receiver = createEthAccount(web3);307308 const address = collectionIdToAddress(collection);309 const contract = await proxyWrap(api, web3, new web3.eth.Contract(nonFungibleAbi as any, address, {from: caller, ...GAS_ARGS}));310 const tokenId = await createItemExpectSuccess(alice, collection, 'NFT', {Ethereum: contract.options.address});311312 {313 const result = await contract.methods.transfer(receiver, tokenId).send({from: caller});314 const events = normalizeEvents(result.events);315 expect(events).to.be.deep.equal([316 {317 address,318 event: 'Transfer',319 args: {320 from: contract.options.address,321 to: receiver,322 tokenId: tokenId.toString(),323 },324 },325 ]);326 }327328 {329 const balance = await contract.methods.balanceOf(contract.options.address).call();330 expect(+balance).to.equal(0);331 }332333 {334 const balance = await contract.methods.balanceOf(receiver).call();335 expect(+balance).to.equal(1);336 }337 });338});