@@ -13,6 +13,7 @@ import (
13
13
"github.com/iotaledger/iota-core/pkg/testsuite"
14
14
"github.com/iotaledger/iota-core/pkg/testsuite/mock"
15
15
iotago "github.com/iotaledger/iota.go/v4"
16
+ "github.com/iotaledger/iota.go/v4/api"
16
17
)
17
18
18
19
func TestConfirmationFlags (t * testing.T ) {
@@ -245,3 +246,88 @@ func TestConfirmationFlags(t *testing.T) {
245
246
)
246
247
}
247
248
}
249
+
250
+ func TestConfirmationOverEpochBoundary (t * testing.T ) {
251
+ ts := testsuite .NewTestSuite (t ,
252
+ testsuite .WithProtocolParametersOptions (
253
+ iotago .WithTimeProviderOptions (
254
+ 0 ,
255
+ testsuite .GenesisTimeWithOffsetBySlots (1000 , testsuite .DefaultSlotDurationInSeconds ),
256
+ testsuite .DefaultSlotDurationInSeconds ,
257
+ 3 ,
258
+ ),
259
+ iotago .WithLivenessOptions (
260
+ 10 ,
261
+ 10 ,
262
+ 3 ,
263
+ 4 ,
264
+ 5 ,
265
+ ),
266
+ ),
267
+ )
268
+ defer ts .Shutdown ()
269
+
270
+ ts .AddValidatorNode ("node0" )
271
+ ts .AddValidatorNode ("node1" )
272
+ ts .AddValidatorNode ("node2" )
273
+ ts .AddValidatorNode ("node3" )
274
+ ts .AddNode ("node4" )
275
+
276
+ ts .Run (true )
277
+
278
+ // Issue blocks up until 1 slot more than the epoch.
279
+ {
280
+ ts .IssueBlocksAtSlots ("" , []iotago.SlotIndex {1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 }, 4 , "Genesis" , ts .Nodes (), true , false )
281
+
282
+ ts .AssertNodeState (ts .Nodes (),
283
+ testsuite .WithLatestFinalizedSlot (5 ),
284
+ testsuite .WithLatestCommitmentSlotIndex (6 ),
285
+ testsuite .WithEqualStoredCommitmentAtIndex (6 ),
286
+ testsuite .WithEvictedSlot (6 ),
287
+ )
288
+
289
+ // Verify propagation of witness weight over epoch boundaries (slot 7).
290
+ {
291
+ // We propagate witness weight for pre-acceptance and acceptance over epoch boundaries.
292
+ ts .AssertBlocksInCachePreAccepted (ts .BlocksWithPrefixes ("7.0" , "7.1" , "7.2" , "7.3" ), true , ts .Nodes ()... )
293
+ ts .AssertBlocksInCacheAccepted (ts .BlocksWithPrefixes ("7.0" , "7.1" , "7.2" , "7.3" ), true , ts .Nodes ()... )
294
+
295
+ // We don't propagate pre-confirmation and confirmation over epoch boundaries:
296
+ // There's 4 rows in a slot, everything except the last row should be pre-confirmed.
297
+ ts .AssertBlocksInCachePreConfirmed (ts .BlocksWithPrefixes ("7.0" , "7.1" , "7.2" ), true , ts .Nodes ()... )
298
+ ts .AssertBlocksInCachePreConfirmed (ts .BlocksWithPrefixes ("7.3" ), false , ts .Nodes ()... )
299
+ // Accordingly, only the first 2 rows are confirmed.
300
+ ts .AssertBlocksInCacheConfirmed (ts .BlocksWithPrefixes ("7.0" , "7.1" ), true , ts .Nodes ()... )
301
+ ts .AssertBlocksInCacheConfirmed (ts .BlocksWithPrefixes ("7.2" , "7.3" ), false , ts .Nodes ()... )
302
+
303
+ }
304
+
305
+ // Slot 8 and 9 behaves normally, as they are in the new epoch.
306
+ {
307
+ ts .AssertBlocksInCacheAccepted (ts .BlocksWithPrefixes ("8.0" , "8.1" , "8.2" , "8.3" , "9.0" , "9.1" ), true , ts .Nodes ()... )
308
+ ts .AssertBlocksInCacheAccepted (ts .BlocksWithPrefixes ("9.2" , "9.3" ), false , ts .Nodes ()... )
309
+ ts .AssertBlocksInCachePreAccepted (ts .BlocksWithPrefixes ("9.2" ), true , ts .Nodes ()... )
310
+ ts .AssertBlocksInCachePreAccepted (ts .BlocksWithPrefixes ("9.3" ), false , ts .Nodes ()... )
311
+
312
+ ts .AssertBlocksInCacheConfirmed (ts .BlocksWithPrefixes ("8.0" , "8.1" , "8.2" , "8.3" , "9.0" , "9.1" ), true , ts .Nodes ()... )
313
+ ts .AssertBlocksInCacheConfirmed (ts .BlocksWithPrefixes ("9.2" , "9.3" ), false , ts .Nodes ()... )
314
+ ts .AssertBlocksInCachePreConfirmed (ts .BlocksWithPrefixes ("9.2" ), true , ts .Nodes ()... )
315
+ ts .AssertBlocksInCachePreConfirmed (ts .BlocksWithPrefixes ("9.3" ), false , ts .Nodes ()... )
316
+ }
317
+ }
318
+
319
+ // Issue more so that blocks at end of epoch become confirmed via finalization.
320
+ {
321
+ ts .IssueBlocksAtSlots ("" , []iotago.SlotIndex {10 , 11 , 12 }, 4 , "9.3" , ts .Nodes (), true , false )
322
+
323
+ ts .AssertNodeState (ts .Nodes (),
324
+ testsuite .WithLatestFinalizedSlot (8 ),
325
+ testsuite .WithLatestCommitmentSlotIndex (9 ),
326
+ testsuite .WithEqualStoredCommitmentAtIndex (9 ),
327
+ testsuite .WithEvictedSlot (9 ),
328
+ )
329
+
330
+ ts .AssertRetainerBlocksState (ts .BlocksWithPrefixes ("7" , "8" ), api .BlockStateFinalized , ts .Nodes ()... )
331
+ ts .AssertRetainerBlocksState (ts .BlocksWithPrefixes ("9" , "10" , "11" ), api .BlockStateConfirmed , ts .Nodes ()... )
332
+ }
333
+ }
0 commit comments