@@ -19,6 +19,7 @@ package ledger
1919import (
2020 "bytes"
2121 "encoding/binary"
22+ "strings"
2223 "testing"
2324 "time"
2425
@@ -156,9 +157,21 @@ func TestBoxCreate(t *testing.T) {
156157 adam := call .Args ("create" , "adam" )
157158 dl .txn (adam , "invalid Box reference adam" )
158159 adam .Boxes = []transactions.BoxRef {{Index : 0 , Name : []byte ("adam" )}}
160+
161+ dl .beginBlock ()
159162 dl .txn (adam )
163+ vb := dl .endBlock ()
164+
165+ // confirm the deltas has the creation
166+ require .Len (t , vb .Delta ().KvMods , 1 )
167+ for _ , kvDelta := range vb .Delta ().KvMods { // There's only one
168+ require .Nil (t , kvDelta .OldData ) // A creation has nil OldData
169+ require .Len (t , kvDelta .Data , 24 )
170+ }
171+
160172 dl .txn (adam .Args ("check" , "adam" , "\x00 \x00 " ))
161173 dl .txgroup ("box_create\n assert" , adam .Noted ("one" ), adam .Noted ("two" ))
174+
162175 bobo := call .Args ("create" , "bobo" )
163176 dl .txn (bobo , "invalid Box reference bobo" )
164177 bobo .Boxes = []transactions.BoxRef {{Index : 0 , Name : []byte ("bobo" )}}
@@ -354,6 +367,7 @@ func TestBoxRW(t *testing.T) {
354367
355368 genBalances , addrs , _ := ledgertesting .NewTestGenesis ()
356369 ledgertesting .TestConsensusRange (t , boxVersion , 0 , func (t * testing.T , ver int , cv protocol.ConsensusVersion ) {
370+ t .Parallel ()
357371 dl := NewDoubleLedger (t , genBalances , cv )
358372 defer dl .Close ()
359373
@@ -369,8 +383,19 @@ func TestBoxRW(t *testing.T) {
369383 Boxes : []transactions.BoxRef {{Index : 0 , Name : []byte ("x" )}},
370384 }
371385
372- dl .txn (call .Args ("create" , "x" , "\x10 " )) // 16
386+ dl .txn (call .Args ("create" , "x" , "\x10 " )) // 16
387+ dl .beginBlock ()
373388 dl .txn (call .Args ("set" , "x" , "ABCDEFGHIJ" )) // 10 long
389+ vb := dl .endBlock ()
390+ // confirm the deltas has the change, including the old value
391+ require .Len (t , vb .Delta ().KvMods , 1 )
392+ for _ , kvDelta := range vb .Delta ().KvMods { // There's only one
393+ require .Equal (t , kvDelta .OldData ,
394+ []byte (strings .Repeat ("\x00 " , 16 )))
395+ require .Equal (t , kvDelta .Data ,
396+ []byte ("ABCDEFGHIJ\x00 \x00 \x00 \x00 \x00 \x00 " ))
397+ }
398+
374399 dl .txn (call .Args ("check" , "x" , "ABCDE" ))
375400 dl .txn (call .Args ("check" , "x" , "ABCDEFGHIJ" ))
376401 dl .txn (call .Args ("check" , "x" , "ABCDEFGHIJ\x00 " ))
0 commit comments