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

difftreelog

Tests: move explicit solc calls to playgrounds

Andrey2022-10-07parent: #05841c0.patch.diff
in: master

4 files changed

modifiedtests/package.jsondiffbeforeafterboth
32 "testEthNesting": "mocha --timeout 9999999 -r ts-node/register './**/eth/nesting/**/*.test.ts'",32 "testEthNesting": "mocha --timeout 9999999 -r ts-node/register './**/eth/nesting/**/*.test.ts'",
33 "testEthFractionalizer": "mocha --timeout 9999999 -r ts-node/register './**/eth/fractionalizer/**/*.test.ts'",33 "testEthFractionalizer": "mocha --timeout 9999999 -r ts-node/register './**/eth/fractionalizer/**/*.test.ts'",
34 "testEthPayable": "mocha --timeout 9999999 -r ts-node/register './**/eth/payable.test.ts'",34 "testEthPayable": "mocha --timeout 9999999 -r ts-node/register './**/eth/payable.test.ts'",
35 "testEvmCoder": "mocha --timeout 9999999 -r ts-node/register './**/eth/evmCoder.test.ts'",
35 "load": "mocha --timeout 9999999 -r ts-node/register './**/*.load.ts'",36 "load": "mocha --timeout 9999999 -r ts-node/register './**/*.load.ts'",
36 "loadTransfer": "ts-node src/transfer.nload.ts",37 "loadTransfer": "ts-node src/transfer.nload.ts",
37 "testCollision": "mocha --timeout 9999999 -r ts-node/register ./src/collision-tests/*.test.ts",38 "testCollision": "mocha --timeout 9999999 -r ts-node/register ./src/collision-tests/*.test.ts",
67 "testAdminTransferAndBurn": "mocha --timeout 9999999 -r ts-node/register ./**/adminTransferAndBurn.test.ts",68 "testAdminTransferAndBurn": "mocha --timeout 9999999 -r ts-node/register ./**/adminTransferAndBurn.test.ts",
68 "testSetPermissions": "mocha --timeout 9999999 -r ts-node/register ./**/setPermissions.test.ts",69 "testSetPermissions": "mocha --timeout 9999999 -r ts-node/register ./**/setPermissions.test.ts",
69 "testCreditFeesToTreasury": "mocha --timeout 9999999 -r ts-node/register ./**/creditFeesToTreasury.test.ts",70 "testCreditFeesToTreasury": "mocha --timeout 9999999 -r ts-node/register ./**/creditFeesToTreasury.test.ts",
70 "testContractSponsoring": "mocha --timeout 9999999 -r ts-node/register ./**/contractSponsoring.test.ts",71 "testContractSponsoring": "mocha --timeout 9999999 -r ts-node/register ./**/eth/contractSponsoring.test.ts",
71 "testEnableContractSponsoring": "mocha --timeout 9999999 -r ts-node/register ./**/enableContractSponsoring.test.ts",72 "testEnableContractSponsoring": "mocha --timeout 9999999 -r ts-node/register ./**/enableContractSponsoring.test.ts",
72 "testRemoveFromContractAllowList": "mocha --timeout 9999999 -r ts-node/register ./**/removeFromContractAllowList.test.ts",73 "testRemoveFromContractAllowList": "mocha --timeout 9999999 -r ts-node/register ./**/removeFromContractAllowList.test.ts",
73 "testSetContractSponsoringRateLimit": "mocha --timeout 9999999 -r ts-node/register ./**/setContractSponsoringRateLimit.test.ts",74 "testSetContractSponsoringRateLimit": "mocha --timeout 9999999 -r ts-node/register ./**/setContractSponsoringRateLimit.test.ts",
modifiedtests/src/eth/contractSponsoring.test.tsdiffbeforeafterboth
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 {IKeyringPair} from '@polkadot/types/types';
18import * as solc from 'solc';
19import {EthUniqueHelper} from './util/playgrounds/unique.dev';18import {EthUniqueHelper} from './util/playgrounds/unique.dev';
20import {itEth, expect, SponsoringMode, usingEthPlaygrounds} from '../eth/util/playgrounds';19import {itEth, expect, SponsoringMode, usingEthPlaygrounds} from '../eth/util/playgrounds';
21import {usingPlaygrounds} from '../util/playgrounds';20import {usingPlaygrounds} from '../util/playgrounds';
455describe('Sponsoring Fee Limit', () => {454describe('Sponsoring Fee Limit', () => {
456 let donor: IKeyringPair;455 let donor: IKeyringPair;
457 let alice: IKeyringPair;456 let alice: IKeyringPair;
458 let DEFAULT_GAS: number;457 let testContract: CompiledContract;
459458
460 function compileTestContract() {459 async function compileTestContract(helper: EthUniqueHelper) {
461 if (!testContract) {460 if (!testContract) {
462 const input = {
463 language: 'Solidity',
464 sources: {
465 ['TestContract.sol']: {
466 content:
467 `
468 // SPDX-License-Identifier: MIT
469 pragma solidity ^0.8.0;
470
471 contract TestContract {
472 event Result(bool);
473
474 function test(uint32 cycles) public {
475 uint256 counter = 0;
476 while(true) {
477 counter ++;
478 if (counter > cycles){
479 break;
480 }
481 }
482 emit Result(true);
483 }
484 }
485 `,
486 },
487 },
488 settings: {
489 outputSelection: {
490 '*': {
491 '*': ['*'],
492 },
493 },
494 },
495 };
496 const json = JSON.parse(solc.compile(JSON.stringify(input)));
497 const out = json.contracts['TestContract.sol']['TestContract'];
498
499 testContract = {461 testContract = await helper.ethContract.compile(
500 abi: out.abi,462 'TestContract',
501 object: '0x' + out.evm.bytecode.object,463 `
464 // SPDX-License-Identifier: MIT
465 pragma solidity ^0.8.0;
466
467 contract TestContract {
468 event Result(bool);
469
470 function test(uint32 cycles) public {
471 uint256 counter = 0;
472 while(true) {
473 counter ++;
474 if (counter > cycles){
475 break;
476 }
477 }
478 emit Result(true);
479 }
480 }
481 `,
502 };482 );
503 }483 }
504 return testContract;484 return testContract;
505 }485 }
506 486
507 async function deployTestContract(helper: EthUniqueHelper, owner: string) {487 async function deployTestContract(helper: EthUniqueHelper, owner: string) {
508 const web3 = helper.getWeb3();
509 const compiled = compileTestContract();488 const compiled = await compileTestContract(helper);
510 const testContract = new web3.eth.Contract(compiled.abi, undefined, {489 return await helper.ethContract.deployByAbi(owner, compiled.abi, compiled.object);
511 data: compiled.object,
512 from: owner,
513 gas: DEFAULT_GAS,
514 });
515 return await testContract.deploy({data: compiled.object}).send({from: owner});
516 }490 }
517491
518 before(async () => {492 before(async () => {
519 await usingEthPlaygrounds(async (helper, privateKey) => {493 await usingEthPlaygrounds(async (_helper, privateKey) => {
520 donor = privateKey('//Alice');494 donor = privateKey('//Alice');
521 DEFAULT_GAS = helper.eth.DEFAULT_GAS;
522 });495 });
523 });496 });
524497
528 });501 });
529 });502 });
530
531 let testContract: CompiledContract;
532
533503
534504
addedtests/src/eth/evmCoder.test.tsdiffbeforeafterboth

no changes

deletedtests/src/evmCoder.test.tsdiffbeforeafterboth

no changes