git.delta.rocks / unique-network / refs/commits / 2b024070c7b0

difftreelog

tests: contract whitelist helpers

Yaroslav Bolyukin2021-02-08parent: #dddaa3d.patch.diff
in: master

1 file changed

modifiedtests/src/util/helpers.tsdiffbeforeafterboth
424 });424 });
425}425}
426
427export async function toggleContractWhitelistExpectSuccess(sender: IKeyringPair, contractAddress: AccountId | string, enabled: boolean) {
428 await usingApi(async (api) => {
429 const tx = api.tx.nft.toggleContractWhiteList(contractAddress, true);
430 const events = await submitTransactionAsync(sender, tx);
431 const result = getGenericResult(events);
432
433 expect(result.success).to.be.true;
434 });
435}
436
437export async function isWhitelistedInContract(contractAddress: AccountId | string, user: string) {
438 let whitelisted: boolean = false;
439 await usingApi(async (api) => {
440 whitelisted = (await api.query.nft.contractWhiteList(contractAddress, user)).toJSON() as boolean;
441 });
442 return whitelisted;
443}
444
445export async function addToContractWhiteListExpectSuccess(sender: IKeyringPair, contractAddress: AccountId | string, user: string) {
446 await usingApi(async (api) => {
447 const tx = api.tx.nft.addToContractWhiteList(contractAddress, user);
448 const events = await submitTransactionAsync(sender, tx);
449 const result = getGenericResult(events);
450
451 expect(result.success).to.be.true;
452 });
453}
454
455export async function removeFromContractWhiteListExpectSuccess(sender: IKeyringPair, contractAddress: AccountId | string, user: string) {
456 await usingApi(async (api) => {
457 const tx = api.tx.nft.removeFromContractWhiteList(contractAddress, user);
458 const events = await submitTransactionAsync(sender, tx);
459 const result = getGenericResult(events);
460
461 expect(result.success).to.be.true;
462 });
463}
464
465export async function removeFromContractWhiteListExpectFailure(sender: IKeyringPair, contractAddress: AccountId | string, user: string) {
466 await usingApi(async (api) => {
467 const tx = api.tx.nft.removeFromContractWhiteList(contractAddress, user);
468 const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;
469 const result = getGenericResult(events);
470
471 expect(result.success).to.be.false;
472 });
473}
426474
427export async function setVariableMetaDataExpectSuccess(sender: IKeyringPair, collectionId: number, itemId: number, data: number[]) {475export async function setVariableMetaDataExpectSuccess(sender: IKeyringPair, collectionId: number, itemId: number, data: number[]) {
428 await usingApi(async (api) => {476 await usingApi(async (api) => {