Skip to content
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

api: Recognize sapphire, cipher as valid Layer values #427

Merged
merged 2 commits into from
May 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,23 @@ fill-cache-for-e2e-regression: oasis-indexer

# Run the api tests locally, assuming the environment is set up with an oasis-node that is
# accessible as specified in the config file.
test-e2e-regression: export TZ=UTC
test-e2e-regression: oasis-indexer
./oasis-indexer --config tests/e2e_regression/e2e_config.yml analyze
@$(ECHO) "$(CYAN)*** Indexer finished; starting api tests...$(OFF)"
./tests/e2e_regression/run.sh

# Accept the outputs of the e2e tests as the new expected outputs.
accept-e2e-regression:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add to .PHONY?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤷 We don't really use/need it. Added, and half-heartedly added several other e2e-related targets that were missing, but didn't make a careful pass to ensure every relevant target is listed under .PHONY.

@# Delete all old expected files first, in case any test cases were renamed or removed.
rm -rf ./tests/e2e_regression/expected
@# Copy the actual outputs to the expected outputs.
cp -r ./tests/e2e_regression/{actual,expected}
@# The result of the "spec" test is a special case. It should always match the
@# current openAPI spec file, so we symlink it to avoid having to update the expected
@# output every time the spec changes.
Comment on lines +79 to +81
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason I abstracted the inline command form run.sh into this accept-e2e-regressions rule in the Makefile. The PR caused e2e regressions to fail just because it changed the openapi JSON (but not the e2e expected file). It would be awkward if every change to the spec produced two equivalent diffs: one in the actual spec, and one in the e2e expected file.

rm ./tests/e2e_regression/expected/spec.body
ln -s ../../../api/spec/v1.yaml ./tests/e2e_regression/expected/spec.body

# Format code.
fmt:
@$(ECHO) "$(CYAN)*** Running Go formatters...$(OFF)"
Expand Down Expand Up @@ -137,6 +148,10 @@ release-build: codegen-go
all build \
codegen-go \
oasis-indexer \
test-e2e \
test-e2e-regression \
fill-cache-for-e2e-regression \
accept-e2e-regression \
docker \
clean \
test \
Expand Down
4 changes: 4 additions & 0 deletions api/spec/v1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1078,10 +1078,14 @@ components:
schemas:
Layer:
type: string
# NOTE: Change IsValid() in util.go if you change this.
# https://github.com/oasisprotocol/oasis-indexer/blob/v0.0.16/api/v1/types/util.go#L40
enum: [emerald, sapphire, cipher, consensus]

Runtime:
type: string
# NOTE: Change IsValid() in util.go if you change this.
# https://github.com/oasisprotocol/oasis-indexer/blob/v0.0.16/api/v1/types/util.go#L49
ptrus marked this conversation as resolved.
Show resolved Hide resolved
enum: [emerald, sapphire, cipher]

List:
Expand Down
2 changes: 1 addition & 1 deletion api/v1/types/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func (c ConsensusEventType) IsValid() bool {

func (c Layer) IsValid() bool {
switch c {
case LayerConsensus, LayerEmerald:
case LayerConsensus, LayerCipher, LayerEmerald, LayerSapphire:
return true
default:
return false
Expand Down
Loading