Skip to content

Commit c31a660

Browse files
authored
fix: setup a no-op PG client in dry-run (#125)
Signed-off-by: Miroslav Bajtoš <[email protected]>
1 parent adb1373 commit c31a660

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

bin/dry-run.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,14 @@ await evaluate({
9999
fetchRoundDetails,
100100
ieContractWithSigner,
101101
logger: console,
102-
recordTelemetry
102+
recordTelemetry,
103+
104+
// We don't want dry runs to update data in `sparks_stats`, therefore we are passing a stub
105+
// connection factory that creates no-op clients. This also keeps the setup simpler. The person
106+
// executing a dry run does not need access to any Postgres instance.
107+
// Evaluate uses the PG client only for updating the statistics, it's not reading any data.
108+
// Thus it's safe to inject a no-op client.
109+
createPgClient: createNoopPgClient
103110
})
104111

105112
console.log(process.memoryUsage())
@@ -209,3 +216,14 @@ async function fetchMeasurementsAddedFromChain (roundIndex) {
209216

210217
return events.filter(e => e.roundIndex.eq(roundIndex)).map(e => e.cid)
211218
}
219+
220+
function createNoopPgClient () {
221+
return {
222+
async query () {
223+
return { rows: [] }
224+
},
225+
async end () {
226+
// no-op
227+
}
228+
}
229+
}

0 commit comments

Comments
 (0)