From 4ca56f6b677f45aa96c91b5c5ee8df210722609e Mon Sep 17 00:00:00 2001 From: jakubkoci Date: Tue, 6 Sep 2022 14:50:05 +0200 Subject: [PATCH] fix(ledger): check taa version instad of aml version (#1013) Signed-off-by: Jakub Koci --- .../ledger/__tests__/IndyLedgerService.test.ts | 12 ++++++------ .../src/modules/ledger/services/IndyLedgerService.ts | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/core/src/modules/ledger/__tests__/IndyLedgerService.test.ts b/packages/core/src/modules/ledger/__tests__/IndyLedgerService.test.ts index 0929cad3dd..023cfe09d5 100644 --- a/packages/core/src/modules/ledger/__tests__/IndyLedgerService.test.ts +++ b/packages/core/src/modules/ledger/__tests__/IndyLedgerService.test.ts @@ -21,7 +21,7 @@ const pools: IndyPoolConfig[] = [ id: 'sovrinMain', isProduction: true, genesisTransactions: 'xxx', - transactionAuthorAgreement: { version: '1', acceptanceMechanism: 'accept' }, + transactionAuthorAgreement: { version: '1.0', acceptanceMechanism: 'accept' }, }, ] @@ -67,7 +67,7 @@ describe('IndyLedgerService', () => { // @ts-ignore jest.spyOn(ledgerService, 'getTransactionAuthorAgreement').mockResolvedValue({ digest: 'abcde', - version: 'abdcg', + version: '2.0', text: 'jhsdhbv', ratification_ts: 12345678, acceptanceMechanisms: { @@ -84,7 +84,7 @@ describe('IndyLedgerService', () => { 'Heinz57' ) ).rejects.toThrowError( - 'Unable to satisfy matching TAA with mechanism "accept" and version "1" in pool.\n Found ["accept"] and version 3 in pool.' + 'Unable to satisfy matching TAA with mechanism "accept" and version "1.0" in pool.\n Found ["accept"] and version 2.0 in pool.' ) }) @@ -93,7 +93,7 @@ describe('IndyLedgerService', () => { // @ts-ignore jest.spyOn(ledgerService, 'getTransactionAuthorAgreement').mockResolvedValue({ digest: 'abcde', - version: 'abdcg', + version: '1.0', text: 'jhsdhbv', ratification_ts: 12345678, acceptanceMechanisms: { @@ -110,7 +110,7 @@ describe('IndyLedgerService', () => { 'Heinz57' ) ).rejects.toThrowError( - 'Unable to satisfy matching TAA with mechanism "accept" and version "1" in pool.\n Found ["decline"] and version 1 in pool.' + 'Unable to satisfy matching TAA with mechanism "accept" and version "1.0" in pool.\n Found ["decline"] and version 1.0 in pool.' ) }) @@ -123,7 +123,7 @@ describe('IndyLedgerService', () => { // @ts-ignore jest.spyOn(ledgerService, 'getTransactionAuthorAgreement').mockResolvedValue({ digest: 'abcde', - version: 'abdcg', + version: '1.0', text: 'jhsdhbv', ratification_ts: 12345678, acceptanceMechanisms: { diff --git a/packages/core/src/modules/ledger/services/IndyLedgerService.ts b/packages/core/src/modules/ledger/services/IndyLedgerService.ts index 60363f628e..72d7a36dc3 100644 --- a/packages/core/src/modules/ledger/services/IndyLedgerService.ts +++ b/packages/core/src/modules/ledger/services/IndyLedgerService.ts @@ -471,7 +471,7 @@ export class IndyLedgerService { // Throw an error if the pool doesn't have the specified version and acceptance mechanism if ( - authorAgreement.acceptanceMechanisms.version !== taa.version || + authorAgreement.version !== taa.version || !(taa.acceptanceMechanism in authorAgreement.acceptanceMechanisms.aml) ) { // Throw an error with a helpful message @@ -479,7 +479,7 @@ export class IndyLedgerService { taa.acceptanceMechanism )} and version ${JSON.stringify(taa.version)} in pool.\n Found ${JSON.stringify( Object.keys(authorAgreement.acceptanceMechanisms.aml) - )} and version ${authorAgreement.acceptanceMechanisms.version} in pool.` + )} and version ${authorAgreement.version} in pool.` throw new LedgerError(errMessage) }