mirror of
https://github.com/IT4Change/gradido.git
synced 2026-02-06 01:46:07 +00:00
changed function names
This commit is contained in:
parent
df12b8f2bd
commit
824334b7e6
@ -1,6 +1,6 @@
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
||||
|
||||
import { sendDataMessage, getMessage } from '@/client/IotaClient'
|
||||
import { sendMessage, receiveMessage } from '@/client/IotaClient'
|
||||
|
||||
jest.mock('@iota/client', () => {
|
||||
const mockMessageSender = jest.fn().mockImplementation(() => {
|
||||
@ -50,12 +50,12 @@ jest.mock('@iota/client', () => {
|
||||
|
||||
describe('Iota Tests', () => {
|
||||
it('test mocked sendDataMessage', async () => {
|
||||
const result = await sendDataMessage('Test Message')
|
||||
const result = await sendMessage('Test Message')
|
||||
expect(result).toBe('5498130bc3918e1a7143969ce05805502417e3e1bd596d3c44d6a0adeea22710')
|
||||
})
|
||||
|
||||
it('should mock getMessage', async () => {
|
||||
const result = await getMessage(
|
||||
const result = await receiveMessage(
|
||||
'5498130bc3918e1a7143969ce05805502417e3e1bd596d3c44d6a0adeea22710',
|
||||
)
|
||||
expect(result).toMatchObject({
|
||||
|
||||
@ -11,7 +11,7 @@ const client = new ClientBuilder().node(CONFIG.IOTA_API_URL).build()
|
||||
* @param {string} message - the message as utf based string, will be converted to hex automatically from @iota/client
|
||||
* @return {Promise<MessageWrapper>} the iota message typed
|
||||
*/
|
||||
function sendDataMessage(message: string): Promise<MessageWrapper> {
|
||||
function sendMessage(message: string): Promise<MessageWrapper> {
|
||||
return client.message().index(CONFIG.IOTA_COMMUNITY_ALIAS).data(message).submit()
|
||||
}
|
||||
|
||||
@ -20,11 +20,11 @@ function sendDataMessage(message: string): Promise<MessageWrapper> {
|
||||
* @param {string} messageId - as hex string
|
||||
* @return {Promise<MessageWrapper>} the iota message typed
|
||||
*/
|
||||
function getMessage(messageId: string): Promise<MessageWrapper> {
|
||||
function receiveMessage(messageId: string): Promise<MessageWrapper> {
|
||||
return client.getMessage().data(messageId)
|
||||
}
|
||||
|
||||
export { sendDataMessage, getMessage }
|
||||
export { sendMessage, receiveMessage }
|
||||
|
||||
/**
|
||||
* example for message:
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
import { sendDataMessage, getMessage } from '@/client/IotaClient'
|
||||
import {
|
||||
sendMessage as iotaSendMessage,
|
||||
receiveMessage as iotaReceiveMessage,
|
||||
} from '@/client/IotaClient'
|
||||
import { CONFIG } from '@/config'
|
||||
import { IndexationPayload } from '@iota/client/lib/types'
|
||||
import { logger } from './server/logger'
|
||||
@ -10,12 +13,12 @@ async function main() {
|
||||
const messageHexString = Buffer.from(messageString, 'utf8').toString('hex')
|
||||
const indexHexString = Buffer.from(CONFIG.IOTA_COMMUNITY_ALIAS, 'utf8').toString('hex')
|
||||
|
||||
const iotaSendedMessage = await sendDataMessage(messageString)
|
||||
const iotaSendedMessage = await iotaSendMessage(messageString)
|
||||
|
||||
if (iotaSendedMessage && iotaSendedMessage.messageId) {
|
||||
logger.info('Hello World Message send to iota, get messageId: %s', iotaSendedMessage.messageId)
|
||||
|
||||
const iotaReceivedMessage = await getMessage(iotaSendedMessage.messageId)
|
||||
const iotaReceivedMessage = await iotaReceiveMessage(iotaSendedMessage.messageId)
|
||||
const indexationPayload = iotaReceivedMessage.message.payload as IndexationPayload
|
||||
if (
|
||||
indexationPayload.index.toString() === indexHexString ||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user