File tree 5 files changed +52
-13
lines changed
teku/src/main/java/tech/pegasys/teku/cli/subcommand/debug
main/java/tech/pegasys/teku/validator/api
test/java/tech/pegasys/teku/validator/api
client/src/test/java/tech/pegasys/teku/validator/client/restapi
5 files changed +52
-13
lines changed Original file line number Diff line number Diff line change 41
41
import tech .pegasys .teku .spec .SpecFactory ;
42
42
import tech .pegasys .teku .spec .datastructures .state .CommitteeAssignment ;
43
43
import tech .pegasys .teku .spec .datastructures .state .beaconstate .BeaconState ;
44
- import tech .pegasys .teku .validator .api .GraffitiManager ;
45
44
import tech .pegasys .teku .validator .api .ValidatorApiChannel ;
45
+ import tech .pegasys .teku .validator .api .noop .NoOpGraffitiManager ;
46
46
import tech .pegasys .teku .validator .beaconnode .GenesisDataProvider ;
47
47
import tech .pegasys .teku .validator .client .KeyManager ;
48
48
import tech .pegasys .teku .validator .client .NoOpKeyManager ;
@@ -167,7 +167,7 @@ public int generateSwaggerDocs(
167
167
new SystemTimeProvider (),
168
168
Optional .empty (),
169
169
new DoppelgangerDetectionAlert (),
170
- new GraffitiManager ( dataDirLayout ));
170
+ new NoOpGraffitiManager ( ));
171
171
172
172
if (api .getRestApiDocs ().isPresent ()) {
173
173
final String docs = api .getRestApiDocs ().get ();
Original file line number Diff line number Diff line change 26
26
import tech .pegasys .teku .service .serviceutils .layout .DataDirLayout ;
27
27
28
28
public class GraffitiManager {
29
+ private static final Logger LOG = LogManager .getLogger ();
29
30
static final String GRAFFITI_DIR = "graffiti" ;
30
31
31
- private static final Logger LOG = LogManager .getLogger ();
32
32
private final Path graffitiPath ;
33
33
34
34
public GraffitiManager (final DataDirLayout dataDirLayout ) {
35
- this . graffitiPath = createManagementDirectory (dataDirLayout );
35
+ this (dataDirLayout . getValidatorDataDirectory (). resolve ( GRAFFITI_DIR ) );
36
36
}
37
37
38
- private Path createManagementDirectory (final DataDirLayout dataDirLayout ) {
39
- final Path graffitiDirectory = dataDirLayout .getValidatorDataDirectory ().resolve (GRAFFITI_DIR );
40
- if (!graffitiDirectory .toFile ().exists () && !graffitiDirectory .toFile ().mkdirs ()) {
41
- throw new IllegalStateException (
42
- "Unable to create " + GRAFFITI_DIR + " directory for graffiti management." );
38
+ public GraffitiManager (final Path graffitiPath ) {
39
+ this .graffitiPath = graffitiPath ;
40
+ if (!graffitiPath .toFile ().exists () && !graffitiPath .toFile ().mkdirs ()) {
41
+ throw new IllegalStateException ("Unable to create directory for graffiti management." );
43
42
}
44
- return graffitiDirectory ;
45
43
}
46
44
47
45
public Optional <String > setGraffiti (final BLSPublicKey publicKey , final String graffiti ) {
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright Consensys Software Inc., 2024
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
5
+ * the License. You may obtain a copy of the License at
6
+ *
7
+ * http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
10
+ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
11
+ * specific language governing permissions and limitations under the License.
12
+ */
13
+
14
+ package tech .pegasys .teku .validator .api .noop ;
15
+
16
+ import java .nio .file .Path ;
17
+ import java .util .Optional ;
18
+ import org .apache .tuweni .bytes .Bytes32 ;
19
+ import tech .pegasys .teku .bls .BLSPublicKey ;
20
+ import tech .pegasys .teku .validator .api .GraffitiManager ;
21
+
22
+ public class NoOpGraffitiManager extends GraffitiManager {
23
+ public NoOpGraffitiManager () {
24
+ super (Path .of ("." ));
25
+ }
26
+
27
+ @ Override
28
+ public Optional <String > setGraffiti (final BLSPublicKey publicKey , final String graffiti ) {
29
+ return Optional .empty ();
30
+ }
31
+
32
+ @ Override
33
+ public Optional <String > deleteGraffiti (final BLSPublicKey publicKey ) {
34
+ return Optional .empty ();
35
+ }
36
+
37
+ @ Override
38
+ public Optional <Bytes32 > getGraffiti (final BLSPublicKey publicKey ) {
39
+ return Optional .empty ();
40
+ }
41
+ }
Original file line number Diff line number Diff line change @@ -50,7 +50,7 @@ void shouldThrowExceptionWhenUnableToCreateManagementDirectory(@TempDir final Pa
50
50
51
51
assertThatThrownBy (() -> new GraffitiManager (dataDirLayout ))
52
52
.isInstanceOf (IllegalStateException .class )
53
- .hasMessage ("Unable to create graffiti directory for graffiti management." );
53
+ .hasMessage ("Unable to create directory for graffiti management." );
54
54
}
55
55
56
56
@ Test
Original file line number Diff line number Diff line change 31
31
import tech .pegasys .teku .service .serviceutils .layout .DataDirLayout ;
32
32
import tech .pegasys .teku .spec .Spec ;
33
33
import tech .pegasys .teku .spec .SpecFactory ;
34
- import tech .pegasys .teku .validator .api .GraffitiManager ;
35
34
import tech .pegasys .teku .validator .api .ValidatorApiChannel ;
35
+ import tech .pegasys .teku .validator .api .noop .NoOpGraffitiManager ;
36
36
import tech .pegasys .teku .validator .beaconnode .GenesisDataProvider ;
37
37
import tech .pegasys .teku .validator .client .OwnedKeyManager ;
38
38
import tech .pegasys .teku .validator .client .ProposerConfigManager ;
@@ -71,7 +71,7 @@ void setup() throws IOException {
71
71
new SystemTimeProvider (),
72
72
Optional .empty (),
73
73
doppelgangerDetectionAction ,
74
- new GraffitiManager ( dataDirLayout ));
74
+ new NoOpGraffitiManager ( ));
75
75
final Optional <String > maybeJson = restApi .getRestApiDocs ();
76
76
assertThat (maybeJson ).isPresent ();
77
77
jsonNode = util .parseSwagger (maybeJson .orElseThrow ());
You can’t perform that action at this time.
0 commit comments