difftreelog
Merge pull request #258 from UniqueNetwork/fix/unit_tests
in: master
Unit tests fixed
6 files changed
pallets/unique/src/mock.rsdiffbeforeafterboth193}193}194194195impl pallet_template::Config for Test {195impl pallet_template::Config for Test {196 type Event = ();196 type WeightInfo = ();197 type WeightInfo = ();197}198}198199pallets/unique/src/tests.rsdiffbeforeafterboth2259 new_test_ext().execute_with(|| {2259 new_test_ext().execute_with(|| {2260 let origin1 = Origin::signed(1);2260 let origin1 = Origin::signed(1);226122612262 for i in 1..COLLECTION_NUMBER_LIMIT {2262 for i in 1..=COLLECTION_NUMBER_LIMIT {2263 create_test_collection(&CollectionMode::NFT, CollectionId(i));2263 create_test_collection(&CollectionMode::NFT, CollectionId(i));2264 }2264 }22652265tests/src/eth/payable.test.tsdiffbeforeafterboth3import {submitTransactionAsync} from '../substrate/substrate-api';3import {submitTransactionAsync} from '../substrate/substrate-api';4import {createEthAccountWithBalance, deployCollector, GAS_ARGS, itWeb3, subToEth, transferBalanceToEth} from './util/helpers';4import {createEthAccountWithBalance, deployCollector, GAS_ARGS, itWeb3, subToEth, transferBalanceToEth} from './util/helpers';5import {evmToAddress} from '@polkadot/util-crypto';5import {evmToAddress} from '@polkadot/util-crypto';6import {getGenericResult} from '../util/helpers';6import {getGenericResult, UNIQUE} from '../util/helpers';7import {getBalanceSingle, transferBalanceExpectSuccess} from '../substrate/get-balance';7import {getBalanceSingle, transferBalanceExpectSuccess} from '../substrate/get-balance';889describe('EVM payable contracts', () => {9describe('EVM payable contracts', () => {55 });55 });565657 itWeb3('Balance can be retrieved from evm contract', async({api, web3}) => {57 itWeb3('Balance can be retrieved from evm contract', async({api, web3}) => {58 const FEE_BALANCE = 10n ** 18n;58 const FEE_BALANCE = 1000n * UNIQUE;59 const CONTRACT_BALANCE = 10n ** 14n;59 const CONTRACT_BALANCE = 1n * UNIQUE;606061 const deployer = await createEthAccountWithBalance(api, web3);61 const deployer = await createEthAccountWithBalance(api, web3);62 const contract = await deployCollector(web3, deployer);62 const contract = await deployCollector(web3, deployer);tests/src/setConstOnChainSchema.test.tsdiffbeforeafterboth30 alice = keyring.addFromUri('//Alice');30 alice = keyring.addFromUri('//Alice');31 bob = keyring.addFromUri('//Bob');31 bob = keyring.addFromUri('//Bob');32 shema = '0x31';32 shema = '0x31';33 largeShema = new Array(4097).fill(0xff);33 largeShema = new Array(1024 * 1024 + 10).fill(0xff);3435 });34 });36});35});88 });87 });89 });88 });908991 it('Set invalid data in schema (size too large:> 1024b)', async () => {90 it('Set invalid data in schema (size too large:> 1MB)', async () => {92 await usingApi(async (api) => {91 await usingApi(async (api) => {93 const collectionId = await createCollectionExpectSuccess();92 const collectionId = await createCollectionExpectSuccess();94 const setShema = api.tx.unique.setConstOnChainSchema(collectionId, largeShema);93 const setShema = api.tx.unique.setConstOnChainSchema(collectionId, largeShema);tests/src/setOffchainSchema.test.tsdiffbeforeafterboth84 await setOffchainSchemaExpectFailure(alice, destroyedCollectionId, DATA);84 await setOffchainSchemaExpectFailure(alice, destroyedCollectionId, DATA);85 });85 });868687 it('fails on too long data', async () => {87 it.only('fails on too long data', async () => {88 const tooLongData = new Array(4097).fill(0xff);88 const tooLongData = new Array(8 * 1024 + 10).fill(0xff);898990 await setOffchainSchemaExpectFailure(alice, validCollectionId, tooLongData);90 await setOffchainSchemaExpectFailure(alice, validCollectionId, tooLongData);91 });91 });tests/src/setVariableOnChainSchema.test.tsdiffbeforeafterboth30 alice = keyring.addFromUri('//Alice');30 alice = keyring.addFromUri('//Alice');31 bob = keyring.addFromUri('//Bob');31 bob = keyring.addFromUri('//Bob');32 schema = '0x31';32 schema = '0x31';33 largeSchema = new Array(4097).fill(0xff);33 largeSchema = new Array(8 * 1024 + 10).fill(0xff);343435 });35 });36});36});104 });104 });105 });105 });106106107 it('Set invalid data in schema (size too large:> 1024b)', async () => {107 it('Set invalid data in schema (size too large:> 8kB)', async () => {108 await usingApi(async (api) => {108 await usingApi(async (api) => {109 const collectionId = await createCollectionExpectSuccess();109 const collectionId = await createCollectionExpectSuccess();110 const setSchema = api.tx.unique.setVariableOnChainSchema(collectionId, largeSchema);110 const setSchema = api.tx.unique.setVariableOnChainSchema(collectionId, largeSchema);