git.delta.rocks / unique-network / refs/commits / 48cdcf7aa35b

difftreelog

fix minor fixes in eth tests

Daniel Shiposha2022-10-03parent: #22fb1ca.patch.diff
in: master

2 files changed

modifiedtests/src/eth/collectionSponsoring.test.tsdiffbeforeafterboth
--- a/tests/src/eth/collectionSponsoring.test.ts
+++ b/tests/src/eth/collectionSponsoring.test.ts
@@ -65,7 +65,7 @@
     let result = await collectionHelpers.methods.createNonfungibleCollection('Sponsor collection', '1', '1').send();
     const collectionIdAddress = helper.ethAddress.normalizeAddress(result.events.CollectionCreated.returnValues.collectionId);
     const sponsor = await helper.eth.createAccountWithBalance(alice);
-    const collectionEvm = await helper.ethNativeContract.collection(collectionIdAddress, 'nft', owner);
+    const collectionEvm = helper.ethNativeContract.collection(collectionIdAddress, 'nft', owner);
 
     expect(await collectionEvm.methods.hasCollectionPendingSponsor().call({from: owner})).to.be.false;
     result = await collectionEvm.methods.setCollectionSponsor(sponsor).send({from: owner});
@@ -220,7 +220,7 @@
     const collectionId = helper.ethAddress.extractCollectionId(collectionIdAddress);
     const collection = helper.nft.getCollectionObject(collectionId);
     const sponsor = await helper.eth.createAccountWithBalance(alice);
-    const collectionEvm = await helper.ethNativeContract.collection(collectionIdAddress, 'nft', owner);
+    const collectionEvm = helper.ethNativeContract.collection(collectionIdAddress, 'nft', owner);
 
     result = await collectionEvm.methods.setCollectionSponsor(sponsor).send();
     let collectionData = (await collection.getData())!;
@@ -228,7 +228,7 @@
     expect(collectionData.raw.sponsorship.Unconfirmed).to.be.eq(evmToAddress(sponsor, Number(ss58Format)));
     await expect(collectionEvm.methods.confirmCollectionSponsorship().call()).to.be.rejectedWith('caller is not set as sponsor');
 
-    const sponsorCollection = await helper.ethNativeContract.collection(collectionIdAddress, 'nft', sponsor);
+    const sponsorCollection = helper.ethNativeContract.collection(collectionIdAddress, 'nft', sponsor);
     await sponsorCollection.methods.confirmCollectionSponsorship().send();
     collectionData = (await collection.getData())!;
     expect(collectionData.raw.sponsorship.Confirmed).to.be.eq(evmToAddress(sponsor, Number(ss58Format)));
@@ -239,7 +239,7 @@
     const ownerBalanceBefore = await helper.balance.getSubstrate(await helper.address.ethToSubstrate(owner));
     const sponsorBalanceBefore = await helper.balance.getSubstrate(await helper.address.ethToSubstrate(sponsor));
 
-    const userCollectionEvm = await helper.ethNativeContract.collection(collectionIdAddress, 'nft', user);
+    const userCollectionEvm = helper.ethNativeContract.collection(collectionIdAddress, 'nft', user);
     const nextTokenId = await userCollectionEvm.methods.nextTokenId().call();
     expect(nextTokenId).to.be.equal('1');
     result = await userCollectionEvm.methods.mintWithTokenURI(
modifiedtests/src/eth/tokenProperties.test.tsdiffbeforeafterboth
before · tests/src/eth/tokenProperties.test.ts
1import {cartesian} from './util/helpers';2import {itEth, expect} from '../eth/util/playgrounds';34describe.only('EVM token properties', () => {5  itEth('Can be reconfigured', async({helper, privateKey}) => {6    const alice = privateKey('//Alice');7    const caller = await helper.eth.createAccountWithBalance(alice);89    for(const [mutable,collectionAdmin, tokenOwner] of cartesian([], [false, true], [false, true], [false, true])) {10      const collection = await helper.nft.mintCollection(alice, {tokenPrefix: 'ethp'});11      await collection.addAdmin(alice, {Ethereum: caller});1213      const address = helper.ethAddress.fromCollectionId(collection.collectionId);14      const contract = helper.ethNativeContract.collection(address, 'nft', caller);1516      await contract.methods.setTokenPropertyPermission('testKey', mutable, collectionAdmin, tokenOwner).send({from: caller});17  18      const state = await collection.getPropertyPermissions();19      expect(state).to.be.deep.equal([{20        key: 'testKey',21        permission: {mutable, collectionAdmin, tokenOwner},22      }]);23    }24  });2526  itEth('Can be set', async({helper, privateKey}) => {27    const alice = privateKey('//Alice');28    const caller = await helper.eth.createAccountWithBalance(alice);29    const collection = await helper.nft.mintCollection(alice, {30      tokenPrefix: 'ethp',31      tokenPropertyPermissions: [{32        key: 'testKey',33        permission: {34          collectionAdmin: true,35        },36      }],37    });38    const token = await collection.mintToken(alice);3940    await collection.addAdmin(alice, {Ethereum: caller});4142    const address = helper.ethAddress.fromCollectionId(collection.collectionId);43    const contract = helper.ethNativeContract.collection(address, 'nft', caller);4445    await contract.methods.setProperty(token.tokenId, 'testKey', Buffer.from('testValue')).send({from: caller});4647    const [{value}] = await token.getProperties(['testKey']);48    expect(value).to.equal('testValue');49  });5051  itEth('Can be deleted', async({helper, privateKey}) => {52    const alice = privateKey('//Alice');53    const caller = await helper.eth.createAccountWithBalance(alice);54    const collection = await helper.nft.mintCollection(alice, {55      tokenPrefix: 'ethp',56      tokenPropertyPermissions: [{57        key: 'testKey',58        permission: {59          mutable: true,60          collectionAdmin: true,61        },62      }],63    });6465    await collection.addAdmin(alice, {Ethereum: caller});6667    const token = await collection.mintToken(alice);68    await token.setProperties(alice, [{key: 'testKey', value: 'testValue'}]);6970    const address = helper.ethAddress.fromCollectionId(collection.collectionId);71    const contract = helper.ethNativeContract.collection(address, 'nft', caller);7273    await contract.methods.deleteProperty(token.tokenId, 'testKey').send({from: caller});7475    const result = await token.getProperties(['testKey']);76    expect(result.length).to.equal(0);77  });7879  itEth('Can be read', async({helper, privateKey}) => {80    const alice = privateKey('//Alice');81    const caller = await helper.eth.createAccountWithBalance(alice);82    const collection = await helper.nft.mintCollection(alice, {83      tokenPrefix: 'ethp',84      tokenPropertyPermissions: [{85        key: 'testKey',86        permission: {87          collectionAdmin: true,88        },89      }],90    });91    const token = await collection.mintToken(alice);92    await token.setProperties(alice, [{key: 'testKey', value: 'testValue'}]);9394    const address = helper.ethAddress.fromCollectionId(collection.collectionId);95    const contract = helper.ethNativeContract.collection(address, 'nft', caller);9697    const value = await contract.methods.property(token.tokenId, 'testKey').call();98    expect(value).to.equal(helper.getWeb3().utils.toHex('testValue'));99  });100});