Commit dfaff20
committed
test(e2e): the full stack against a real chain, and four indexer bugs it found
Deploys the real contracts to anvil, registers a quote asset through every §420
gate, launches a market, buys twice and sells, then runs the real indexer and
asserts the projection equals what the chain actually did. Contracts come from
the artifacts Foundry already built, so this indexes the same bytecode the test
suite ran against.
It found four bugs on its first run, none of which any existing test could see,
because every one of them lives between the contracts and the reducer.
Blocks: only the first block of each range was recorded, while rows referencing
every block in the range were inserted. With a 500-block batch that is 499
blocks of foreign key violations, the tick fails, the cursor never advances, and
indexing stops at the first range with an event outside its own first block.
Timestamps: every log in a range was stamped with the range's first block time.
That puts trades in the wrong candle and, far worse, in the wrong TWAB epoch —
Stockback integrates balances over time, so a shifted timestamp is a shifted
entitlement.
Quote decimals: hardcoded to eighteen. xStocks are not eighteen-decimal assets,
so every price and notional in the projection was scaled by 10^12. Now read from
the registry, which is where §699 says it comes from.
Same-range launches: getLogs filters by address, and a market's address is only
known after its launch log is read — so everything a market emitted in the range
it launched in was never fetched. On mainnet that is the first several minutes
of every market's life.
Two smaller faults surfaced while fixing those: the in-memory market map was
mutated inside the transaction, so a rollback left it claiming a market the
database did not have and every subsequent tick failed forever; and a token's
genesis transfers precede TokenLaunched in the same transaction, so the market's
opening balance was dropped and the first buy drove it negative.1 parent 77fb742 commit dfaff20
8 files changed
Lines changed: 672 additions & 19 deletions
File tree
- .github/workflows
- services/indexer
- src
- tests/e2e
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
157 | 157 | | |
158 | 158 | | |
159 | 159 | | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
160 | 178 | | |
161 | 179 | | |
162 | 180 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
42 | | - | |
| 42 | + | |
| 43 | + | |
43 | 44 | | |
44 | 45 | | |
45 | 46 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
7 | 10 | | |
8 | 11 | | |
9 | 12 | | |
| |||
0 commit comments