git.delta.rocks / unique-network / refs/commits / b30d78a48678

difftreelog

added substrate interraction in tests `transferCross`

PraetorP2022-11-15parent: #bbafef4.patch.diff
in: master

3 files changed

modifiedtests/src/eth/fungible.test.tsdiffbeforeafterboth
234 const owner = await helper.eth.createAccountWithBalance(donor);234 const owner = await helper.eth.createAccountWithBalance(donor);
235 const receiver = await helper.eth.createAccountWithBalance(donor);235 const receiver = await helper.eth.createAccountWithBalance(donor);
236 const to = helper.ethCrossAccount.fromAddress(receiver);236 const to = helper.ethCrossAccount.fromAddress(receiver);
237 const toSubstrate = helper.ethCrossAccount.fromKeyringPair(donor);
237 const collection = await helper.ft.mintCollection(alice);238 const collection = await helper.ft.mintCollection(alice);
238 await collection.mint(alice, 200n, {Ethereum: owner});239 await collection.mint(alice, 200n, {Ethereum: owner});
239240
260 expect(+balance).to.equal(50);261 expect(+balance).to.equal(50);
261 }262 }
263
264 {
265 const result = await contract.methods.transferCross(toSubstrate, 50).send({from: owner});
266
267 const event = result.events.Transfer;
268 expect(event.address).to.be.equal(collectionAddress);
269 expect(event.returnValues.from).to.be.equal(owner);
270 expect(event.returnValues.to).to.be.equal(helper.address.substrateToEth(donor.address));
271 expect(event.returnValues.value).to.be.equal('50');
272 }
273
274 {
275 const balance = await collection.getBalance({Ethereum: owner});
276 expect(balance).to.equal(100n);
277 }
278
279 {
280 const balance = await collection.getBalance({Substrate: donor.address});
281 expect(balance).to.equal(50n);
282 }
283
262 });284 });
263 285
modifiedtests/src/eth/nonFungible.test.tsdiffbeforeafterboth
406 itEth('Can perform transferCross()', async ({helper}) => {406 itEth('Can perform transferCross()', async ({helper}) => {
407 const collection = await helper.nft.mintCollection(minter, {});407 const collection = await helper.nft.mintCollection(minter, {});
408 const owner = await helper.eth.createAccountWithBalance(donor);408 const owner = await helper.eth.createAccountWithBalance(donor);
409 const receiver = helper.eth.createAccount();409 const receiver = await helper.eth.createAccountWithBalance(donor);
410 const to = helper.ethCrossAccount.fromAddress(receiver);410 const to = helper.ethCrossAccount.fromAddress(receiver);
411 const toSubstrate = helper.ethCrossAccount.fromKeyringPair(minter);
412
411 const {tokenId} = await collection.mintToken(minter, {Ethereum: owner});413 const {tokenId} = await collection.mintToken(minter, {Ethereum: owner});
412414
433 expect(+balance).to.equal(1);435 expect(+balance).to.equal(1);
434 }436 }
437
438 {
439 const substrateResult = await contract.methods.transferCross(toSubstrate, tokenId).send({from: receiver});
440
441
442 const event = substrateResult.events.Transfer;
443 expect(event.address).to.be.equal(collectionAddress);
444 expect(event.returnValues.from).to.be.equal(receiver);
445 expect(event.returnValues.to).to.be.equal(helper.address.substrateToEth(minter.address));
446 expect(event.returnValues.tokenId).to.be.equal(`${tokenId}`);
447 }
448
449 {
450 const balance = await contract.methods.balanceOf(receiver).call();
451 expect(+balance).to.equal(0);
452 }
453
454 {
455 const balance = await helper.nft.getTokensByAddress(collection.collectionId, {Substrate: minter.address});
456 expect(balance).to.be.contain(tokenId);
457 }
435 });458 });
436});459});
437460
modifiedtests/src/eth/reFungible.test.tsdiffbeforeafterboth
362 362
363 itEth('Can perform transferCross()', async ({helper}) => {363 itEth('Can perform transferCross()', async ({helper}) => {
364 const caller = await helper.eth.createAccountWithBalance(donor);364 const caller = await helper.eth.createAccountWithBalance(donor);
365 const receiver = helper.eth.createAccount();365 const receiver = await helper.eth.createAccountWithBalance(donor);
366 const to = helper.ethCrossAccount.fromAddress(receiver);366 const to = helper.ethCrossAccount.fromAddress(receiver);
367 const toSubstrate = helper.ethCrossAccount.fromKeyringPair(minter);
367 const {collectionAddress} = await helper.eth.createRFTCollection(caller, 'Transferry', '6', '6');368 const collection = await helper.rft.mintCollection(minter, {});
369 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);
368 const contract = helper.ethNativeContract.collection(collectionAddress, 'rft', caller);370 const contract = helper.ethNativeContract.collection(collectionAddress, 'rft', caller);
369371
370 const result = await contract.methods.mint(caller).send();372 const {tokenId} = await collection.mintToken(minter, 1n, {Ethereum: caller});
371 const tokenId = result.events.Transfer.returnValues.tokenId;
372373
373 {374 {
374 const result = await contract.methods.transferCross(to, tokenId).send({from: caller});375 const result = await contract.methods.transferCross(to, tokenId).send({from: caller});
390 expect(+balance).to.equal(1);391 expect(+balance).to.equal(1);
391 }392 }
393
394 {
395 const substrateResult = await contract.methods.transferCross(toSubstrate, tokenId).send({from: receiver});
396
397
398 const event = substrateResult.events.Transfer;
399 expect(event.address).to.be.equal(collectionAddress);
400 expect(event.returnValues.from).to.be.equal(receiver);
401 expect(event.returnValues.to).to.be.equal(helper.address.substrateToEth(minter.address));
402 expect(event.returnValues.tokenId).to.be.equal(`${tokenId}`);
403 }
404
405 {
406 const balance = await contract.methods.balanceOf(receiver).call();
407 expect(+balance).to.equal(0);
408 }
409
410 {
411 const balance = await helper.nft.getTokensByAddress(collection.collectionId, {Substrate: minter.address});
412 expect(balance).to.be.contain(tokenId);
413 }
392 });414 });
393415
394 itEth('transfer event on transfer from partial ownership to full ownership', async ({helper}) => {416 itEth('transfer event on transfer from partial ownership to full ownership', async ({helper}) => {