difftreelog
Merge pull request #226 from UniqueNetwork/fix/tests
in: master
Tests fixed
5 files changed
pallets/nonfungible/src/lib.rsdiffbeforeafterboth--- a/pallets/nonfungible/src/lib.rs
+++ b/pallets/nonfungible/src/lib.rs
@@ -328,7 +328,7 @@
.checked_add(data.len() as u32)
.ok_or(ArithmeticError::Overflow)?;
ensure!(
- tokens_minted < collection.limits.token_limit(),
+ tokens_minted <= collection.limits.token_limit(),
<CommonError<T>>::CollectionTokenLimitExceeded
);
collection.consume_sstore()?;
tests/src/limits.test.tsdiffbeforeafterboth--- a/tests/src/limits.test.ts
+++ b/tests/src/limits.test.ts
@@ -78,7 +78,7 @@
});
});
-describe('Sponsor timeout (NFT)', () => {
+describe.skip('Sponsor timeout (NFT) (only for special chain limits test)', () => {
let alice: IKeyringPair;
let bob: IKeyringPair;
let charlie: IKeyringPair;
@@ -91,7 +91,7 @@
});
});
- it('Collection limits have greater timeout value than chain limits, collection limits are enforced', async () => {
+ it.skip('Collection limits have greater timeout value than chain limits, collection limits are enforced', async () => {
const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
await setCollectionLimitsExpectSuccess(alice, collectionId, {sponsorTransferTimeout: 7});
const tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT');
@@ -141,7 +141,7 @@
});
});
-describe('Sponsor timeout (Fungible)', () => {
+describe.skip('Sponsor timeout (Fungible) (only for special chain limits test)', () => {
let alice: IKeyringPair;
let bob: IKeyringPair;
let charlie: IKeyringPair;
@@ -208,7 +208,7 @@
});
});
-describe('Sponsor timeout (ReFungible)', () => {
+describe.skip('Sponsor timeout (ReFungible) (only for special chain limits test)', () => {
let alice: IKeyringPair;
let bob: IKeyringPair;
let charlie: IKeyringPair;
tests/src/overflow.test.tsdiffbeforeafterboth1//2// This file is subject to the terms and conditions defined in3// file 'LICENSE', which is part of this source code package.4//56import {IKeyringPair} from '@polkadot/types/types';7import chai from 'chai';8import chaiAsPromised from 'chai-as-promised';9import privateKey from './substrate/privateKey';10import usingApi from './substrate/substrate-api';11import {approveExpectSuccess, createCollectionExpectSuccess, createFungibleItemExpectSuccess, getAllowance, getBalance, transferExpectFailure, transferExpectSuccess, transferFromExpectFail, transferFromExpectSuccess, U128_MAX} from './util/helpers';1213chai.use(chaiAsPromised);14const expect = chai.expect;1516describe('Integration Test fungible overflows', () => {17 let alice: IKeyringPair;18 let bob: IKeyringPair;19 let charlie: IKeyringPair;2021 before(async () => {22 await usingApi(async () => {23 alice = privateKey('//Alice');24 bob = privateKey('//Bob');25 charlie = privateKey('//Charlie');26 });27 });2829 it('fails when overflows on transfer', async () => {30 await usingApi(async api => {31 const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});3233 await createFungibleItemExpectSuccess(alice, fungibleCollectionId, {Value: U128_MAX});34 await transferExpectSuccess(fungibleCollectionId, 0, alice, bob, U128_MAX, 'Fungible');3536 await createFungibleItemExpectSuccess(alice, fungibleCollectionId, {Value: 1n});37 await transferExpectFailure(fungibleCollectionId, 0, alice, bob, 1);3839 expect(await getBalance(api, fungibleCollectionId, alice.address, 0)).to.equal(1n);40 expect(await getBalance(api, fungibleCollectionId, bob.address, 0)).to.equal(U128_MAX);41 });42 });4344 it('fails when overflows on transferFrom', async () => {45 await usingApi(async api => {46 const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});47 await createFungibleItemExpectSuccess(alice, fungibleCollectionId, {Value: U128_MAX});48 await approveExpectSuccess(fungibleCollectionId, 0, alice, bob.address, U128_MAX);49 await transferFromExpectSuccess(fungibleCollectionId, 0, bob, alice, charlie, U128_MAX, 'Fungible');5051 expect(await getBalance(api, fungibleCollectionId, charlie.address, 0)).to.equal(U128_MAX);52 expect(await getAllowance(api, fungibleCollectionId, alice.address, bob.address, 0)).to.equal(0n);5354 await createFungibleItemExpectSuccess(alice, fungibleCollectionId, {Value: U128_MAX});55 await approveExpectSuccess(fungibleCollectionId, 0, alice, bob.address, 1n);56 await transferFromExpectFail(fungibleCollectionId, 0, bob, alice, charlie, 1);5758 expect(await getBalance(api, fungibleCollectionId, charlie.address, 0)).to.equal(U128_MAX);59 expect(await getAllowance(api, fungibleCollectionId, alice.address, bob.address, 0)).to.equal(1n);60 });61 });62});tests/src/setOffchainSchema.test.tsdiffbeforeafterboth--- a/tests/src/setOffchainSchema.test.ts
+++ b/tests/src/setOffchainSchema.test.ts
@@ -40,7 +40,7 @@
await setOffchainSchemaExpectSuccess(alice, collectionId, DATA);
const collection = await queryCollectionExpectSuccess(api, collectionId);
- expect(collection.offchainSchema).to.be.equal('0x' + Buffer.from(DATA).toString('hex'));
+ expect('0x' + Buffer.from(collection.offchainSchema).toString('hex')).to.be.equal('0x' + Buffer.from(DATA).toString('hex'));
});
});
@@ -51,7 +51,7 @@
await setOffchainSchemaExpectSuccess(bob, collectionId, DATA);
const collection = await queryCollectionExpectSuccess(api, collectionId);
- expect(collection.offchainSchema).to.be.equal('0x' + Buffer.from(DATA).toString('hex'));
+ expect('0x' + Buffer.from(collection.offchainSchema).toString('hex')).to.be.equal('0x' + Buffer.from(DATA).toString('hex'));
});
});
});
tests/src/util/helpers.tsdiffbeforeafterboth--- a/tests/src/util/helpers.ts
+++ b/tests/src/util/helpers.ts
@@ -905,11 +905,12 @@
await usingApi(async (api: ApiPromise) => {
const transferTx = api.tx.nft.transfer(normalizeAccountId(recipient.address), collectionId, tokenId, value);
const events = await expect(submitTransactionExpectFailAsync(sender, transferTx)).to.be.rejected;
- if (events && Array.isArray(events)) {
- const result = getCreateCollectionResult(events);
- // tslint:disable-next-line:no-unused-expression
- expect(result.success).to.be.false;
- }
+ const result = getGenericResult(events);
+ // if (events && Array.isArray(events)) {
+ // const result = getCreateCollectionResult(events);
+ // tslint:disable-next-line:no-unused-expression
+ expect(result.success).to.be.false;
+ //}
});
}