diff --git a/packages/adapters/database/test/client.spec.ts b/packages/adapters/database/test/client.spec.ts index 15b751970e..d87592a1bf 100644 --- a/packages/adapters/database/test/client.spec.ts +++ b/packages/adapters/database/test/client.spec.ts @@ -133,6 +133,7 @@ describe("Database client", () => { await pool.query("DELETE FROM snapshot_roots CASCADE"); await pool.query("DELETE FROM snapshots CASCADE"); await pool.query("DELETE FROM stableswap_exchanges CASCADE"); + await pool.end(); restore(); reset(); }); @@ -1605,12 +1606,18 @@ describe("Database client", () => { it("should save and get single snapshot", async () => { const snapshots: Snapshot[] = []; + const optimisticRootPropagated: OptimisticRootPropagated[] = []; for (let _i = 0; _i < batchSize; _i++) { const m = mock.entity.snapshot(); m.id = `${_i}`; snapshots.push(m); + const o = mock.entity.optimisticRootPropagated(); + o.id = m.id; + o.aggregateRoot = m.aggregateRoot; + optimisticRootPropagated.push(o); } await saveProposedSnapshots(snapshots, pool); + await savePropagatedOptimisticRoots(optimisticRootPropagated, pool); const dbSnapshot = await getPendingAggregateRoot(snapshots[0].aggregateRoot, pool); expect(dbSnapshot!.id).to.eq(snapshots[0].id); diff --git a/packages/agents/cartographer/poller/test/lib/operations/roots.spec.ts b/packages/agents/cartographer/poller/test/lib/operations/roots.spec.ts index 5fd82ef258..a18e1697b0 100644 --- a/packages/agents/cartographer/poller/test/lib/operations/roots.spec.ts +++ b/packages/agents/cartographer/poller/test/lib/operations/roots.spec.ts @@ -113,8 +113,12 @@ describe("Roots operations", () => { describe("#updateProposedSnapshots", () => { it("should work", async () => { (mockContext.adapters.subgraph.getProposedSnapshotsByDomain as SinonStub).resolves( - mockReceivedAggregateRootSubgraphResponse, + mockProposedSnapshotsSubgraphResponse, + mockProposedSnapshotsSubgraphResponse, ); + const newDisputeCliff = mockProposedSnapshotsSubgraphResponse.sort((a, b) => b.endOfDispute - a.endOfDispute)[0] + .endOfDispute; + await updateProposedSnapshots(); expect(mockContext.adapters.database.saveProposedSnapshots as SinonStub).callCount(1); expect(mockContext.adapters.database.saveCheckPoint as SinonStub).callCount(1); @@ -123,11 +127,11 @@ describe("Roots operations", () => { { hub: "1337", snapshotId: 42, limit: 100 }, ]); expect(mockContext.adapters.database.saveCheckPoint as SinonStub).to.be.calledOnceWithExactly( - "proposed_optimistic_root" + mockConnectorMeta[0].hubDomain, - 43, + "proposed_optimistic_root_" + mockConnectorMeta[0].hubDomain, + mockProposedSnapshotsSubgraphResponse[1].endOfDispute, ); expect(mockContext.adapters.database.getCheckPoint as SinonStub).to.be.calledOnceWithExactly( - "proposed_optimistic_root" + mockConnectorMeta[0].hubDomain, + "proposed_optimistic_root_" + mockConnectorMeta[0].hubDomain, ); }); it("initial conditions", async () => {