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

difftreelog

Add checks to burnFromCross test

Max Andreev2022-12-01parent: #ccf797c.patch.diff
in: master

1 file changed

modifiedtests/src/eth/nonFungible.test.tsdiffbeforeafterboth
252 itEth('Can perform burnFromCross()', async ({helper}) => {252 itEth('Can perform burnFromCross()', async ({helper}) => {
253 const collection = await helper.nft.mintCollection(minter, {name: 'A', description: 'B', tokenPrefix: 'C'});253 const collection = await helper.nft.mintCollection(minter, {name: 'A', description: 'B', tokenPrefix: 'C'});
254
255 const owner = bob;254 const ownerSub = bob;
255 const ownerCross = helper.ethCrossAccount.fromKeyringPair(ownerSub);
256 const spender = await helper.eth.createAccountWithBalance(donor, 100n);256 const ownerEth = await helper.eth.createAccountWithBalance(donor, 100n);
257
258 const burnerEth = await helper.eth.createAccountWithBalance(donor, 100n);
259 const burnerCrossEth = helper.ethCrossAccount.fromAddress(burnerEth);
257260
258 const token = await collection.mintToken(minter, {Substrate: owner.address});261 const token1 = await collection.mintToken(minter, {Substrate: ownerSub.address});
262 const token2 = await collection.mintToken(minter, {Ethereum: ownerEth});
259263
260 const address = helper.ethAddress.fromCollectionId(collection.collectionId);264 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);
261 const contract = helper.ethNativeContract.collection(address, 'nft');265 const collectionEvm = helper.ethNativeContract.collection(collectionAddress, 'nft');
262266
263 {267 // Approve tokens from substrate and ethereum:
264 await token.approve(owner, {Ethereum: spender});268 await token1.approve(ownerSub, {Ethereum: burnerEth});
269 await collectionEvm.methods.approveCross(burnerCrossEth, token2.tokenId).send({from: ownerEth});
270
271 // can burnFromCross:
265 const ownerCross = helper.ethCrossAccount.fromKeyringPair(owner);272 const result1 = await collectionEvm.methods.burnFromCross(ownerCross, token1.tokenId).send({from: burnerEth});
273 // FIXME Error No Permission?:
266 const result = await contract.methods.burnFromCross(ownerCross, token.tokenId).send({from: spender});274 const result2 = await collectionEvm.methods.burnFromCross(ownerCross, token2.tokenId).send({from: burnerEth});
267 const events = result.events.Transfer;275 const events1 = result1.events.Transfer;
276 const events2 = result2.events.Transfer;
268277
269 expect(events).to.be.like({278 [[events1, token1], [events2, token2]].map(burnEvents => {
279 expect(burnEvents[0]).to.be.like({
270 address,280 address: collectionAddress,
271 event: 'Transfer',281 event: 'Transfer',
272 returnValues: {282 returnValues: {
273 from: helper.address.substrateToEth(owner.address),283 from: helper.address.substrateToEth(ownerSub.address),
274 to: '0x0000000000000000000000000000000000000000',284 to: '0x0000000000000000000000000000000000000000',
275 tokenId: token.tokenId.toString(),285 tokenId: burnEvents[1].tokenId.toString(),
276 },286 },
277 });287 });
278 }288 });
289
290 expect(await token1.doesExist()).to.be.false;
291 expect(await token2.doesExist()).to.be.false;
279 });292 });
280293
281 itEth('Can perform approveCross()', async ({helper}) => {294 itEth('Can perform approveCross()', async ({helper}) => {