difftreelog
chore fix tests
in: master
12 files changed
tests/src/eth/collectionAdmin.test.tsdiffbeforeafterboth--- a/tests/src/eth/collectionAdmin.test.ts
+++ b/tests/src/eth/collectionAdmin.test.ts
@@ -30,10 +30,10 @@
itWeb3('Add admin by owner', async ({api, web3, privateKeyWrapper}) => {
const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
const collectionHelper = evmCollectionHelpers(web3, owner);
-
+
const result = await collectionHelper.methods
.createNonfungibleCollection('A', 'B', 'C')
- .send();
+ .send({value: Number(2n * UNIQUE)});
const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);
const newAdmin = createEthAccount(web3);
@@ -69,7 +69,7 @@
const result = await collectionHelper.methods
.createNonfungibleCollection('A', 'B', 'C')
- .send();
+ .send({value: Number(2n * UNIQUE)});
const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);
const newAdmin = createEthAccount(web3);
@@ -85,7 +85,7 @@
const result = await collectionHelper.methods
.createNonfungibleCollection('A', 'B', 'C')
- .send();
+ .send({value: Number(2n * UNIQUE)});
const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);
const admin = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
@@ -108,7 +108,7 @@
const result = await collectionHelper.methods
.createNonfungibleCollection('A', 'B', 'C')
- .send();
+ .send({value: Number(2n * UNIQUE)});
const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);
const notAdmin = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
@@ -174,7 +174,7 @@
const result = await collectionHelper.methods
.createNonfungibleCollection('A', 'B', 'C')
- .send();
+ .send({value: Number(2n * UNIQUE)});
const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);
const newAdmin = createEthAccount(web3);
@@ -222,7 +222,7 @@
const result = await collectionHelper.methods
.createNonfungibleCollection('A', 'B', 'C')
- .send();
+ .send({value: Number(2n * UNIQUE)});
const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);
const collectionEvm = evmCollection(web3, owner, collectionIdAddress);
@@ -249,7 +249,7 @@
const result = await collectionHelper.methods
.createNonfungibleCollection('A', 'B', 'C')
- .send();
+ .send({value: Number(2n * UNIQUE)});
const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);
const collectionEvm = evmCollection(web3, owner, collectionIdAddress);
@@ -326,7 +326,7 @@
const collectionHelper = evmCollectionHelpers(web3, owner);
const result = await collectionHelper.methods
.createNonfungibleCollection('A', 'B', 'C')
- .send();
+ .send({value: Number(2n * UNIQUE)});
const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);
const collectionEvm = evmCollection(web3, owner, collectionIdAddress);
@@ -342,7 +342,7 @@
const collectionHelper = evmCollectionHelpers(web3, owner);
const result = await collectionHelper.methods
.createNonfungibleCollection('A', 'B', 'C')
- .send();
+ .send({value: Number(2n * UNIQUE)});
const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);
const collectionEvm = evmCollection(web3, owner, collectionIdAddress);
@@ -357,7 +357,7 @@
const collectionHelper = evmCollectionHelpers(web3, owner);
const result = await collectionHelper.methods
.createNonfungibleCollection('A', 'B', 'C')
- .send();
+ .send({value: Number(2n * UNIQUE)});
const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);
const collectionEvm = evmCollection(web3, owner, collectionIdAddress);
tests/src/eth/collectionSponsoring.test.tsdiffbeforeafterboth--- a/tests/src/eth/collectionSponsoring.test.ts
+++ b/tests/src/eth/collectionSponsoring.test.ts
@@ -1,10 +1,8 @@
-import {addToAllowListExpectSuccess, bigIntToSub, confirmSponsorshipExpectSuccess, createCollectionExpectSuccess, enablePublicMintingExpectSuccess, getDetailedCollectionInfo, setCollectionSponsorExpectSuccess} from '../util/helpers';
+import {addToAllowListExpectSuccess, confirmSponsorshipExpectSuccess, createCollectionExpectSuccess, enablePublicMintingExpectSuccess, getDetailedCollectionInfo, setCollectionSponsorExpectSuccess, UNIQUE} from '../util/helpers';
import {itWeb3, createEthAccount, collectionIdToAddress, GAS_ARGS, normalizeEvents, createEthAccountWithBalance, evmCollectionHelpers, getCollectionAddressFromResult, evmCollection, ethBalanceViaSub} from './util/helpers';
import nonFungibleAbi from './nonFungibleAbi.json';
import {expect} from 'chai';
import {evmToAddress} from '@polkadot/util-crypto';
-import {submitTransactionAsync} from '../substrate/substrate-api';
-import getBalance from '../substrate/get-balance';
describe('evm collection sponsoring', () => {
itWeb3('sponsors mint transactions', async ({web3, privateKeyWrapper}) => {
@@ -64,7 +62,7 @@
itWeb3('Remove sponsor', async ({api, web3, privateKeyWrapper}) => {
const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
const collectionHelpers = evmCollectionHelpers(web3, owner);
- let result = await collectionHelpers.methods.createNonfungibleCollection('Sponsor collection', '1', '1').send();
+ let result = await collectionHelpers.methods.createNonfungibleCollection('Sponsor collection', '1', '1').send({value: Number(2n * UNIQUE)});
const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);
const sponsor = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
const collectionEvm = evmCollection(web3, owner, collectionIdAddress);
@@ -85,7 +83,7 @@
itWeb3('Sponsoring collection from evm address via access list', async ({api, web3, privateKeyWrapper}) => {
const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
const collectionHelpers = evmCollectionHelpers(web3, owner);
- let result = await collectionHelpers.methods.createNonfungibleCollection('Sponsor collection', '1', '1').send();
+ let result = await collectionHelpers.methods.createNonfungibleCollection('Sponsor collection', '1', '1').send({value: Number(2n * UNIQUE)});
const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);
const sponsor = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
const collectionEvm = evmCollection(web3, owner, collectionIdAddress);
@@ -210,7 +208,7 @@
itWeb3('Check that transaction via EVM spend money from sponsor address', async ({api, web3, privateKeyWrapper}) => {
const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
const collectionHelpers = evmCollectionHelpers(web3, owner);
- let result = await collectionHelpers.methods.createNonfungibleCollection('Sponsor collection', '1', '1').send();
+ let result = await collectionHelpers.methods.createNonfungibleCollection('Sponsor collection', '1', '1').send({value: Number(2n * UNIQUE)});
const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);
const sponsor = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
const collectionEvm = evmCollection(web3, owner, collectionIdAddress);
tests/src/eth/createNFTCollection.test.tsdiffbeforeafterboth--- a/tests/src/eth/createNFTCollection.test.ts
+++ b/tests/src/eth/createNFTCollection.test.ts
@@ -17,6 +17,7 @@
import {evmToAddress} from '@polkadot/util-crypto';
import {IKeyringPair} from '@polkadot/types/types';
import {expect, itEth, usingEthPlaygrounds} from './util/playgrounds';
+import {UNIQUE} from '../util/helpers';
describe('Create NFT collection from EVM', () => {
let donor: IKeyringPair;
@@ -64,7 +65,7 @@
await collectionHelpers.methods
.createNonfungibleCollection('A', 'A', 'A')
- .send();
+ .send({value: Number(2n * UNIQUE)});
expect(await collectionHelpers.methods
.isCollectionExist(expectedCollectionAddress)
@@ -164,7 +165,7 @@
await expect(collectionHelper.methods
.createNonfungibleCollection(collectionName, description, tokenPrefix)
- .call()).to.be.rejectedWith('name is too long. Max length is ' + MAX_NAME_LENGTH);
+ .call({value: Number(2n * UNIQUE)})).to.be.rejectedWith('name is too long. Max length is ' + MAX_NAME_LENGTH);
}
{
@@ -174,7 +175,7 @@
const tokenPrefix = 'A';
await expect(collectionHelper.methods
.createNonfungibleCollection(collectionName, description, tokenPrefix)
- .call()).to.be.rejectedWith('description is too long. Max length is ' + MAX_DESCRIPTION_LENGTH);
+ .call({value: Number(2n * UNIQUE)})).to.be.rejectedWith('description is too long. Max length is ' + MAX_DESCRIPTION_LENGTH);
}
{
const MAX_TOKEN_PREFIX_LENGTH = 16;
@@ -183,16 +184,16 @@
const tokenPrefix = 'A'.repeat(MAX_TOKEN_PREFIX_LENGTH + 1);
await expect(collectionHelper.methods
.createNonfungibleCollection(collectionName, description, tokenPrefix)
- .call()).to.be.rejectedWith('token_prefix is too long. Max length is ' + MAX_TOKEN_PREFIX_LENGTH);
+ .call({value: Number(2n * UNIQUE)})).to.be.rejectedWith('token_prefix is too long. Max length is ' + MAX_TOKEN_PREFIX_LENGTH);
}
});
itEth('(!negative test!) Create collection (no funds)', async ({helper}) => {
- const owner = helper.eth.createAccount();
+ const owner = await helper.eth.createAccountWithBalance(donor);
const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);
await expect(collectionHelper.methods
.createNonfungibleCollection('Peasantry', 'absolutely anything', 'CVE')
- .call()).to.be.rejectedWith('NotSufficientFounds');
+ .call({value: Number(1n * UNIQUE)})).to.be.rejectedWith('Sent amount not equals to collection creation price (2000000000000000000)');
});
itEth('(!negative test!) Check owner', async ({helper}) => {
tests/src/eth/createRFTCollection.test.tsdiffbeforeafterboth--- a/tests/src/eth/createRFTCollection.test.ts
+++ b/tests/src/eth/createRFTCollection.test.ts
@@ -18,6 +18,7 @@
import {IKeyringPair} from '@polkadot/types/types';
import {Pallets, requirePalletsOrSkip} from '../util/playgrounds';
import {expect, itEth, usingEthPlaygrounds} from './util/playgrounds';
+import {UNIQUE} from '../util/helpers';
describe('Create RFT collection from EVM', () => {
let donor: IKeyringPair;
@@ -65,7 +66,7 @@
await collectionHelpers.methods
.createRFTCollection('A', 'A', 'A')
- .send();
+ .send({value: Number(2n * UNIQUE)});
expect(await collectionHelpers.methods
.isCollectionExist(expectedCollectionAddress)
@@ -166,7 +167,7 @@
await expect(collectionHelper.methods
.createRFTCollection(collectionName, description, tokenPrefix)
- .call()).to.be.rejectedWith('name is too long. Max length is ' + MAX_NAME_LENGTH);
+ .call({value: Number(2n * UNIQUE)})).to.be.rejectedWith('name is too long. Max length is ' + MAX_NAME_LENGTH);
}
{
const MAX_DESCRIPTION_LENGTH = 256;
@@ -175,7 +176,7 @@
const tokenPrefix = 'A';
await expect(collectionHelper.methods
.createRFTCollection(collectionName, description, tokenPrefix)
- .call()).to.be.rejectedWith('description is too long. Max length is ' + MAX_DESCRIPTION_LENGTH);
+ .call({value: Number(2n * UNIQUE)})).to.be.rejectedWith('description is too long. Max length is ' + MAX_DESCRIPTION_LENGTH);
}
{
const MAX_TOKEN_PREFIX_LENGTH = 16;
@@ -184,16 +185,16 @@
const tokenPrefix = 'A'.repeat(MAX_TOKEN_PREFIX_LENGTH + 1);
await expect(collectionHelper.methods
.createRFTCollection(collectionName, description, tokenPrefix)
- .call()).to.be.rejectedWith('token_prefix is too long. Max length is ' + MAX_TOKEN_PREFIX_LENGTH);
+ .call({value: Number(2n * UNIQUE)})).to.be.rejectedWith('token_prefix is too long. Max length is ' + MAX_TOKEN_PREFIX_LENGTH);
}
});
itEth('(!negative test!) Create collection (no funds)', async ({helper}) => {
- const owner = helper.eth.createAccount();
+ const owner = await helper.eth.createAccountWithBalance(donor);
const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);
await expect(collectionHelper.methods
.createRFTCollection('Peasantry', 'absolutely anything', 'TWIW')
- .call()).to.be.rejectedWith('NotSufficientFounds');
+ .call({value: Number(1n * UNIQUE)})).to.be.rejectedWith('Sent amount not equals to collection creation price (2000000000000000000)');
});
itEth('(!negative test!) Check owner', async ({helper}) => {
tests/src/eth/fractionalizer/Fractionalizer.soldiffbeforeafterboth--- a/tests/src/eth/fractionalizer/Fractionalizer.sol
+++ b/tests/src/eth/fractionalizer/Fractionalizer.sol
@@ -81,10 +81,10 @@
string calldata _name,
string calldata _description,
string calldata _tokenPrefix
- ) external onlyOwner {
+ ) external payable onlyOwner {
require(rftCollection == address(0), "RFT collection is already set");
address collectionHelpers = 0x6C4E9fE1AE37a41E93CEE429e8E1881aBdcbb54F;
- rftCollection = CollectionHelpers(collectionHelpers).createRFTCollection(_name, _description, _tokenPrefix);
+ rftCollection = CollectionHelpers(collectionHelpers).createRFTCollection{value: msg.value}(_name, _description, _tokenPrefix);
emit RFTCollectionSet(rftCollection);
}
tests/src/eth/fractionalizer/fractionalizer.test.tsdiffbeforeafterboth--- a/tests/src/eth/fractionalizer/fractionalizer.test.ts
+++ b/tests/src/eth/fractionalizer/fractionalizer.test.ts
@@ -93,7 +93,7 @@
const fractionalizer = await deployFractionalizer(web3, owner);
const amount = 10n * UNIQUE;
await web3.eth.sendTransaction({from: owner, to: fractionalizer.options.address, value: `${amount}`, ...GAS_ARGS});
- const result = await fractionalizer.methods.createAndSetRFTCollection('A', 'B', 'C').send();
+ const result = await fractionalizer.methods.createAndSetRFTCollection('A', 'B', 'C').send({value: Number(2n * UNIQUE)});
const rftCollectionAddress = result.events.RFTCollectionSet.returnValues._collection;
return {fractionalizer, rftCollectionAddress};
}
@@ -141,9 +141,9 @@
const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
const fractionalizer = await deployFractionalizer(web3, owner);
const tx = api.tx.balances.transfer(evmToAddress(fractionalizer.options.address), 10n * UNIQUE);
- await submitTransactionAsync(alice, tx);
+ await executeTransaction(api, alice, tx);
- const result = await fractionalizer.methods.createAndSetRFTCollection('A', 'B', 'C').send({from: owner});
+ const result = await fractionalizer.methods.createAndSetRFTCollection('A', 'B', 'C').send({from: owner, value: Number(2n * UNIQUE)});
expect(result.events).to.be.like({
RFTCollectionSet: {},
});
@@ -295,7 +295,7 @@
const tx = api.tx.balances.transfer(evmToAddress(fractionalizer.options.address), 10n * UNIQUE);
await submitTransactionAsync(alice, tx);
- const result = await fractionalizer.methods.createAndSetRFTCollection('A', 'B', 'C').send({from: owner});
+ const result = await fractionalizer.methods.createAndSetRFTCollection('A', 'B', 'C').send({from: owner, value: Number(2n * UNIQUE)});
const collectionIdAddress = result.events.RFTCollectionSet.returnValues._collection;
await expect(fractionalizer.methods.setRFTCollection(collectionIdAddress).call())
tests/src/eth/nonFungible.test.tsdiffbeforeafterboth--- a/tests/src/eth/nonFungible.test.ts
+++ b/tests/src/eth/nonFungible.test.ts
@@ -17,6 +17,7 @@
import {itEth, usingEthPlaygrounds, expect, EthUniqueHelper} from './util/playgrounds';
import {IKeyringPair} from '@polkadot/types/types';
import {Contract} from 'web3-eth-contract';
+import {UNIQUE} from '../util/helpers';
describe('NFT: Information getting', () => {
let donor: IKeyringPair;
@@ -83,7 +84,7 @@
const receiver = helper.eth.createAccount();
const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);
- let result = await collectionHelper.methods.createERC721MetadataCompatibleCollection('Mint collection', 'a', 'b', tokenPrefix).send();
+ let result = await collectionHelper.methods.createERC721MetadataCompatibleCollection('Mint collection', 'a', 'b', tokenPrefix).send({value: Number(2n * UNIQUE)});
const collectionAddress = helper.ethAddress.normalizeAddress(result.events.CollectionCreated.returnValues.collectionId);
const contract = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);
tests/src/eth/proxy/nonFungibleProxy.test.tsdiffbeforeafterboth--- a/tests/src/eth/proxy/nonFungibleProxy.test.ts
+++ b/tests/src/eth/proxy/nonFungibleProxy.test.ts
@@ -14,7 +14,7 @@
// 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 {createCollectionExpectSuccess, createItemExpectSuccess} from '../../util/helpers';
+import {createCollectionExpectSuccess, createItemExpectSuccess, UNIQUE} from '../../util/helpers';
import {collectionIdToAddress, createEthAccount, createEthAccountWithBalance, evmCollection, evmCollectionHelpers, GAS_ARGS, getCollectionAddressFromResult, itWeb3, normalizeEvents} from '../util/helpers';
import nonFungibleAbi from '../nonFungibleAbi.json';
import {expect} from 'chai';
@@ -93,7 +93,7 @@
const collectionHelper = evmCollectionHelpers(web3, owner);
const result = await collectionHelper.methods
.createNonfungibleCollection('A', 'A', 'A')
- .send();
+ .send({value: Number(2n * UNIQUE)});
const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);
const caller = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
const receiver = createEthAccount(web3);
tests/src/eth/reFungibleToken.test.tsdiffbeforeafterboth--- a/tests/src/eth/reFungibleToken.test.ts
+++ b/tests/src/eth/reFungibleToken.test.ts
@@ -18,6 +18,7 @@
import {EthUniqueHelper, expect, itEth, usingEthPlaygrounds} from './util/playgrounds';
import {IKeyringPair} from '@polkadot/types/types';
import {Contract} from 'web3-eth-contract';
+import {UNIQUE} from '../util/helpers';
describe('Refungible token: Information getting', () => {
let donor: IKeyringPair;
@@ -80,7 +81,7 @@
const receiver = helper.eth.createAccount();
const collectionHelper = helper.ethNativeContract.collectionHelpers(owner);
- let result = await collectionHelper.methods.createERC721MetadataCompatibleCollection('Mint collection', 'a', 'b', tokenPrefix).send();
+ let result = await collectionHelper.methods.createERC721MetadataCompatibleCollection('Mint collection', 'a', 'b', tokenPrefix).send({value: Number(2n * UNIQUE)});
const collectionAddress = helper.ethAddress.normalizeAddress(result.events.CollectionCreated.returnValues.collectionId);
const contract = helper.ethNativeContract.collection(collectionAddress, 'rft', owner);
tests/src/eth/util/helpers.tsdiffbeforeafterboth--- a/tests/src/eth/util/helpers.ts
+++ b/tests/src/eth/util/helpers.ts
@@ -145,7 +145,7 @@
const collectionHelper = evmCollectionHelpers(web3, owner);
const result = await collectionHelper.methods
.createRFTCollection('A', 'B', 'C')
- .send();
+ .send({value: Number(2n * UNIQUE)});
return await getCollectionAddressFromResult(api, result);
}
@@ -154,7 +154,7 @@
const collectionHelper = evmCollectionHelpers(web3, owner);
const result = await collectionHelper.methods
.createNonfungibleCollection('A', 'B', 'C')
- .send();
+ .send({value: Number(2n * UNIQUE)});
return await getCollectionAddressFromResult(api, result);
}
tests/src/eth/util/playgrounds/unique.dev.tsdiffbeforeafterboth170 }170 }171171172 async createNonfungibleCollection(signer: string, name: string, description: string, tokenPrefix: string): Promise<{collectionId: number, collectionAddress: string}> {172 async createNonfungibleCollection(signer: string, name: string, description: string, tokenPrefix: string): Promise<{collectionId: number, collectionAddress: string}> {173 const collectionCreationPrice = this.helper.balance.getCollectionCreationPrice();173 const collectionHelper = this.helper.ethNativeContract.collectionHelpers(signer);174 const collectionHelper = this.helper.ethNativeContract.collectionHelpers(signer);174175 175 const result = await collectionHelper.methods.createNonfungibleCollection(name, description, tokenPrefix).send();176 const result = await collectionHelper.methods.createNonfungibleCollection(name, description, tokenPrefix).send({value: Number(collectionCreationPrice)});176177177 const collectionAddress = this.helper.ethAddress.normalizeAddress(result.events.CollectionCreated.returnValues.collectionId);178 const collectionAddress = this.helper.ethAddress.normalizeAddress(result.events.CollectionCreated.returnValues.collectionId);178 const collectionId = this.helper.ethAddress.extractCollectionId(collectionAddress);179 const collectionId = this.helper.ethAddress.extractCollectionId(collectionAddress);181 }182 }182183183 async createRefungibleCollection(signer: string, name: string, description: string, tokenPrefix: string): Promise<{collectionId: number, collectionAddress: string}> {184 async createRefungibleCollection(signer: string, name: string, description: string, tokenPrefix: string): Promise<{collectionId: number, collectionAddress: string}> {185 const collectionCreationPrice = this.helper.balance.getCollectionCreationPrice();184 const collectionHelper = this.helper.ethNativeContract.collectionHelpers(signer);186 const collectionHelper = this.helper.ethNativeContract.collectionHelpers(signer);185187 186 const result = await collectionHelper.methods.createRFTCollection(name, description, tokenPrefix).send();188 const result = await collectionHelper.methods.createRFTCollection(name, description, tokenPrefix).send({value: Number(collectionCreationPrice)});187189188 const collectionAddress = this.helper.ethAddress.normalizeAddress(result.events.CollectionCreated.returnValues.collectionId);190 const collectionAddress = this.helper.ethAddress.normalizeAddress(result.events.CollectionCreated.returnValues.collectionId);189 const collectionId = this.helper.ethAddress.extractCollectionId(collectionAddress);191 const collectionId = this.helper.ethAddress.extractCollectionId(collectionAddress);tests/src/util/playgrounds/unique.tsdiffbeforeafterboth--- a/tests/src/util/playgrounds/unique.ts
+++ b/tests/src/util/playgrounds/unique.ts
@@ -2034,6 +2034,9 @@
class BalanceGroup extends HelperGroup {
+ getCollectionCreationPrice(): bigint {
+ return 2n * this.helper.balance.getOneTokenNominal();
+ }
/**
* Representation of the native token in the smallest unit - one OPAL (OPL), QUARTZ (QTZ), or UNIQUE (UNQ).
* @example getOneTokenNominal()