Skip to content

Commit

Permalink
fix(ledger): check taa version instad of aml version (#1013)
Browse files Browse the repository at this point in the history
Signed-off-by: Jakub Koci <[email protected]>
  • Loading branch information
jakubkoci authored Sep 6, 2022
1 parent f0ca8b6 commit 4ca56f6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const pools: IndyPoolConfig[] = [
id: 'sovrinMain',
isProduction: true,
genesisTransactions: 'xxx',
transactionAuthorAgreement: { version: '1', acceptanceMechanism: 'accept' },
transactionAuthorAgreement: { version: '1.0', acceptanceMechanism: 'accept' },
},
]

Expand Down Expand Up @@ -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: {
Expand All @@ -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.'
)
})

Expand All @@ -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: {
Expand All @@ -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.'
)
})

Expand All @@ -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: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -471,15 +471,15 @@ 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
const errMessage = `Unable to satisfy matching TAA with mechanism ${JSON.stringify(
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)
}

Expand Down

0 comments on commit 4ca56f6

Please sign in to comment.