@@ -71,30 +71,27 @@ func TestAccountBlob_Reservation(t *testing.T) {
71
71
quorums := []uint8 {0 , 1 }
72
72
73
73
header , err := accountant .AccountBlob (ctx , symbolLength , quorums )
74
- metadata := core .ConvertPaymentHeader (header )
75
74
76
75
assert .NoError (t , err )
77
76
assert .Equal (t , meterer .GetBinIndex (uint64 (time .Now ().Unix ()), reservationWindow ), header .BinIndex )
78
- assert .Equal (t , big .NewInt (0 ), metadata .CumulativePayment )
77
+ assert .Equal (t , big .NewInt (0 ), header .CumulativePayment )
79
78
assert .Equal (t , isRotation ([]uint64 {500 , 0 , 0 }, mapRecordUsage (accountant .binRecords )), true )
80
79
81
80
symbolLength = uint64 (700 )
82
81
83
82
header , err = accountant .AccountBlob (ctx , symbolLength , quorums )
84
- metadata = core .ConvertPaymentHeader (header )
85
83
86
84
assert .NoError (t , err )
87
85
assert .NotEqual (t , 0 , header .BinIndex )
88
- assert .Equal (t , big .NewInt (0 ), metadata .CumulativePayment )
86
+ assert .Equal (t , big .NewInt (0 ), header .CumulativePayment )
89
87
assert .Equal (t , isRotation ([]uint64 {1200 , 0 , 200 }, mapRecordUsage (accountant .binRecords )), true )
90
88
91
89
// Second call should use on-demand payment
92
90
header , err = accountant .AccountBlob (ctx , 300 , quorums )
93
- metadata = core .ConvertPaymentHeader (header )
94
91
95
92
assert .NoError (t , err )
96
93
assert .Equal (t , uint32 (0 ), header .BinIndex )
97
- assert .Equal (t , big .NewInt (300 ), metadata .CumulativePayment )
94
+ assert .Equal (t , big .NewInt (300 ), header .CumulativePayment )
98
95
}
99
96
100
97
func TestAccountBlob_OnDemand (t * testing.T ) {
@@ -124,10 +121,9 @@ func TestAccountBlob_OnDemand(t *testing.T) {
124
121
header , err := accountant .AccountBlob (ctx , numSymbols , quorums )
125
122
assert .NoError (t , err )
126
123
127
- metadata := core .ConvertPaymentHeader (header )
128
124
expectedPayment := big .NewInt (int64 (numSymbols * uint64 (pricePerSymbol )))
129
125
assert .Equal (t , uint32 (0 ), header .BinIndex )
130
- assert .Equal (t , expectedPayment , metadata .CumulativePayment )
126
+ assert .Equal (t , expectedPayment , header .CumulativePayment )
131
127
assert .Equal (t , isRotation ([]uint64 {0 , 0 , 0 }, mapRecordUsage (accountant .binRecords )), true )
132
128
assert .Equal (t , expectedPayment , accountant .cumulativePayment )
133
129
}
@@ -180,24 +176,21 @@ func TestAccountBlobCallSeries(t *testing.T) {
180
176
181
177
// First call: Use reservation
182
178
header , err := accountant .AccountBlob (ctx , 800 , quorums )
183
- metadata := core .ConvertPaymentHeader (header )
184
179
assert .NoError (t , err )
185
180
assert .Equal (t , meterer .GetBinIndex (uint64 (now ), reservationWindow ), header .BinIndex )
186
- assert .Equal (t , big .NewInt (0 ), metadata .CumulativePayment )
181
+ assert .Equal (t , big .NewInt (0 ), header .CumulativePayment )
187
182
188
183
// Second call: Use remaining reservation + overflow
189
184
header , err = accountant .AccountBlob (ctx , 300 , quorums )
190
- metadata = core .ConvertPaymentHeader (header )
191
185
assert .NoError (t , err )
192
186
assert .Equal (t , meterer .GetBinIndex (uint64 (now ), reservationWindow ), header .BinIndex )
193
- assert .Equal (t , big .NewInt (0 ), metadata .CumulativePayment )
187
+ assert .Equal (t , big .NewInt (0 ), header .CumulativePayment )
194
188
195
189
// Third call: Use on-demand
196
190
header , err = accountant .AccountBlob (ctx , 500 , quorums )
197
- metadata = core .ConvertPaymentHeader (header )
198
191
assert .NoError (t , err )
199
192
assert .Equal (t , uint32 (0 ), header .BinIndex )
200
- assert .Equal (t , big .NewInt (500 ), metadata .CumulativePayment )
193
+ assert .Equal (t , big .NewInt (500 ), header .CumulativePayment )
201
194
202
195
// Fourth call: Insufficient on-demand
203
196
_ , err = accountant .AccountBlob (ctx , 600 , quorums )
@@ -321,23 +314,20 @@ func TestAccountBlob_ReservationWithOneOverflow(t *testing.T) {
321
314
header , err := accountant .AccountBlob (ctx , 800 , quorums )
322
315
assert .NoError (t , err )
323
316
assert .Equal (t , meterer .GetBinIndex (uint64 (now ), reservationWindow ), header .BinIndex )
324
- metadata := core .ConvertPaymentHeader (header )
325
- assert .Equal (t , big .NewInt (0 ), metadata .CumulativePayment )
317
+ assert .Equal (t , big .NewInt (0 ), header .CumulativePayment )
326
318
assert .Equal (t , isRotation ([]uint64 {800 , 0 , 0 }, mapRecordUsage (accountant .binRecords )), true )
327
319
328
320
// Second call: Allow one overflow
329
321
header , err = accountant .AccountBlob (ctx , 500 , quorums )
330
322
assert .NoError (t , err )
331
- metadata = core .ConvertPaymentHeader (header )
332
- assert .Equal (t , big .NewInt (0 ), metadata .CumulativePayment )
323
+ assert .Equal (t , big .NewInt (0 ), header .CumulativePayment )
333
324
assert .Equal (t , isRotation ([]uint64 {1300 , 0 , 300 }, mapRecordUsage (accountant .binRecords )), true )
334
325
335
326
// Third call: Should use on-demand payment
336
327
header , err = accountant .AccountBlob (ctx , 200 , quorums )
337
328
assert .NoError (t , err )
338
329
assert .Equal (t , uint32 (0 ), header .BinIndex )
339
- metadata = core .ConvertPaymentHeader (header )
340
- assert .Equal (t , big .NewInt (200 ), metadata .CumulativePayment )
330
+ assert .Equal (t , big .NewInt (200 ), header .CumulativePayment )
341
331
assert .Equal (t , isRotation ([]uint64 {1300 , 0 , 300 }, mapRecordUsage (accountant .binRecords )), true )
342
332
}
343
333
@@ -373,8 +363,7 @@ func TestAccountBlob_ReservationOverflowReset(t *testing.T) {
373
363
header , err := accountant .AccountBlob (ctx , 500 , quorums )
374
364
assert .NoError (t , err )
375
365
assert .Equal (t , isRotation ([]uint64 {1000 , 0 , 0 }, mapRecordUsage (accountant .binRecords )), true )
376
- metadata := core .ConvertPaymentHeader (header )
377
- assert .Equal (t , big .NewInt (500 ), metadata .CumulativePayment )
366
+ assert .Equal (t , big .NewInt (500 ), header .CumulativePayment )
378
367
379
368
// Wait for next reservation duration
380
369
time .Sleep (time .Duration (reservationWindow ) * time .Second )
0 commit comments