Closed 2ndshadow closed 4 months ago
Use in-memory sqlite data source (outdated example here)
Do we need it? Devs can just delete files manually after testing
I haven't found an easy solution to mock BigQuery. I think best solution here would be to recommend users to use something like https://github.com/goccy/bigquery-emulator and connect to it
MockEvmBatchProcessor gets EvmProcessor instance and only cares for what was set in .addLog
, .addTransaction
, .addStateDiff
, .addTrace
& .setFields
calls
import {handler, processor} from "./src"
import {encodeLog} from "@subsquid/evm-utils"
import * as contract from "./abi/contract.ts"
const tokenAddress = '0x12313123...'
test("Correctly calculates minted amounts", () => {
const mockProcessor = new MockEvmBatchProcessor(processor)
const db = new MockTypeOrm()
mockProcessor.run(db, handler)
// This would wait until handler(ctx) is called
await mockProcessor.inject([{
logs: [
encodeLog(contract.events.Mint, tokenAddress, {
to: ...
amount: 10n
}),
encodeLog(contract.events.Mint, tokenAddress, {
to: ...
amount: 100n
}),
],
}])
expect((await db.get(Token, tokenAddress)).totalSupply).toBe(110n)
})
Similar one for substrate
Can we generate events from the ABI?
also not clear how db.get()
works
also not clear how db.get() works
Why we can't use a real database?
Epic: Testing framework for squids #220 Estimate: 2d