difftreelog
Merge pull request #85 from usetech-llc/feature/NFTPAR-244_setContractSponsoringRateLimit
in: master
Add tests for setContractSponsoringRateLimit
4 files changed
tests/package.jsondiffbeforeafterboth35 "testAddToContractWhiteList": "mocha --timeout 9999999 -r ts-node/register ./**/addToContractWhiteList.test.ts",35 "testAddToContractWhiteList": "mocha --timeout 9999999 -r ts-node/register ./**/addToContractWhiteList.test.ts",36 "testTransfer": "mocha --timeout 9999999 -r ts-node/register ./**/transfer.test.ts",36 "testTransfer": "mocha --timeout 9999999 -r ts-node/register ./**/transfer.test.ts",37 "testBurnItem": "mocha --timeout 9999999 -r ts-node/register ./**/burnItem.test.ts",37 "testBurnItem": "mocha --timeout 9999999 -r ts-node/register ./**/burnItem.test.ts",38 "testCreditFeesToTreasury": "mocha --timeout 9999999 -r ts-node/register ./**/creditFeesToTreasury.test.ts"38 "testCreditFeesToTreasury": "mocha --timeout 9999999 -r ts-node/register ./**/creditFeesToTreasury.test.ts",39 "testSetContractSponsoringRateLimit": "mocha --timeout 9999999 -r ts-node/register ./**/setContractSponsoringRateLimit.test.ts"39 },40 },40 "author": "",41 "author": "",41 "license": "SEE LICENSE IN ../LICENSE",42 "license": "SEE LICENSE IN ../LICENSE",tests/src/setContractSponsoringRateLimit.test.tsdiffbeforeafterbothno changes
tests/src/util/contracthelpers.tsdiffbeforeafterboth556import chai from "chai";6import chai from "chai";7import chaiAsPromised from 'chai-as-promised';7import chaiAsPromised from 'chai-as-promised';8import { submitTransactionAsync } from "../substrate/substrate-api";8import { submitTransactionAsync, submitTransactionExpectFailAsync } from "../substrate/substrate-api";9import fs from "fs";9import fs from "fs";10import { Abi, BlueprintPromise as Blueprint, CodePromise, ContractPromise as Contract } from "@polkadot/api-contract";10import { Abi, BlueprintPromise as Blueprint, CodePromise, ContractPromise as Contract } from "@polkadot/api-contract";11import { IKeyringPair } from "@polkadot/types/types";11import { IKeyringPair } from "@polkadot/types/types";14chai.use(chaiAsPromised);14chai.use(chaiAsPromised);15const expect = chai.expect;15const expect = chai.expect;16import { BigNumber } from 'bignumber.js';16import { BigNumber } from 'bignumber.js';17import { findUnusedAddress } from '../util/helpers';17import { findUnusedAddress, getGenericResult } from '../util/helpers';181819const value = 0;19const value = 0;20const gasLimit = '200000000000';20const gasLimit = '200000000000';92 return (result.result.asOk.data[0] == 0x00) ? false : true;92 return (result.result.asOk.data[0] == 0x00) ? false : true;93}93}9495export async function toggleFlipValueExpectSuccess(sender: IKeyringPair, contract: Contract) {96 const tx = contract.tx.flip(value, gasLimit);97 const events = await submitTransactionAsync(sender, tx);98 const result = getGenericResult(events);99100 expect(result.success).to.be.true;101}102103export async function toggleFlipValueExpectFailure(sender: IKeyringPair, contract: Contract) {104 const tx = contract.tx.flip(value, gasLimit);105 await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;106}9410795function instantiateTransferContract(alice: IKeyringPair, blueprint: Blueprint) : Promise<any> {108function instantiateTransferContract(alice: IKeyringPair, blueprint: Blueprint) : Promise<any> {96 return new Promise<any>(async (resolve, reject) => {109 return new Promise<any>(async (resolve, reject) => {tests/src/util/helpers.tsdiffbeforeafterboth384 });384 });385}385}386387export async function enableContractSponsoringExpectSuccess(sender: IKeyringPair, contractAddress: AccountId | string, enable: boolean) {388 await usingApi(async (api) => {389 const tx = api.tx.nft.enableContractSponsoring(contractAddress, enable);390 const events = await submitTransactionAsync(sender, tx);391 const result = getGenericResult(events);392393 expect(result.success).to.be.true;394 });395}396397export async function enableContractSponsoringExpectFailure(sender: IKeyringPair, contractAddress: AccountId | string, enable: boolean) {398 await usingApi(async (api) => {399 const tx = api.tx.nft.enableContractSponsoring(contractAddress, enable);400 const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;401 const result = getGenericResult(events);402403 expect(result.success).to.be.false;404 });405}406407export async function setContractSponsoringRateLimitExpectSuccess(sender: IKeyringPair, contractAddress: AccountId | string, rateLimit: number) {408 await usingApi(async (api) => {409 const tx = api.tx.nft.setContractSponsoringRateLimit(contractAddress, rateLimit);410 const events = await submitTransactionAsync(sender, tx);411 const result = getGenericResult(events);412413 expect(result.success).to.be.true;414 });415}416417export async function setContractSponsoringRateLimitExpectFailure(sender: IKeyringPair, contractAddress: AccountId | string, rateLimit: number) {418 await usingApi(async (api) => {419 const tx = api.tx.nft.setContractSponsoringRateLimit(contractAddress, rateLimit);420 const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;421 const result = getGenericResult(events);422423 expect(result.success).to.be.false;424 });425}386426387export async function setVariableMetaDataExpectSuccess(sender: IKeyringPair, collectionId: number, itemId: number, data: number[]) {427export async function setVariableMetaDataExpectSuccess(sender: IKeyringPair, collectionId: number, itemId: number, data: number[]) {388 await usingApi(async (api) => {428 await usingApi(async (api) => {