From 6b56d6d674756195e9bf460cab6999d70ea3a0b7 Mon Sep 17 00:00:00 2001 From: str-mv Date: Mon, 29 Nov 2021 08:01:58 +0000 Subject: [PATCH] CORE-215 --- --- a/tests/src/transfer.test.ts +++ b/tests/src/transfer.test.ts @@ -24,7 +24,13 @@ getTokenOwner, normalizeAccountId, getBalance as getTokenBalance, + transferFromExpectSuccess, } from './util/helpers'; +import { + createEthAccountWithBalance, + subToEth, + itWeb3, +} from './eth/util/helpers'; let alice: IKeyringPair; let bob: IKeyringPair; @@ -292,4 +298,30 @@ expect((balanceBeforeBob)).to.be.equal(balanceAfterBob); }); }); -}); \ No newline at end of file +}); + +describe('Transfers to self (potentially over substrate-evm boundary)', () => { + itWeb3('Transfers to self. In case of same frontend', async ({api}) => { + const collectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}}); + const alice = privateKey('//Alice'); + const aliceProxy = subToEth(alice.address); + const tokenId = await createItemExpectSuccess(alice, collectionId, 'Fungible', {Substrate: alice.address}); + const balanceAliceBefore = await getTokenBalance(api, collectionId, normalizeAccountId(alice), tokenId); + await transferExpectSuccess(collectionId, tokenId, alice, {Ethereum: aliceProxy} , 10, 'ReFungible'); + await transferFromExpectSuccess(collectionId, tokenId, alice, {Ethereum: aliceProxy}, alice, 10, 'ReFungible'); + const balanceAliceAfter = await getTokenBalance(api, collectionId, normalizeAccountId(alice), tokenId); + expect(balanceAliceBefore).to.be.eq(balanceAliceAfter); + }); + + itWeb3('Transfers to self. In case of substrate-evm boundary', async ({api, web3}) => { + const collectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}}); + const alice = privateKey('//Alice'); + const aliceProxy = await createEthAccountWithBalance(api, web3); + const tokenId = await createItemExpectSuccess(alice, collectionId, 'Fungible', {Substrate: alice.address}); + const balanceAliceBefore = await getTokenBalance(api, collectionId, normalizeAccountId(alice), tokenId); + await transferExpectSuccess(collectionId, tokenId, alice, {Ethereum: aliceProxy} , 10, 'ReFungible'); + await transferFromExpectSuccess(collectionId, tokenId, alice, {Ethereum: aliceProxy}, alice, 10, 'ReFungible'); + const balanceAliceAfter = await getTokenBalance(api, collectionId, normalizeAccountId(alice), tokenId); + expect(balanceAliceBefore).to.be.eq(balanceAliceAfter); + }); +}); -- gitstuff