@@ -111,7 +111,7 @@ func testClientPool(t *testing.T, connLimit, clientCount, paidCount int, randomD
111111 // give a positive balance to some of the peers
112112 amount := testClientPoolTicks / 2 * int64 (time .Second ) // enough for half of the simulation period
113113 for i := 0 ; i < paidCount ; i ++ {
114- pool .updateBalance (poolTestPeer (i ).ID (), amount , "" )
114+ pool .addBalance (poolTestPeer (i ).ID (), amount , "" )
115115 }
116116 }
117117
@@ -178,7 +178,7 @@ func TestConnectPaidClient(t *testing.T) {
178178 pool .setDefaultFactors (priceFactors {1 , 0 , 1 }, priceFactors {1 , 0 , 1 })
179179
180180 // Add balance for an external client and mark it as paid client
181- pool .updateBalance (poolTestPeer (0 ).ID (), 1000 , "" )
181+ pool .addBalance (poolTestPeer (0 ).ID (), 1000 , "" )
182182
183183 if ! pool .connect (poolTestPeer (0 ), 10 ) {
184184 t .Fatalf ("Failed to connect paid client" )
@@ -196,7 +196,7 @@ func TestConnectPaidClientToSmallPool(t *testing.T) {
196196 pool .setDefaultFactors (priceFactors {1 , 0 , 1 }, priceFactors {1 , 0 , 1 })
197197
198198 // Add balance for an external client and mark it as paid client
199- pool .updateBalance (poolTestPeer (0 ).ID (), 1000 , "" )
199+ pool .addBalance (poolTestPeer (0 ).ID (), 1000 , "" )
200200
201201 // Connect a fat paid client to pool, should reject it.
202202 if pool .connect (poolTestPeer (0 ), 100 ) {
@@ -216,15 +216,15 @@ func TestConnectPaidClientToFullPool(t *testing.T) {
216216 pool .setDefaultFactors (priceFactors {1 , 0 , 1 }, priceFactors {1 , 0 , 1 })
217217
218218 for i := 0 ; i < 10 ; i ++ {
219- pool .updateBalance (poolTestPeer (i ).ID (), 1000000000 , "" )
219+ pool .addBalance (poolTestPeer (i ).ID (), 1000000000 , "" )
220220 pool .connect (poolTestPeer (i ), 1 )
221221 }
222- pool .updateBalance (poolTestPeer (11 ).ID (), 1000 , "" ) // Add low balance to new paid client
222+ pool .addBalance (poolTestPeer (11 ).ID (), 1000 , "" ) // Add low balance to new paid client
223223 if pool .connect (poolTestPeer (11 ), 1 ) {
224224 t .Fatalf ("Low balance paid client should be rejected" )
225225 }
226226 clock .Run (time .Second )
227- pool .updateBalance (poolTestPeer (12 ).ID (), 1000000000 * 60 * 3 , "" ) // Add high balance to new paid client
227+ pool .addBalance (poolTestPeer (12 ).ID (), 1000000000 * 60 * 3 , "" ) // Add high balance to new paid client
228228 if ! pool .connect (poolTestPeer (12 ), 1 ) {
229229 t .Fatalf ("High balance paid client should be accpected" )
230230 }
@@ -243,7 +243,7 @@ func TestPaidClientKickedOut(t *testing.T) {
243243 pool .setDefaultFactors (priceFactors {1 , 0 , 1 }, priceFactors {1 , 0 , 1 })
244244
245245 for i := 0 ; i < 10 ; i ++ {
246- pool .updateBalance (poolTestPeer (i ).ID (), 1000000000 , "" ) // 1 second allowance
246+ pool .addBalance (poolTestPeer (i ).ID (), 1000000000 , "" ) // 1 second allowance
247247 pool .connect (poolTestPeer (i ), 1 )
248248 clock .Run (time .Millisecond )
249249 }
@@ -351,7 +351,7 @@ func TestPositiveBalanceCalculation(t *testing.T) {
351351 pool .setLimits (10 , uint64 (10 )) // Total capacity limit is 10
352352 pool .setDefaultFactors (priceFactors {1 , 0 , 1 }, priceFactors {1 , 0 , 1 })
353353
354- pool .updateBalance (poolTestPeer (0 ).ID (), int64 (time .Minute * 3 ), "" )
354+ pool .addBalance (poolTestPeer (0 ).ID (), int64 (time .Minute * 3 ), "" )
355355 pool .connect (poolTestPeer (0 ), 10 )
356356 clock .Run (time .Minute )
357357
@@ -377,7 +377,7 @@ func TestDowngradePriorityClient(t *testing.T) {
377377 p := & poolTestPeerWithCap {
378378 poolTestPeer : poolTestPeer (0 ),
379379 }
380- pool .updateBalance (p .ID (), int64 (time .Minute ), "" )
380+ pool .addBalance (p .ID (), int64 (time .Minute ), "" )
381381 pool .connect (p , 10 )
382382 if p .cap != 10 {
383383 t .Fatalf ("The capcacity of priority peer hasn't been updated, got: %d" , p .cap )
@@ -393,7 +393,7 @@ func TestDowngradePriorityClient(t *testing.T) {
393393 t .Fatalf ("Positive balance mismatch, want %v, got %v" , 0 , pb .value )
394394 }
395395
396- pool .updateBalance (poolTestPeer (0 ).ID (), int64 (time .Minute ), "" )
396+ pool .addBalance (poolTestPeer (0 ).ID (), int64 (time .Minute ), "" )
397397 pb = pool .ndb .getOrNewPB (poolTestPeer (0 ).ID ())
398398 if pb .value != uint64 (time .Minute ) {
399399 t .Fatalf ("Positive balance mismatch, want %v, got %v" , uint64 (time .Minute ), pb .value )
0 commit comments