difftreelog
Merge pull request #603 from UniqueNetwork/tests/finish-refactoring-base-folder
in: master
8 files changed
tests/src/addToContractAllowList.test.tsdiffbeforeafterboth--- a/tests/src/addToContractAllowList.test.ts
+++ b/tests/src/addToContractAllowList.test.ts
@@ -27,6 +27,7 @@
chai.use(chaiAsPromised);
const expect = chai.expect;
+// todo:playgrounds skipped ~ postponed
describe.skip('Integration Test addToContractAllowList', () => {
it('Add an address to a contract allow list', async () => {
tests/src/block-production.test.tsdiffbeforeafterboth--- a/tests/src/block-production.test.ts
+++ b/tests/src/block-production.test.ts
@@ -14,9 +14,8 @@
// 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 usingApi from './substrate/substrate-api';
-import {expect} from 'chai';
import {ApiPromise} from '@polkadot/api';
+import {expect, itSub} from './util/playgrounds';
const BLOCK_TIME_MS = 12000;
const TOLERANCE_MS = 3000;
@@ -37,10 +36,8 @@
}
describe('Block Production smoke test', () => {
- it('Node produces new blocks', async () => {
- await usingApi(async (api) => {
- const blocks: number[] | undefined = await getBlocks(api);
- expect(blocks[0]).to.be.lessThan(blocks[1]);
- });
+ itSub('Node produces new blocks', async ({helper}) => {
+ const blocks: number[] | undefined = await getBlocks(helper.api!);
+ expect(blocks[0]).to.be.lessThan(blocks[1]);
});
});
tests/src/connection.test.tsdiffbeforeafterboth--- a/tests/src/connection.test.ts
+++ b/tests/src/connection.test.ts
@@ -14,29 +14,19 @@
// 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 usingApi from './substrate/substrate-api';
-import {WsProvider} from '@polkadot/api';
-import * as chai from 'chai';
-import chaiAsPromised from 'chai-as-promised';
-
-chai.use(chaiAsPromised);
-
-const expect = chai.expect;
+import {itSub, expect, usingPlaygrounds} from './util/playgrounds';
describe('Connection smoke test', () => {
- it('Connection can be established', async () => {
- await usingApi(async api => {
- const health = await api.rpc.system.health();
- expect(health).to.be.not.empty;
- });
+ itSub('Connection can be established', async ({helper}) => {
+ const health = (await helper.callRpc('api.rpc.system.health')).toJSON();
+ expect(health).to.be.not.empty;
});
it('Cannot connect to 255.255.255.255', async () => {
- const neverConnectProvider = new WsProvider('ws://255.255.255.255:9944');
await expect((async () => {
- await usingApi(async api => {
- await api.rpc.system.health();
- }, {provider: neverConnectProvider});
+ await usingPlaygrounds(async helper => {
+ await helper.callRpc('api.rpc.system.health');
+ }, 'ws://255.255.255.255:9944');
})()).to.be.eventually.rejected;
});
});
tests/src/contracts.test.tsdiffbeforeafterboth1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617import chai from 'chai';18import chaiAsPromised from 'chai-as-promised';19import usingApi, {submitTransactionAsync} from './substrate/substrate-api';20import fs from 'fs';21import {Abi, ContractPromise as Contract} from '@polkadot/api-contract';22import {23 deployFlipper,24 getFlipValue,25 deployTransferContract,26} from './util/contracthelpers';2728import {29 addToAllowListExpectSuccess,30 approveExpectSuccess,31 createCollectionExpectSuccess,32 createItemExpectSuccess,33 enablePublicMintingExpectSuccess,34 enableAllowListExpectSuccess,35 getGenericResult,36 normalizeAccountId,37 isAllowlisted,38 transferFromExpectSuccess,39 getTokenOwner,40} from './util/helpers';414243chai.use(chaiAsPromised);44const expect = chai.expect;4546const value = 0;47const gasLimit = 9000n * 1000000n;48const marketContractAddress = '5CYN9j3YvRkqxewoxeSvRbhAym4465C57uMmX5j4yz99L5H6';4950describe.skip('Contracts', () => {51 it('Can deploy smart contract Flipper, instantiate it and call it\'s get and flip messages.', async () => {52 await usingApi(async (api, privateKeyWrapper) => {53 const [contract, deployer] = await deployFlipper(api, privateKeyWrapper);54 const initialGetResponse = await getFlipValue(contract, deployer);5556 const bob = privateKeyWrapper('//Bob');57 const flip = contract.tx.flip({value, gasLimit});58 await submitTransactionAsync(bob, flip);5960 const afterFlipGetResponse = await getFlipValue(contract, deployer);61 expect(afterFlipGetResponse).not.to.be.eq(initialGetResponse, 'Flipping should change value.');62 });63 });6465 it('Can initialize contract instance', async () => {66 await usingApi(async (api) => {67 const metadata = JSON.parse(fs.readFileSync('./src/flipper/metadata.json').toString('utf-8'));68 const abi = new Abi(metadata);69 const newContractInstance = new Contract(api, abi, marketContractAddress);70 expect(newContractInstance).to.have.property('address');71 expect(newContractInstance.address.toString()).to.equal(marketContractAddress);72 });73 });74});7576describe.skip('Chain extensions', () => {77 it('Transfer CE', async () => {78 await usingApi(async (api, privateKeyWrapper) => {79 const alice = privateKeyWrapper('//Alice');80 const bob = privateKeyWrapper('//Bob');8182 // Prep work83 const collectionId = await createCollectionExpectSuccess();84 const tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT');85 const [contract] = await deployTransferContract(api, privateKeyWrapper);86 const changeAdminTx = api.tx.unique.addCollectionAdmin(collectionId, contract.address);87 await submitTransactionAsync(alice, changeAdminTx);8889 expect(await getTokenOwner(api, collectionId, tokenId)).to.be.deep.equal(normalizeAccountId(alice.address));9091 // Transfer92 const transferTx = contract.tx.transfer({value, gasLimit}, bob.address, collectionId, tokenId, 1);93 const events = await submitTransactionAsync(alice, transferTx);94 const result = getGenericResult(events);95 expect(result.success).to.be.true;9697 expect(await getTokenOwner(api, collectionId, tokenId)).to.be.deep.equal(normalizeAccountId(bob.address));98 });99 });100101 it('Mint CE', async () => {102 await usingApi(async (api, privateKeyWrapper) => {103 const alice = privateKeyWrapper('//Alice');104 const bob = privateKeyWrapper('//Bob');105106 const collectionId = await createCollectionExpectSuccess();107 const [contract] = await deployTransferContract(api, privateKeyWrapper);108 await enablePublicMintingExpectSuccess(alice, collectionId);109 await enableAllowListExpectSuccess(alice, collectionId);110 await addToAllowListExpectSuccess(alice, collectionId, contract.address);111 await addToAllowListExpectSuccess(alice, collectionId, bob.address);112113 const transferTx = contract.tx.createItem({value, gasLimit}, bob.address, collectionId, {Nft: {const_data: '0x010203'}});114 const events = await submitTransactionAsync(alice, transferTx);115 const result = getGenericResult(events);116 expect(result.success).to.be.true;117118 const tokensAfter = (await api.query.unique.nftItemList.entries(collectionId)).map((kv: any) => kv[1].toJSON());119 expect(tokensAfter).to.be.deep.equal([120 {121 owner: bob.address,122 constData: '0x010203',123 },124 ]);125 });126 });127128 it('Bulk mint CE', async () => {129 await usingApi(async (api, privateKeyWrapper) => {130 const alice = privateKeyWrapper('//Alice');131 const bob = privateKeyWrapper('//Bob');132133 const collectionId = await createCollectionExpectSuccess();134 const [contract] = await deployTransferContract(api, privateKeyWrapper);135 await enablePublicMintingExpectSuccess(alice, collectionId);136 await enableAllowListExpectSuccess(alice, collectionId);137 await addToAllowListExpectSuccess(alice, collectionId, contract.address);138 await addToAllowListExpectSuccess(alice, collectionId, bob.address);139140 const transferTx = contract.tx.createMultipleItems({value, gasLimit}, bob.address, collectionId, [141 {NFT: {/*const_data: '0x010203'*/}},142 {NFT: {/*const_data: '0x010204'*/}},143 {NFT: {/*const_data: '0x010205'*/}},144 ]);145 const events = await submitTransactionAsync(alice, transferTx);146 const result = getGenericResult(events);147 expect(result.success).to.be.true;148149 const tokensAfter: any = (await api.query.unique.nftItemList.entries(collectionId) as any)150 .map((kv: any) => kv[1].toJSON())151 .sort((a: any, b: any) => a.constData.localeCompare(b.constData));152 expect(tokensAfter).to.be.deep.equal([153 {154 Owner: bob.address,155 //ConstData: '0x010203',156 },157 {158 Owner: bob.address,159 //ConstData: '0x010204',160 },161 {162 Owner: bob.address,163 //ConstData: '0x010205',164 },165 ]);166 });167 });168169 it('Approve CE', async () => {170 await usingApi(async (api, privateKeyWrapper) => {171 const alice = privateKeyWrapper('//Alice');172 const bob = privateKeyWrapper('//Bob');173 const charlie = privateKeyWrapper('//Charlie');174175 const collectionId = await createCollectionExpectSuccess();176 const [contract] = await deployTransferContract(api, privateKeyWrapper);177 const tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT', contract.address.toString());178179 const transferTx = contract.tx.approve({value, gasLimit}, bob.address, collectionId, tokenId, 1);180 const events = await submitTransactionAsync(alice, transferTx);181 const result = getGenericResult(events);182 expect(result.success).to.be.true;183184 await transferFromExpectSuccess(collectionId, tokenId, bob, normalizeAccountId(contract.address.toString()), charlie, 1, 'NFT');185 });186 });187188 it('TransferFrom CE', async () => {189 await usingApi(async (api, privateKeyWrapper) => {190 const alice = privateKeyWrapper('//Alice');191 const bob = privateKeyWrapper('//Bob');192 const charlie = privateKeyWrapper('//Charlie');193194 const collectionId = await createCollectionExpectSuccess();195 const [contract] = await deployTransferContract(api, privateKeyWrapper);196 const tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT', bob.address);197 await approveExpectSuccess(collectionId, tokenId, bob, contract.address.toString(), 1);198199 const transferTx = contract.tx.transferFrom({value, gasLimit}, bob.address, charlie.address, collectionId, tokenId, 1);200 const events = await submitTransactionAsync(alice, transferTx);201 const result = getGenericResult(events);202 expect(result.success).to.be.true;203204 const token: any = (await api.query.unique.nftItemList(collectionId, tokenId) as any).unwrap();205 expect(token.owner.toString()).to.be.equal(charlie.address);206 });207 });208209 it('ToggleAllowList CE', async () => {210 await usingApi(async (api, privateKeyWrapper) => {211 const alice = privateKeyWrapper('//Alice');212 const bob = privateKeyWrapper('//Bob');213214 const collectionId = await createCollectionExpectSuccess();215 const [contract] = await deployTransferContract(api, privateKeyWrapper);216 const changeAdminTx = api.tx.unique.addCollectionAdmin(collectionId, contract.address);217 await submitTransactionAsync(alice, changeAdminTx);218219 expect(await isAllowlisted(api, collectionId, bob.address)).to.be.false;220221 {222 const transferTx = contract.tx.toggleAllowList({value, gasLimit}, collectionId, bob.address, true);223 const events = await submitTransactionAsync(alice, transferTx);224 const result = getGenericResult(events);225 expect(result.success).to.be.true;226227 expect(await isAllowlisted(api, collectionId, bob.address)).to.be.true;228 }229 {230 const transferTx = contract.tx.toggleAllowList({value, gasLimit}, collectionId, bob.address, false);231 const events = await submitTransactionAsync(alice, transferTx);232 const result = getGenericResult(events);233 expect(result.success).to.be.true;234235 expect(await isAllowlisted(api, collectionId, bob.address)).to.be.false;236 }237 });238 });239});1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617import chai from 'chai';18import chaiAsPromised from 'chai-as-promised';19import usingApi, {submitTransactionAsync} from './substrate/substrate-api';20import fs from 'fs';21import {Abi, ContractPromise as Contract} from '@polkadot/api-contract';22import {23 deployFlipper,24 getFlipValue,25 deployTransferContract,26} from './util/contracthelpers';2728import {29 addToAllowListExpectSuccess,30 approveExpectSuccess,31 createCollectionExpectSuccess,32 createItemExpectSuccess,33 enablePublicMintingExpectSuccess,34 enableAllowListExpectSuccess,35 getGenericResult,36 normalizeAccountId,37 isAllowlisted,38 transferFromExpectSuccess,39 getTokenOwner,40} from './util/helpers';414243chai.use(chaiAsPromised);44const expect = chai.expect;4546const value = 0;47const gasLimit = 9000n * 1000000n;48const marketContractAddress = '5CYN9j3YvRkqxewoxeSvRbhAym4465C57uMmX5j4yz99L5H6';4950// todo:playgrounds skipped ~ postponed51describe.skip('Contracts', () => {52 it('Can deploy smart contract Flipper, instantiate it and call it\'s get and flip messages.', async () => {53 await usingApi(async (api, privateKeyWrapper) => {54 const [contract, deployer] = await deployFlipper(api, privateKeyWrapper);55 const initialGetResponse = await getFlipValue(contract, deployer);5657 const bob = privateKeyWrapper('//Bob');58 const flip = contract.tx.flip({value, gasLimit});59 await submitTransactionAsync(bob, flip);6061 const afterFlipGetResponse = await getFlipValue(contract, deployer);62 expect(afterFlipGetResponse).not.to.be.eq(initialGetResponse, 'Flipping should change value.');63 });64 });6566 it('Can initialize contract instance', async () => {67 await usingApi(async (api) => {68 const metadata = JSON.parse(fs.readFileSync('./src/flipper/metadata.json').toString('utf-8'));69 const abi = new Abi(metadata);70 const newContractInstance = new Contract(api, abi, marketContractAddress);71 expect(newContractInstance).to.have.property('address');72 expect(newContractInstance.address.toString()).to.equal(marketContractAddress);73 });74 });75});7677describe.skip('Chain extensions', () => {78 it('Transfer CE', async () => {79 await usingApi(async (api, privateKeyWrapper) => {80 const alice = privateKeyWrapper('//Alice');81 const bob = privateKeyWrapper('//Bob');8283 // Prep work84 const collectionId = await createCollectionExpectSuccess();85 const tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT');86 const [contract] = await deployTransferContract(api, privateKeyWrapper);87 const changeAdminTx = api.tx.unique.addCollectionAdmin(collectionId, contract.address);88 await submitTransactionAsync(alice, changeAdminTx);8990 expect(await getTokenOwner(api, collectionId, tokenId)).to.be.deep.equal(normalizeAccountId(alice.address));9192 // Transfer93 const transferTx = contract.tx.transfer({value, gasLimit}, bob.address, collectionId, tokenId, 1);94 const events = await submitTransactionAsync(alice, transferTx);95 const result = getGenericResult(events);96 expect(result.success).to.be.true;9798 expect(await getTokenOwner(api, collectionId, tokenId)).to.be.deep.equal(normalizeAccountId(bob.address));99 });100 });101102 it('Mint CE', async () => {103 await usingApi(async (api, privateKeyWrapper) => {104 const alice = privateKeyWrapper('//Alice');105 const bob = privateKeyWrapper('//Bob');106107 const collectionId = await createCollectionExpectSuccess();108 const [contract] = await deployTransferContract(api, privateKeyWrapper);109 await enablePublicMintingExpectSuccess(alice, collectionId);110 await enableAllowListExpectSuccess(alice, collectionId);111 await addToAllowListExpectSuccess(alice, collectionId, contract.address);112 await addToAllowListExpectSuccess(alice, collectionId, bob.address);113114 const transferTx = contract.tx.createItem({value, gasLimit}, bob.address, collectionId, {Nft: {const_data: '0x010203'}});115 const events = await submitTransactionAsync(alice, transferTx);116 const result = getGenericResult(events);117 expect(result.success).to.be.true;118119 const tokensAfter = (await api.query.unique.nftItemList.entries(collectionId)).map((kv: any) => kv[1].toJSON());120 expect(tokensAfter).to.be.deep.equal([121 {122 owner: bob.address,123 constData: '0x010203',124 },125 ]);126 });127 });128129 it('Bulk mint CE', async () => {130 await usingApi(async (api, privateKeyWrapper) => {131 const alice = privateKeyWrapper('//Alice');132 const bob = privateKeyWrapper('//Bob');133134 const collectionId = await createCollectionExpectSuccess();135 const [contract] = await deployTransferContract(api, privateKeyWrapper);136 await enablePublicMintingExpectSuccess(alice, collectionId);137 await enableAllowListExpectSuccess(alice, collectionId);138 await addToAllowListExpectSuccess(alice, collectionId, contract.address);139 await addToAllowListExpectSuccess(alice, collectionId, bob.address);140141 const transferTx = contract.tx.createMultipleItems({value, gasLimit}, bob.address, collectionId, [142 {NFT: {/*const_data: '0x010203'*/}},143 {NFT: {/*const_data: '0x010204'*/}},144 {NFT: {/*const_data: '0x010205'*/}},145 ]);146 const events = await submitTransactionAsync(alice, transferTx);147 const result = getGenericResult(events);148 expect(result.success).to.be.true;149150 const tokensAfter: any = (await api.query.unique.nftItemList.entries(collectionId) as any)151 .map((kv: any) => kv[1].toJSON())152 .sort((a: any, b: any) => a.constData.localeCompare(b.constData));153 expect(tokensAfter).to.be.deep.equal([154 {155 Owner: bob.address,156 //ConstData: '0x010203',157 },158 {159 Owner: bob.address,160 //ConstData: '0x010204',161 },162 {163 Owner: bob.address,164 //ConstData: '0x010205',165 },166 ]);167 });168 });169170 it('Approve CE', async () => {171 await usingApi(async (api, privateKeyWrapper) => {172 const alice = privateKeyWrapper('//Alice');173 const bob = privateKeyWrapper('//Bob');174 const charlie = privateKeyWrapper('//Charlie');175176 const collectionId = await createCollectionExpectSuccess();177 const [contract] = await deployTransferContract(api, privateKeyWrapper);178 const tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT', contract.address.toString());179180 const transferTx = contract.tx.approve({value, gasLimit}, bob.address, collectionId, tokenId, 1);181 const events = await submitTransactionAsync(alice, transferTx);182 const result = getGenericResult(events);183 expect(result.success).to.be.true;184185 await transferFromExpectSuccess(collectionId, tokenId, bob, normalizeAccountId(contract.address.toString()), charlie, 1, 'NFT');186 });187 });188189 it('TransferFrom CE', async () => {190 await usingApi(async (api, privateKeyWrapper) => {191 const alice = privateKeyWrapper('//Alice');192 const bob = privateKeyWrapper('//Bob');193 const charlie = privateKeyWrapper('//Charlie');194195 const collectionId = await createCollectionExpectSuccess();196 const [contract] = await deployTransferContract(api, privateKeyWrapper);197 const tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT', bob.address);198 await approveExpectSuccess(collectionId, tokenId, bob, contract.address.toString(), 1);199200 const transferTx = contract.tx.transferFrom({value, gasLimit}, bob.address, charlie.address, collectionId, tokenId, 1);201 const events = await submitTransactionAsync(alice, transferTx);202 const result = getGenericResult(events);203 expect(result.success).to.be.true;204205 const token: any = (await api.query.unique.nftItemList(collectionId, tokenId) as any).unwrap();206 expect(token.owner.toString()).to.be.equal(charlie.address);207 });208 });209210 it('ToggleAllowList CE', async () => {211 await usingApi(async (api, privateKeyWrapper) => {212 const alice = privateKeyWrapper('//Alice');213 const bob = privateKeyWrapper('//Bob');214215 const collectionId = await createCollectionExpectSuccess();216 const [contract] = await deployTransferContract(api, privateKeyWrapper);217 const changeAdminTx = api.tx.unique.addCollectionAdmin(collectionId, contract.address);218 await submitTransactionAsync(alice, changeAdminTx);219220 expect(await isAllowlisted(api, collectionId, bob.address)).to.be.false;221222 {223 const transferTx = contract.tx.toggleAllowList({value, gasLimit}, collectionId, bob.address, true);224 const events = await submitTransactionAsync(alice, transferTx);225 const result = getGenericResult(events);226 expect(result.success).to.be.true;227228 expect(await isAllowlisted(api, collectionId, bob.address)).to.be.true;229 }230 {231 const transferTx = contract.tx.toggleAllowList({value, gasLimit}, collectionId, bob.address, false);232 const events = await submitTransactionAsync(alice, transferTx);233 const result = getGenericResult(events);234 expect(result.success).to.be.true;235236 expect(await isAllowlisted(api, collectionId, bob.address)).to.be.false;237 }238 });239 });240});tests/src/enableContractSponsoring.test.tsdiffbeforeafterboth--- a/tests/src/enableContractSponsoring.test.ts
+++ b/tests/src/enableContractSponsoring.test.ts
@@ -29,6 +29,7 @@
chai.use(chaiAsPromised);
const expect = chai.expect;
+// todo:playgrounds skipped ~ postponed
describe.skip('Integration Test enableContractSponsoring', () => {
it('ensure tx fee is paid from endowment', async () => {
await usingApi(async (api, privateKeyWrapper) => {
tests/src/evmCoder.test.tsdiffbeforeafterboth--- a/tests/src/evmCoder.test.ts
+++ b/tests/src/evmCoder.test.ts
@@ -14,13 +14,11 @@
// 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 {createEthAccountWithBalance, createNonfungibleCollection, GAS_ARGS, itWeb3} from './eth/util/helpers';
+import {itEth, expect, usingEthPlaygrounds} from './eth/util/playgrounds';
import * as solc from 'solc';
-import chai from 'chai';
-const expect = chai.expect;
-
async function compileTestContract(collectionAddress: string, contractAddress: string) {
const input = {
language: 'Solidity',
@@ -79,22 +77,30 @@
};
}
-async function deployTestContract(web3: Web3, owner: string, collectionAddress: string, contractAddress: string) {
+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_ARGS,
+ gas,
});
return await fractionalizerContract.deploy({data: compiled.object}).send({from: owner});
}
describe('Evm Coder tests', () => {
- itWeb3('Call non-existing function', async ({api, web3, privateKeyWrapper}) => {
- const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
- const {collectionIdAddress} = await createNonfungibleCollection(api, web3, owner);
- const contract = await deployTestContract(web3, owner, collectionIdAddress, '0x1bfed5D614b886b9Ab2eA4CBAc22A96B7EC29c9c');
- const testContract = await deployTestContract(web3, owner, collectionIdAddress, contract.options.address);
+ 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({
tests/src/setContractSponsoringRateLimit.test.tsdiffbeforeafterboth--- a/tests/src/setContractSponsoringRateLimit.test.ts
+++ b/tests/src/setContractSponsoringRateLimit.test.ts
@@ -25,7 +25,7 @@
setContractSponsoringRateLimitExpectSuccess,
} from './util/helpers';
-// todo:playgrounds postponed skipped test
+// todo:playgrounds skipped~postponed test
describe.skip('Integration Test setContractSponsoringRateLimit', () => {
it('ensure sponsored contract can\'t be called twice without pause for free', async () => {
await usingApi(async (api, privateKeyWrapper) => {
tests/src/util/playgrounds/index.tsdiffbeforeafterboth--- a/tests/src/util/playgrounds/index.ts
+++ b/tests/src/util/playgrounds/index.ts
@@ -13,14 +13,14 @@
chai.use(chaiAsPromised);
export const expect = chai.expect;
-export const usingPlaygrounds = async (code: (helper: DevUniqueHelper, privateKey: (seed: string) => IKeyringPair) => Promise<void>) => {
+export const usingPlaygrounds = async (code: (helper: DevUniqueHelper, privateKey: (seed: string) => IKeyringPair) => Promise<void>, url: string = config.substrateUrl) => {
const silentConsole = new SilentConsole();
silentConsole.enable();
const helper = new DevUniqueHelper(new SilentLogger());
try {
- await helper.connect(config.substrateUrl);
+ await helper.connect(url);
const ss58Format = helper.chain.getChainProperties().ss58Format;
const privateKey = (seed: string) => helper.util.fromSeed(seed, ss58Format);
await code(helper, privateKey);