@@ -29,7 +29,6 @@ public class JsonRpcPrunedHistoryTest {
2929 private static final long RECEIPT_FLOOR_BLOCK_NUM = 150L ;
3030 private static final long HEAD_BLOCK_NUM = 200L ;
3131 private static final String PRUNED_MESSAGE = "Pruned history unavailable" ;
32- private static final String BODY_FLOOR_HEX = "0x64" ;
3332 private static final String BELOW_CUTOFF_HEX = "0x10" ;
3433 private static final String AT_CUTOFF_HEX = "0x64" ;
3534 private static final long IN_RECEIPT_GAP_NUM = 112L ;
@@ -101,18 +100,7 @@ public void testGetBlockByNumberBelowCutoffReturns4444() {
101100 JsonRpcPrunedHistoryException e = assertThrows (JsonRpcPrunedHistoryException .class ,
102101 () -> liteRpc .ethGetBlockByNumber (BELOW_CUTOFF_HEX , false ));
103102 Assert .assertEquals (PRUNED_MESSAGE , e .getMessage ());
104- // data carries the same height "earliest" resolves to, not the endpoint's own floor
105- Assert .assertEquals (RECEIPT_FLOOR_HEX , e .getData ());
106- }
107-
108- @ Test
109- public void testGetBlockByNumberBelowCutoffWithHistoryOffReportsBodyFloor () {
110- rpc = new TronJsonRpcImpl (mock (NodeInfoService .class ), newHistoryOffMockWallet ());
111-
112- JsonRpcPrunedHistoryException e = assertThrows (JsonRpcPrunedHistoryException .class ,
113- () -> rpc .ethGetBlockByNumber (BELOW_CUTOFF_HEX , false ));
114- Assert .assertEquals (PRUNED_MESSAGE , e .getMessage ());
115- Assert .assertEquals (BODY_FLOOR_HEX , e .getData ());
103+ Assert .assertNull (e .getData ());
116104 }
117105
118106 @ Test
@@ -167,7 +155,7 @@ public void testGetBlockTransactionCountBelowCutoffReturns4444() {
167155 JsonRpcPrunedHistoryException e = assertThrows (JsonRpcPrunedHistoryException .class ,
168156 () -> liteRpc .ethGetBlockTransactionCountByNumber (BELOW_CUTOFF_HEX ));
169157 Assert .assertEquals (PRUNED_MESSAGE , e .getMessage ());
170- Assert .assertEquals ( RECEIPT_FLOOR_HEX , e .getData ());
158+ Assert .assertNull ( e .getData ());
171159 }
172160
173161 @ Test
@@ -177,7 +165,7 @@ public void testGetTransactionByBlockNumberAndIndexBelowCutoffReturns4444() {
177165 JsonRpcPrunedHistoryException e = assertThrows (JsonRpcPrunedHistoryException .class ,
178166 () -> liteRpc .getTransactionByBlockNumberAndIndex (BELOW_CUTOFF_HEX , "0x0" ));
179167 Assert .assertEquals (PRUNED_MESSAGE , e .getMessage ());
180- Assert .assertEquals ( RECEIPT_FLOOR_HEX , e .getData ());
168+ Assert .assertNull ( e .getData ());
181169 }
182170
183171 @ Test
@@ -187,18 +175,15 @@ public void testGetBlockReceiptsBelowCutoffReturns4444() {
187175 JsonRpcPrunedHistoryException e = assertThrows (JsonRpcPrunedHistoryException .class ,
188176 () -> liteRpc .getBlockReceipts (BELOW_CUTOFF_HEX ));
189177 Assert .assertEquals (PRUNED_MESSAGE , e .getMessage ());
190- Assert .assertEquals ( RECEIPT_FLOOR_HEX , e .getData ());
178+ Assert .assertNull ( e .getData ());
191179 }
192180
193181 @ Test
194- public void testGetBlockReceiptsBelowCutoffWithHistoryOffReportsBodyFloor () {
195- // with receipts never persisted, "earliest" falls back to the body floor and so does data
182+ public void testGetBlockReceiptsFutureBlockWithHistoryOffReturnsNull () throws Exception {
183+ // a block that does not exist yet is not pruned history
196184 rpc = new TronJsonRpcImpl (mock (NodeInfoService .class ), newHistoryOffMockWallet ());
197185
198- JsonRpcPrunedHistoryException e = assertThrows (JsonRpcPrunedHistoryException .class ,
199- () -> rpc .getBlockReceipts (BELOW_CUTOFF_HEX ));
200- Assert .assertEquals (PRUNED_MESSAGE , e .getMessage ());
201- Assert .assertEquals (BODY_FLOOR_HEX , e .getData ());
186+ Assert .assertNull (rpc .getBlockReceipts ("0x7fffffff" ));
202187 }
203188
204189 @ Test
@@ -209,7 +194,7 @@ public void testGetLogsFromBlockBelowCutoffReturns4444() {
209194 JsonRpcPrunedHistoryException e = assertThrows (JsonRpcPrunedHistoryException .class ,
210195 () -> liteRpc .getLogs (fr ));
211196 Assert .assertEquals (PRUNED_MESSAGE , e .getMessage ());
212- Assert .assertEquals ( RECEIPT_FLOOR_HEX , e .getData ());
197+ Assert .assertNull ( e .getData ());
213198 }
214199
215200 @ Test
@@ -220,7 +205,7 @@ public void testNewFilterFromBlockBelowCutoffReturns4444() {
220205 JsonRpcPrunedHistoryException e = assertThrows (JsonRpcPrunedHistoryException .class ,
221206 () -> liteRpc .newFilter (fr ));
222207 Assert .assertEquals (PRUNED_MESSAGE , e .getMessage ());
223- Assert .assertEquals ( RECEIPT_FLOOR_HEX , e .getData ());
208+ Assert .assertNull ( e .getData ());
224209 }
225210
226211 @ Test
@@ -273,7 +258,7 @@ public void testGetLogsInReceiptGapReturns4444() {
273258 JsonRpcPrunedHistoryException e = assertThrows (JsonRpcPrunedHistoryException .class ,
274259 () -> liteRpc .getLogs (fr ));
275260 Assert .assertEquals (PRUNED_MESSAGE , e .getMessage ());
276- Assert .assertEquals ( RECEIPT_FLOOR_HEX , e .getData ());
261+ Assert .assertNull ( e .getData ());
277262 }
278263
279264 @ Test
@@ -286,12 +271,12 @@ public void testGetBlockReceiptsInReceiptGapReturns4444() {
286271 JsonRpcPrunedHistoryException e = assertThrows (JsonRpcPrunedHistoryException .class ,
287272 () -> rpc .getBlockReceipts (IN_RECEIPT_GAP_HEX ));
288273 Assert .assertEquals (PRUNED_MESSAGE , e .getMessage ());
289- Assert .assertEquals ( RECEIPT_FLOOR_HEX , e .getData ());
274+ Assert .assertNull ( e .getData ());
290275 }
291276
292277 @ Test
293278 public void testGetBlockReceiptsEmptyBlockInReceiptGapReturns4444 () {
294- // the floor is checked before the body is read , so an empty block is not special-cased
279+ // the floor check ignores the transaction count , so an empty block is not special-cased
295280 Wallet wallet = newMockWallet (true );
296281 when (wallet .getBlockByNum (IN_RECEIPT_GAP_NUM ))
297282 .thenReturn (newBlock (IN_RECEIPT_GAP_NUM , 0 ));
@@ -300,7 +285,7 @@ public void testGetBlockReceiptsEmptyBlockInReceiptGapReturns4444() {
300285 JsonRpcPrunedHistoryException e = assertThrows (JsonRpcPrunedHistoryException .class ,
301286 () -> rpc .getBlockReceipts (IN_RECEIPT_GAP_HEX ));
302287 Assert .assertEquals (PRUNED_MESSAGE , e .getMessage ());
303- Assert .assertEquals ( RECEIPT_FLOOR_HEX , e .getData ());
288+ Assert .assertNull ( e .getData ());
304289 }
305290
306291 @ Test
0 commit comments