Skip to content

Commit

Permalink
test: fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelTaylor3D committed Dec 12, 2023
1 parent b77fa5d commit 6a2ac8c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
17 changes: 9 additions & 8 deletions src/tasks/sync-registries.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ const syncOrganizationAudit = async (organization) => {
console.log('USING MOCK ROOT HISTORY');
lastRootSaved = rootHistory[0];
lastRootSaved.rootHash = lastRootSaved.root_hash;
lastRootSaved.generation = 0;
} else {
lastRootSaved = await Audit.findOne({
where: { registryId: organization.registryId },
Expand All @@ -175,20 +176,20 @@ const syncOrganizationAudit = async (organization) => {
}
}

let generation = _.get(rootHistory, '[0]');
let currentGeneration = _.get(rootHistory, '[0]');

if (!lastRootSaved) {
logger.info(`Syncing new registry ${organization.name}`);

await Audit.create({
orgUid: organization.orgUid,
registryId: organization.registryId,
rootHash: generation.root_hash,
rootHash: currentGeneration.root_hash,
type: 'CREATE REGISTRY',
generation: 0,
currentGeneration: 0,
change: null,
table: null,
onchainConfirmationTimeStamp: generation.timestamp.toString(),
onchainConfirmationTimeStamp: currentGeneration.timestamp.toString(),
});

// Destroy existing records for this singleton
Expand All @@ -207,18 +208,18 @@ const syncOrganizationAudit = async (organization) => {

return;
} else {
generation = lastRootSaved;
currentGeneration = lastRootSaved;
}

const historyIndex = generation.generation + 1;
const historyIndex = currentGeneration.generation;

if (historyIndex > rootHistory.length) {
logger.error(
`Could not find root history for ${organization.name} with timestamp ${generation.timestamp}, something is wrong and the sync for this organization will be paused until this is resolved.`,
`Could not find root history for ${organization.name} with timestamp ${currentGeneration.timestamp}, something is wrong and the sync for this organization will be paused until this is resolved.`,
);
}

const syncRemaining = rootHistory.length - generation.generation;
const syncRemaining = rootHistory.length - currentGeneration.generation;
const isSynced = syncRemaining === 0;

await Organization.update(
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/project.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe('Project Resource Integration Tests', function () {
homeOrgUid = await testFixtures.getHomeOrgId();
});

it('deletes a project end-to-end (with simulator)', async function () {
it.only('deletes a project end-to-end (with simulator)', async function () {
/*
Basic Idea for this test is that we are going to create a project and verify that
the new project propagates through the data layer and into our db. Then we are going
Expand Down

0 comments on commit 6a2ac8c

Please sign in to comment.