Skip to content

Commit

Permalink
fix(drive): documents have mixed owner ids (#283)
Browse files Browse the repository at this point in the history
  • Loading branch information
shumkov authored Mar 8, 2022
1 parent a5fc1c1 commit 26fcca7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,19 +137,21 @@ function synchronizeMasternodeIdentitiesFactory(
}

// Process masternode reward contract updates
if (documentsToCreate.length > 0 || documentsToDelete > 0) {
const chunkedDocuments = splitDocumentsIntoChunks({
create: documentsToCreate,
delete: documentsToDelete,

for (const document of documentsToCreate) {
const documentsBatchTransition = transactionalDpp.document.createStateTransition({
create: [document],
});

for (const documentsChunk of chunkedDocuments) {
const documentsBatchTransition = transactionalDpp.document.createStateTransition(
documentsChunk,
);
await transactionalDpp.stateTransition.apply(documentsBatchTransition);
}

await transactionalDpp.stateTransition.apply(documentsBatchTransition);
}
for (const document of documentsToDelete) {
const documentsBatchTransition = transactionalDpp.document.createStateTransition({
delete: [document],
});

await transactionalDpp.stateTransition.apply(documentsBatchTransition);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ describe('synchronizeMasternodeIdentitiesFactory', () => {
{ mnList: smlFixture.concat(newSmlFixture) },
);

const newIdentities = { create: [documentsFixture[0]], delete: [] };
const newIdentities = { create: [documentsFixture[0]] };

handleNewMasternodeMock.returns(newIdentities);
splitDocumentsIntoChunksMock.returns([newIdentities]);
Expand All @@ -222,7 +222,6 @@ describe('synchronizeMasternodeIdentitiesFactory', () => {
expect(handleUpdatedPubKeyOperatorMock).to.be.not.called();
expect(stateRepositoryMock.fetchDocuments).to.be.not.called();

expect(splitDocumentsIntoChunksMock).to.be.calledWithExactly(newIdentities);
expect(transactionalDppMock.document.createStateTransition)
.to.be.calledWithExactly(newIdentities);
expect(transactionalDppMock.stateTransition.apply).to.be.calledWithExactly(
Expand Down

0 comments on commit 26fcca7

Please sign in to comment.