git.delta.rocks / unique-network / refs/commits / 99b194acc32e

difftreelog

test fix marketplace config

Yaroslav Bolyukin2021-11-29parent: #6bc741d.patch.diff
in: master

1 file changed

modifiedtests/src/eth/marketplace/marketplace.test.tsdiffbeforeafterboth
before · tests/src/eth/marketplace/marketplace.test.ts
1import {readFile} from 'fs/promises';2import {getBalanceSingle, transferBalanceExpectSuccess} from '../../substrate/get-balance';3import privateKey from '../../substrate/privateKey';4import {addToAllowListExpectSuccess, confirmSponsorshipExpectSuccess, createCollectionExpectSuccess, createFungibleItemExpectSuccess, createItemExpectSuccess, getTokenOwner, setCollectionSponsorExpectSuccess, transferExpectSuccess, transferFromExpectSuccess} from '../../util/helpers';5import {collectionIdToAddress, contractHelpers, createEthAccountWithBalance, executeEthTxOnSub, GAS_ARGS, itWeb3, subToEth, subToEthLowercase, transferBalanceToEth} from '../util/helpers';6import {evmToAddress} from '@polkadot/util-crypto';7import nonFungibleAbi from '../nonFungibleAbi.json';8import fungibleAbi from '../fungibleAbi.json';9import {expect} from 'chai';1011const PRICE = 2000n;1213describe('Matcher contract usage', () => {14  itWeb3('With UNQ', async ({api, web3}) => {15    const alice = privateKey('//Alice');16    const matcherOwner = await createEthAccountWithBalance(api, web3);17    const matcherContract = new web3.eth.Contract(JSON.parse((await readFile(`${__dirname}/MarketPlace.abi`)).toString()), undefined, {18      from: matcherOwner,19      ...GAS_ARGS,20    });21    const matcher = await matcherContract.deploy({data: (await readFile(`${__dirname}/MarketPlace.bin`)).toString(), arguments:[matcherOwner]}).send({from: matcherOwner});22    const helpers = contractHelpers(web3, matcherOwner);23    await helpers.methods.toggleSponsoring(matcher.options.address, true).send({from: matcherOwner});24    await helpers.methods.setSponsoringRateLimit(matcher.options.address, 1).send({from: matcherOwner});25    await transferBalanceToEth(api, alice, matcher.options.address);2627    const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});28    const evmCollection = new web3.eth.Contract(nonFungibleAbi as any, collectionIdToAddress(collectionId), {from: matcherOwner});29    await setCollectionSponsorExpectSuccess(collectionId, alice.address);30    await confirmSponsorshipExpectSuccess(collectionId);3132    await helpers.methods.toggleAllowed(matcher.options.address, subToEth(alice.address), true).send({from: matcherOwner});33    await addToAllowListExpectSuccess(alice, collectionId, evmToAddress(subToEth(alice.address)));3435    const seller = privateKey('//Bob');36    await helpers.methods.toggleAllowed(matcher.options.address, subToEth(seller.address), true).send({from: matcherOwner});37    await addToAllowListExpectSuccess(alice, collectionId, evmToAddress(subToEth(seller.address)));3839    const tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT', seller.address);4041    // To transfer item to matcher it first needs to be transfered to EVM account of bob42    await transferExpectSuccess(collectionId, tokenId, seller, {Ethereum: subToEth(seller.address)});4344    // Token is owned by seller initially45    expect(await getTokenOwner(api, collectionId, tokenId)).to.be.deep.equal({Ethereum: subToEthLowercase(seller.address)});4647    // Ask48    {49      await executeEthTxOnSub(web3, api, seller, evmCollection, m => m.approve(matcher.options.address, tokenId));50      await executeEthTxOnSub(web3, api, seller, matcher, m => m.addAsk(PRICE, '0x0000000000000000000000000000000000000001', evmCollection.options.address, tokenId));51    }5253    // Token is transferred to matcher54    expect(await getTokenOwner(api, collectionId, tokenId)).to.be.deep.equal({Ethereum: matcher.options.address.toLowerCase()});5556    // Buy57    {58      const sellerBalanceBeforePurchase = await getBalanceSingle(api, seller.address);59      await executeEthTxOnSub(web3, api, alice, matcher, m => m.buy(evmCollection.options.address, tokenId), {value: PRICE});60      expect(await getBalanceSingle(api, seller.address) - sellerBalanceBeforePurchase === PRICE);61    }6263    // Token is transferred to evm account of alice64    expect(await getTokenOwner(api, collectionId, tokenId)).to.be.deep.equal({Ethereum: subToEthLowercase(alice.address)});6566    // Transfer token to substrate side of alice67    await transferFromExpectSuccess(collectionId, tokenId, alice, {Ethereum: subToEth(alice.address)}, {Substrate: alice.address});6869    // Token is transferred to substrate account of alice, seller received funds70    expect(await getTokenOwner(api, collectionId, tokenId)).to.be.deep.equal({Substrate: alice.address});71  });7273  // selling for custom tokens excluded from release74  itWeb3.skip('With custom ERC20', async ({api, web3}) => {75    const alice = privateKey('//Alice');76    const matcherOwner = await createEthAccountWithBalance(api, web3);77    const matcherContract = new web3.eth.Contract(JSON.parse((await readFile(`${__dirname}/MarketPlace.abi`)).toString()), undefined, {78      from: matcherOwner,79      ...GAS_ARGS,80    });81    const matcher = await matcherContract.deploy({data: (await readFile(`${__dirname}/MarketPlace.bin`)).toString(), arguments: [matcherOwner]}).send({from: matcherOwner});8283    const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});84    const evmCollection = new web3.eth.Contract(nonFungibleAbi as any, collectionIdToAddress(collectionId), {from: matcherOwner});8586    const fungibleId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});87    const evmFungible = new web3.eth.Contract(fungibleAbi as any, collectionIdToAddress(fungibleId), {from: matcherOwner, ...GAS_ARGS});88    await createFungibleItemExpectSuccess(alice, fungibleId, {Value: PRICE}, {Ethereum: subToEth(alice.address)});8990    const seller = privateKey('//Bob');9192    const tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT', seller.address);9394    // To transfer item to matcher it first needs to be transfered to EVM account of bob95    await transferExpectSuccess(collectionId, tokenId, seller, {Ethereum: subToEth(seller.address)});96    // Fees will be paid from EVM account, so we should have some balance here97    await transferBalanceExpectSuccess(api, seller, evmToAddress(subToEth(seller.address)), 10n ** 18n);98    await transferBalanceExpectSuccess(api, alice, evmToAddress(subToEth(alice.address)), 10n ** 18n);99100    // Token is owned by seller initially101    expect(await getTokenOwner(api, collectionId, tokenId)).to.be.deep.equal({Ethereum: subToEthLowercase(seller.address)});102103    // Ask104    {105      await executeEthTxOnSub(web3, api, seller, evmCollection, m => m.approve(matcher.options.address, tokenId));106      await executeEthTxOnSub(web3, api, seller, matcher, m => m.addAsk(PRICE, evmFungible.options.address, evmCollection.options.address, tokenId, 1));107    }108109    // Token is transferred to matcher110    expect(await getTokenOwner(api, collectionId, tokenId)).to.be.deep.equal({Ethereum: matcher.options.address.toLowerCase()});111112    // Buy113    {114      const sellerBalanceBeforePurchase = BigInt(await evmFungible.methods.balanceOf(subToEth(seller.address)).call());115      const buyerBalanceBeforePurchase = BigInt(await evmFungible.methods.balanceOf(subToEth(alice.address)).call());116117      await executeEthTxOnSub(web3, api, alice, evmFungible, m => m.approve(matcher.options.address, PRICE));118      // There is two functions named 'buy', so we should provide full signature119      await executeEthTxOnSub(web3, api, alice, matcher, m =>120        m['buy(address,uint256,address,uint256)'](evmCollection.options.address, tokenId, evmFungible.options.address, PRICE));121122      // Approved price is removed from buyer balance, and added to seller123      expect(BigInt(await evmFungible.methods.balanceOf(subToEth(seller.address)).call()) - sellerBalanceBeforePurchase === PRICE);124      expect(buyerBalanceBeforePurchase - BigInt(await evmFungible.methods.balanceOf(subToEth(alice.address)).call()) === PRICE);125    }126127    // Token is transferred to evm account of alice128    expect(await getTokenOwner(api, collectionId, tokenId)).to.be.deep.equal({Ethereum: subToEthLowercase(alice.address)});129130131    // Transfer token to substrate side of alice132    await transferFromExpectSuccess(collectionId, tokenId, alice, {Ethereum: subToEth(alice.address)}, {Substrate: alice.address});133134    // Token is transferred to substrate account of alice135    expect(await getTokenOwner(api, collectionId, tokenId)).to.be.deep.equal({Substrate: alice.address});136  });137138  itWeb3('With escrow', async ({api, web3}) => {139    const alice = privateKey('//Alice');140    const matcherOwner = await createEthAccountWithBalance(api, web3);141    const escrow = await createEthAccountWithBalance(api, web3);142    const matcherContract = new web3.eth.Contract(JSON.parse((await readFile(`${__dirname}/MarketPlace.abi`)).toString()), undefined, {143      from: matcherOwner,144      ...GAS_ARGS,145    });146    const matcher = await matcherContract.deploy({data: (await readFile(`${__dirname}/MarketPlace.bin`)).toString(), arguments: [matcherOwner]}).send({from: matcherOwner, gas: 10000000});147    await matcher.methods.setEscrow(escrow).send({from: matcherOwner});148    const helpers = contractHelpers(web3, matcherOwner);149    await helpers.methods.toggleSponsoring(matcher.options.address, true).send({from: matcherOwner});150    await helpers.methods.setSponsoringRateLimit(matcher.options.address, 1).send({from: matcherOwner});151    await transferBalanceToEth(api, alice, matcher.options.address);152153    const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});154    const evmCollection = new web3.eth.Contract(nonFungibleAbi as any, collectionIdToAddress(collectionId), {from: matcherOwner});155    await setCollectionSponsorExpectSuccess(collectionId, alice.address);156    await confirmSponsorshipExpectSuccess(collectionId);157158    await helpers.methods.toggleAllowed(matcher.options.address, subToEth(alice.address), true).send({from: matcherOwner});159    await addToAllowListExpectSuccess(alice, collectionId, evmToAddress(subToEth(alice.address)));160161    const seller = privateKey('//Bob');162    await helpers.methods.toggleAllowed(matcher.options.address, subToEth(seller.address), true).send({from: matcherOwner});163    await addToAllowListExpectSuccess(alice, collectionId, evmToAddress(subToEth(seller.address)));164165    const tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT', seller.address);166167    // To transfer item to matcher it first needs to be transfered to EVM account of bob168    await transferExpectSuccess(collectionId, tokenId, seller, {Ethereum: subToEth(seller.address)});169170    // Token is owned by seller initially171    expect(await getTokenOwner(api, collectionId, tokenId)).to.be.deep.equal({Ethereum: subToEthLowercase(seller.address)});172173    // Ask174    {175      await executeEthTxOnSub(web3, api, seller, evmCollection, m => m.approve(matcher.options.address, tokenId));176      await executeEthTxOnSub(web3, api, seller, matcher, m => m.addAsk(PRICE, '0x0000000000000000000000000000000000000001', evmCollection.options.address, tokenId));177    }178179    // Token is transferred to matcher180    expect(await getTokenOwner(api, collectionId, tokenId)).to.be.deep.equal({Ethereum: matcher.options.address.toLowerCase()});181182    // Give buyer KSM183    await matcher.methods.depositKSM(PRICE, subToEth(alice.address)).send({from: escrow});184185    // Buy186    {187      expect(await matcher.methods.balanceKSM(subToEth(seller.address)).call()).to.be.equal('0');188      expect(await matcher.methods.balanceKSM(subToEth(alice.address)).call()).to.be.equal(PRICE.toString());189190      await executeEthTxOnSub(web3, api, alice, matcher, m => m.buyKSM(evmCollection.options.address, tokenId, subToEth(alice.address), subToEth(alice.address)));191192      // Price is removed from buyer balance, and added to seller193      expect(await matcher.methods.balanceKSM(subToEth(alice.address)).call()).to.be.equal('0');194      expect(await matcher.methods.balanceKSM(subToEth(seller.address)).call()).to.be.equal(PRICE.toString());195    }196197    // Token is transferred to evm account of alice198    expect(await getTokenOwner(api, collectionId, tokenId)).to.be.deep.equal({Ethereum: subToEthLowercase(alice.address)});199200    // Transfer token to substrate side of alice201    await transferFromExpectSuccess(collectionId, tokenId, alice, {Ethereum: subToEth(alice.address)}, {Substrate: alice.address});202203    // Token is transferred to substrate account of alice, seller received funds204    expect(await getTokenOwner(api, collectionId, tokenId)).to.be.deep.equal({Substrate: alice.address});205  });206});
after · tests/src/eth/marketplace/marketplace.test.ts
1import {readFile} from 'fs/promises';2import {getBalanceSingle, transferBalanceExpectSuccess} from '../../substrate/get-balance';3import privateKey from '../../substrate/privateKey';4import {addToAllowListExpectSuccess, confirmSponsorshipExpectSuccess, createCollectionExpectSuccess, createFungibleItemExpectSuccess, createItemExpectSuccess, getTokenOwner, setCollectionLimitsExpectSuccess, setCollectionSponsorExpectSuccess, transferExpectSuccess, transferFromExpectSuccess} from '../../util/helpers';5import {collectionIdToAddress, contractHelpers, createEthAccountWithBalance, executeEthTxOnSub, GAS_ARGS, itWeb3, subToEth, subToEthLowercase, transferBalanceToEth} from '../util/helpers';6import {evmToAddress} from '@polkadot/util-crypto';7import nonFungibleAbi from '../nonFungibleAbi.json';8import fungibleAbi from '../fungibleAbi.json';9import {expect} from 'chai';1011const PRICE = 2000n;1213describe('Matcher contract usage', () => {14  itWeb3('With UNQ', async ({api, web3}) => {15    const alice = privateKey('//Alice');16    const matcherOwner = await createEthAccountWithBalance(api, web3);17    const matcherContract = new web3.eth.Contract(JSON.parse((await readFile(`${__dirname}/MarketPlace.abi`)).toString()), undefined, {18      from: matcherOwner,19      ...GAS_ARGS,20    });21    const matcher = await matcherContract.deploy({data: (await readFile(`${__dirname}/MarketPlace.bin`)).toString(), arguments:[matcherOwner]}).send({from: matcherOwner});22    const helpers = contractHelpers(web3, matcherOwner);23    await helpers.methods.toggleSponsoring(matcher.options.address, true).send({from: matcherOwner});24    await helpers.methods.setSponsoringRateLimit(matcher.options.address, 1).send({from: matcherOwner});25    await transferBalanceToEth(api, alice, matcher.options.address);2627    const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});28    await setCollectionLimitsExpectSuccess(alice, collectionId, {sponsorApproveTimeout: 1});29    const evmCollection = new web3.eth.Contract(nonFungibleAbi as any, collectionIdToAddress(collectionId), {from: matcherOwner});30    await setCollectionSponsorExpectSuccess(collectionId, alice.address);31    await transferBalanceToEth(api, alice, subToEth(alice.address));32    await confirmSponsorshipExpectSuccess(collectionId);3334    await helpers.methods.toggleAllowed(matcher.options.address, subToEth(alice.address), true).send({from: matcherOwner});35    await addToAllowListExpectSuccess(alice, collectionId, evmToAddress(subToEth(alice.address)));3637    const seller = privateKey(`//Seller/${Date.now()}`);38    await helpers.methods.toggleAllowed(matcher.options.address, subToEth(seller.address), true).send({from: matcherOwner});3940    const tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT', seller.address);4142    // To transfer item to matcher it first needs to be transfered to EVM account of bob43    await transferExpectSuccess(collectionId, tokenId, seller, {Ethereum: subToEth(seller.address)});4445    // Token is owned by seller initially46    expect(await getTokenOwner(api, collectionId, tokenId)).to.be.deep.equal({Ethereum: subToEthLowercase(seller.address)});4748    // Ask49    {50      await executeEthTxOnSub(web3, api, seller, evmCollection, m => m.approve(matcher.options.address, tokenId));51      await executeEthTxOnSub(web3, api, seller, matcher, m => m.addAsk(PRICE, '0x0000000000000000000000000000000000000001', evmCollection.options.address, tokenId));52    }5354    // Token is transferred to matcher55    expect(await getTokenOwner(api, collectionId, tokenId)).to.be.deep.equal({Ethereum: matcher.options.address.toLowerCase()});5657    // Buy58    {59      const sellerBalanceBeforePurchase = await getBalanceSingle(api, seller.address);60      await executeEthTxOnSub(web3, api, alice, matcher, m => m.buy(evmCollection.options.address, tokenId), {value: PRICE});61      expect(await getBalanceSingle(api, seller.address) - sellerBalanceBeforePurchase === PRICE);62    }6364    // Token is transferred to evm account of alice65    expect(await getTokenOwner(api, collectionId, tokenId)).to.be.deep.equal({Ethereum: subToEthLowercase(alice.address)});6667    // Transfer token to substrate side of alice68    await transferFromExpectSuccess(collectionId, tokenId, alice, {Ethereum: subToEth(alice.address)}, {Substrate: alice.address});6970    // Token is transferred to substrate account of alice, seller received funds71    expect(await getTokenOwner(api, collectionId, tokenId)).to.be.deep.equal({Substrate: alice.address});72  });7374  // selling for custom tokens excluded from release75  itWeb3.skip('With custom ERC20', async ({api, web3}) => {76    const alice = privateKey('//Alice');77    const matcherOwner = await createEthAccountWithBalance(api, web3);78    const matcherContract = new web3.eth.Contract(JSON.parse((await readFile(`${__dirname}/MarketPlace.abi`)).toString()), undefined, {79      from: matcherOwner,80      ...GAS_ARGS,81    });82    const matcher = await matcherContract.deploy({data: (await readFile(`${__dirname}/MarketPlace.bin`)).toString(), arguments: [matcherOwner]}).send({from: matcherOwner});8384    const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});85    const evmCollection = new web3.eth.Contract(nonFungibleAbi as any, collectionIdToAddress(collectionId), {from: matcherOwner});8687    const fungibleId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});88    const evmFungible = new web3.eth.Contract(fungibleAbi as any, collectionIdToAddress(fungibleId), {from: matcherOwner, ...GAS_ARGS});89    await createFungibleItemExpectSuccess(alice, fungibleId, {Value: PRICE}, {Ethereum: subToEth(alice.address)});9091    const seller = privateKey('//Bob');9293    const tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT', seller.address);9495    // To transfer item to matcher it first needs to be transfered to EVM account of bob96    await transferExpectSuccess(collectionId, tokenId, seller, {Ethereum: subToEth(seller.address)});97    // Fees will be paid from EVM account, so we should have some balance here98    await transferBalanceExpectSuccess(api, seller, evmToAddress(subToEth(seller.address)), 10n ** 18n);99    await transferBalanceExpectSuccess(api, alice, evmToAddress(subToEth(alice.address)), 10n ** 18n);100101    // Token is owned by seller initially102    expect(await getTokenOwner(api, collectionId, tokenId)).to.be.deep.equal({Ethereum: subToEthLowercase(seller.address)});103104    // Ask105    {106      await executeEthTxOnSub(web3, api, seller, evmCollection, m => m.approve(matcher.options.address, tokenId));107      await executeEthTxOnSub(web3, api, seller, matcher, m => m.addAsk(PRICE, evmFungible.options.address, evmCollection.options.address, tokenId, 1));108    }109110    // Token is transferred to matcher111    expect(await getTokenOwner(api, collectionId, tokenId)).to.be.deep.equal({Ethereum: matcher.options.address.toLowerCase()});112113    // Buy114    {115      const sellerBalanceBeforePurchase = BigInt(await evmFungible.methods.balanceOf(subToEth(seller.address)).call());116      const buyerBalanceBeforePurchase = BigInt(await evmFungible.methods.balanceOf(subToEth(alice.address)).call());117118      await executeEthTxOnSub(web3, api, alice, evmFungible, m => m.approve(matcher.options.address, PRICE));119      // There is two functions named 'buy', so we should provide full signature120      await executeEthTxOnSub(web3, api, alice, matcher, m =>121        m['buy(address,uint256,address,uint256)'](evmCollection.options.address, tokenId, evmFungible.options.address, PRICE));122123      // Approved price is removed from buyer balance, and added to seller124      expect(BigInt(await evmFungible.methods.balanceOf(subToEth(seller.address)).call()) - sellerBalanceBeforePurchase === PRICE);125      expect(buyerBalanceBeforePurchase - BigInt(await evmFungible.methods.balanceOf(subToEth(alice.address)).call()) === PRICE);126    }127128    // Token is transferred to evm account of alice129    expect(await getTokenOwner(api, collectionId, tokenId)).to.be.deep.equal({Ethereum: subToEthLowercase(alice.address)});130131132    // Transfer token to substrate side of alice133    await transferFromExpectSuccess(collectionId, tokenId, alice, {Ethereum: subToEth(alice.address)}, {Substrate: alice.address});134135    // Token is transferred to substrate account of alice136    expect(await getTokenOwner(api, collectionId, tokenId)).to.be.deep.equal({Substrate: alice.address});137  });138139  itWeb3('With escrow', async ({api, web3}) => {140    const alice = privateKey('//Alice');141    const matcherOwner = await createEthAccountWithBalance(api, web3);142    const escrow = await createEthAccountWithBalance(api, web3);143    const matcherContract = new web3.eth.Contract(JSON.parse((await readFile(`${__dirname}/MarketPlace.abi`)).toString()), undefined, {144      from: matcherOwner,145      ...GAS_ARGS,146    });147    const matcher = await matcherContract.deploy({data: (await readFile(`${__dirname}/MarketPlace.bin`)).toString(), arguments: [matcherOwner]}).send({from: matcherOwner, gas: 10000000});148    await matcher.methods.setEscrow(escrow).send({from: matcherOwner});149    const helpers = contractHelpers(web3, matcherOwner);150    await helpers.methods.toggleSponsoring(matcher.options.address, true).send({from: matcherOwner});151    await helpers.methods.setSponsoringRateLimit(matcher.options.address, 1).send({from: matcherOwner});152    await transferBalanceToEth(api, alice, matcher.options.address);153154    const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});155    await setCollectionLimitsExpectSuccess(alice, collectionId, {sponsorApproveTimeout: 1});156    const evmCollection = new web3.eth.Contract(nonFungibleAbi as any, collectionIdToAddress(collectionId), {from: matcherOwner});157    await setCollectionSponsorExpectSuccess(collectionId, alice.address);158    await transferBalanceToEth(api, alice, subToEth(alice.address));159    await confirmSponsorshipExpectSuccess(collectionId);160161    await helpers.methods.toggleAllowed(matcher.options.address, subToEth(alice.address), true).send({from: matcherOwner});162    await addToAllowListExpectSuccess(alice, collectionId, evmToAddress(subToEth(alice.address)));163164    const seller = privateKey(`//Seller/${Date.now()}`);165    await helpers.methods.toggleAllowed(matcher.options.address, subToEth(seller.address), true).send({from: matcherOwner});166167    const tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT', seller.address);168169    // To transfer item to matcher it first needs to be transfered to EVM account of bob170    await transferExpectSuccess(collectionId, tokenId, seller, {Ethereum: subToEth(seller.address)});171172    // Token is owned by seller initially173    expect(await getTokenOwner(api, collectionId, tokenId)).to.be.deep.equal({Ethereum: subToEthLowercase(seller.address)});174175    // Ask176    {177      await executeEthTxOnSub(web3, api, seller, evmCollection, m => m.approve(matcher.options.address, tokenId));178      await executeEthTxOnSub(web3, api, seller, matcher, m => m.addAsk(PRICE, '0x0000000000000000000000000000000000000001', evmCollection.options.address, tokenId));179    }180181    // Token is transferred to matcher182    expect(await getTokenOwner(api, collectionId, tokenId)).to.be.deep.equal({Ethereum: matcher.options.address.toLowerCase()});183184    // Give buyer KSM185    await matcher.methods.depositKSM(PRICE, subToEth(alice.address)).send({from: escrow});186187    // Buy188    {189      expect(await matcher.methods.balanceKSM(subToEth(seller.address)).call()).to.be.equal('0');190      expect(await matcher.methods.balanceKSM(subToEth(alice.address)).call()).to.be.equal(PRICE.toString());191192      await executeEthTxOnSub(web3, api, alice, matcher, m => m.buyKSM(evmCollection.options.address, tokenId, subToEth(alice.address), subToEth(alice.address)));193194      // Price is removed from buyer balance, and added to seller195      expect(await matcher.methods.balanceKSM(subToEth(alice.address)).call()).to.be.equal('0');196      expect(await matcher.methods.balanceKSM(subToEth(seller.address)).call()).to.be.equal(PRICE.toString());197    }198199    // Token is transferred to evm account of alice200    expect(await getTokenOwner(api, collectionId, tokenId)).to.be.deep.equal({Ethereum: subToEthLowercase(alice.address)});201202    // Transfer token to substrate side of alice203    await transferFromExpectSuccess(collectionId, tokenId, alice, {Ethereum: subToEth(alice.address)}, {Substrate: alice.address});204205    // Token is transferred to substrate account of alice, seller received funds206    expect(await getTokenOwner(api, collectionId, tokenId)).to.be.deep.equal({Substrate: alice.address});207  });208});