Test DIA extern interfaces and generated metadata#47
Conversation
Exercise extern dispatch through the deployed contract and enforce committed interface, metadata, and pointer-table invariants. Co-authored-by: Cursor <cursoragent@cursor.com>
Decode the public subparser output to enforce its extern opcode and operand mapping. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
| } | ||
|
|
||
| function testDiaPriceSubParserEncodesDiaPriceOpcodeAndZeroOperand() external { | ||
| DiaWords diaWords = new DiaWords(); |
There was a problem hiding this comment.
should fix: this decodes the extern constant but throws away the bytecode subParseWord2 returns, so it'd still pass if the subparser emitted empty bytecode, a non-extern opcode, or the wrong io byte. worth capturing the bytes and asserting len == 4, byte 0 == OPCODE_EXTERN, byte 1 == the 0x22 io byte for 2 inputs/2 outputs, and bytes 2-3 == constants height. or better, add a parser-level test for price updated-at: dia-price("AMZN" 3600); since that's the real path. also note ioByte is 0 here so the 2in/2out shape from the README never gets exercised.
| authoringMeta[0].description, | ||
| "Returns the current price of the given asset according to DIA. Accepts 2 inputs, the price key as a string (e.g. \"AMZN\") and the timeout in seconds. The price has 18 decimal places. The timeout will be used to determine if the price is stale and revert if it is. Returns 2 outputs: the price and the timestamp of the last update." | ||
| ); | ||
| } |
There was a problem hiding this comment.
minor: this pins the in-memory authoringMetaV2() word and description, but nothing ties the committed meta/DiaSubParserAuthoringMeta.rain.meta to it. so that file can silently drift if someone edits the lib and forgets to re-run BuildAuthoringMeta, and CI stays green. DiaWords.meta.t.sol already guards the other meta file by hashing the committed bytes, would mirror that here: assertEq(vm.readFileBinary("meta/DiaSubParserAuthoringMeta.rain.meta"), LibDiaSubParser.authoringMetaV2()).
| DiaWords diaWords = new DiaWords(); | ||
|
|
||
| assertEq(diaWords.buildLiteralParserFunctionPointers(), hex""); | ||
| } |
There was a problem hiding this comment.
nit: buildLiteralParserFunctionPointers() is just return ""; with no branches, so this asserts a constant equals itself and can't catch a regression. i'd drop it. a comment in DiaSubParser.sol is enough if we want to document that literal parsers aren't supported.

Summary
DiaWords.externand integrity surfaces instead of bypassing dispatchdia-pricesubparser path emits the expected extern opcode and operandStack
Reopened after accidental merge into PR #2. Keeps #33 in PR #2; this is the first PR above that cut.
Formerly #34.
Test plan
nix develop -c forge fmt --checknix develop -c forge testCloses #11
Closes #18
Closes #19
Closes #20
Closes #21
Closes #32
Made with Cursor