difftreelog
Tests: code-style fixes
in: master
14 files changed
tests/src/addCollectionAdmin.test.tsdiffbeforeafterboth--- a/tests/src/addCollectionAdmin.test.ts
+++ b/tests/src/addCollectionAdmin.test.ts
@@ -110,7 +110,7 @@
const [alice, ...accounts] = await helper.arrange.createAccounts([10n, 0n, 0n, 0n, 0n, 0n, 0n, 0n], donor);
const collection = await helper.nft.mintCollection(alice, {name: 'Collection Name', description: 'Collection Description', tokenPrefix: 'COL'});
- const chainAdminLimit = (helper.api!.consts.common.collectionAdminsLimit as any).toNumber();
+ const chainAdminLimit = (helper.getApi().consts.common.collectionAdminsLimit as any).toNumber();
expect(chainAdminLimit).to.be.equal(5);
for (let i = 0; i < chainAdminLimit; i++) {
tests/src/approve.test.tsdiffbeforeafterboth--- a/tests/src/approve.test.ts
+++ b/tests/src/approve.test.ts
@@ -60,7 +60,7 @@
const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: alice.address});
await helper.nft.approveToken(alice, collectionId, tokenId, {Substrate: bob.address});
expect(await helper.nft.isTokenApproved(collectionId, tokenId, {Substrate: bob.address})).to.be.true;
- await helper.signTransaction(alice, helper.api?.tx.unique.approve({Substrate: bob.address}, collectionId, tokenId, 0));
+ await helper.signTransaction(alice, helper.constructApiCall('api.tx.unique.approve', [{Substrate: bob.address}, collectionId, tokenId, 0]));
expect(await helper.nft.isTokenApproved(collectionId, tokenId, {Substrate: bob.address})).to.be.false;
});
@@ -275,7 +275,7 @@
const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: alice.address});
await helper.nft.approveToken(alice, collectionId, tokenId, {Substrate: bob.address});
expect(await helper.nft.isTokenApproved(collectionId, tokenId, {Substrate: bob.address})).to.be.true;
- await helper.signTransaction(alice, helper.api?.tx.unique.approve({Substrate: bob.address}, collectionId, tokenId, 0));
+ await helper.signTransaction(alice, helper.constructApiCall('api.tx.unique.approve', [{Substrate: bob.address}, collectionId, tokenId, 0]));
expect(await helper.nft.isTokenApproved(collectionId, tokenId, {Substrate: bob.address})).to.be.false;
const transferTokenFromTx = async () => helper.nft.transferTokenFrom(bob, collectionId, tokenId, {Substrate: bob.address}, {Substrate: bob.address});
await expect(transferTokenFromTx()).to.be.rejected;
@@ -328,7 +328,7 @@
itSub('1 for NFT', async ({helper}) => {
const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: bob.address});
- const approveTx = async () => helper.signTransaction(bob, helper.api?.tx.unique.approve({Substrate: charlie.address}, collectionId, tokenId, 2));
+ const approveTx = async () => helper.signTransaction(bob, helper.constructApiCall('api.tx.unique.approve', [{Substrate: charlie.address}, collectionId, tokenId, 2]));
await expect(approveTx()).to.be.rejected;
expect(await helper.nft.isTokenApproved(collectionId, tokenId, {Substrate: charlie.address})).to.be.false;
});
tests/src/block-production.test.tsdiffbeforeafterboth--- a/tests/src/block-production.test.ts
+++ b/tests/src/block-production.test.ts
@@ -37,7 +37,7 @@
describe('Block Production smoke test', () => {
itSub('Node produces new blocks', async ({helper}) => {
- const blocks: number[] | undefined = await getBlocks(helper.api!);
+ const blocks: number[] | undefined = await getBlocks(helper.getApi());
expect(blocks[0]).to.be.lessThan(blocks[1]);
});
});
tests/src/createMultipleItemsEx.test.tsdiffbeforeafterboth1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617import {IKeyringPair} from '@polkadot/types/types';18import {usingPlaygrounds, expect, Pallets, itSub} from './util/playgrounds';19import {IProperty} from './util/playgrounds/types';2021describe('Integration Test: createMultipleItemsEx', () => {22 let alice: IKeyringPair;23 let bob: IKeyringPair;24 let charlie: IKeyringPair;2526 before(async () => {27 await usingPlaygrounds(async (helper, privateKey) => {28 const donor = privateKey('//Alice');29 [alice, bob, charlie] = await helper.arrange.createAccounts([100n, 100n, 100n], donor);30 });31 });3233 itSub('can initialize multiple NFT with different owners', async ({helper}) => {34 const collection = await helper.nft.mintCollection(alice, {35 name: 'name',36 description: 'descr',37 tokenPrefix: 'COL',38 });39 const args = [40 {41 owner: {Substrate: alice.address},42 },43 {44 owner: {Substrate: bob.address},45 },46 {47 owner: {Substrate: charlie.address},48 },49 ];5051 const tokens = await collection.mintMultipleTokens(alice, args);52 for (const [i, token] of tokens.entries()) {53 expect(await token.getOwner()).to.be.deep.equal(args[i].owner);54 }55 });5657 itSub('createMultipleItemsEx with property Admin', async ({helper}) => {58 const collection = await helper.nft.mintCollection(alice, {59 name: 'name',60 description: 'descr',61 tokenPrefix: 'COL',62 tokenPropertyPermissions: [63 {64 key: 'k',65 permission: {66 mutable: true,67 collectionAdmin: true,68 tokenOwner: false,69 },70 },71 ],72 });7374 const args = [75 {76 owner: {Substrate: alice.address},77 properties: [{key: 'k', value: 'v1'}],78 },79 {80 owner: {Substrate: bob.address},81 properties: [{key: 'k', value: 'v2'}],82 },83 {84 owner: {Substrate: charlie.address},85 properties: [{key: 'k', value: 'v3'}],86 },87 ];8889 const tokens = await collection.mintMultipleTokens(alice, args);90 for (const [i, token] of tokens.entries()) {91 expect(await token.getOwner()).to.be.deep.equal(args[i].owner);92 expect(await token.getData()).to.not.be.empty;93 }94 });9596 itSub('createMultipleItemsEx with property AdminConst', async ({helper}) => {97 const collection = await helper.nft.mintCollection(alice, {98 name: 'name',99 description: 'descr',100 tokenPrefix: 'COL',101 tokenPropertyPermissions: [102 {103 key: 'k',104 permission: {105 mutable: false,106 collectionAdmin: true,107 tokenOwner: false,108 },109 },110 ],111 });112113 const args = [114 {115 owner: {Substrate: alice.address},116 properties: [{key: 'k', value: 'v1'}],117 },118 {119 owner: {Substrate: bob.address},120 properties: [{key: 'k', value: 'v2'}],121 },122 {123 owner: {Substrate: charlie.address},124 properties: [{key: 'k', value: 'v3'}],125 },126 ];127128 const tokens = await collection.mintMultipleTokens(alice, args);129 for (const [i, token] of tokens.entries()) {130 expect(await token.getOwner()).to.be.deep.equal(args[i].owner);131 expect(await token.getData()).to.not.be.empty;132 }133 });134135 itSub('createMultipleItemsEx with property itemOwnerOrAdmin', async ({helper}) => {136 const collection = await helper.nft.mintCollection(alice, {137 name: 'name',138 description: 'descr',139 tokenPrefix: 'COL',140 tokenPropertyPermissions: [141 {142 key: 'k',143 permission: {144 mutable: false,145 collectionAdmin: true,146 tokenOwner: true,147 },148 },149 ],150 });151152 const args = [153 {154 owner: {Substrate: alice.address},155 properties: [{key: 'k', value: 'v1'}],156 },157 {158 owner: {Substrate: bob.address},159 properties: [{key: 'k', value: 'v2'}],160 },161 {162 owner: {Substrate: charlie.address},163 properties: [{key: 'k', value: 'v3'}],164 },165 ];166167 const tokens = await collection.mintMultipleTokens(alice, args);168 for (const [i, token] of tokens.entries()) {169 expect(await token.getOwner()).to.be.deep.equal(args[i].owner);170 expect(await token.getData()).to.not.be.empty;171 }172 });173174 itSub('can initialize fungible with multiple owners', async ({helper}) => {175 const collection = await helper.ft.mintCollection(alice, {176 name: 'name',177 description: 'descr',178 tokenPrefix: 'COL',179 }, 0);180181 const api = helper.api;182 await helper.signTransaction(alice, api?.tx.unique.createMultipleItemsEx(collection.collectionId, {183 Fungible: new Map([184 [JSON.stringify({Substrate: alice.address}), 50],185 [JSON.stringify({Substrate: bob.address}), 100],186 ]),187 }));188189 expect(await collection.getBalance({Substrate: alice.address})).to.be.equal(50n);190 expect(await collection.getBalance({Substrate: bob.address})).to.be.equal(100n);191 });192193 itSub.ifWithPallets('can initialize an RFT with multiple owners', [Pallets.ReFungible], async ({helper}) => {194 const collection = await helper.rft.mintCollection(alice, {195 name: 'name',196 description: 'descr',197 tokenPrefix: 'COL',198 tokenPropertyPermissions: [199 {key: 'k', permission: {tokenOwner: true, mutable: false, collectionAdmin: false}},200 ],201 });202203 const api = helper.api;204 await helper.signTransaction(alice, api?.tx.unique.createMultipleItemsEx(collection.collectionId, {205 RefungibleMultipleOwners: {206 users: new Map([207 [JSON.stringify({Substrate: alice.address}), 1],208 [JSON.stringify({Substrate: bob.address}), 2],209 ]),210 properties: [211 {key: 'k', value: 'v'},212 ],213 },214 }));215 const tokenId = await collection.getLastTokenId();216 expect(tokenId).to.be.equal(1);217 expect(await collection.getTokenBalance(1, {Substrate: alice.address})).to.be.equal(1n);218 expect(await collection.getTokenBalance(1, {Substrate: bob.address})).to.be.equal(2n);219 });220221 itSub.ifWithPallets('can initialize multiple RFTs with the same owner', [Pallets.ReFungible], async ({helper}) => {222 const collection = await helper.rft.mintCollection(alice, {223 name: 'name',224 description: 'descr',225 tokenPrefix: 'COL',226 tokenPropertyPermissions: [227 {key: 'k', permission: {tokenOwner: true, mutable: false, collectionAdmin: false}},228 ],229 });230231 const api = helper.api;232233 await helper.signTransaction(alice, api?.tx.unique.createMultipleItemsEx(collection.collectionId, {234 RefungibleMultipleItems: [235 {236 user: {Substrate: alice.address}, pieces: 1,237 properties: [238 {key: 'k', value: 'v1'},239 ],240 },241 {242 user: {Substrate: alice.address}, pieces: 3,243 properties: [244 {key: 'k', value: 'v2'},245 ],246 },247 ],248 }));249250 expect(await collection.getLastTokenId()).to.be.equal(2);251 expect(await collection.getTokenBalance(1, {Substrate: alice.address})).to.be.equal(1n);252 expect(await collection.getTokenBalance(2, {Substrate: alice.address})).to.be.equal(3n);253254 const tokenData1 = await helper.rft.getToken(collection.collectionId, 1);255 expect(tokenData1).to.not.be.null;256 expect(tokenData1?.properties[0]).to.be.deep.equal({key: 'k', value: 'v1'});257258 const tokenData2 = await helper.rft.getToken(collection.collectionId, 2);259 expect(tokenData2).to.not.be.null;260 expect(tokenData2?.properties[0]).to.be.deep.equal({key: 'k', value: 'v2'});261 });262});263264describe('Negative test: createMultipleItemsEx', () => {265 let alice: IKeyringPair;266 let bob: IKeyringPair;267 let charlie: IKeyringPair;268269 before(async () => {270 await usingPlaygrounds(async (helper, privateKey) => {271 const donor = privateKey('//Alice');272 [alice, bob, charlie] = await helper.arrange.createAccounts([100n, 100n, 100n], donor);273 });274 });275276 itSub('No editing rights', async ({helper}) => {277 const collection = await helper.nft.mintCollection(alice, {278 name: 'name',279 description: 'descr',280 tokenPrefix: 'COL',281 tokenPropertyPermissions: [282 {283 key: 'k',284 permission: {285 mutable: true,286 collectionAdmin: false,287 tokenOwner: false,288 },289 },290 ],291 });292293 const args = [294 {295 owner: {Substrate: alice.address},296 properties: [{key: 'k', value: 'v1'}],297 },298 {299 owner: {Substrate: bob.address},300 properties: [{key: 'k', value: 'v2'}],301 },302 {303 owner: {Substrate: charlie.address},304 properties: [{key: 'k', value: 'v3'}],305 },306 ];307308 await expect(collection.mintMultipleTokens(alice, args)).to.be.rejectedWith(/common\.NoPermission/);309 });310311 itSub('User doesnt have editing rights', async ({helper}) => {312 const collection = await helper.nft.mintCollection(alice, {313 name: 'name',314 description: 'descr',315 tokenPrefix: 'COL',316 tokenPropertyPermissions: [317 {318 key: 'k',319 permission: {320 mutable: false,321 collectionAdmin: false,322 tokenOwner: false,323 },324 },325 ],326 });327328 const args = [329 {330 owner: {Substrate: alice.address},331 properties: [{key: 'k', value: 'v1'}],332 },333 {334 owner: {Substrate: bob.address},335 properties: [{key: 'k', value: 'v2'}],336 },337 {338 owner: {Substrate: charlie.address},339 properties: [{key: 'k', value: 'v3'}],340 },341 ];342343 await expect(collection.mintMultipleTokens(alice, args)).to.be.rejectedWith(/common\.NoPermission/);344 });345346 itSub('Adding property without access rights', async ({helper}) => {347 const collection = await helper.nft.mintCollection(alice, {348 name: 'name',349 description: 'descr',350 tokenPrefix: 'COL',351 });352353 const args = [354 {355 owner: {Substrate: alice.address},356 properties: [{key: 'k', value: 'v1'}],357 },358 {359 owner: {Substrate: bob.address},360 properties: [{key: 'k', value: 'v2'}],361 },362 {363 owner: {Substrate: charlie.address},364 properties: [{key: 'k', value: 'v3'}],365 },366 ];367368 await expect(collection.mintMultipleTokens(alice, args)).to.be.rejectedWith(/common\.NoPermission/);369 });370371 itSub('Adding more than 64 properties', async ({helper}) => {372 const collection = await helper.nft.mintCollection(alice, {373 name: 'name',374 description: 'descr',375 tokenPrefix: 'COL',376 tokenPropertyPermissions: [377 {378 key: 'k',379 permission: {380 mutable: true,381 collectionAdmin: true,382 tokenOwner: true,383 },384 },385 ],386 });387388 const properties: IProperty[] = [];389390 for (let i = 0; i < 65; i++) {391 properties.push({key: `k${i}`, value: `v${i}`});392 }393394 const args = [395 {396 owner: {Substrate: alice.address},397 properties: properties,398 },399 {400 owner: {Substrate: bob.address},401 properties: properties,402 },403 {404 owner: {Substrate: charlie.address},405 properties: properties,406 },407 ];408409 await expect(collection.mintMultipleTokens(alice, args)).to.be.rejectedWith('Verification Error');410 });411412 itSub('Trying to add bigger property than allowed', async ({helper}) => {413 const collection = await helper.nft.mintCollection(alice, {414 name: 'name',415 description: 'descr',416 tokenPrefix: 'COL',417 tokenPropertyPermissions: [418 {419 key: 'k',420 permission: {421 mutable: true,422 collectionAdmin: true,423 tokenOwner: true,424 },425 },426 ],427 });428429 const args = [430 {431 owner: {Substrate: alice.address},432 properties: [{key: 'k', value: 'A'.repeat(32769)}],433 },434 {435 owner: {Substrate: bob.address},436 properties: [{key: 'k', value: 'A'.repeat(32769)}],437 },438 {439 owner: {Substrate: charlie.address},440 properties: [{key: 'k', value: 'A'.repeat(32769)}],441 },442 ];443444 await expect(collection.mintMultipleTokens(alice, args)).to.be.rejectedWith('Verification Error');445 });446});tests/src/creditFeesToTreasury.test.tsdiffbeforeafterboth--- a/tests/src/creditFeesToTreasury.test.ts
+++ b/tests/src/creditFeesToTreasury.test.ts
@@ -70,7 +70,7 @@
});
itSub('Sender balance decreased by fee+sent amount, Treasury balance increased by fee', async ({helper}) => {
- await skipInflationBlock(helper.api!);
+ await skipInflationBlock(helper.getApi());
await helper.wait.newBlocks(1);
const treasuryBalanceBefore = await helper.balance.getSubstrate(TREASURY);
@@ -89,7 +89,7 @@
});
itSub('Treasury balance increased by failed tx fee', async ({helper}) => {
- const api = helper.api!;
+ const api = helper.getApi();
await helper.wait.newBlocks(1);
const treasuryBalanceBefore = await helper.balance.getSubstrate(TREASURY);
@@ -107,7 +107,7 @@
});
itSub('NFT Transactions also send fees to Treasury', async ({helper}) => {
- await skipInflationBlock(helper.api!);
+ await skipInflationBlock(helper.getApi());
await helper.wait.newBlocks(1);
const treasuryBalanceBefore = await helper.balance.getSubstrate(TREASURY);
@@ -125,7 +125,7 @@
itSub('Fees are sane', async ({helper}) => {
const unique = helper.balance.getOneTokenNominal();
- await skipInflationBlock(helper.api!);
+ await skipInflationBlock(helper.getApi());
await helper.wait.newBlocks(1);
const aliceBalanceBefore = await helper.balance.getSubstrate(alice.address);
@@ -140,7 +140,7 @@
});
itSub('NFT Transfer fee is close to 0.1 Unique', async ({helper}) => {
- await skipInflationBlock(helper.api!);
+ await skipInflationBlock(helper.getApi());
await helper.wait.newBlocks(1);
const collection = await helper.nft.mintCollection(alice, {
tests/src/eth/createNFTCollection.test.tsdiffbeforeafterboth--- a/tests/src/eth/createNFTCollection.test.ts
+++ b/tests/src/eth/createNFTCollection.test.ts
@@ -152,7 +152,7 @@
before(async function() {
await usingEthPlaygrounds(async (helper, privateKey) => {
donor = privateKey('//Alice');
- nominal = helper.balance.getOneTokenNominal()
+ nominal = helper.balance.getOneTokenNominal();
});
});
tests/src/eth/proxy/nonFungibleProxy.test.tsdiffbeforeafterboth--- a/tests/src/eth/proxy/nonFungibleProxy.test.ts
+++ b/tests/src/eth/proxy/nonFungibleProxy.test.ts
@@ -138,23 +138,16 @@
});
//TODO: CORE-302 add eth methods
- itEth.skip('Can perform mintBulk()', async ({helper, privateKey}) => {
- const api = helper.getApi();
- const web3 = helper.getWeb3();
- const privateKeyWrapper = privateKey;
- /*
- const collection = await createCollectionExpectSuccess({
- mode: {type: 'NFT'},
- });
- const alice = privateKeyWrapper('//Alice');
+ itEth.skip('Can perform mintBulk()', async ({helper}) => {
+ const collection = await helper.nft.mintCollection(donor, {name: 'New', description: 'New collection', tokenPrefix: 'NEW'});
- const caller = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
- const receiver = createEthAccount(web3);
+ const caller = await helper.eth.createAccountWithBalance(donor, 30n);
+ const receiver = helper.eth.createAccount();
- const address = collectionIdToAddress(collection);
- const contract = await proxyWrap(api, web3, new web3.eth.Contract(nonFungibleAbi as any, address, {from: caller, ...GAS_ARGS}), privateKeyWrapper);
- const changeAdminTx = api.tx.unique.addCollectionAdmin(collection, {Ethereum: contract.options.address});
- await submitTransactionAsync(alice, changeAdminTx);
+ const address = helper.ethAddress.fromCollectionId(collection.collectionId);
+ const evmCollection = helper.ethNativeContract.collection(address, 'nft', caller);
+ const contract = await proxyWrap(helper, evmCollection, donor);
+ await collection.addAdmin(donor, {Ethereum: contract.options.address});
{
const nextTokenId = await contract.methods.nextTokenId().call();
@@ -167,7 +160,7 @@
[+nextTokenId + 2, 'Test URI 2'],
],
).send({from: caller});
- const events = normalizeEvents(result.events);
+ const events = helper.eth.normalizeEvents(result.events);
expect(events).to.be.deep.equal([
{
@@ -203,7 +196,6 @@
expect(await contract.methods.tokenURI(+nextTokenId + 1).call()).to.be.equal('Test URI 1');
expect(await contract.methods.tokenURI(+nextTokenId + 2).call()).to.be.equal('Test URI 2');
}
- */
});
itEth('Can perform burn()', async ({helper}) => {
tests/src/eth/util/playgrounds/unique.dev.tsdiffbeforeafterboth--- a/tests/src/eth/util/playgrounds/unique.dev.ts
+++ b/tests/src/eth/util/playgrounds/unique.dev.ts
@@ -285,8 +285,8 @@
await code();
// In dev mode, the transaction might not finish processing in time
await this.helper.wait.newBlocks(1);
- }
- return await this.helper.arrange.calculcateFee(address, code);
+ };
+ return await this.helper.arrange.calculcateFee(address, wrappedCode);
}
}
tests/src/inflation.test.tsdiffbeforeafterboth--- a/tests/src/inflation.test.ts
+++ b/tests/src/inflation.test.ts
@@ -40,9 +40,9 @@
const tx = helper.constructApiCall('api.tx.inflation.startInflation', [1]);
await expect(helper.executeExtrinsic(superuser, 'api.tx.sudo.sudo', [tx])).to.not.be.rejected;
- const blockInterval = (helper.api!.consts.inflation.inflationBlockInterval as any).toBigInt();
- const totalIssuanceStart = ((await helper.api!.query.inflation.startingYearTotalIssuance()) as any).toBigInt();
- const blockInflation = (await helper.api!.query.inflation.blockInflation() as any).toBigInt();
+ const blockInterval = (helper.getApi().consts.inflation.inflationBlockInterval as any).toBigInt();
+ const totalIssuanceStart = ((await helper.callRpc('api.query.inflation.startingYearTotalIssuance', [])) as any).toBigInt();
+ const blockInflation = (await helper.callRpc('api.query.inflation.blockInflation', []) as any).toBigInt();
const YEAR = 5259600n; // 6-second block. Blocks in one year
// const YEAR = 2629800n; // 12-second block. Blocks in one year
tests/src/nesting/properties.test.tsdiffbeforeafterboth--- a/tests/src/nesting/properties.test.ts
+++ b/tests/src/nesting/properties.test.ts
@@ -276,7 +276,7 @@
itSub('Reads access rights to properties of a collection', async ({helper}) => {
const collection = await helper.nft.mintCollection(alice);
- const propertyRights = (await helper.api!.query.common.collectionPropertyPermissions(collection.collectionId)).toJSON();
+ const propertyRights = (await helper.callRpc('api.query.common.collectionPropertyPermissions', [collection.collectionId])).toJSON();
expect(propertyRights).to.be.empty;
});
@@ -817,7 +817,7 @@
).to.be.fulfilled;
}
- const originalSpace = await getConsumedSpace(token.collection.helper.api, token.collectionId, token.tokenId, pieces == 1n ? 'NFT' : 'RFT');
+ const originalSpace = await getConsumedSpace(token.collection.helper.getApi(), token.collectionId, token.tokenId, pieces == 1n ? 'NFT' : 'RFT');
return originalSpace;
}
@@ -840,7 +840,7 @@
).to.be.rejectedWith(/common\.NoPermission/);
}
- const consumedSpace = await getConsumedSpace(token.collection.helper.api, token.collectionId, token.tokenId, pieces == 1n ? 'NFT' : 'RFT');
+ const consumedSpace = await getConsumedSpace(token.collection.helper.getApi(), token.collectionId, token.tokenId, pieces == 1n ? 'NFT' : 'RFT');
expect(consumedSpace).to.be.equal(originalSpace);
}
@@ -875,7 +875,7 @@
).to.be.rejectedWith(/common\.NoPermission/);
}
- const consumedSpace = await getConsumedSpace(token.collection.helper.api, token.collectionId, token.tokenId, pieces == 1n ? 'NFT' : 'RFT');
+ const consumedSpace = await getConsumedSpace(token.collection.helper.getApi(), token.collectionId, token.tokenId, pieces == 1n ? 'NFT' : 'RFT');
expect(consumedSpace).to.be.equal(originalSpace);
}
@@ -911,7 +911,7 @@
expect(await token.getProperties(['non-existent', 'now-existent'])).to.be.empty;
- const consumedSpace = await getConsumedSpace(token.collection.helper.api, token.collectionId, token.tokenId, pieces == 1n ? 'NFT' : 'RFT');
+ const consumedSpace = await getConsumedSpace(token.collection.helper.getApi(), token.collectionId, token.tokenId, pieces == 1n ? 'NFT' : 'RFT');
expect(consumedSpace).to.be.equal(originalSpace);
}
@@ -951,7 +951,7 @@
])).to.be.rejectedWith(/common\.NoSpaceForProperty/);
expect(await token.getProperties(['a_holy_book', 'young_years'])).to.be.empty;
- const consumedSpace = await getConsumedSpace(token.collection.helper.api, token.collectionId, token.tokenId, pieces == 1n ? 'NFT' : 'RFT');
+ const consumedSpace = await getConsumedSpace(token.collection.helper.getApi(), token.collectionId, token.tokenId, pieces == 1n ? 'NFT' : 'RFT');
expect(consumedSpace).to.be.equal(originalSpace);
}
tests/src/pallet-presence.test.tsdiffbeforeafterboth--- a/tests/src/pallet-presence.test.ts
+++ b/tests/src/pallet-presence.test.ts
@@ -59,7 +59,7 @@
describe('Pallet presence', () => {
before(async () => {
await usingPlaygrounds(async helper => {
- const chain = await helper.api!.rpc.system.chain();
+ const chain = await helper.callRpc('api.rpc.system.chain', []);
const refungible = 'refungible';
const scheduler = 'scheduler';
tests/src/tx-version-presence.test.tsdiffbeforeafterboth--- a/tests/src/tx-version-presence.test.ts
+++ b/tests/src/tx-version-presence.test.ts
@@ -22,7 +22,7 @@
describe('TxVersion is present', () => {
before(async () => {
await usingPlaygrounds(async helper => {
- metadata = await helper.api!.rpc.state.getMetadata();
+ metadata = await helper.callRpc('api.rpc.state.getMetadata', []);
});
});
tests/src/util/playgrounds/unique.dev.tsdiffbeforeafterboth--- a/tests/src/util/playgrounds/unique.dev.ts
+++ b/tests/src/util/playgrounds/unique.dev.ts
@@ -215,8 +215,8 @@
};
isDevNode = async () => {
- const block1 = await this.helper.api?.rpc.chain.getBlock(await this.helper.api?.rpc.chain.getBlockHash(1));
- const block2 = await this.helper.api?.rpc.chain.getBlock(await this.helper.api?.rpc.chain.getBlockHash(2));
+ const block1 = await this.helper.callRpc('api.rpc.chain.getBlock', [await this.helper.callRpc('api.rpc.chain.getBlockHash', [1])]);
+ const block2 = await this.helper.callRpc('api.rpc.chain.getBlock', [await this.helper.callRpc('api.rpc.chain.getBlockHash', [2])]);
const findCreationDate = async (block: any) => {
const humanBlock = block.toHuman();
let date;
@@ -259,7 +259,7 @@
async newBlocks(blocksCount = 1): Promise<void> {
// eslint-disable-next-line no-async-promise-executor
const promise = new Promise<void>(async (resolve) => {
- const unsubscribe = await this.helper.api!.rpc.chain.subscribeNewHeads(() => {
+ const unsubscribe = await this.helper.getApi().rpc.chain.subscribeNewHeads(() => {
if (blocksCount > 0) {
blocksCount--;
} else {
@@ -274,7 +274,7 @@
async forParachainBlockNumber(blockNumber: bigint) {
// eslint-disable-next-line no-async-promise-executor
return new Promise<void>(async (resolve) => {
- const unsubscribe = await this.helper.api!.rpc.chain.subscribeNewHeads(async (data: any) => {
+ const unsubscribe = await this.helper.getApi().rpc.chain.subscribeNewHeads(async (data: any) => {
if (data.number.toNumber() >= blockNumber) {
unsubscribe();
resolve();
@@ -286,7 +286,7 @@
async forRelayBlockNumber(blockNumber: bigint) {
// eslint-disable-next-line no-async-promise-executor
return new Promise<void>(async (resolve) => {
- const unsubscribe = await this.helper.api!.query.parachainSystem.validationData(async (data: any) => {
+ const unsubscribe = await this.helper.getApi().query.parachainSystem.validationData(async (data: any) => {
if (data.value.relayParentNumber.toNumber() >= blockNumber) {
// @ts-ignore
unsubscribe();
tests/src/util/playgrounds/unique.tsdiffbeforeafterboth--- a/tests/src/util/playgrounds/unique.ts
+++ b/tests/src/util/playgrounds/unique.ts
@@ -1991,7 +1991,7 @@
* @returns ss58Format, token decimals, and token symbol
*/
getChainProperties(): IChainProperties {
- const properties = (this.helper.api as any).registry.getChainProperties().toJSON();
+ const properties = (this.helper.getApi() as any).registry.getChainProperties().toJSON();
return {
ss58Format: properties.ss58Format.toJSON(),
tokenDecimals: properties.tokenDecimals.toJSON(),
@@ -2034,7 +2034,7 @@
* @returns number, account's nonce
*/
async getNonce(address: TSubstrateAccount): Promise<number> {
- return (await (this.helper.api as any).query.system.account(address)).nonce.toNumber();
+ return (await this.helper.callRpc('api.query.system.account', [address])).nonce.toNumber();
}
}