-
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
Merged
Merged
Andrew7234/api tests #360
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
201deb1
nodeapi: Store raw oasis-core in serialized form
mitjat b8d7a81
method-based cached ConsensusApiLite
Andrew7234 0c80484
wip: unit test to dump state
Andrew7234 dac3917
switch encoding/gob -> encoding/json
Andrew7234 719c141
smoother test flow
Andrew7234 4ea13d2
nits
Andrew7234 414666c
working api-test flow
Andrew7234 c67d8c6
address comments
Andrew7234 1fa8e7f
add runtime file backend
Andrew7234 daeb908
change runtime api methods to return slices of values
Andrew7234 ca22d12
update config with file-based cache; switch encoding to cbor
Andrew7234 5e78d3c
remove data files and unnecessary tests that are now part of the make…
Andrew7234 46d8b95
switch encoding to cbor; deserialize to explicit type
Andrew7234 02df003
remove json annotations
Andrew7234 9292d28
check for latestHeight; do not connect to node for pure file-based co…
Andrew7234 461e835
move api tests -> e2e_regression
Andrew7234 a899da8
nits
Andrew7234 5c975c2
Factor out cache handling in FileConsensusApiLite
mitjat 172bac7
Avoid marshal+unmarshall on every uncached call; serde is a CPU bottl…
mitjat 8cd781c
Remove unnecessary params
mitjat 5a40bba
Create KVStore type
mitjat d2e5479
pogreb constructor: rename filename->cacheDir
mitjat 671130f
Move volatile call detection (HeightLatest) out of cache logic
mitjat f6953a9
nodeapi/file/runtime.go: Use KVStore, abstract away duplicated code
mitjat 1179568
address comments
Andrew7234 91564bc
nits
Andrew7234 8ff116c
linter
Andrew7234 File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
package common | ||
|
||
import ( | ||
"encoding/json" | ||
"errors" | ||
"fmt" | ||
"math/big" | ||
|
@@ -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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. oh that was #382, turns out it never got merged |
||
encoded, err := json.Marshal(v) | ||
if err != nil { | ||
return json.RawMessage("null") | ||
} | ||
return json.RawMessage(encoded) | ||
} | ||
|
||
// Key used to set values in a web request context. API uses this to set | ||
// values, backend uses this to retrieve values. | ||
type ContextKey string | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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?