3333
3434public class GetProposerDutiesIntegrationTest extends AbstractDataBackedRestAPIIntegrationTest {
3535
36- // epoch | 0 | 1
37- // slot | 1 2 3 4 5 6 7 | 8
38- // query | | ^
39- // dep | D |
40- // EXPECT epoch 1 duties with dependent root slot 7
4136 private static final Logger LOG = LogManager .getLogger ();
4237
4338 @ Test
@@ -52,13 +47,13 @@ void shouldReturnCorrectDependentRootPreFulu() throws IOException {
5247 assertThat (dependentRoot (responseBody )).isEqualTo (chain .getLast ().getParentRoot ());
5348 }
5449
55- // epoch | 0 | 1
50+ // epoch | 0 |<1>
5651 // slot | 1 2 3 4 5 6 7 |
5752 // query | ^ |
5853 // dep | D |
59- // EXPECT - should be able to query for the next epoch, may not be stable if its too early.
54+ // EXPECT - should be able to query for the next epoch, may not be stable if it's too early.
6055 @ Test
61- void shouldReturnNextEpochDutiesBeforeEpochTransition () throws IOException {
56+ void shouldReturnNextEpochDutiesFutureEpochPreFulu () throws IOException {
6257 startRestApiAtGenesisWithValidatorApiHandler (SpecMilestone .ALTAIR );
6358 final List <SignedBlockAndState > chain = createBlocksAtSlots (1 , 2 , 3 , 4 , 5 , 6 , 7 );
6459 when (syncService .getCurrentSyncState ()).thenReturn (SyncState .IN_SYNC );
@@ -70,43 +65,67 @@ void shouldReturnNextEpochDutiesBeforeEpochTransition() throws IOException {
7065 assertThat (dependentRoot (responseBody )).isEqualTo (chain .getLast ().getRoot ());
7166 }
7267
73- // epoch | 0 | 1 | 2
74- // slot | 1 2 3 4 5 6 7 | 8 9 10 11 12 13 14 15 | 16
75- // query | | | ^
76- // dep | | D |
77- // EXPECT - expect epoch 2 duties with dependent root slot 15
68+ // epoch GENESIS | 0 |<1>
69+ // slot 0 | 1 2 3 4 5 6 7 |
70+ // query | ^ |
71+ // dep D | |
72+ // EXPECT epoch 1 duties with dependent root slot 0 (GENESIS)
7873 @ Test
79- void shouldReturnCorrectDependentRootPreFuluExtraSlots () throws IOException {
80- startRestApiAtGenesisWithValidatorApiHandler (SpecMilestone .BELLATRIX );
81- final List <SignedBlockAndState > chain =
82- createBlocksAtSlots (1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 , 16 );
74+ void shouldReturnNextEpochDutiesFutureEpochPostFulu () throws IOException {
75+ startRestApiAtGenesisWithValidatorApiHandler (SpecMilestone .FULU );
76+ final List <SignedBlockAndState > chain = createBlocksAtSlots (1 , 2 , 3 , 4 , 5 , 6 , 7 );
8377 when (syncService .getCurrentSyncState ()).thenReturn (SyncState .IN_SYNC );
8478 when (syncStateProvider .getCurrentSyncState ()).thenReturn (SyncState .IN_SYNC );
79+ logChainData (chain );
80+ final Response response = getProposerDuties ("1" );
81+ final String responseBody = response .body ().string ();
82+ assertThat (response .code ()).isEqualTo (200 );
83+ assertThat (dependentRoot (responseBody )).isEqualTo (chain .getFirst ().getParentRoot ());
84+ }
8585
86+ // epoch GENESIS | 0 |<1>
87+ // slot 0 | 1 2 3 4 5 6 7 | 8
88+ // query | | ^
89+ // dep D | |
90+ // EXPECT epoch 1 duties with dependent root slot 0 (GENESIS)
91+ @ Test
92+ void shouldReturnCorrectDependentRootPostFulu () throws IOException {
93+ startRestApiAtGenesisWithValidatorApiHandler (SpecMilestone .FULU );
94+ final List <SignedBlockAndState > chain = createBlocksAtSlots (1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 );
95+ when (syncService .getCurrentSyncState ()).thenReturn (SyncState .IN_SYNC );
96+ when (syncStateProvider .getCurrentSyncState ()).thenReturn (SyncState .IN_SYNC );
8697 logChainData (chain );
87- final Response response = getProposerDuties ("2 " );
98+ final Response response = getProposerDuties ("1 " );
8899 final String responseBody = response .body ().string ();
89100 assertThat (response .code ()).isEqualTo (200 );
90- assertThat (dependentRoot (responseBody )).isEqualTo (chain .getLast ().getParentRoot ());
101+ assertThat (dependentRoot (responseBody )).isEqualTo (chain .getFirst ().getParentRoot ());
91102 }
92103
93- // epoch | 0 | 1 | 2
104+ // epoch | 0 | 1 | <2>
94105 // slot | 1 2 3 4 5 6 7 | 8 9 10 11 12 13 14 15 | 16
95106 // query | | | ^
96107 // dep | | D |
97108 // EXPECT - expect epoch 2 duties with dependent root slot 15
98109 @ Test
99- void shouldReturnCorrectDependentRootPostFulu () throws IOException {
100- startRestApiAtGenesisWithValidatorApiHandler (SpecMilestone .FULU );
101- final List <SignedBlockAndState > chain = createBlocksAtSlots (1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 );
110+ void shouldReturnCorrectDependentRootPreFuluExtraSlots () throws IOException {
111+ startRestApiAtGenesisWithValidatorApiHandler (SpecMilestone .BELLATRIX );
112+ final List <SignedBlockAndState > chain =
113+ createBlocksAtSlots (1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 , 16 );
102114 when (syncService .getCurrentSyncState ()).thenReturn (SyncState .IN_SYNC );
103115 when (syncStateProvider .getCurrentSyncState ()).thenReturn (SyncState .IN_SYNC );
104- final Response response = getProposerDuties ("1" );
116+
117+ logChainData (chain );
118+ final Response response = getProposerDuties ("2" );
105119 final String responseBody = response .body ().string ();
106120 assertThat (response .code ()).isEqualTo (200 );
107121 assertThat (dependentRoot (responseBody )).isEqualTo (chain .getLast ().getParentRoot ());
108122 }
109123
124+ // epoch GENESIS | 0 |<1> | 2
125+ // slot 0 | 1 2 3 4 5 6 7 | 8 9 10 11 12 13 14 15 | 16
126+ // query | | | ^
127+ // dep D | | |
128+ // EXPECT - expect epoch 1 duties with dependent root slot 0 (GENESIS)
110129 @ Test
111130 void shouldReturnCorrectDependentRootPostFuluExtraSlots () throws IOException {
112131 startRestApiAtGenesisWithValidatorApiHandler (SpecMilestone .FULU );
@@ -118,16 +137,16 @@ void shouldReturnCorrectDependentRootPostFuluExtraSlots() throws IOException {
118137 final Response response = getProposerDuties ("1" );
119138 final String responseBody = response .body ().string ();
120139 assertThat (response .code ()).isEqualTo (200 );
121- assertThat (dependentRoot (responseBody )).isEqualTo (chain .get ( 6 ). getRoot ());
140+ assertThat (dependentRoot (responseBody )).isEqualTo (chain .getFirst (). getParentRoot ());
122141 }
123142
124- // epoch | 0 | 1 | 2
143+ // epoch | 0 | 1 | <2>
125144 // slot | 1 2 3 4 5 6 7 | 8 9 10 11 12 13 14 15 |
126145 // query | | ^ |
127- // dep | | D |
146+ // dep | D | |
128147 // EXPECT - expect epoch 2 duties with dependent root slot 15
129148 @ Test
130- void shouldReturnCorrectDependentRootPostFuluExtraSlots2 () throws IOException {
149+ void shouldReturnCorrectDependentRootPostFuluExtraSlotsFutureEpoch () throws IOException {
131150 startRestApiAtGenesisWithValidatorApiHandler (SpecMilestone .FULU );
132151 final List <SignedBlockAndState > chain =
133152 createBlocksAtSlots (1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 );
@@ -138,13 +157,13 @@ void shouldReturnCorrectDependentRootPostFuluExtraSlots2() throws IOException {
138157 final Response response = getProposerDuties ("2" );
139158 final String responseBody = response .body ().string ();
140159 assertThat (response .code ()).isEqualTo (200 );
141- assertThat (dependentRoot (responseBody )).isEqualTo (chain .getLast ( ).getRoot ());
160+ assertThat (dependentRoot (responseBody )).isEqualTo (chain .get ( 6 ).getRoot ());
142161 }
143162
144- // epoch | 0 | 1 | 2
163+ // epoch | 0 | 1 | <2>
145164 // slot | 1 2 3 4 5 6 7 | 8 9 10 11 12 13 14 15 | 16
146165 // query | | | ^
147- // dep | | D |
166+ // dep | D | |
148167 // EXPECT - expect epoch 2 duties with dependent root slot 15
149168 @ Test
150169 void shouldReturnCorrectDependentRootSecondEpoch () throws IOException {
@@ -157,7 +176,7 @@ void shouldReturnCorrectDependentRootSecondEpoch() throws IOException {
157176 final Response response = getProposerDuties ("2" );
158177 final String responseBody = response .body ().string ();
159178 assertThat (response .code ()).isEqualTo (200 );
160- assertThat (dependentRoot (responseBody )).isEqualTo (chain .getLast (). getParentRoot ());
179+ assertThat (dependentRoot (responseBody )).isEqualTo (chain .get ( 6 ). getRoot ());
161180 }
162181
163182 final Bytes32 dependentRoot (final String responseBody ) {
@@ -174,12 +193,14 @@ private Response getProposerDuties(final String epoch) throws IOException {
174193 }
175194
176195 private void logChainData (final List <SignedBlockAndState > chain ) {
196+ LOG .info (
197+ "Genesis root: {}" ,
198+ recentChainData .getGenesisData ().orElseThrow ().getGenesisValidatorsRoot ());
177199 chain .forEach (
178200 signedBlockAndState ->
179201 LOG .info (
180- "SLOT : {}, root: {}, ROOT : {}" ,
202+ "slot : {}, root: {}" ,
181203 signedBlockAndState .getSlot (),
182- signedBlockAndState .getRoot (),
183- signedBlockAndState .getBlock ().getRoot ()));
204+ signedBlockAndState .getRoot ()));
184205 }
185206}
0 commit comments