-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Andrew7234/api tests #360
Andrew7234/api tests #360
Conversation
c03bb05
to
ba43ba0
Compare
aa51ad6
to
d0a5c97
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! Really curious about the speed of running the analyzer against the cached data.
Also, looks like you already intended to split it this way, but let's worry about integrating this into CI in a separate PR.
008765a
to
b52d813
Compare
b52d813
to
46d8801
Compare
while ! curl --silent localhost:8008/v1/ >/dev/null; do | ||
echo "Waiting for API server to start..." | ||
sleep 1 | ||
done | ||
|
||
# Run the test cases. | ||
seen=() | ||
seen=("placeholder") # avoids 'seen[*]: unbound variable' error on zsh |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious: because of the #!/bin/bash
shebang, don't you have to go to extra trouble to run this in zsh? Alternatively, is there an invocation where you can explicitly invoke the script with bash and avoid zsh compat issues?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! I left only one more not-entirely-trivial comment, but I think it's not contentious either.
Reviewing the code made me wonder if it can be written with less repetition. My proof of concept ended up working out; I pushed it to this PR as three additional commits. Benefits of the slight refactor:
I only made the changes on the consensus side; I feel the runtime side has too few methods to warrant generalizing them. Although I guess the whole Disclaimer: This is untested beyond satisfying the compiler. And we don't have the habit of slipping into each other's PRs. So I'm happy to submit this as a follow-up PR too, or we can leave it as a part of this one, whichever you prefer. |
Uh a pretty big problem I noticed: the docs for |
Done that now, and also simplified the runtime FileApiLite. Will work on the Close() problem tomorrow. |
…eneck for indexer
bbd8697
to
91564bc
Compare
@@ -248,7 +248,7 @@ func registerTokenDecrease(tokenChanges map[TokenChangeKey]*big.Int, contractAdd | |||
change.Sub(change, amount) | |||
} | |||
|
|||
func ExtractRound(blockHeader nodeapi.RuntimeBlockHeader, txrs []*nodeapi.RuntimeTransactionWithResults, rawEvents []*nodeapi.RuntimeEvent, logger *log.Logger) (*BlockData, error) { //nolint:gocyclo | |||
func ExtractRound(blockHeader nodeapi.RuntimeBlockHeader, txrs []nodeapi.RuntimeTransactionWithResults, rawEvents []nodeapi.RuntimeEvent, logger *log.Logger) (*BlockData, error) { //nolint:gocyclo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what did these * removals do? originally they were pointers so that we don't have to copy structs around. not that that's particularly expensive.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh it's so that we don't need a zillion different GetFromCacheOrCall variants, right?
@@ -90,6 +91,16 @@ func Ptr[T any](v T) *T { | |||
return &v | |||
} | |||
|
|||
// Returns `v` as a JSON string. If `v` cannot be marshaled, | |||
// returns the string "null" instead. | |||
func TryAsJSON(v interface{}) json.RawMessage { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
didn't this appear in an earlier PR? what happened to that? now I can't find it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh that was #382, turns out it never got merged
nice, thanks! |
https://app.clickup.com/t/861md6gue
Test flow:
make dump-state
: dumps consensus node state requests to file using pogrebmake test-api
: runs a fresh indexer according to the params inapi-dev.yml
using the file-based consensus node state created in the previous step. Then runs the e2e api tests to find the diff between the expected responses (generated previously and checked into github) and the actual responses from the indexer.The initial idea of this PR is to
run.sh
tool to verify both analyzer and indexer api functionalityOpen questions/todos: