From 47ea0fdb9b2a0ae4f2a9ac51c8e5745f711df1cf Mon Sep 17 00:00:00 2001 From: Claus-Peter Huebner Date: Fri, 1 Sep 2023 01:41:38 +0200 Subject: [PATCH] activate recipientCommunityIdentifier for sendCoins api --- .../src/graphql/arg/TransactionSendArgs.ts | 3 -- .../resolver/TransactionResolver.test.ts | 28 +++++++++++++++++++ .../src/graphql/resolver/semaphore.test.ts | 15 ++++++++++ 3 files changed, 43 insertions(+), 3 deletions(-) diff --git a/backend/src/graphql/arg/TransactionSendArgs.ts b/backend/src/graphql/arg/TransactionSendArgs.ts index 9d6842bdc..48827be8d 100644 --- a/backend/src/graphql/arg/TransactionSendArgs.ts +++ b/backend/src/graphql/arg/TransactionSendArgs.ts @@ -23,7 +23,4 @@ export class TransactionSendArgs { @MaxLength(MEMO_MAX_CHARS) @MinLength(MEMO_MIN_CHARS) memo: string - - @Field(() => String) - communityIdentifier: string } diff --git a/backend/src/graphql/resolver/TransactionResolver.test.ts b/backend/src/graphql/resolver/TransactionResolver.test.ts index bd7d0f2a8..0f4171dd4 100644 --- a/backend/src/graphql/resolver/TransactionResolver.test.ts +++ b/backend/src/graphql/resolver/TransactionResolver.test.ts @@ -2,6 +2,7 @@ /* eslint-disable @typescript-eslint/no-unsafe-member-access */ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ import { Connection, In } from '@dbTools/typeorm' +import { Community as DbCommunity } from '@entity/Community' import { DltTransaction } from '@entity/DltTransaction' import { Event as DbEvent } from '@entity/Event' import { Transaction } from '@entity/Transaction' @@ -56,12 +57,24 @@ let user: User[] let bob: User let peter: User +let homeCom: DbCommunity + describe('send coins', () => { beforeAll(async () => { peter = await userFactory(testEnv, peterLustig) bob = await userFactory(testEnv, bobBaumeister) await userFactory(testEnv, stephenHawking) await userFactory(testEnv, garrickOllivander) + homeCom = DbCommunity.create() + homeCom.communityUuid = 'homeCom-UUID' + homeCom.creationDate = new Date('2000-01-01') + homeCom.description = 'homeCom description' + homeCom.foreign = false + homeCom.name = 'homeCom name' + homeCom.privateKey = Buffer.from('homeCom privateKey') + homeCom.publicKey = Buffer.from('homeCom publicKey') + homeCom.url = 'homeCom url' + homeCom = await DbCommunity.save(homeCom) bobData = { email: 'bob@baumeister.de', @@ -91,6 +104,7 @@ describe('send coins', () => { await mutate({ mutation: sendCoins, variables: { + recipientCommunityIdentifier: homeCom.communityUuid, recipientIdentifier: 'wrong@email.com', amount: 100, memo: 'test test', @@ -119,6 +133,7 @@ describe('send coins', () => { await mutate({ mutation: sendCoins, variables: { + recipientCommunityIdentifier: homeCom.communityUuid, recipientIdentifier: 'stephen@hawking.uk', amount: 100, memo: 'test test', @@ -148,6 +163,7 @@ describe('send coins', () => { await mutate({ mutation: sendCoins, variables: { + recipientCommunityIdentifier: homeCom.communityUuid, recipientIdentifier: 'garrick@ollivander.com', amount: 100, memo: 'test test', @@ -184,6 +200,7 @@ describe('send coins', () => { await mutate({ mutation: sendCoins, variables: { + recipientCommunityIdentifier: homeCom.communityUuid, recipientIdentifier: 'bob@baumeister.de', amount: 100, memo: 'test test', @@ -207,6 +224,7 @@ describe('send coins', () => { const { errors: errorObjects } = await mutate({ mutation: sendCoins, variables: { + recipientCommunityIdentifier: homeCom.communityUuid, recipientIdentifier: 'peter@lustig.de', amount: 100, memo: 'Test', @@ -238,6 +256,7 @@ describe('send coins', () => { const { errors: errorObjects } = await mutate({ mutation: sendCoins, variables: { + recipientCommunityIdentifier: homeCom.communityUuid, recipientIdentifier: 'peter@lustig.de', amount: 100, memo: 'test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test t', @@ -270,6 +289,7 @@ describe('send coins', () => { await mutate({ mutation: sendCoins, variables: { + recipientCommunityIdentifier: homeCom.communityUuid, recipientIdentifier: 'peter@lustig.de', amount: 100, memo: 'testing', @@ -319,6 +339,7 @@ describe('send coins', () => { const { errors: errorObjects } = await mutate({ mutation: sendCoins, variables: { + recipientCommunityIdentifier: homeCom.communityUuid, recipientIdentifier: 'peter@lustig.de', amount: -50, memo: 'testing negative', @@ -350,6 +371,7 @@ describe('send coins', () => { await mutate({ mutation: sendCoins, variables: { + recipientCommunityIdentifier: homeCom.communityUuid, recipientIdentifier: 'peter@lustig.de', amount: 50, memo: 'unrepeatable memo', @@ -456,6 +478,7 @@ describe('send coins', () => { mutate({ mutation: sendCoins, variables: { + recipientCommunityIdentifier: homeCom.communityUuid, recipientIdentifier: peter?.gradidoID, amount: 10, memo: 'send via gradido ID', @@ -496,6 +519,7 @@ describe('send coins', () => { mutate({ mutation: sendCoins, variables: { + recipientCommunityIdentifier: homeCom.communityUuid, recipientIdentifier: 'bob', amount: 6.66, memo: 'send via alias', @@ -564,6 +588,7 @@ describe('send coins', () => { mutate({ mutation: sendCoins, variables: { + recipientCommunityIdentifier: homeCom.communityUuid, recipientIdentifier: 'peter@lustig.de', amount: 10, memo: 'first transaction', @@ -580,6 +605,7 @@ describe('send coins', () => { mutate({ mutation: sendCoins, variables: { + recipientCommunityIdentifier: homeCom.communityUuid, recipientIdentifier: 'peter@lustig.de', amount: 20, memo: 'second transaction', @@ -596,6 +622,7 @@ describe('send coins', () => { mutate({ mutation: sendCoins, variables: { + recipientCommunityIdentifier: homeCom.communityUuid, recipientIdentifier: 'peter@lustig.de', amount: 30, memo: 'third transaction', @@ -612,6 +639,7 @@ describe('send coins', () => { mutate({ mutation: sendCoins, variables: { + recipientCommunityIdentifier: homeCom.communityUuid, recipientIdentifier: 'peter@lustig.de', amount: 40, memo: 'fourth transaction', diff --git a/backend/src/graphql/resolver/semaphore.test.ts b/backend/src/graphql/resolver/semaphore.test.ts index 37331d832..dc6c5b364 100644 --- a/backend/src/graphql/resolver/semaphore.test.ts +++ b/backend/src/graphql/resolver/semaphore.test.ts @@ -2,6 +2,7 @@ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ /* eslint-disable @typescript-eslint/restrict-template-expressions */ import { Connection } from '@dbTools/typeorm' +import { Community as DbCommunity } from '@entity/Community' import { ApolloServerTestClient } from 'apollo-server-testing' import { Decimal } from 'decimal.js-light' import { GraphQLError } from 'graphql' @@ -48,9 +49,21 @@ describe('semaphore', () => { let bibisTransactionLinkCode = '' let bibisOpenContributionId = -1 let bobsOpenContributionId = -1 + let homeCom: DbCommunity beforeAll(async () => { const now = new Date() + homeCom = DbCommunity.create() + homeCom.communityUuid = 'homeCom-UUID' + homeCom.creationDate = new Date('2000-01-01') + homeCom.description = 'homeCom description' + homeCom.foreign = false + homeCom.name = 'homeCom name' + homeCom.privateKey = Buffer.from('homeCom privateKey') + homeCom.publicKey = Buffer.from('homeCom publicKey') + homeCom.url = 'homeCom url' + homeCom = await DbCommunity.save(homeCom) + await userFactory(testEnv, bibiBloxberg) await userFactory(testEnv, peterLustig) await userFactory(testEnv, bobBaumeister) @@ -157,6 +170,7 @@ describe('semaphore', () => { const bibisTransaction = mutate({ mutation: sendCoins, variables: { + recipientCommunityIdentifier: homeCom.communityUuid, recipientIdentifier: 'bob@baumeister.de', amount: '50', memo: 'Das ist für dich, Bob', @@ -177,6 +191,7 @@ describe('semaphore', () => { const bobsTransaction = mutate({ mutation: sendCoins, variables: { + recipientCommunityIdentifier: homeCom.communityUuid, recipientIdentifier: 'bibi@bloxberg.de', amount: '50', memo: 'Das ist für dich, Bibi',