difftreelog
Tests: move explicit solc calls to playgrounds
in: master
4 files changed
tests/package.jsondiffbeforeafterboth1{2 "name": "unique-tests",3 "version": "1.0.0",4 "description": "Unique Chain Tests",5 "main": "",6 "devDependencies": {7 "@polkadot/ts": "0.4.22",8 "@polkadot/typegen": "9.2.2",9 "@types/chai": "^4.3.1",10 "@types/chai-as-promised": "^7.1.5",11 "@types/chai-like": "^1.1.1",12 "@types/mocha": "^9.1.1",13 "@types/node": "^17.0.35",14 "@typescript-eslint/eslint-plugin": "^5.26.0",15 "@typescript-eslint/parser": "^5.26.0",16 "chai": "^4.3.6",17 "eslint": "^8.16.0",18 "mocha": "^10.0.0",19 "ts-node": "^10.8.0",20 "typescript": "^4.7.2"21 },22 "mocha": {23 "timeout": 9999999,24 "require": "ts-node/register"25 },26 "scripts": {27 "lint": "eslint --ext .ts,.js src/",28 "fix": "eslint --ext .ts,.js src/ --fix",29 "test": "mocha --timeout 9999999 -r ts-node/register './src/**/*.test.ts'",30 "testEth": "mocha --timeout 9999999 -r ts-node/register './**/eth/**/*.test.ts'",31 "testEthMarketplace": "mocha --timeout 9999999 -r ts-node/register './**/eth/marketplace/**/*.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'",34 "testEthPayable": "mocha --timeout 9999999 -r ts-node/register './**/eth/payable.test.ts'",35 "load": "mocha --timeout 9999999 -r ts-node/register './**/*.load.ts'",36 "loadTransfer": "ts-node src/transfer.nload.ts",37 "testCollision": "mocha --timeout 9999999 -r ts-node/register ./src/collision-tests/*.test.ts",38 "testEvent": "mocha --timeout 9999999 -r ts-node/register ./src/check-event/*.test.ts",39 "testNesting": "mocha --timeout 9999999 -r ts-node/register ./**/nest.test.ts",40 "testUnnesting": "mocha --timeout 9999999 -r ts-node/register ./**/unnest.test.ts",41 "testStructure": "mocha --timeout 9999999 -r ts-node/register ./**/nesting/**.test.ts",42 "testProperties": "mocha --timeout 9999999 -r ts-node/register ./**/properties.test.ts ./**/getPropertiesRpc.test.ts",43 "testMigration": "mocha --timeout 9999999 -r ts-node/register ./**/nesting/migration-check.test.ts",44 "testRmrk": "mocha --timeout 9999999 -r ts-node/register ./**/rmrk/**.test.ts",45 "testAddCollectionAdmin": "mocha --timeout 9999999 -r ts-node/register ./**/addCollectionAdmin.test.ts",46 "testSetSchemaVersion": "mocha --timeout 9999999 -r ts-node/register ./**/setSchemaVersion.test.ts",47 "testSetCollectionLimits": "mocha --timeout 9999999 -r ts-node/register ./**/setCollectionLimits.test.ts",48 "testChangeCollectionOwner": "mocha --timeout 9999999 -r ts-node/register ./**/change-collection-owner.test.ts",49 "testSetCollectionSponsor": "mocha --timeout 9999999 -r ts-node/register ./**/setCollectionSponsor.test.ts",50 "testConfirmSponsorship": "mocha --timeout 9999999 -r ts-node/register ./**/confirmSponsorship.test.ts",51 "testRemoveCollectionAdmin": "mocha --timeout 9999999 -r ts-node/register ./**/removeCollectionAdmin.test.ts",52 "testRemoveCollectionSponsor": "mocha --timeout 9999999 -r ts-node/register ./**/removeCollectionSponsor.test.ts",53 "testAllowLists": "mocha --timeout 9999999 -r ts-node/register ./**/allowLists.test.ts",54 "testConnection": "mocha --timeout 9999999 -r ts-node/register ./**/connection.test.ts",55 "testContracts": "mocha --timeout 9999999 -r ts-node/register ./**/contracts.test.ts",56 "testCreateItem": "mocha --timeout 9999999 -r ts-node/register ./**/createItem.test.ts",57 "testCreateMultipleItems": "mocha --timeout 9999999 -r ts-node/register ./**/createMultipleItems.test.ts",58 "testCreateMultipleItemsEx": "mocha --timeout 9999999 -r ts-node/register ./**/createMultipleItemsEx.test.ts",59 "testApprove": "mocha --timeout 9999999 -r ts-node/register ./**/approve.test.ts",60 "testTransferFrom": "mocha --timeout 9999999 -r ts-node/register ./**/transferFrom.test.ts",61 "testCreateCollection": "mocha --timeout 9999999 -r ts-node/register ./**/createCollection.test.ts",62 "testDestroyCollection": "mocha --timeout 9999999 -r ts-node/register ./**/destroyCollection.test.ts",63 "testToggleContractAllowList": "mocha --timeout 9999999 -r ts-node/register ./**/toggleContractAllowList.test.ts",64 "testAddToContractAllowList": "mocha --timeout 9999999 -r ts-node/register ./**/addToContractAllowList.test.ts",65 "testTransfer": "mocha --timeout 9999999 -r ts-node/register ./**/transfer.test.ts",66 "testBurnItem": "mocha --timeout 9999999 -r ts-node/register ./**/burnItem.test.ts",67 "testAdminTransferAndBurn": "mocha --timeout 9999999 -r ts-node/register ./**/adminTransferAndBurn.test.ts",68 "testSetPermissions": "mocha --timeout 9999999 -r ts-node/register ./**/setPermissions.test.ts",69 "testCreditFeesToTreasury": "mocha --timeout 9999999 -r ts-node/register ./**/creditFeesToTreasury.test.ts",70 "testContractSponsoring": "mocha --timeout 9999999 -r ts-node/register ./**/contractSponsoring.test.ts",71 "testEnableContractSponsoring": "mocha --timeout 9999999 -r ts-node/register ./**/enableContractSponsoring.test.ts",72 "testRemoveFromContractAllowList": "mocha --timeout 9999999 -r ts-node/register ./**/removeFromContractAllowList.test.ts",73 "testSetContractSponsoringRateLimit": "mocha --timeout 9999999 -r ts-node/register ./**/setContractSponsoringRateLimit.test.ts",74 "testSetOffchainSchema": "mocha --timeout 9999999 -r ts-node/register ./**/setOffchainSchema.test.ts",75 "testNextSponsoring": "mocha --timeout 9999999 -r ts-node/register ./**/nextSponsoring.test.ts",76 "testOverflow": "mocha --timeout 9999999 -r ts-node/register ./**/overflow.test.ts",77 "testInflation": "mocha --timeout 9999999 -r ts-node/register ./**/inflation.test.ts",78 "testScheduler": "mocha --timeout 9999999 -r ts-node/register ./**/scheduler.test.ts",79 "testSchedulingEVM": "mocha --timeout 9999999 -r ts-node/register ./**/eth/scheduling.test.ts",80 "testXcmUnique": "RUN_XCM_TESTS=1 mocha --timeout 9999999 -r ts-node/register ./**/xcm/xcmUnique.test.ts",81 "testXcmQuartz": "RUN_XCM_TESTS=1 mocha --timeout 9999999 -r ts-node/register ./**/xcm/xcmQuartz.test.ts",82 "testXcmOpal": "RUN_XCM_TESTS=1 mocha --timeout 9999999 -r ts-node/register ./**/xcm/xcmOpal.test.ts",83 "testXcmTransferAcala": "mocha --timeout 9999999 -r ts-node/register ./**/xcm/xcmTransferAcala.test.ts acalaId=2000 uniqueId=5000",84 "testXcmTransferStatemine": "mocha --timeout 9999999 -r ts-node/register ./**/xcm/xcmTransferStatemine.test.ts statemineId=1000 uniqueId=5000",85 "testXcmTransferMoonbeam": "mocha --timeout 9999999 -r ts-node/register ./**/xcm/xcmTransferMoonbeam.test.ts",86 "testPalletPresence": "mocha --timeout 9999999 -r ts-node/register ./**/pallet-presence.test.ts",87 "testBlockProduction": "mocha --timeout 9999999 -r ts-node/register ./**/block-production.test.ts",88 "testEnableDisableTransfers": "mocha --timeout 9999999 -r ts-node/register ./**/enableDisableTransfer.test.ts",89 "testLimits": "mocha --timeout 9999999 -r ts-node/register ./**/limits.test.ts",90 "testEthCreateNFTCollection": "mocha --timeout 9999999 -r ts-node/register ./**/eth/createNFTCollection.test.ts",91 "testEthCreateRFTCollection": "mocha --timeout 9999999 -r ts-node/register ./**/eth/createRFTCollection.test.ts",92 "testEthNFT": "mocha --timeout 9999999 -r ts-node/register ./**/eth/nonFungible.test.ts",93 "testRFT": "mocha --timeout 9999999 -r ts-node/register ./**/refungible.test.ts",94 "testEthRFT": "mocha --timeout 9999999 -r ts-node/register ./**/eth/reFungible.test.ts ./**/eth/reFungibleToken.test.ts",95 "testFT": "mocha --timeout 9999999 -r ts-node/register ./**/fungible.test.ts",96 "testEthFT": "mocha --timeout 9999999 -r ts-node/register ./**/eth/fungible.test.ts",97 "testRPC": "mocha --timeout 9999999 -r ts-node/register ./**/rpc.test.ts",98 "testPromotion": "mocha --timeout 9999999 -r ts-node/register ./**/app-promotion.test.ts",99 "polkadot-types-fetch-metadata": "curl -H 'Content-Type: application/json' -d '{\"id\":\"1\", \"jsonrpc\":\"2.0\", \"method\": \"state_getMetadata\", \"params\":[]}' http://localhost:9933 > src/interfaces/metadata.json",100 "polkadot-types-from-defs": "ts-node ./node_modules/.bin/polkadot-types-from-defs --endpoint src/interfaces/metadata.json --input src/interfaces/ --package .",101 "polkadot-types-from-chain": "ts-node ./node_modules/.bin/polkadot-types-from-chain --endpoint src/interfaces/metadata.json --output src/interfaces/ --package .",102 "polkadot-types": "echo \"export default {}\" > src/interfaces/lookup.ts && yarn polkadot-types-fetch-metadata && yarn polkadot-types-from-defs && yarn polkadot-types-from-defs && yarn polkadot-types-from-chain"103 },104 "author": "",105 "license": "SEE LICENSE IN ../LICENSE",106 "homepage": "",107 "dependencies": {108 "@polkadot/api": "9.2.2",109 "@polkadot/api-contract": "9.2.2",110 "@polkadot/util-crypto": "10.1.7",111 "bignumber.js": "^9.0.2",112 "chai-as-promised": "^7.1.1",113 "chai-like": "^1.1.1",114 "find-process": "^1.4.7",115 "solc": "0.8.14-fixed",116 "web3": "^1.7.3"117 },118 "standard": {119 "globals": [120 "it",121 "assert",122 "beforeEach",123 "afterEach",124 "describe",125 "contract",126 "artifacts"127 ]128 },129 "resolutions": {130 "simple-get": "^4.0.1"131 }132}1{2 "name": "unique-tests",3 "version": "1.0.0",4 "description": "Unique Chain Tests",5 "main": "",6 "devDependencies": {7 "@polkadot/ts": "0.4.22",8 "@polkadot/typegen": "9.2.2",9 "@types/chai": "^4.3.1",10 "@types/chai-as-promised": "^7.1.5",11 "@types/chai-like": "^1.1.1",12 "@types/mocha": "^9.1.1",13 "@types/node": "^17.0.35",14 "@typescript-eslint/eslint-plugin": "^5.26.0",15 "@typescript-eslint/parser": "^5.26.0",16 "chai": "^4.3.6",17 "eslint": "^8.16.0",18 "mocha": "^10.0.0",19 "ts-node": "^10.8.0",20 "typescript": "^4.7.2"21 },22 "mocha": {23 "timeout": 9999999,24 "require": "ts-node/register"25 },26 "scripts": {27 "lint": "eslint --ext .ts,.js src/",28 "fix": "eslint --ext .ts,.js src/ --fix",29 "test": "mocha --timeout 9999999 -r ts-node/register './src/**/*.test.ts'",30 "testEth": "mocha --timeout 9999999 -r ts-node/register './**/eth/**/*.test.ts'",31 "testEthMarketplace": "mocha --timeout 9999999 -r ts-node/register './**/eth/marketplace/**/*.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'",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'",36 "load": "mocha --timeout 9999999 -r ts-node/register './**/*.load.ts'",37 "loadTransfer": "ts-node src/transfer.nload.ts",38 "testCollision": "mocha --timeout 9999999 -r ts-node/register ./src/collision-tests/*.test.ts",39 "testEvent": "mocha --timeout 9999999 -r ts-node/register ./src/check-event/*.test.ts",40 "testNesting": "mocha --timeout 9999999 -r ts-node/register ./**/nest.test.ts",41 "testUnnesting": "mocha --timeout 9999999 -r ts-node/register ./**/unnest.test.ts",42 "testStructure": "mocha --timeout 9999999 -r ts-node/register ./**/nesting/**.test.ts",43 "testProperties": "mocha --timeout 9999999 -r ts-node/register ./**/properties.test.ts ./**/getPropertiesRpc.test.ts",44 "testMigration": "mocha --timeout 9999999 -r ts-node/register ./**/nesting/migration-check.test.ts",45 "testRmrk": "mocha --timeout 9999999 -r ts-node/register ./**/rmrk/**.test.ts",46 "testAddCollectionAdmin": "mocha --timeout 9999999 -r ts-node/register ./**/addCollectionAdmin.test.ts",47 "testSetSchemaVersion": "mocha --timeout 9999999 -r ts-node/register ./**/setSchemaVersion.test.ts",48 "testSetCollectionLimits": "mocha --timeout 9999999 -r ts-node/register ./**/setCollectionLimits.test.ts",49 "testChangeCollectionOwner": "mocha --timeout 9999999 -r ts-node/register ./**/change-collection-owner.test.ts",50 "testSetCollectionSponsor": "mocha --timeout 9999999 -r ts-node/register ./**/setCollectionSponsor.test.ts",51 "testConfirmSponsorship": "mocha --timeout 9999999 -r ts-node/register ./**/confirmSponsorship.test.ts",52 "testRemoveCollectionAdmin": "mocha --timeout 9999999 -r ts-node/register ./**/removeCollectionAdmin.test.ts",53 "testRemoveCollectionSponsor": "mocha --timeout 9999999 -r ts-node/register ./**/removeCollectionSponsor.test.ts",54 "testAllowLists": "mocha --timeout 9999999 -r ts-node/register ./**/allowLists.test.ts",55 "testConnection": "mocha --timeout 9999999 -r ts-node/register ./**/connection.test.ts",56 "testContracts": "mocha --timeout 9999999 -r ts-node/register ./**/contracts.test.ts",57 "testCreateItem": "mocha --timeout 9999999 -r ts-node/register ./**/createItem.test.ts",58 "testCreateMultipleItems": "mocha --timeout 9999999 -r ts-node/register ./**/createMultipleItems.test.ts",59 "testCreateMultipleItemsEx": "mocha --timeout 9999999 -r ts-node/register ./**/createMultipleItemsEx.test.ts",60 "testApprove": "mocha --timeout 9999999 -r ts-node/register ./**/approve.test.ts",61 "testTransferFrom": "mocha --timeout 9999999 -r ts-node/register ./**/transferFrom.test.ts",62 "testCreateCollection": "mocha --timeout 9999999 -r ts-node/register ./**/createCollection.test.ts",63 "testDestroyCollection": "mocha --timeout 9999999 -r ts-node/register ./**/destroyCollection.test.ts",64 "testToggleContractAllowList": "mocha --timeout 9999999 -r ts-node/register ./**/toggleContractAllowList.test.ts",65 "testAddToContractAllowList": "mocha --timeout 9999999 -r ts-node/register ./**/addToContractAllowList.test.ts",66 "testTransfer": "mocha --timeout 9999999 -r ts-node/register ./**/transfer.test.ts",67 "testBurnItem": "mocha --timeout 9999999 -r ts-node/register ./**/burnItem.test.ts",68 "testAdminTransferAndBurn": "mocha --timeout 9999999 -r ts-node/register ./**/adminTransferAndBurn.test.ts",69 "testSetPermissions": "mocha --timeout 9999999 -r ts-node/register ./**/setPermissions.test.ts",70 "testCreditFeesToTreasury": "mocha --timeout 9999999 -r ts-node/register ./**/creditFeesToTreasury.test.ts",71 "testContractSponsoring": "mocha --timeout 9999999 -r ts-node/register ./**/eth/contractSponsoring.test.ts",72 "testEnableContractSponsoring": "mocha --timeout 9999999 -r ts-node/register ./**/enableContractSponsoring.test.ts",73 "testRemoveFromContractAllowList": "mocha --timeout 9999999 -r ts-node/register ./**/removeFromContractAllowList.test.ts",74 "testSetContractSponsoringRateLimit": "mocha --timeout 9999999 -r ts-node/register ./**/setContractSponsoringRateLimit.test.ts",75 "testSetOffchainSchema": "mocha --timeout 9999999 -r ts-node/register ./**/setOffchainSchema.test.ts",76 "testNextSponsoring": "mocha --timeout 9999999 -r ts-node/register ./**/nextSponsoring.test.ts",77 "testOverflow": "mocha --timeout 9999999 -r ts-node/register ./**/overflow.test.ts",78 "testInflation": "mocha --timeout 9999999 -r ts-node/register ./**/inflation.test.ts",79 "testScheduler": "mocha --timeout 9999999 -r ts-node/register ./**/scheduler.test.ts",80 "testSchedulingEVM": "mocha --timeout 9999999 -r ts-node/register ./**/eth/scheduling.test.ts",81 "testXcmUnique": "RUN_XCM_TESTS=1 mocha --timeout 9999999 -r ts-node/register ./**/xcm/xcmUnique.test.ts",82 "testXcmQuartz": "RUN_XCM_TESTS=1 mocha --timeout 9999999 -r ts-node/register ./**/xcm/xcmQuartz.test.ts",83 "testXcmOpal": "RUN_XCM_TESTS=1 mocha --timeout 9999999 -r ts-node/register ./**/xcm/xcmOpal.test.ts",84 "testXcmTransferAcala": "mocha --timeout 9999999 -r ts-node/register ./**/xcm/xcmTransferAcala.test.ts acalaId=2000 uniqueId=5000",85 "testXcmTransferStatemine": "mocha --timeout 9999999 -r ts-node/register ./**/xcm/xcmTransferStatemine.test.ts statemineId=1000 uniqueId=5000",86 "testXcmTransferMoonbeam": "mocha --timeout 9999999 -r ts-node/register ./**/xcm/xcmTransferMoonbeam.test.ts",87 "testPalletPresence": "mocha --timeout 9999999 -r ts-node/register ./**/pallet-presence.test.ts",88 "testBlockProduction": "mocha --timeout 9999999 -r ts-node/register ./**/block-production.test.ts",89 "testEnableDisableTransfers": "mocha --timeout 9999999 -r ts-node/register ./**/enableDisableTransfer.test.ts",90 "testLimits": "mocha --timeout 9999999 -r ts-node/register ./**/limits.test.ts",91 "testEthCreateNFTCollection": "mocha --timeout 9999999 -r ts-node/register ./**/eth/createNFTCollection.test.ts",92 "testEthCreateRFTCollection": "mocha --timeout 9999999 -r ts-node/register ./**/eth/createRFTCollection.test.ts",93 "testEthNFT": "mocha --timeout 9999999 -r ts-node/register ./**/eth/nonFungible.test.ts",94 "testRFT": "mocha --timeout 9999999 -r ts-node/register ./**/refungible.test.ts",95 "testEthRFT": "mocha --timeout 9999999 -r ts-node/register ./**/eth/reFungible.test.ts ./**/eth/reFungibleToken.test.ts",96 "testFT": "mocha --timeout 9999999 -r ts-node/register ./**/fungible.test.ts",97 "testEthFT": "mocha --timeout 9999999 -r ts-node/register ./**/eth/fungible.test.ts",98 "testRPC": "mocha --timeout 9999999 -r ts-node/register ./**/rpc.test.ts",99 "testPromotion": "mocha --timeout 9999999 -r ts-node/register ./**/app-promotion.test.ts",100 "polkadot-types-fetch-metadata": "curl -H 'Content-Type: application/json' -d '{\"id\":\"1\", \"jsonrpc\":\"2.0\", \"method\": \"state_getMetadata\", \"params\":[]}' http://localhost:9933 > src/interfaces/metadata.json",101 "polkadot-types-from-defs": "ts-node ./node_modules/.bin/polkadot-types-from-defs --endpoint src/interfaces/metadata.json --input src/interfaces/ --package .",102 "polkadot-types-from-chain": "ts-node ./node_modules/.bin/polkadot-types-from-chain --endpoint src/interfaces/metadata.json --output src/interfaces/ --package .",103 "polkadot-types": "echo \"export default {}\" > src/interfaces/lookup.ts && yarn polkadot-types-fetch-metadata && yarn polkadot-types-from-defs && yarn polkadot-types-from-defs && yarn polkadot-types-from-chain"104 },105 "author": "",106 "license": "SEE LICENSE IN ../LICENSE",107 "homepage": "",108 "dependencies": {109 "@polkadot/api": "9.2.2",110 "@polkadot/api-contract": "9.2.2",111 "@polkadot/util-crypto": "10.1.7",112 "bignumber.js": "^9.0.2",113 "chai-as-promised": "^7.1.1",114 "chai-like": "^1.1.1",115 "find-process": "^1.4.7",116 "solc": "0.8.14-fixed",117 "web3": "^1.7.3"118 },119 "standard": {120 "globals": [121 "it",122 "assert",123 "beforeEach",124 "afterEach",125 "describe",126 "contract",127 "artifacts"128 ]129 },130 "resolutions": {131 "simple-get": "^4.0.1"132 }133}tests/src/eth/contractSponsoring.test.tsdiffbeforeafterboth--- a/tests/src/eth/contractSponsoring.test.ts
+++ b/tests/src/eth/contractSponsoring.test.ts
@@ -15,7 +15,6 @@
// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
import {IKeyringPair} from '@polkadot/types/types';
-import * as solc from 'solc';
import {EthUniqueHelper} from './util/playgrounds/unique.dev';
import {itEth, expect, SponsoringMode, usingEthPlaygrounds} from '../eth/util/playgrounds';
import {usingPlaygrounds} from '../util/playgrounds';
@@ -455,70 +454,44 @@
describe('Sponsoring Fee Limit', () => {
let donor: IKeyringPair;
let alice: IKeyringPair;
- let DEFAULT_GAS: number;
+ let testContract: CompiledContract;
- function compileTestContract() {
+ async function compileTestContract(helper: EthUniqueHelper) {
if (!testContract) {
- const input = {
- language: 'Solidity',
- sources: {
- ['TestContract.sol']: {
- content:
- `
- // SPDX-License-Identifier: MIT
- pragma solidity ^0.8.0;
-
- contract TestContract {
- event Result(bool);
+ testContract = await helper.ethContract.compile(
+ 'TestContract',
+ `
+ // SPDX-License-Identifier: MIT
+ pragma solidity ^0.8.0;
+
+ contract TestContract {
+ event Result(bool);
- function test(uint32 cycles) public {
- uint256 counter = 0;
- while(true) {
- counter ++;
- if (counter > cycles){
- break;
- }
- }
- emit Result(true);
+ function test(uint32 cycles) public {
+ uint256 counter = 0;
+ while(true) {
+ counter ++;
+ if (counter > cycles){
+ break;
}
}
- `,
- },
- },
- settings: {
- outputSelection: {
- '*': {
- '*': ['*'],
- },
- },
- },
- };
- const json = JSON.parse(solc.compile(JSON.stringify(input)));
- const out = json.contracts['TestContract.sol']['TestContract'];
-
- testContract = {
- abi: out.abi,
- object: '0x' + out.evm.bytecode.object,
- };
+ emit Result(true);
+ }
+ }
+ `,
+ );
}
return testContract;
}
async function deployTestContract(helper: EthUniqueHelper, owner: string) {
- const web3 = helper.getWeb3();
- const compiled = compileTestContract();
- const testContract = new web3.eth.Contract(compiled.abi, undefined, {
- data: compiled.object,
- from: owner,
- gas: DEFAULT_GAS,
- });
- return await testContract.deploy({data: compiled.object}).send({from: owner});
+ const compiled = await compileTestContract(helper);
+ return await helper.ethContract.deployByAbi(owner, compiled.abi, compiled.object);
}
before(async () => {
- await usingEthPlaygrounds(async (helper, privateKey) => {
+ await usingEthPlaygrounds(async (_helper, privateKey) => {
donor = privateKey('//Alice');
- DEFAULT_GAS = helper.eth.DEFAULT_GAS;
});
});
@@ -526,10 +499,7 @@
await usingPlaygrounds(async (helper) => {
[alice] = await helper.arrange.createAccounts([1000n], donor);
});
- });
-
- let testContract: CompiledContract;
-
+ });
itEth('Default fee limit', async ({helper}) => {
tests/src/eth/evmCoder.test.tsdiffbeforeafterboth--- /dev/null
+++ b/tests/src/eth/evmCoder.test.ts
@@ -0,0 +1,90 @@
+// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.
+// This file is part of Unique Network.
+
+// Unique Network is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// Unique Network is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
+
+import {IKeyringPair} from '@polkadot/types/types';
+import {itEth, expect, usingEthPlaygrounds} from './util/playgrounds';
+
+const getContractSource = (collectionAddress: string, contractAddress: string): string => {
+ return `
+ // SPDX-License-Identifier: MIT
+ pragma solidity ^0.8.0;
+ interface ITest {
+ function ztestzzzzzzz() external returns (uint256 n);
+ }
+ contract Test {
+ event Result(bool, uint256);
+ function test1() public {
+ try
+ ITest(${collectionAddress}).ztestzzzzzzz()
+ returns (uint256 n) {
+ // enters
+ emit Result(true, n); // => [true, BigNumber { value: "43648854190028290368124427828690944273759144372138548774646036134290060795932" }]
+ } catch {
+ emit Result(false, 0);
+ }
+ }
+ function test2() public {
+ try
+ ITest(${contractAddress}).ztestzzzzzzz()
+ returns (uint256 n) {
+ emit Result(true, n);
+ } catch {
+ // enters
+ emit Result(false, 0); // => [ false, BigNumber { value: "0" } ]
+ }
+ }
+ function test3() public {
+ ITest(${collectionAddress}).ztestzzzzzzz();
+ }
+ }
+ `;
+};
+
+
+describe('Evm Coder tests', () => {
+ let donor: IKeyringPair;
+
+ before(async function() {
+ await usingEthPlaygrounds(async (_helper, privateKey) => {
+ donor = privateKey('//Alice');
+ });
+ });
+
+ itEth('Call non-existing function', async ({helper}) => {
+ const owner = await helper.eth.createAccountWithBalance(donor);
+ const collection = await helper.eth.createNonfungibleCollection(owner, 'EVMCODER', '', 'TEST');
+ const contract = await helper.ethContract.deployByCode(owner, 'Test', getContractSource(collection.collectionAddress, '0x1bfed5D614b886b9Ab2eA4CBAc22A96B7EC29c9c'));
+ const testContract = await helper.ethContract.deployByCode(owner, 'Test', getContractSource(collection.collectionAddress, contract.options.address));
+ {
+ const result = await testContract.methods.test1().send();
+ expect(result.events.Result.returnValues).to.deep.equal({
+ '0': false,
+ '1': '0',
+ });
+ }
+ {
+ const result = await testContract.methods.test2().send();
+ expect(result.events.Result.returnValues).to.deep.equal({
+ '0': false,
+ '1': '0',
+ });
+ }
+ {
+ await expect(testContract.methods.test3().call())
+ .to.be.rejectedWith(/unrecognized selector: 0xd9f02b36$/g);
+ }
+ });
+});
tests/src/evmCoder.test.tsdiffbeforeafterboth--- a/tests/src/evmCoder.test.ts
+++ /dev/null
@@ -1,123 +0,0 @@
-// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.
-// This file is part of Unique Network.
-
-// Unique Network is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-
-// Unique Network is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License
-// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
-
-import {IKeyringPair} from '@polkadot/types/types';
-import Web3 from 'web3';
-import {itEth, expect, usingEthPlaygrounds} from './eth/util/playgrounds';
-import * as solc from 'solc';
-
-async function compileTestContract(collectionAddress: string, contractAddress: string) {
- const input = {
- language: 'Solidity',
- sources: {
- ['Test.sol']: {
- content:
- `
- // SPDX-License-Identifier: MIT
- pragma solidity ^0.8.0;
- interface ITest {
- function ztestzzzzzzz() external returns (uint256 n);
- }
- contract Test {
- event Result(bool, uint256);
- function test1() public {
- try
- ITest(${collectionAddress}).ztestzzzzzzz()
- returns (uint256 n) {
- // enters
- emit Result(true, n); // => [true, BigNumber { value: "43648854190028290368124427828690944273759144372138548774646036134290060795932" }]
- } catch {
- emit Result(false, 0);
- }
- }
- function test2() public {
- try
- ITest(${contractAddress}).ztestzzzzzzz()
- returns (uint256 n) {
- emit Result(true, n);
- } catch {
- // enters
- emit Result(false, 0); // => [ false, BigNumber { value: "0" } ]
- }
- }
- function test3() public {
- ITest(${collectionAddress}).ztestzzzzzzz();
- }
- }
- `,
- },
- },
- settings: {
- outputSelection: {
- '*': {
- '*': ['*'],
- },
- },
- },
- };
- const json = JSON.parse(solc.compile(JSON.stringify(input)));
- const out = json.contracts['Test.sol']['Test'];
-
- return {
- abi: out.abi,
- object: '0x' + out.evm.bytecode.object,
- };
-}
-
-async function deployTestContract(web3: Web3, owner: string, collectionAddress: string, contractAddress: string, gas: number) {
- const compiled = await compileTestContract(collectionAddress, contractAddress);
- const fractionalizerContract = new web3.eth.Contract(compiled.abi, undefined, {
- data: compiled.object,
- from: owner,
- gas,
- });
- return await fractionalizerContract.deploy({data: compiled.object}).send({from: owner});
-}
-
-describe('Evm Coder tests', () => {
- let donor: IKeyringPair;
-
- before(async function() {
- await usingEthPlaygrounds(async (_helper, privateKey) => {
- donor = privateKey('//Alice');
- });
- });
-
- itEth('Call non-existing function', async ({helper}) => {
- const owner = await helper.eth.createAccountWithBalance(donor);
- const collection = await helper.eth.createNonfungibleCollection(owner, 'EVMCODER', '', 'TEST');
- const contract = await deployTestContract(helper.getWeb3(), owner, collection.collectionAddress, '0x1bfed5D614b886b9Ab2eA4CBAc22A96B7EC29c9c', helper.eth.DEFAULT_GAS);
- const testContract = await deployTestContract(helper.getWeb3(), owner, collection.collectionAddress, contract.options.address, helper.eth.DEFAULT_GAS);
- {
- const result = await testContract.methods.test1().send();
- expect(result.events.Result.returnValues).to.deep.equal({
- '0': false,
- '1': '0',
- });
- }
- {
- const result = await testContract.methods.test2().send();
- expect(result.events.Result.returnValues).to.deep.equal({
- '0': false,
- '1': '0',
- });
- }
- {
- await expect(testContract.methods.test3().call())
- .to.be.rejectedWith(/unrecognized selector: 0xd9f02b36$/g);
- }
- });
-});