-
Notifications
You must be signed in to change notification settings - Fork 301
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
schema definitions for Event types that aren't just standard objects (#…
…5294) These were missing from the schema definitions we use from swagger. Signed-off-by: Paul Harris <[email protected]> Signed-off-by: Paul Harris <[email protected]>
- Loading branch information
Showing
15 changed files
with
279 additions
and
12 deletions.
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
59 changes: 59 additions & 0 deletions
59
...onrestapi/src/test/java/tech/pegasys/teku/beaconrestapi/handlers/v1/events/EventTest.java
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 |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* Copyright 2022 ConsenSys AG. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations under the License. | ||
*/ | ||
|
||
package tech.pegasys.teku.beaconrestapi.handlers.v1.events; | ||
|
||
import com.fasterxml.jackson.core.JsonProcessingException; | ||
import java.util.stream.Stream; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.Arguments; | ||
import org.junit.jupiter.params.provider.MethodSource; | ||
import tech.pegasys.teku.infrastructure.json.types.OpenApiTypeDefinition; | ||
import tech.pegasys.teku.infrastructure.restapi.OpenApiTestUtil; | ||
import tech.pegasys.teku.spec.Spec; | ||
import tech.pegasys.teku.spec.TestSpecFactory; | ||
import tech.pegasys.teku.spec.util.DataStructureUtil; | ||
|
||
public class EventTest { | ||
private final OpenApiTestUtil<EventTest> util = new OpenApiTestUtil<>(EventTest.class); | ||
|
||
@ParameterizedTest(name = "{0}") | ||
@MethodSource("getEventTypes") | ||
void shouldHaveConsistentSchema(final String testName, final OpenApiTypeDefinition apiDefinition) | ||
throws JsonProcessingException { | ||
util.compareToKnownDefinition(apiDefinition); | ||
} | ||
|
||
public static Stream<Arguments> getEventTypes() { | ||
|
||
final Spec spec = TestSpecFactory.createMinimalPhase0(); | ||
final DataStructureUtil dataStructureUtil = new DataStructureUtil(spec); | ||
return Stream.of( | ||
Arguments.of( | ||
"AttestationEvent", | ||
new AttestationEvent(dataStructureUtil.randomAttestation()).getJsonTypeDefinition()), | ||
Arguments.of( | ||
"BlockEvent", | ||
new BlockEvent(dataStructureUtil.randomSignedBeaconBlock(1), false) | ||
.getJsonTypeDefinition()), | ||
Arguments.of("ChainReorgEvent", ChainReorgEvent.CHAIN_REORG_EVENT_TYPE), | ||
Arguments.of( | ||
"FinalizedCheckpointEvent", FinalizedCheckpointEvent.FINALIZED_CHECKPOINT_EVENT_TYPE), | ||
Arguments.of("HeadEvent", HeadEvent.HEAD_EVENT_TYPE), | ||
Arguments.of("SyncStateChangeEvent", SyncStateChangeEvent.SYNC_STATE_CHANGE_EVENT_TYPE), | ||
Arguments.of( | ||
"VoluntaryExitEvent", | ||
new VoluntaryExitEvent(dataStructureUtil.randomSignedVoluntaryExit()) | ||
.getJsonTypeDefinition())); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
...test/resources/tech/pegasys/teku/beaconrestapi/handlers/v1/events/schema/Attestation.json
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"title" : "Attestation", | ||
"type" : "object", | ||
"required" : [ "aggregation_bits", "data", "signature" ], | ||
"properties" : { | ||
"aggregation_bits" : { | ||
"type" : "string", | ||
"pattern" : "^0x[a-fA-F0-9]{2,}$", | ||
"description" : "SSZ hexadecimal", | ||
"format" : "bytes" | ||
}, | ||
"data" : { | ||
"$ref" : "#/components/schemas/AttestationData" | ||
}, | ||
"signature" : { | ||
"type" : "string", | ||
"pattern" : "^0x[a-fA-F0-9]{2,}$", | ||
"description" : "SSZ hexadecimal", | ||
"format" : "bytes" | ||
} | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
.../test/resources/tech/pegasys/teku/beaconrestapi/handlers/v1/events/schema/BlockEvent.json
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"title" : "BlockEvent", | ||
"type" : "object", | ||
"required" : [ "slot", "block" ], | ||
"properties" : { | ||
"slot" : { | ||
"type" : "string", | ||
"description" : "unsigned 64 bit integer", | ||
"example" : "1", | ||
"format" : "uint64" | ||
}, | ||
"block" : { | ||
"type" : "string", | ||
"description" : "Bytes32 hexadecimal", | ||
"example" : "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2", | ||
"format" : "byte" | ||
} | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
.../resources/tech/pegasys/teku/beaconrestapi/handlers/v1/events/schema/ChainReorgEvent.json
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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
{ | ||
"title" : "ChainReorgEvent", | ||
"type" : "object", | ||
"required" : [ "slot", "depth", "old_head_block", "new_head_block", "old_head_state", "new_head_state", "epoch" ], | ||
"properties" : { | ||
"slot" : { | ||
"type" : "string", | ||
"description" : "unsigned 64 bit integer", | ||
"example" : "1", | ||
"format" : "uint64" | ||
}, | ||
"depth" : { | ||
"type" : "string", | ||
"description" : "unsigned 64 bit integer", | ||
"example" : "1", | ||
"format" : "uint64" | ||
}, | ||
"old_head_block" : { | ||
"type" : "string", | ||
"description" : "Bytes32 hexadecimal", | ||
"example" : "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2", | ||
"format" : "byte" | ||
}, | ||
"new_head_block" : { | ||
"type" : "string", | ||
"description" : "Bytes32 hexadecimal", | ||
"example" : "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2", | ||
"format" : "byte" | ||
}, | ||
"old_head_state" : { | ||
"type" : "string", | ||
"description" : "Bytes32 hexadecimal", | ||
"example" : "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2", | ||
"format" : "byte" | ||
}, | ||
"new_head_state" : { | ||
"type" : "string", | ||
"description" : "Bytes32 hexadecimal", | ||
"example" : "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2", | ||
"format" : "byte" | ||
}, | ||
"epoch" : { | ||
"type" : "string", | ||
"description" : "unsigned 64 bit integer", | ||
"example" : "1", | ||
"format" : "uint64" | ||
} | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
...s/tech/pegasys/teku/beaconrestapi/handlers/v1/events/schema/FinalizedCheckpointEvent.json
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"title" : "FinalizedCheckpointEvent", | ||
"type" : "object", | ||
"required" : [ "block", "state", "epoch" ], | ||
"properties" : { | ||
"block" : { | ||
"type" : "string", | ||
"description" : "Bytes32 hexadecimal", | ||
"example" : "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2", | ||
"format" : "byte" | ||
}, | ||
"state" : { | ||
"type" : "string", | ||
"description" : "Bytes32 hexadecimal", | ||
"example" : "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2", | ||
"format" : "byte" | ||
}, | ||
"epoch" : { | ||
"type" : "string", | ||
"description" : "unsigned 64 bit integer", | ||
"example" : "1", | ||
"format" : "uint64" | ||
} | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
...c/test/resources/tech/pegasys/teku/beaconrestapi/handlers/v1/events/schema/HeadEvent.json
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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
{ | ||
"title" : "HeadEvent", | ||
"type" : "object", | ||
"required" : [ "slot", "block", "state", "epoch_transition", "previous_duty_dependent_root", "current_duty_dependent_root" ], | ||
"properties" : { | ||
"slot" : { | ||
"type" : "string", | ||
"description" : "unsigned 64 bit integer", | ||
"example" : "1", | ||
"format" : "uint64" | ||
}, | ||
"block" : { | ||
"type" : "string", | ||
"description" : "Bytes32 hexadecimal", | ||
"example" : "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2", | ||
"format" : "byte" | ||
}, | ||
"state" : { | ||
"type" : "string", | ||
"description" : "Bytes32 hexadecimal", | ||
"example" : "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2", | ||
"format" : "byte" | ||
}, | ||
"epoch_transition" : { | ||
"type" : "boolean" | ||
}, | ||
"previous_duty_dependent_root" : { | ||
"type" : "string", | ||
"description" : "Bytes32 hexadecimal", | ||
"example" : "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2", | ||
"format" : "byte" | ||
}, | ||
"current_duty_dependent_root" : { | ||
"type" : "string", | ||
"description" : "Bytes32 hexadecimal", | ||
"example" : "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2", | ||
"format" : "byte" | ||
} | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
...ources/tech/pegasys/teku/beaconrestapi/handlers/v1/events/schema/SignedVoluntaryExit.json
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"title" : "SignedVoluntaryExit", | ||
"type" : "object", | ||
"required" : [ "message", "signature" ], | ||
"properties" : { | ||
"message" : { | ||
"$ref" : "#/components/schemas/VoluntaryExit" | ||
}, | ||
"signature" : { | ||
"type" : "string", | ||
"pattern" : "^0x[a-fA-F0-9]{2,}$", | ||
"description" : "SSZ hexadecimal", | ||
"format" : "bytes" | ||
} | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
...urces/tech/pegasys/teku/beaconrestapi/handlers/v1/events/schema/SyncStateChangeEvent.json
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"title" : "SyncStateChangeEvent", | ||
"type" : "object", | ||
"required" : [ "sync_state" ], | ||
"properties" : { | ||
"sync_state" : { | ||
"type" : "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