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

difftreelog

Merge pull request #603 from UniqueNetwork/tests/finish-refactoring-base-folder

ut-akuznetsov2022-09-20parents: #2f6a65e #e876e8d.patch.diff
in: master

8 files changed

modifiedtests/src/addToContractAllowList.test.tsdiffbeforeafterboth
27chai.use(chaiAsPromised);27chai.use(chaiAsPromised);
28const expect = chai.expect;28const expect = chai.expect;
2929
30// todo:playgrounds skipped ~ postponed
30describe.skip('Integration Test addToContractAllowList', () => {31describe.skip('Integration Test addToContractAllowList', () => {
3132
32 it('Add an address to a contract allow list', async () => {33 it('Add an address to a contract allow list', async () => {
modifiedtests/src/block-production.test.tsdiffbeforeafterboth
14// You should have received a copy of the GNU General Public License14// You should have received a copy of the GNU General Public License
15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
1616
17import usingApi from './substrate/substrate-api';17import {ApiPromise} from '@polkadot/api';
18import {expect} from 'chai';18import {expect, itSub} from './util/playgrounds';
19import {ApiPromise} from '@polkadot/api';
2019
21const BLOCK_TIME_MS = 12000;20const BLOCK_TIME_MS = 12000;
22const TOLERANCE_MS = 3000;21const TOLERANCE_MS = 3000;
37}36}
3837
39describe('Block Production smoke test', () => {38describe('Block Production smoke test', () => {
40 it('Node produces new blocks', async () => {39 itSub('Node produces new blocks', async ({helper}) => {
41 await usingApi(async (api) => {40 const blocks: number[] | undefined = await getBlocks(helper.api!);
42 const blocks: number[] | undefined = await getBlocks(api);
43 expect(blocks[0]).to.be.lessThan(blocks[1]);41 expect(blocks[0]).to.be.lessThan(blocks[1]);
44 });
45 });42 });
46});43});
4744
modifiedtests/src/connection.test.tsdiffbeforeafterboth
14// You should have received a copy of the GNU General Public License14// You should have received a copy of the GNU General Public License
15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
1616
17import usingApi from './substrate/substrate-api';
18import {WsProvider} from '@polkadot/api';17import {itSub, expect, usingPlaygrounds} from './util/playgrounds';
19import * as chai from 'chai';
20import chaiAsPromised from 'chai-as-promised';
21
22chai.use(chaiAsPromised);
23
24const expect = chai.expect;
2518
26describe('Connection smoke test', () => {19describe('Connection smoke test', () => {
27 it('Connection can be established', async () => {20 itSub('Connection can be established', async ({helper}) => {
28 await usingApi(async api => {21 const health = (await helper.callRpc('api.rpc.system.health')).toJSON();
29 const health = await api.rpc.system.health();
30 expect(health).to.be.not.empty;22 expect(health).to.be.not.empty;
31 });
32 });23 });
3324
34 it('Cannot connect to 255.255.255.255', async () => {25 it('Cannot connect to 255.255.255.255', async () => {
35 const neverConnectProvider = new WsProvider('ws://255.255.255.255:9944');
36 await expect((async () => {26 await expect((async () => {
37 await usingApi(async api => {27 await usingPlaygrounds(async helper => {
38 await api.rpc.system.health();28 await helper.callRpc('api.rpc.system.health');
39 }, {provider: neverConnectProvider});29 }, 'ws://255.255.255.255:9944');
40 })()).to.be.eventually.rejected;30 })()).to.be.eventually.rejected;
41 });31 });
42});32});
modifiedtests/src/contracts.test.tsdiffbeforeafterboth
47const gasLimit = 9000n * 1000000n;47const gasLimit = 9000n * 1000000n;
48const marketContractAddress = '5CYN9j3YvRkqxewoxeSvRbhAym4465C57uMmX5j4yz99L5H6';48const marketContractAddress = '5CYN9j3YvRkqxewoxeSvRbhAym4465C57uMmX5j4yz99L5H6';
4949
50// todo:playgrounds skipped ~ postponed
50describe.skip('Contracts', () => {51describe.skip('Contracts', () => {
51 it('Can deploy smart contract Flipper, instantiate it and call it\'s get and flip messages.', async () => {52 it('Can deploy smart contract Flipper, instantiate it and call it\'s get and flip messages.', async () => {
52 await usingApi(async (api, privateKeyWrapper) => {53 await usingApi(async (api, privateKeyWrapper) => {
modifiedtests/src/enableContractSponsoring.test.tsdiffbeforeafterboth
29chai.use(chaiAsPromised);29chai.use(chaiAsPromised);
30const expect = chai.expect;30const expect = chai.expect;
3131
32// todo:playgrounds skipped ~ postponed
32describe.skip('Integration Test enableContractSponsoring', () => {33describe.skip('Integration Test enableContractSponsoring', () => {
33 it('ensure tx fee is paid from endowment', async () => {34 it('ensure tx fee is paid from endowment', async () => {
34 await usingApi(async (api, privateKeyWrapper) => {35 await usingApi(async (api, privateKeyWrapper) => {
modifiedtests/src/evmCoder.test.tsdiffbeforeafterboth
14// You should have received a copy of the GNU General Public License14// You should have received a copy of the GNU General Public License
15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
1616
17import {IKeyringPair} from '@polkadot/types/types';
17import Web3 from 'web3';18import Web3 from 'web3';
18import {createEthAccountWithBalance, createNonfungibleCollection, GAS_ARGS, itWeb3} from './eth/util/helpers';19import {itEth, expect, usingEthPlaygrounds} from './eth/util/playgrounds';
19import * as solc from 'solc';20import * as solc from 'solc';
20
21import chai from 'chai';
22const expect = chai.expect;
2321
24async function compileTestContract(collectionAddress: string, contractAddress: string) {22async function compileTestContract(collectionAddress: string, contractAddress: string) {
25 const input = {23 const input = {
79 };77 };
80}78}
8179
82async function deployTestContract(web3: Web3, owner: string, collectionAddress: string, contractAddress: string) {80async function deployTestContract(web3: Web3, owner: string, collectionAddress: string, contractAddress: string, gas: number) {
83 const compiled = await compileTestContract(collectionAddress, contractAddress);81 const compiled = await compileTestContract(collectionAddress, contractAddress);
84 const fractionalizerContract = new web3.eth.Contract(compiled.abi, undefined, {82 const fractionalizerContract = new web3.eth.Contract(compiled.abi, undefined, {
85 data: compiled.object,83 data: compiled.object,
86 from: owner,84 from: owner,
87 ...GAS_ARGS,85 gas,
88 });86 });
89 return await fractionalizerContract.deploy({data: compiled.object}).send({from: owner});87 return await fractionalizerContract.deploy({data: compiled.object}).send({from: owner});
90}88}
9189
92describe('Evm Coder tests', () => {90describe('Evm Coder tests', () => {
91 let donor: IKeyringPair;
92
93 before(async function() {
94 await usingEthPlaygrounds(async (_helper, privateKey) => {
95 donor = privateKey('//Alice');
96 });
97 });
98
93 itWeb3('Call non-existing function', async ({api, web3, privateKeyWrapper}) => {99 itEth('Call non-existing function', async ({helper}) => {
94 const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);100 const owner = await helper.eth.createAccountWithBalance(donor);
95 const {collectionIdAddress} = await createNonfungibleCollection(api, web3, owner);101 const collection = await helper.eth.createNonfungibleCollection(owner, 'EVMCODER', '', 'TEST');
96 const contract = await deployTestContract(web3, owner, collectionIdAddress, '0x1bfed5D614b886b9Ab2eA4CBAc22A96B7EC29c9c');102 const contract = await deployTestContract(helper.getWeb3(), owner, collection.collectionAddress, '0x1bfed5D614b886b9Ab2eA4CBAc22A96B7EC29c9c', helper.eth.DEFAULT_GAS);
97 const testContract = await deployTestContract(web3, owner, collectionIdAddress, contract.options.address);103 const testContract = await deployTestContract(helper.getWeb3(), owner, collection.collectionAddress, contract.options.address, helper.eth.DEFAULT_GAS);
98 {104 {
99 const result = await testContract.methods.test1().send();105 const result = await testContract.methods.test1().send();
100 expect(result.events.Result.returnValues).to.deep.equal({106 expect(result.events.Result.returnValues).to.deep.equal({
modifiedtests/src/setContractSponsoringRateLimit.test.tsdiffbeforeafterboth
25 setContractSponsoringRateLimitExpectSuccess,25 setContractSponsoringRateLimitExpectSuccess,
26} from './util/helpers';26} from './util/helpers';
2727
28// todo:playgrounds postponed skipped test28// todo:playgrounds skipped~postponed test
29describe.skip('Integration Test setContractSponsoringRateLimit', () => {29describe.skip('Integration Test setContractSponsoringRateLimit', () => {
30 it('ensure sponsored contract can\'t be called twice without pause for free', async () => {30 it('ensure sponsored contract can\'t be called twice without pause for free', async () => {
31 await usingApi(async (api, privateKeyWrapper) => {31 await usingApi(async (api, privateKeyWrapper) => {
modifiedtests/src/util/playgrounds/index.tsdiffbeforeafterboth
13chai.use(chaiAsPromised);13chai.use(chaiAsPromised);
14export const expect = chai.expect;14export const expect = chai.expect;
1515
16export const usingPlaygrounds = async (code: (helper: DevUniqueHelper, privateKey: (seed: string) => IKeyringPair) => Promise<void>) => {16export const usingPlaygrounds = async (code: (helper: DevUniqueHelper, privateKey: (seed: string) => IKeyringPair) => Promise<void>, url: string = config.substrateUrl) => {
17 const silentConsole = new SilentConsole();17 const silentConsole = new SilentConsole();
18 silentConsole.enable();18 silentConsole.enable();
1919
20 const helper = new DevUniqueHelper(new SilentLogger());20 const helper = new DevUniqueHelper(new SilentLogger());
2121
22 try {22 try {
23 await helper.connect(config.substrateUrl);23 await helper.connect(url);
24 const ss58Format = helper.chain.getChainProperties().ss58Format;24 const ss58Format = helper.chain.getChainProperties().ss58Format;
25 const privateKey = (seed: string) => helper.util.fromSeed(seed, ss58Format);25 const privateKey = (seed: string) => helper.util.fromSeed(seed, ss58Format);
26 await code(helper, privateKey);26 await code(helper, privateKey);