@@ -32,6 +32,7 @@ import (
32
32
"github.com/iotexproject/iotex-core/action/protocol/execution/evm"
33
33
"github.com/iotexproject/iotex-core/action/protocol/rewarding"
34
34
"github.com/iotexproject/iotex-core/action/protocol/rolldpos"
35
+ "github.com/iotexproject/iotex-core/actpool"
35
36
"github.com/iotexproject/iotex-core/blockchain"
36
37
"github.com/iotexproject/iotex-core/blockchain/block"
37
38
"github.com/iotexproject/iotex-core/blockchain/blockdao"
@@ -215,6 +216,7 @@ func runExecution(
215
216
bc blockchain.Blockchain ,
216
217
sf factory.Factory ,
217
218
dao blockdao.BlockDAO ,
219
+ ap actpool.ActPool ,
218
220
ecfg * ExecutionConfig ,
219
221
contractAddr string ,
220
222
) ([]byte , * action.Receipt , error ) {
@@ -256,12 +258,10 @@ func runExecution(
256
258
if err != nil {
257
259
return nil , nil , err
258
260
}
259
- actionMap := make (map [string ][]action.SealedEnvelope )
260
- actionMap [ecfg .Executor ().String ()] = []action.SealedEnvelope {selp }
261
- blk , err := bc .MintNewBlock (
262
- actionMap ,
263
- testutil .TimestampNow (),
264
- )
261
+ if err := ap .Add (context .Background (), selp ); err != nil {
262
+ return nil , nil , err
263
+ }
264
+ blk , err := bc .MintNewBlock (testutil .TimestampNow ())
265
265
if err != nil {
266
266
return nil , nil , err
267
267
}
@@ -276,14 +276,15 @@ func runExecution(
276
276
func (sct * SmartContractTest ) prepareBlockchain (
277
277
ctx context.Context ,
278
278
r * require.Assertions ,
279
- ) (blockchain.Blockchain , factory.Factory , blockdao.BlockDAO ) {
279
+ ) (blockchain.Blockchain , factory.Factory , blockdao.BlockDAO , actpool. ActPool ) {
280
280
cfg := config .Default
281
281
defer func () {
282
282
delete (cfg .Plugins , config .GatewayPlugin )
283
283
}()
284
284
cfg .Plugins [config .GatewayPlugin ] = true
285
285
cfg .Chain .EnableAsyncIndexWrite = false
286
286
cfg .Genesis .EnableGravityChainVoting = false
287
+ cfg .ActPool .MinGasPriceStr = "0"
287
288
if sct .InitGenesis .IsBering {
288
289
cfg .Genesis .Blockchain .BeringBlockHeight = 0
289
290
}
@@ -298,6 +299,8 @@ func (sct *SmartContractTest) prepareBlockchain(
298
299
// create state factory
299
300
sf , err := factory .NewFactory (cfg , factory .InMemTrieOption (), factory .RegistryOption (registry ))
300
301
r .NoError (err )
302
+ ap , err := actpool .NewActPool (sf , cfg .ActPool )
303
+ r .NoError (err )
301
304
// create indexer
302
305
indexer , err := blockindex .NewIndexer (db .NewMemKVStore (), cfg .Genesis .Hash ())
303
306
r .NoError (err )
@@ -307,7 +310,7 @@ func (sct *SmartContractTest) prepareBlockchain(
307
310
bc := blockchain .NewBlockchain (
308
311
cfg ,
309
312
dao ,
310
- sf ,
313
+ factory . NewMinter ( sf , ap ) ,
311
314
blockchain .BlockValidatorOption (block .NewValidator (
312
315
sf ,
313
316
protocol .NewGenericValidator (sf , accountutil .AccountState ),
@@ -321,20 +324,21 @@ func (sct *SmartContractTest) prepareBlockchain(
321
324
r .NoError (execution .Register (registry ))
322
325
r .NoError (bc .Start (ctx ))
323
326
324
- return bc , sf , dao
327
+ return bc , sf , dao , ap
325
328
}
326
329
327
330
func (sct * SmartContractTest ) deployContracts (
328
331
bc blockchain.Blockchain ,
329
332
sf factory.Factory ,
330
333
dao blockdao.BlockDAO ,
334
+ ap actpool.ActPool ,
331
335
r * require.Assertions ,
332
336
) (contractAddresses []string ) {
333
337
for i , contract := range sct .Deployments {
334
338
if contract .AppendContractAddress {
335
339
contract .ContractAddressToAppend = contractAddresses [contract .ContractIndexToAppend ]
336
340
}
337
- _ , receipt , err := runExecution (bc , sf , dao , & contract , action .EmptyAddress )
341
+ _ , receipt , err := runExecution (bc , sf , dao , ap , & contract , action .EmptyAddress )
338
342
r .NoError (err )
339
343
r .NotNil (receipt )
340
344
if sct .InitGenesis .IsBering {
@@ -372,13 +376,13 @@ func (sct *SmartContractTest) deployContracts(
372
376
func (sct * SmartContractTest ) run (r * require.Assertions ) {
373
377
// prepare blockchain
374
378
ctx := context .Background ()
375
- bc , sf , dao := sct .prepareBlockchain (ctx , r )
379
+ bc , sf , dao , ap := sct .prepareBlockchain (ctx , r )
376
380
defer func () {
377
381
r .NoError (bc .Stop (ctx ))
378
382
}()
379
383
380
384
// deploy smart contract
381
- contractAddresses := sct .deployContracts (bc , sf , dao , r )
385
+ contractAddresses := sct .deployContracts (bc , sf , dao , ap , r )
382
386
if len (contractAddresses ) == 0 {
383
387
return
384
388
}
@@ -389,7 +393,7 @@ func (sct *SmartContractTest) run(r *require.Assertions) {
389
393
if exec .AppendContractAddress {
390
394
exec .ContractAddressToAppend = contractAddresses [exec .ContractIndexToAppend ]
391
395
}
392
- retval , receipt , err := runExecution (bc , sf , dao , & exec , contractAddr )
396
+ retval , receipt , err := runExecution (bc , sf , dao , ap , & exec , contractAddr )
393
397
r .NoError (err )
394
398
r .NotNil (receipt )
395
399
@@ -482,6 +486,7 @@ func TestProtocol_Handle(t *testing.T) {
482
486
cfg .Chain .IndexDBPath = testIndexPath
483
487
cfg .Chain .EnableAsyncIndexWrite = false
484
488
cfg .Genesis .EnableGravityChainVoting = false
489
+ cfg .ActPool .MinGasPriceStr = "0"
485
490
cfg .Genesis .InitBalanceMap [identityset .Address (27 ).String ()] = unit .ConvertIotxToRau (1000000000 ).String ()
486
491
registry := protocol .NewRegistry ()
487
492
acc := account .NewProtocol (rewarding .DepositGas )
@@ -491,6 +496,8 @@ func TestProtocol_Handle(t *testing.T) {
491
496
// create state factory
492
497
sf , err := factory .NewStateDB (cfg , factory .DefaultStateDBOption (), factory .RegistryStateDBOption (registry ))
493
498
require .NoError (err )
499
+ ap , err := actpool .NewActPool (sf , cfg .ActPool )
500
+ require .NoError (err )
494
501
// create indexer
495
502
cfg .DB .DbPath = cfg .Chain .IndexDBPath
496
503
indexer , err := blockindex .NewIndexer (db .NewBoltDB (cfg .DB ), hash .ZeroHash256 )
@@ -502,7 +509,7 @@ func TestProtocol_Handle(t *testing.T) {
502
509
bc := blockchain .NewBlockchain (
503
510
cfg ,
504
511
dao ,
505
- sf ,
512
+ factory . NewMinter ( sf , ap ) ,
506
513
blockchain .BlockValidatorOption (block .NewValidator (
507
514
sf ,
508
515
protocol .NewGenericValidator (sf , accountutil .AccountState ),
@@ -527,12 +534,8 @@ func TestProtocol_Handle(t *testing.T) {
527
534
selp , err := action .Sign (elp , identityset .PrivateKey (27 ))
528
535
require .NoError (err )
529
536
530
- actionMap := make (map [string ][]action.SealedEnvelope )
531
- actionMap [identityset .Address (27 ).String ()] = []action.SealedEnvelope {selp }
532
- blk , err := bc .MintNewBlock (
533
- actionMap ,
534
- testutil .TimestampNow (),
535
- )
537
+ require .NoError (ap .Add (context .Background (), selp ))
538
+ blk , err := bc .MintNewBlock (testutil .TimestampNow ())
536
539
require .NoError (err )
537
540
require .NoError (bc .CommitBlock (blk ))
538
541
require .Equal (1 , len (blk .Receipts ))
@@ -580,12 +583,8 @@ func TestProtocol_Handle(t *testing.T) {
580
583
581
584
log .S ().Infof ("execution %+v" , execution )
582
585
583
- actionMap = make (map [string ][]action.SealedEnvelope )
584
- actionMap [identityset .Address (27 ).String ()] = []action.SealedEnvelope {selp }
585
- blk , err = bc .MintNewBlock (
586
- actionMap ,
587
- testutil .TimestampNow (),
588
- )
586
+ require .NoError (ap .Add (context .Background (), selp ))
587
+ blk , err = bc .MintNewBlock (testutil .TimestampNow ())
589
588
require .NoError (err )
590
589
require .NoError (bc .CommitBlock (blk ))
591
590
require .Equal (1 , len (blk .Receipts ))
@@ -618,12 +617,8 @@ func TestProtocol_Handle(t *testing.T) {
618
617
require .NoError (err )
619
618
620
619
log .S ().Infof ("execution %+v" , execution )
621
- actionMap = make (map [string ][]action.SealedEnvelope )
622
- actionMap [identityset .Address (27 ).String ()] = []action.SealedEnvelope {selp }
623
- blk , err = bc .MintNewBlock (
624
- actionMap ,
625
- testutil .TimestampNow (),
626
- )
620
+ require .NoError (ap .Add (context .Background (), selp ))
621
+ blk , err = bc .MintNewBlock (testutil .TimestampNow ())
627
622
require .NoError (err )
628
623
require .NoError (bc .CommitBlock (blk ))
629
624
require .Equal (1 , len (blk .Receipts ))
@@ -644,12 +639,8 @@ func TestProtocol_Handle(t *testing.T) {
644
639
selp , err = action .Sign (elp , identityset .PrivateKey (27 ))
645
640
require .NoError (err )
646
641
647
- actionMap = make (map [string ][]action.SealedEnvelope )
648
- actionMap [identityset .Address (27 ).String ()] = []action.SealedEnvelope {selp }
649
- blk , err = bc .MintNewBlock (
650
- actionMap ,
651
- testutil .TimestampNow (),
652
- )
642
+ require .NoError (ap .Add (context .Background (), selp ))
643
+ blk , err = bc .MintNewBlock (testutil .TimestampNow ())
653
644
require .NoError (err )
654
645
require .NoError (bc .CommitBlock (blk ))
655
646
require .Equal (1 , len (blk .Receipts ))
0 commit comments