mirror of
https://github.com/IT4Change/gradido.git
synced 2026-02-06 09:56:05 +00:00
linting
This commit is contained in:
parent
7b5ab0c1d6
commit
ca2e1ccf52
@ -79,14 +79,10 @@ export class DltConnectorClient {
|
||||
* and update dltTransactionId of transaction in db with iota message id
|
||||
*/
|
||||
public async transmitTransaction(transaction?: DbTransaction | null): Promise<string> {
|
||||
console.log('transmitTransaction tx=', transaction)
|
||||
if (transaction) {
|
||||
const typeString = getTransactionTypeString(transaction.typeId)
|
||||
const secondsSinceEpoch = Math.round(transaction.balanceDate.getTime() / 1000)
|
||||
const amountString = transaction.amount.toString()
|
||||
console.log('typeString=', typeString)
|
||||
console.log('secondsSinceEpoch=', secondsSinceEpoch)
|
||||
console.log('amountString=', amountString)
|
||||
try {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
||||
const { data } = await this.client.rawRequest(sendTransaction, {
|
||||
@ -96,11 +92,9 @@ export class DltConnectorClient {
|
||||
createdAt: secondsSinceEpoch,
|
||||
},
|
||||
})
|
||||
console.log('result data=', data)
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access
|
||||
return data.sendTransaction.dltTransactionIdHex
|
||||
} catch (e) {
|
||||
console.log('error return result ', e)
|
||||
throw new LogError('Error send sending transaction to dlt-connector: ', e)
|
||||
}
|
||||
} else {
|
||||
|
||||
@ -206,6 +206,7 @@ async function createTxReceive2FromSend1(verified: boolean): Promise<Transaction
|
||||
return tx
|
||||
}
|
||||
|
||||
/*
|
||||
async function createTxSend2ToReceive3(verified: boolean): Promise<Transaction> {
|
||||
let tx = Transaction.create()
|
||||
tx.amount = new Decimal(200)
|
||||
@ -313,6 +314,7 @@ async function createTxReceive1FromSend3(verified: boolean): Promise<Transaction
|
||||
}
|
||||
return tx
|
||||
}
|
||||
*/
|
||||
|
||||
let con: Connection
|
||||
let testEnv: {
|
||||
@ -338,10 +340,10 @@ describe('create and send Transactions to DltConnector', () => {
|
||||
let txCREATION3: Transaction
|
||||
let txSEND1to2: Transaction
|
||||
let txRECEIVE2From1: Transaction
|
||||
let txSEND2To3: Transaction
|
||||
let txRECEIVE3From2: Transaction
|
||||
let txSEND3To1: Transaction
|
||||
let txRECEIVE1From3: Transaction
|
||||
// let txSEND2To3: Transaction
|
||||
// let txRECEIVE3From2: Transaction
|
||||
// let txSEND3To1: Transaction
|
||||
// let txRECEIVE1From3: Transaction
|
||||
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks()
|
||||
@ -407,7 +409,6 @@ describe('create and send Transactions to DltConnector', () => {
|
||||
})
|
||||
|
||||
describe('with 3 creations and active dlt-connector', () => {
|
||||
|
||||
it('found 3 dlt-transactions', async () => {
|
||||
txCREATION1 = await createTxCREATION1(false)
|
||||
txCREATION2 = await createTxCREATION2(false)
|
||||
@ -511,10 +512,12 @@ describe('create and send Transactions to DltConnector', () => {
|
||||
expect(logger.info).toBeCalledWith('sendTransactionsToDltConnector...')
|
||||
|
||||
// Find the previous created transactions of sendCoin mutation
|
||||
/*
|
||||
const transactions = await Transaction.find({
|
||||
// where: { memo: 'unrepeatable memo' },
|
||||
order: { balanceDate: 'ASC', id: 'ASC' },
|
||||
})
|
||||
*/
|
||||
|
||||
const dltTransactions = await DltTransaction.find({
|
||||
// where: { transactionId: In([transaction[0].id, transaction[1].id]) },
|
||||
|
||||
@ -17,23 +17,18 @@ export async function sendTransactionsToDltConnector(): Promise<void> {
|
||||
await createDltTransactions()
|
||||
const dltConnector = DltConnectorClient.getInstance()
|
||||
if (dltConnector) {
|
||||
console.log('aktiv dltConnector...')
|
||||
logger.debug('with sending to DltConnector...')
|
||||
const dltTransactions = await DltTransaction.find({
|
||||
where: { messageId: IsNull() },
|
||||
relations: ['transaction'],
|
||||
order: { createdAt: 'ASC', id: 'ASC' },
|
||||
})
|
||||
console.log('dltTransactions=', dltTransactions)
|
||||
for (const dltTx of dltTransactions) {
|
||||
console.log('sending dltTx=', dltTx)
|
||||
try {
|
||||
const messageId = await dltConnector.transmitTransaction(dltTx.transaction)
|
||||
console.log('received messageId=', messageId)
|
||||
const dltMessageId = Buffer.from(messageId, 'hex')
|
||||
console.log('dltMessageId as Buffer=', dltMessageId)
|
||||
if (dltMessageId.length !== 32) {
|
||||
console.log(
|
||||
logger.error(
|
||||
'Error dlt message id is invalid: %s, should by 32 Bytes long in binary after converting from hex',
|
||||
dltMessageId,
|
||||
)
|
||||
@ -45,7 +40,6 @@ export async function sendTransactionsToDltConnector(): Promise<void> {
|
||||
await DltTransaction.save(dltTx)
|
||||
logger.info('store messageId=%s in dltTx=%d', dltTx.messageId, dltTx.id)
|
||||
} catch (e) {
|
||||
console.log('error ', e)
|
||||
logger.error(
|
||||
`error while sending to dlt-connector or writing messageId of dltTx=${dltTx.id}`,
|
||||
e,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user