fix tests

This commit is contained in:
einhornimmond 2026-03-03 10:07:10 +01:00
parent e9350e82ed
commit bf438b8b36
7 changed files with 29 additions and 10 deletions

View File

@ -48,7 +48,7 @@ describe('transactionIdentifierSchema ', () => {
transactionId: 1,
hieroTransactionId: '0.0.261-1755348116-1281621',
}),
).toThrowError(new Error('Invalid key: Expected "topic" but received undefined'))
).toThrowError(new Error('Invalid key: Expected "communityId" but received undefined'))
})
it('invalid, transactionNr and iotaMessageId set', () => {
expect(() =>

View File

@ -33,6 +33,7 @@ mock.module('../../config', () => ({
}))
const topicId = '0.0.21732'
const communityId = '1e88a0f4-d4fc-4cae-a7e8-a88e613ce324'
const userUuid = 'aa25cf6f-2879-4745-b2ea-6d3c37fb44b0'
afterAll(() => {
@ -45,7 +46,7 @@ describe('KeyPairCalculation', () => {
})
it('community key pair', async () => {
const identifier = new KeyPairIdentifierLogic(
v.parse(identifierKeyPairSchema, { communityTopicId: topicId }),
v.parse(identifierKeyPairSchema, { communityId, communityTopicId: topicId }),
)
const keyPair = await ResolveKeyPair(identifier)
expect(keyPair.getPublicKey()?.convertToHex()).toBe(
@ -55,6 +56,7 @@ describe('KeyPairCalculation', () => {
it('user key pair', async () => {
const identifier = new KeyPairIdentifierLogic(
v.parse(identifierKeyPairSchema, {
communityId,
communityTopicId: topicId,
account: { userUuid },
}),
@ -70,6 +72,7 @@ describe('KeyPairCalculation', () => {
it('account key pair', async () => {
const identifier = new KeyPairIdentifierLogic(
v.parse(identifierKeyPairSchema, {
communityId,
communityTopicId: topicId,
account: { userUuid, accountNr: 1 },
}),

View File

@ -4,11 +4,14 @@ import * as v from 'valibot'
import { transactionSchema } from '../../schemas/transaction.schema'
import { hieroIdSchema } from '../../schemas/typeGuard.schema'
import { RegisterAddressTransactionRole } from './RegisterAddressTransaction.role'
import { InMemoryBlockchainProvider } from 'gradido-blockchain-js'
const userUuid = '408780b2-59b3-402a-94be-56a4f4f4e8ec'
const communityId = '1e88a0f4-d4fc-4cae-a7e8-a88e613ce324'
const transaction = {
user: {
communityTopicId: '0.0.21732',
communityId,
account: {
userUuid,
accountNr: 0,
@ -18,6 +21,8 @@ const transaction = {
accountType: 'COMMUNITY_HUMAN',
createdAt: '2022-01-01T00:00:00.000Z',
}
// create blockchain in native module
InMemoryBlockchainProvider.getInstance().getBlockchain(communityId)
describe('RegisterAddressTransaction.role', () => {
it('get correct prepared builder', async () => {

View File

@ -35,7 +35,7 @@ const transactionLinkCode = (date: Date): string => {
let topic: HieroId
const topicString = '0.0.261'
let communityUuid: Uuidv4
const communityUuidString = '123e4567-e89b-12d3-a456-426614174000'
const communityUuidString = 'fcd48487-6d31-4f4c-be9b-b3c8ca853912'
beforeAll(() => {
topic = v.parse(hieroIdSchema, topicString)

View File

@ -2,7 +2,7 @@
import { describe, expect, it } from 'bun:test'
import { TypeCompiler } from '@sinclair/typebox/compiler'
import { Static, TypeBoxFromValibot } from '@sinclair/typemap'
import { AddressType_COMMUNITY_AUF } from 'gradido-blockchain-js'
import { AddressType_COMMUNITY_AUF, InMemoryBlockchainProvider } from 'gradido-blockchain-js'
import * as v from 'valibot'
import { AccountType } from '../data/AccountType.enum'
import {
@ -96,9 +96,15 @@ describe('basic.schema', () => {
})
it('confirmedTransactionSchema', () => {
// create blockchain in native module
const communityId = 'fcd48487-6d31-4f4c-be9b-b3c8ca853912'
InMemoryBlockchainProvider.getInstance().getBlockchain(communityId)
const confirmedTransaction = v.parse(
confirmedTransactionSchema,
'CAcS5AEKZgpkCiCBZwMplGmI7fRR9MQkaR2Dz1qQQ5BCiC1btyJD71Ue9BJABODQ9sS70th9yHn8X3K+SNv2gsiIdX/V09baCvQCb+yEj2Dd/fzShIYqf3pooIMwJ01BkDJdNGBZs5MDzEAkChJ6ChkIAhIVRGFua2UgZnVlciBkZWluIFNlaW4hEggIgMy5/wUQABoDMy41IAAyTAooCiDbDtYSWhTwMKvtG/yDHgohjPn6v87n7NWBwMDniPAXxxCUmD0aABIgJE0o18xb6P6PsNjh0bkN52AzhggteTzoh09jV+blMq0aCAjC8rn/BRAAIgMzLjUqICiljeEjGHifWe4VNzoe+DN9oOLNZvJmv3VlkP+1RH7MMiAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADomCiDbDtYSWhTwMKvtG/yDHgohjPn6v87n7NWBwMDniPAXxxDAhD06JwogJE0o18xb6P6PsNjh0bkN52AzhggteTzoh09jV+blMq0Q65SlBA==',
{
base64: 'CAcS4AEKZgpkCiCBZwMplGmI7fRR9MQkaR2Dz1qQQ5BCiC1btyJD71Ue9BJABODQ9sS70th9yHn8X3K+SNv2gsiIdX/V09baCvQCb+zo7nEQgCUXOEe/tN7YaRppwt6TDcXBPxkwnw4gfpCODhJ0ChkIAhIVRGFua2UgZnVlciBkZWluIFNlaW4hEgYIgMy5/wUaAzMuNTJKCiYKINsO1hJaFPAwq+0b/IMeCiGM+fq/zufs1YHAwOeI8BfHEJSYPRIgJE0o18xb6P6PsNjh0bkN52AzhggteTzoh09jV+blMq0aABoGCMLyuf8FIgMzLjcqIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMhUIAhoRCgkIqemnUhD+4wESBBj8sgc6Jgog2w7WEloU8DCr7Rv8gx4KIYz5+r/O5+zVgcDA54jwF8cQwIQ9OicKICRNKNfMW+j+j7DY4dG5DedgM4YILXk86IdPY1fm5TKtEOuUpQRAAg==',
communityId,
},
)
expect(confirmedTransaction.getId()).toBe(7)
expect(confirmedTransaction.getConfirmedAt().getSeconds()).toBe(1609464130)

View File

@ -1,7 +1,7 @@
import { describe, expect, it } from 'bun:test'
import { v4 as uuidv4 } from 'uuid'
import * as v from 'valibot'
import { memoSchema, uuidv4Schema } from './typeGuard.schema'
import { memoSchema, MEMO_MAX_CHARS, MEMO_MIN_CHARS, uuidv4Schema } from './typeGuard.schema'
describe('typeGuard.schema', () => {
describe('Uuidv4', () => {
@ -20,18 +20,18 @@ describe('typeGuard.schema', () => {
expect(memoValueParsed.toString()).toBe(memoValue)
})
it('max length', () => {
const memoValue = 's'.repeat(255)
const memoValue = 's'.repeat(MEMO_MAX_CHARS)
const memoValueParsed = v.parse(memoSchema, memoValue)
expect(memoValueParsed.toString()).toBe(memoValue)
})
it('to short', () => {
const memoValue = 'memo'
expect(() => v.parse(memoSchema, memoValue)).toThrow(new Error('expect string length >= 5'))
expect(() => v.parse(memoSchema, memoValue)).toThrow(new Error(`expect string length >= ${MEMO_MIN_CHARS}`))
})
it('to long', () => {
const memoValue = 's'.repeat(256)
const memoValue = 's'.repeat(MEMO_MAX_CHARS + 1)
expect(() => v.parse(memoSchema, memoValue)).toThrow(
new Error('expect string length <= 255'),
new Error(`expect string length <= ${MEMO_MAX_CHARS}`),
)
})
})

View File

@ -5,6 +5,7 @@ import * as v from 'valibot'
import { KeyPairCacheManager } from '../cache/KeyPairCacheManager'
import { HieroId, hieroIdSchema } from '../schemas/typeGuard.schema'
import { appRoutes } from '.'
import { InMemoryBlockchainProvider } from 'gradido-blockchain-js'
const userUuid = '408780b2-59b3-402a-94be-56a4f4f4e8ec'
@ -55,9 +56,13 @@ beforeAll(() => {
describe('Server', () => {
it('send register address transaction', async () => {
// create blockchain in native module
const communityId = '1e88a0f4-d4fc-4cae-a7e8-a88e613ce324'
InMemoryBlockchainProvider.getInstance().getBlockchain(communityId)
const transaction = {
user: {
communityTopicId: '0.0.21732',
communityId,
account: {
userUuid,
accountNr: 0,