@@ -56,8 +56,13 @@ test('core - append and truncate', async function (t) {
5656 b4a . from ( 'ooo' )
5757 ] )
5858
59+ t . is ( core . state . lastTruncation , null )
60+
5961 await core . state . truncate ( 3 , 1 )
6062
63+ t . is ( core . state . lastTruncation . from , 4 )
64+ t . is ( core . state . lastTruncation . to , 3 )
65+
6166 t . is ( core . state . length , 3 )
6267 t . is ( core . state . byteLength , 12 )
6368 t . is ( core . state . fork , 1 )
@@ -71,30 +76,52 @@ test('core - append and truncate', async function (t) {
7176
7277 await core . state . truncate ( 3 , 2 )
7378
79+ t . is ( core . state . lastTruncation . from , 7 )
80+ t . is ( core . state . lastTruncation . to , 3 )
81+
7482 t . is ( core . state . length , 3 )
7583 t . is ( core . state . byteLength , 12 )
7684 t . is ( core . state . fork , 2 )
7785
7886 await core . state . truncate ( 2 , 3 )
87+ t . is ( core . state . lastTruncation . from , 3 )
88+ t . is ( core . state . lastTruncation . to , 2 )
7989
8090 await core . state . append ( [ b4a . from ( 'a' ) ] )
91+ t . is ( core . state . lastTruncation , null )
92+
8193 await core . state . truncate ( 2 , 4 )
94+ t . is ( core . state . lastTruncation . from , 3 )
95+ t . is ( core . state . lastTruncation . to , 2 )
8296
8397 await core . state . append ( [ b4a . from ( 'a' ) ] )
98+ t . is ( core . state . lastTruncation , null )
99+
84100 await core . state . truncate ( 2 , 5 )
101+ t . is ( core . state . lastTruncation . from , 3 )
102+ t . is ( core . state . lastTruncation . to , 2 )
85103
86104 await core . state . append ( [ b4a . from ( 'a' ) ] )
105+ t . is ( core . state . lastTruncation , null )
106+
87107 await core . state . truncate ( 2 , 6 )
108+ t . is ( core . state . lastTruncation . from , 3 )
109+ t . is ( core . state . lastTruncation . to , 2 )
88110
89111 await core . state . append ( [ b4a . from ( 'a' ) ] )
112+ t . is ( core . state . lastTruncation , null )
113+
90114 await core . state . truncate ( 2 , 7 )
115+ t . is ( core . state . lastTruncation . from , 3 )
116+ t . is ( core . state . lastTruncation . to , 2 )
91117
92118 // check that it was persisted
93119 const coreReopen = await reopen ( )
94120
95121 t . is ( coreReopen . state . length , 2 )
96122 t . is ( coreReopen . state . byteLength , 10 )
97123 t . is ( coreReopen . state . fork , 7 )
124+ t . is ( coreReopen . state . lastTruncation , null )
98125 // t.is(coreReopen.header.hints.reorgs.length, 4)
99126} )
100127
0 commit comments