51
51
priKey4 = testaddress .Keyinfo ["delta" ].PriKey
52
52
addr5 = testaddress .Addrinfo ["echo" ].String ()
53
53
priKey5 = testaddress .Keyinfo ["echo" ].PriKey
54
+ addr6 = testaddress .Addrinfo ["foxtrot" ].String ()
55
+ priKey6 = testaddress .Keyinfo ["foxtrot" ].PriKey
54
56
)
55
57
56
58
func TestActPool_validateGenericAction (t * testing.T ) {
@@ -202,12 +204,17 @@ func TestActPool_AddActs(t *testing.T) {
202
204
pNonce2 , _ = ap .getPendingNonce (addr2 )
203
205
require .Equal (uint64 (4 ), pNonce2 )
204
206
// Error Case Handling
205
- // Case I: Action already exists in pool
207
+ // Case I: Action source address is blacklisted
208
+ bannedTsf , err := testutil .SignedTransfer (addr6 , priKey6 , uint64 (1 ), big .NewInt (0 ), []byte {}, uint64 (100000 ), big .NewInt (0 ))
209
+ require .NoError (err )
210
+ err = ap .Add (bannedTsf )
211
+ require .True (strings .Contains (err .Error (), "action source address is blacklisted" ))
212
+ // Case II: Action already exists in pool
206
213
err = ap .Add (tsf1 )
207
214
require .Error (err )
208
215
err = ap .Add (vote4 )
209
216
require .Error (err )
210
- // Case II : Pool space/gas space is full
217
+ // Case III : Pool space/gas space is full
211
218
mockBC := mock_blockchain .NewMockBlockchain (ctrl )
212
219
Ap2 , err := NewActPool (mockBC , apConfig , EnableExperimentalActions ())
213
220
require .NoError (err )
@@ -241,7 +248,7 @@ func TestActPool_AddActs(t *testing.T) {
241
248
err = ap3 .Add (tsf10 )
242
249
require .True (strings .Contains (err .Error (), "insufficient gas space for action" ))
243
250
244
- // Case III : Nonce already exists
251
+ // Case IV : Nonce already exists
245
252
replaceTsf , err := testutil .SignedTransfer (addr2 , priKey1 , uint64 (1 ), big .NewInt (1 ), []byte {}, uint64 (100000 ), big .NewInt (0 ))
246
253
require .NoError (err )
247
254
err = ap .Add (replaceTsf )
@@ -259,17 +266,17 @@ func TestActPool_AddActs(t *testing.T) {
259
266
260
267
err = ap .Add (selp )
261
268
require .Equal (action .ErrNonce , errors .Cause (err ))
262
- // Case IV : Nonce is too large
269
+ // Case V : Nonce is too large
263
270
outOfBoundsTsf , err := testutil .SignedTransfer (addr1 , priKey1 , ap .cfg .MaxNumActsPerAcct + 1 , big .NewInt (1 ), []byte {}, uint64 (100000 ), big .NewInt (0 ))
264
271
require .NoError (err )
265
272
err = ap .Add (outOfBoundsTsf )
266
273
require .Equal (action .ErrNonce , errors .Cause (err ))
267
- // Case V : Insufficient balance
274
+ // Case VI : Insufficient balance
268
275
overBalTsf , err := testutil .SignedTransfer (addr2 , priKey2 , uint64 (4 ), big .NewInt (20 ), []byte {}, uint64 (100000 ), big .NewInt (0 ))
269
276
require .NoError (err )
270
277
err = ap .Add (overBalTsf )
271
278
require .Equal (action .ErrBalance , errors .Cause (err ))
272
- // Case VI : over gas limit
279
+ // Case VII : over gas limit
273
280
creationExecution , err := action .NewExecution (
274
281
action .EmptyAddress ,
275
282
uint64 (5 ),
@@ -290,7 +297,7 @@ func TestActPool_AddActs(t *testing.T) {
290
297
291
298
err = ap .Add (selp )
292
299
require .Equal (action .ErrGasHigherThanLimit , errors .Cause (err ))
293
- // Case VII : insufficient gas
300
+ // Case VIII : insufficient gas
294
301
tmpData := [1234 ]byte {}
295
302
creationExecution , err = action .NewExecution (
296
303
action .EmptyAddress ,
@@ -1136,6 +1143,7 @@ func getActPoolCfg() config.ActPool {
1136
1143
MaxGasLimitPerPool : maxGasLimitPerPool ,
1137
1144
MaxNumActsPerAcct : maxNumActsPerAcct ,
1138
1145
MinGasPriceStr : "0" ,
1146
+ BlackList : []string {addr6 },
1139
1147
}
1140
1148
}
1141
1149
0 commit comments