@@ -128,6 +128,7 @@ var passThruSource = main(`
128
128
` )
129
129
130
130
const boxVersion = 36
131
+ const boxQuotaBumpVersion = 41
131
132
132
133
func boxFee (p config.ConsensusParams , nameAndValueSize uint64 ) uint64 {
133
134
return p .BoxFlatMinBalance + p .BoxByteMinBalance * (nameAndValueSize )
@@ -539,16 +540,20 @@ func TestBoxIOBudgets(t *testing.T) {
539
540
ApplicationID : appID ,
540
541
Boxes : []transactions.BoxRef {{Index : 0 , Name : []byte ("x" )}},
541
542
}
542
- dl .txn (call .Args ("create" , "x" , "\x10 \x00 " ), // 4096
543
- "write budget (1024) exceeded" )
544
- call .Boxes = append (call .Boxes , transactions.BoxRef {})
543
+ if ver < boxQuotaBumpVersion {
544
+ dl .txn (call .Args ("create" , "x" , "\x10 \x00 " ), // 4096
545
+ "write budget (1024) exceeded" )
546
+ call .Boxes = append (call .Boxes , transactions.BoxRef {})
547
+ }
545
548
dl .txn (call .Args ("create" , "x" , "\x10 \x00 " ), // 4096
546
549
"write budget (2048) exceeded" )
547
550
call .Boxes = append (call .Boxes , transactions.BoxRef {})
548
- dl .txn (call .Args ("create" , "x" , "\x10 \x00 " ), // 4096
549
- "write budget (3072) exceeded" )
550
- call .Boxes = append (call .Boxes , transactions.BoxRef {})
551
- dl .txn (call .Args ("create" , "x" , "\x10 \x00 " ), // now there are 4 box refs
551
+ if ver < boxQuotaBumpVersion {
552
+ dl .txn (call .Args ("create" , "x" , "\x10 \x00 " ), // 4096
553
+ "write budget (3072) exceeded" )
554
+ call .Boxes = append (call .Boxes , transactions.BoxRef {})
555
+ }
556
+ dl .txn (call .Args ("create" , "x" , "\x10 \x00 " ), // now there are enough box refs
552
557
"below min" ) // big box would need more balance
553
558
dl .txn (call .Args ("create" , "x" , "\x10 \x01 " ), // 4097
554
559
"write budget (4096) exceeded" )
@@ -572,11 +577,10 @@ func TestBoxIOBudgets(t *testing.T) {
572
577
dl .txgroup ("" , & fundApp , create )
573
578
574
579
// Now that we've created a 4,096 byte box, test READ budget
575
- // It works at the start, because call still has 4 brs.
580
+ // It works at the start, because call still has enough brs.
576
581
dl .txn (call .Args ("check" , "x" , "\x00 " ))
577
- call .Boxes = call .Boxes [:3 ]
578
- dl .txn (call .Args ("check" , "x" , "\x00 " ),
579
- "box read budget (3072) exceeded" )
582
+ call .Boxes = call .Boxes [:len (call .Boxes )- 1 ] // remove one ref
583
+ dl .txn (call .Args ("check" , "x" , "\x00 " ), "box read budget" )
580
584
581
585
// Give a budget over 32768, confirm failure anyway
582
586
empties := [32 ]transactions.BoxRef {}
@@ -603,7 +607,7 @@ func TestBoxInners(t *testing.T) {
603
607
dl .txn (& txntest.Txn {Type : "pay" , Sender : addrs [0 ], Receiver : addrs [0 ]})
604
608
dl .txn (& txntest.Txn {Type : "pay" , Sender : addrs [0 ], Receiver : addrs [0 ]})
605
609
606
- boxID := dl .fundedApp (addrs [0 ], 2_000_000 , boxAppSource ) // there are some big boxes made
610
+ boxID := dl .fundedApp (addrs [0 ], 4_000_000 , boxAppSource ) // there are some big boxes made
607
611
passID := dl .fundedApp (addrs [0 ], 120_000 , passThruSource ) // lowish, show it's not paying for boxes
608
612
call := txntest.Txn {
609
613
Type : "appl" ,
@@ -621,11 +625,19 @@ func TestBoxInners(t *testing.T) {
621
625
require .Error (t , call .Txn ().WellFormed (transactions.SpecialAddresses {}, dl .generator .genesisProto ))
622
626
623
627
call .Boxes = []transactions.BoxRef {{Index : 1 , Name : []byte ("x" )}}
624
- dl .txn (call .Args ("create" , "x" , "\x10 \x00 " ), // 4096
625
- "write budget (1024) exceeded" )
626
- dl .txn (call .Args ("create" , "x" , "\x04 \x00 " )) // 1024
627
- call .Boxes = append (call .Boxes , transactions.BoxRef {Index : 1 , Name : []byte ("y" )})
628
- dl .txn (call .Args ("create" , "y" , "\x08 \x00 " )) // 2048
628
+ if ver < boxQuotaBumpVersion {
629
+ dl .txn (call .Args ("create" , "x" , "\x10 \x00 " ), // 4096
630
+ "write budget (1024) exceeded" )
631
+ dl .txn (call .Args ("create" , "x" , "\x04 \x00 " )) // 1024
632
+ call .Boxes = append (call .Boxes , transactions.BoxRef {Index : 1 , Name : []byte ("y" )})
633
+ dl .txn (call .Args ("create" , "y" , "\x08 \x00 " )) // 2048
634
+ } else {
635
+ dl .txn (call .Args ("create" , "x" , "\x10 \x00 " ), // 4096
636
+ "write budget (2048) exceeded" )
637
+ dl .txn (call .Args ("create" , "x" , "\x08 \x00 " )) // 2048
638
+ call .Boxes = append (call .Boxes , transactions.BoxRef {Index : 1 , Name : []byte ("y" )})
639
+ dl .txn (call .Args ("create" , "y" , "\x10 \x00 " )) // 4096
640
+ }
629
641
630
642
require .Len (t , call .Boxes , 2 )
631
643
setX := call .Args ("set" , "x" , "A" )
0 commit comments