Skip to content
This repository has been archived by the owner on Feb 17, 2021. It is now read-only.

Commit

Permalink
fix: dont mark a partially synced transaction as synced
Browse files Browse the repository at this point in the history
  • Loading branch information
gjgd committed Dec 12, 2019
1 parent e7ebf0a commit 698dab0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/element-lib/src/sidetree-v2/func.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ const syncTransaction = async (sidetree, transaction, onlyDidUniqueSuffix = null
writeOperationToCache,
filteredOperationByDidUniqueSuffixes,
).then(() => {
if (operationsByDidUniqueSuffixes.length !== filteredOperationByDidUniqueSuffixes.length) {
return null;
}
return sidetree.db.write(`transaction:${transaction.transactionNumber}`, {
type: 'transaction',
...transaction,
Expand Down
7 changes: 7 additions & 0 deletions packages/element-lib/src/sidetree-v2/protocol/resolve.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -415,5 +415,12 @@ describe.only('resolve just in time', () => {
const cachedTransactions = await sidetree.db.readCollection('transaction');
expect(cachedTransactions).toHaveLength(0);
});

it('should fully synced transaction if did is the only suffix in the batch', async () => {
const didDocument = await resolve(sidetree)(didUniqueSuffix3, true);
expect(didDocument.id).toContain(didUniqueSuffix3);
const cachedTransactions = await sidetree.db.readCollection('transaction');
expect(cachedTransactions).toHaveLength(1);
});
});
});

0 comments on commit 698dab0

Please sign in to comment.