difftreelog
added substrate interraction in tests `transferCross`
in: master
3 files changed
tests/src/eth/fungible.test.tsdiffbeforeafterboth234 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});239240260 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 }273274 {275 const balance = await collection.getBalance({Ethereum: owner});276 expect(balance).to.equal(100n);277 }278279 {280 const balance = await collection.getBalance({Substrate: donor.address});281 expect(balance).to.equal(50n);282 }283 262 });284 });263 285 tests/src/eth/nonFungible.test.tsdiffbeforeafterboth--- a/tests/src/eth/nonFungible.test.ts
+++ b/tests/src/eth/nonFungible.test.ts
@@ -406,8 +406,10 @@
itEth('Can perform transferCross()', async ({helper}) => {
const collection = await helper.nft.mintCollection(minter, {});
const owner = await helper.eth.createAccountWithBalance(donor);
- const receiver = helper.eth.createAccount();
+ const receiver = await helper.eth.createAccountWithBalance(donor);
const to = helper.ethCrossAccount.fromAddress(receiver);
+ const toSubstrate = helper.ethCrossAccount.fromKeyringPair(minter);
+
const {tokenId} = await collection.mintToken(minter, {Ethereum: owner});
const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);
@@ -432,6 +434,27 @@
const balance = await contract.methods.balanceOf(receiver).call();
expect(+balance).to.equal(1);
}
+
+ {
+ const substrateResult = await contract.methods.transferCross(toSubstrate, tokenId).send({from: receiver});
+
+
+ const event = substrateResult.events.Transfer;
+ expect(event.address).to.be.equal(collectionAddress);
+ expect(event.returnValues.from).to.be.equal(receiver);
+ expect(event.returnValues.to).to.be.equal(helper.address.substrateToEth(minter.address));
+ expect(event.returnValues.tokenId).to.be.equal(`${tokenId}`);
+ }
+
+ {
+ const balance = await contract.methods.balanceOf(receiver).call();
+ expect(+balance).to.equal(0);
+ }
+
+ {
+ const balance = await helper.nft.getTokensByAddress(collection.collectionId, {Substrate: minter.address});
+ expect(balance).to.be.contain(tokenId);
+ }
});
});
tests/src/eth/reFungible.test.tsdiffbeforeafterboth--- a/tests/src/eth/reFungible.test.ts
+++ b/tests/src/eth/reFungible.test.ts
@@ -362,13 +362,14 @@
itEth('Can perform transferCross()', async ({helper}) => {
const caller = await helper.eth.createAccountWithBalance(donor);
- const receiver = helper.eth.createAccount();
+ const receiver = await helper.eth.createAccountWithBalance(donor);
const to = helper.ethCrossAccount.fromAddress(receiver);
- const {collectionAddress} = await helper.eth.createRFTCollection(caller, 'Transferry', '6', '6');
+ const toSubstrate = helper.ethCrossAccount.fromKeyringPair(minter);
+ const collection = await helper.rft.mintCollection(minter, {});
+ const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);
const contract = helper.ethNativeContract.collection(collectionAddress, 'rft', caller);
- const result = await contract.methods.mint(caller).send();
- const tokenId = result.events.Transfer.returnValues.tokenId;
+ const {tokenId} = await collection.mintToken(minter, 1n, {Ethereum: caller});
{
const result = await contract.methods.transferCross(to, tokenId).send({from: caller});
@@ -389,6 +390,27 @@
const balance = await contract.methods.balanceOf(receiver).call();
expect(+balance).to.equal(1);
}
+
+ {
+ const substrateResult = await contract.methods.transferCross(toSubstrate, tokenId).send({from: receiver});
+
+
+ const event = substrateResult.events.Transfer;
+ expect(event.address).to.be.equal(collectionAddress);
+ expect(event.returnValues.from).to.be.equal(receiver);
+ expect(event.returnValues.to).to.be.equal(helper.address.substrateToEth(minter.address));
+ expect(event.returnValues.tokenId).to.be.equal(`${tokenId}`);
+ }
+
+ {
+ const balance = await contract.methods.balanceOf(receiver).call();
+ expect(+balance).to.equal(0);
+ }
+
+ {
+ const balance = await helper.nft.getTokensByAddress(collection.collectionId, {Substrate: minter.address});
+ expect(balance).to.be.contain(tokenId);
+ }
});
itEth('transfer event on transfer from partial ownership to full ownership', async ({helper}) => {