difftreelog
Merge branch 'develop' into tests/feed-alices
in: master
5 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 "feedAlices": "ts-node ./src/util/playgrounds/feedAlices.ts",3031 "test": "yarn feedAlices && mocha --parallel --timeout 9999999 -r ts-node/register './src/**/*.test.ts'",32 "testSequential": "yarn feedAlices && mocha --timeout 9999999 -r ts-node/register './src/**/*.seqtest.ts'",33 "testStructure": "yarn feedAlices && mocha --parallel --timeout 9999999 -r ts-node/register ./**/nesting/**.test.ts",34 "testEth": "yarn feedAlices && mocha --parallel --timeout 9999999 -r ts-node/register './**/eth/**/*.test.ts'",35 "testEthNesting": "yarn feedAlices && mocha --parallel --timeout 9999999 -r ts-node/register './**/eth/nesting/**/*.test.ts'",36 "testEthFractionalizer": "yarn feedAlices && mocha --parallel --timeout 9999999 -r ts-node/register './**/eth/fractionalizer/**/*.test.ts'",37 "testEthMarketplace": "yarn feedAlices && mocha --parallel --timeout 9999999 -r ts-node/register './**/eth/marketplace/**/*.test.ts'",38 "testEvent": "yarn feedAlices && mocha --parallel --timeout 9999999 -r ts-node/register ./src/check-event/*.test.ts",39 "testRmrk": "mocha --timeout 9999999 -r ts-node/register ./**/rmrk/**test.ts",4041 "testEthPayable": "mocha --timeout 9999999 -r ts-node/register './**/eth/payable.test.ts'",42 "testEthTokenProperties": "mocha --timeout 9999999 -r ts-node/register ./**/eth/tokenProperties.test.ts",43 "testNesting": "mocha --timeout 9999999 -r ts-node/register ./**/nest.test.ts",44 "testUnnesting": "mocha --timeout 9999999 -r ts-node/register ./**/unnest.test.ts",45 "testProperties": "mocha --timeout 9999999 -r ts-node/register ./**/properties.test.ts ./**/getPropertiesRpc.test.ts",46 "testMigration": "mocha --timeout 9999999 -r ts-node/register ./**/nesting/migration-check.test.ts",47 "testAddCollectionAdmin": "mocha --timeout 9999999 -r ts-node/register ./**/addCollectionAdmin.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 --parallel -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 ./**/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 "testPalletPresence": "mocha --timeout 9999999 -r ts-node/register ./**/pallet-presence.test.ts",82 "testBlockProduction": "mocha --timeout 9999999 -r ts-node/register ./**/block-production.test.ts",83 "testEnableDisableTransfers": "mocha --timeout 9999999 -r ts-node/register ./**/enableDisableTransfer.test.ts",84 "testLimits": "mocha --timeout 9999999 -r ts-node/register ./**/limits.test.ts",85 "testEthCreateNFTCollection": "mocha --timeout 9999999 -r ts-node/register ./**/eth/createNFTCollection.test.ts",86 "testEthCreateRFTCollection": "mocha --timeout 9999999 -r ts-node/register ./**/eth/createRFTCollection.test.ts",87 "testEthNFT": "mocha --timeout 9999999 -r ts-node/register ./**/eth/nonFungible.test.ts",88 "testRFT": "mocha --timeout 9999999 -r ts-node/register ./**/refungible.test.ts",89 "testEthRFT": "mocha --timeout 9999999 -r ts-node/register ./**/eth/reFungible.test.ts ./**/eth/reFungibleToken.test.ts",90 "testFT": "mocha --timeout 9999999 -r ts-node/register ./**/fungible.test.ts",91 "testEthFT": "mocha --timeout 9999999 -r ts-node/register ./**/eth/fungible.test.ts",92 "testRPC": "mocha --timeout 9999999 -r ts-node/register ./**/rpc.test.ts",93 "testPromotion": "mocha --timeout 9999999 -r ts-node/register ./**/app-promotion.test.ts",94 95 "testXcmUnique": "RUN_XCM_TESTS=1 mocha --timeout 9999999 -r ts-node/register ./**/xcm/xcmUnique.test.ts",96 "testXcmQuartz": "RUN_XCM_TESTS=1 mocha --timeout 9999999 -r ts-node/register ./**/xcm/xcmQuartz.test.ts",97 "testXcmOpal": "RUN_XCM_TESTS=1 mocha --timeout 9999999 -r ts-node/register ./**/xcm/xcmOpal.test.ts",98 "testXcmTransferAcala": "mocha --timeout 9999999 -r ts-node/register ./**/xcm/xcmTransferAcala.test.ts acalaId=2000 uniqueId=5000",99 "testXcmTransferStatemine": "mocha --timeout 9999999 -r ts-node/register ./**/xcm/xcmTransferStatemine.test.ts statemineId=1000 uniqueId=5000",100 "testXcmTransferMoonbeam": "mocha --timeout 9999999 -r ts-node/register ./**/xcm/xcmTransferMoonbeam.test.ts",101102 "load": "mocha --timeout 9999999 -r ts-node/register './**/*.load.ts'",103 "loadTransfer": "ts-node src/transfer.nload.ts",104 105 "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",106 "polkadot-types-from-defs": "ts-node ./node_modules/.bin/polkadot-types-from-defs --endpoint src/interfaces/metadata.json --input src/interfaces/ --package .",107 "polkadot-types-from-chain": "ts-node ./node_modules/.bin/polkadot-types-from-chain --endpoint src/interfaces/metadata.json --output src/interfaces/ --package .",108 "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"109 },110 "author": "",111 "license": "SEE LICENSE IN ../LICENSE",112 "homepage": "",113 "dependencies": {114 "@polkadot/api": "9.2.2",115 "@polkadot/api-contract": "9.2.2",116 "@polkadot/util-crypto": "10.1.7",117 "bignumber.js": "^9.0.2",118 "chai-as-promised": "^7.1.1",119 "chai-like": "^1.1.1",120 "find-process": "^1.4.7",121 "solc": "0.8.14-fixed",122 "web3": "^1.7.3"123 },124 "standard": {125 "globals": [126 "it",127 "assert",128 "beforeEach",129 "afterEach",130 "describe",131 "contract",132 "artifacts"133 ]134 },135 "resolutions": {136 "simple-get": "^4.0.1"137 }138}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 "feedAlices": "ts-node ./src/util/playgrounds/feedAlices.ts",3031 "test": "yarn feedAlices && mocha --parallel --timeout 9999999 -r ts-node/register './src/**/*.test.ts'",32 "testSequential": "yarn feedAlices && mocha --timeout 9999999 -r ts-node/register './src/**/*.seqtest.ts'",33 "testStructure": "yarn feedAlices && mocha --parallel --timeout 9999999 -r ts-node/register ./**/nesting/**.test.ts",34 "testEth": "yarn feedAlices && mocha --parallel --timeout 9999999 -r ts-node/register './**/eth/**/*.test.ts'",35 "testEthNesting": "yarn feedAlices && mocha --parallel --timeout 9999999 -r ts-node/register './**/eth/nesting/**/*.test.ts'",36 "testEthFractionalizer": "yarn feedAlices && mocha --parallel --timeout 9999999 -r ts-node/register './**/eth/fractionalizer/**/*.test.ts'",37 "testEthMarketplace": "yarn feedAlices && mocha --parallel --timeout 9999999 -r ts-node/register './**/eth/marketplace/**/*.test.ts'",38 "testEvent": "yarn feedAlices && mocha --parallel --timeout 9999999 -r ts-node/register ./src/check-event/*.test.ts",39 "testRmrk": "mocha --timeout 9999999 -r ts-node/register ./**/rmrk/**test.ts",4041 "testEthPayable": "mocha --timeout 9999999 -r ts-node/register './**/eth/payable.test.ts'",42 "testEthTokenProperties": "mocha --timeout 9999999 -r ts-node/register ./**/eth/tokenProperties.test.ts",43 "testEvmCoder": "mocha --timeout 9999999 -r ts-node/register './**/eth/evmCoder.test.ts'",44 "testNesting": "mocha --timeout 9999999 -r ts-node/register ./**/nest.test.ts",45 "testUnnesting": "mocha --timeout 9999999 -r ts-node/register ./**/unnest.test.ts",46 "testProperties": "mocha --timeout 9999999 -r ts-node/register ./**/properties.test.ts ./**/getPropertiesRpc.test.ts",47 "testMigration": "mocha --timeout 9999999 -r ts-node/register ./**/nesting/migration-check.test.ts",48 "testAddCollectionAdmin": "mocha --timeout 9999999 -r ts-node/register ./**/addCollectionAdmin.test.ts",49 "testSetCollectionLimits": "mocha --timeout 9999999 -r ts-node/register ./**/setCollectionLimits.test.ts",50 "testChangeCollectionOwner": "mocha --timeout 9999999 -r ts-node/register ./**/change-collection-owner.test.ts",51 "testSetCollectionSponsor": "mocha --timeout 9999999 -r ts-node/register ./**/setCollectionSponsor.test.ts",52 "testConfirmSponsorship": "mocha --timeout 9999999 --parallel -r ts-node/register ./**/confirmSponsorship.test.ts",53 "testRemoveCollectionAdmin": "mocha --timeout 9999999 -r ts-node/register ./**/removeCollectionAdmin.test.ts",54 "testRemoveCollectionSponsor": "mocha --timeout 9999999 -r ts-node/register ./**/removeCollectionSponsor.test.ts",55 "testAllowLists": "mocha --timeout 9999999 -r ts-node/register ./**/allowLists.test.ts",56 "testConnection": "mocha --timeout 9999999 -r ts-node/register ./**/connection.test.ts",57 "testContracts": "mocha --timeout 9999999 -r ts-node/register ./**/contracts.test.ts",58 "testCreateItem": "mocha --timeout 9999999 -r ts-node/register ./**/createItem.test.ts",59 "testCreateMultipleItems": "mocha --timeout 9999999 -r ts-node/register ./**/createMultipleItems.test.ts",60 "testCreateMultipleItemsEx": "mocha --timeout 9999999 -r ts-node/register ./**/createMultipleItemsEx.test.ts",61 "testApprove": "mocha --timeout 9999999 -r ts-node/register ./**/approve.test.ts",62 "testTransferFrom": "mocha --timeout 9999999 -r ts-node/register ./**/transferFrom.test.ts",63 "testCreateCollection": "mocha --timeout 9999999 -r ts-node/register ./**/createCollection.test.ts",64 "testDestroyCollection": "mocha --timeout 9999999 -r ts-node/register ./**/destroyCollection.test.ts",65 "testToggleContractAllowList": "mocha --timeout 9999999 -r ts-node/register ./**/toggleContractAllowList.test.ts",66 "testAddToContractAllowList": "mocha --timeout 9999999 -r ts-node/register ./**/addToContractAllowList.test.ts",67 "testTransfer": "mocha --timeout 9999999 -r ts-node/register ./**/transfer.test.ts",68 "testBurnItem": "mocha --timeout 9999999 -r ts-node/register ./**/burnItem.test.ts",69 "testAdminTransferAndBurn": "mocha --timeout 9999999 -r ts-node/register ./**/adminTransferAndBurn.test.ts",70 "testSetPermissions": "mocha --timeout 9999999 -r ts-node/register ./**/setPermissions.test.ts",71 "testCreditFeesToTreasury": "mocha --timeout 9999999 -r ts-node/register ./**/creditFeesToTreasury.test.ts",72 "testContractSponsoring": "mocha --timeout 9999999 -r ts-node/register ./**/eth/contractSponsoring.test.ts",73 "testEnableContractSponsoring": "mocha --timeout 9999999 -r ts-node/register ./**/enableContractSponsoring.test.ts",74 "testRemoveFromContractAllowList": "mocha --timeout 9999999 -r ts-node/register ./**/removeFromContractAllowList.test.ts",75 "testSetContractSponsoringRateLimit": "mocha --timeout 9999999 -r ts-node/register ./**/setContractSponsoringRateLimit.test.ts",76 "testSetOffchainSchema": "mocha --timeout 9999999 -r ts-node/register ./**/setOffchainSchema.test.ts",77 "testNextSponsoring": "mocha --timeout 9999999 -r ts-node/register ./**/nextSponsoring.test.ts",78 "testOverflow": "mocha --timeout 9999999 -r ts-node/register ./**/overflow.test.ts",79 "testInflation": "mocha --timeout 9999999 -r ts-node/register ./**/inflation.test.ts",80 "testScheduler": "mocha --timeout 9999999 -r ts-node/register ./**/scheduler.test.ts",81 "testSchedulingEVM": "mocha --timeout 9999999 -r ts-node/register ./**/eth/scheduling.test.ts",82 "testPalletPresence": "mocha --timeout 9999999 -r ts-node/register ./**/pallet-presence.test.ts",83 "testBlockProduction": "mocha --timeout 9999999 -r ts-node/register ./**/block-production.test.ts",84 "testEnableDisableTransfers": "mocha --timeout 9999999 -r ts-node/register ./**/enableDisableTransfer.test.ts",85 "testLimits": "mocha --timeout 9999999 -r ts-node/register ./**/limits.test.ts",86 "testEthCreateNFTCollection": "mocha --timeout 9999999 -r ts-node/register ./**/eth/createNFTCollection.test.ts",87 "testEthCreateRFTCollection": "mocha --timeout 9999999 -r ts-node/register ./**/eth/createRFTCollection.test.ts",88 "testEthNFT": "mocha --timeout 9999999 -r ts-node/register ./**/eth/nonFungible.test.ts",89 "testRFT": "mocha --timeout 9999999 -r ts-node/register ./**/refungible.test.ts",90 "testEthRFT": "mocha --timeout 9999999 -r ts-node/register ./**/eth/reFungible.test.ts ./**/eth/reFungibleToken.test.ts",91 "testFT": "mocha --timeout 9999999 -r ts-node/register ./**/fungible.test.ts",92 "testEthFT": "mocha --timeout 9999999 -r ts-node/register ./**/eth/fungible.test.ts",93 "testRPC": "mocha --timeout 9999999 -r ts-node/register ./**/rpc.test.ts",94 "testPromotion": "mocha --timeout 9999999 -r ts-node/register ./**/app-promotion.test.ts",95 96 "testXcmUnique": "RUN_XCM_TESTS=1 mocha --timeout 9999999 -r ts-node/register ./**/xcm/xcmUnique.test.ts",97 "testXcmQuartz": "RUN_XCM_TESTS=1 mocha --timeout 9999999 -r ts-node/register ./**/xcm/xcmQuartz.test.ts",98 "testXcmOpal": "RUN_XCM_TESTS=1 mocha --timeout 9999999 -r ts-node/register ./**/xcm/xcmOpal.test.ts",99 "testXcmTransferAcala": "mocha --timeout 9999999 -r ts-node/register ./**/xcm/xcmTransferAcala.test.ts acalaId=2000 uniqueId=5000",100 "testXcmTransferStatemine": "mocha --timeout 9999999 -r ts-node/register ./**/xcm/xcmTransferStatemine.test.ts statemineId=1000 uniqueId=5000",101 "testXcmTransferMoonbeam": "mocha --timeout 9999999 -r ts-node/register ./**/xcm/xcmTransferMoonbeam.test.ts",102103 "load": "mocha --timeout 9999999 -r ts-node/register './**/*.load.ts'",104 "loadTransfer": "ts-node src/transfer.nload.ts",105 106 "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",107 "polkadot-types-from-defs": "ts-node ./node_modules/.bin/polkadot-types-from-defs --endpoint src/interfaces/metadata.json --input src/interfaces/ --package .",108 "polkadot-types-from-chain": "ts-node ./node_modules/.bin/polkadot-types-from-chain --endpoint src/interfaces/metadata.json --output src/interfaces/ --package .",109 "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"110 },111 "author": "",112 "license": "SEE LICENSE IN ../LICENSE",113 "homepage": "",114 "dependencies": {115 "@polkadot/api": "9.2.2",116 "@polkadot/api-contract": "9.2.2",117 "@polkadot/util-crypto": "10.1.7",118 "bignumber.js": "^9.0.2",119 "chai-as-promised": "^7.1.1",120 "chai-like": "^1.1.1",121 "find-process": "^1.4.7",122 "solc": "0.8.14-fixed",123 "web3": "^1.7.3"124 },125 "standard": {126 "globals": [127 "it",128 "assert",129 "beforeEach",130 "afterEach",131 "describe",132 "contract",133 "artifacts"134 ]135 },136 "resolutions": {137 "simple-get": "^4.0.1"138 }139}tests/src/app-promotion.test.tsdiffbeforeafterboth--- a/tests/src/app-promotion.test.ts
+++ b/tests/src/app-promotion.test.ts
@@ -557,6 +557,7 @@
// caller payed for call
expect(1000n * nominal > callerBalance).to.be.true;
+ // todo:playgrounds look into. why did it work before with 1000n, and is now 100n?
expect(contractBalanceAfter).to.be.equal(100n * nominal);
});
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,75 +454,47 @@
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) => {
donor = await privateKey({filename: __filename});
[alice] = await helper.arrange.createAccounts([100n], donor);
- DEFAULT_GAS = helper.eth.DEFAULT_GAS;
});
});
-
- let testContract: CompiledContract;
itEth('Default fee limit', async ({helper}) => {
const owner = await helper.eth.createAccountWithBalance(donor);
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 = await privateKey({filename: __filename});
+ });
+ });
+
+ 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 = await privateKey({filename: __filename});
- });
- });
-
- 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);
- }
- });
-});