@@ -33,9 +33,9 @@ import (
33
33
)
34
34
35
35
const (
36
- maxNumActsPerPool = 8192
36
+ maxNumActsPerPool = 8192
37
37
maxGasLimitPerPool = 81920000
38
- maxNumActsPerAcct = 256
38
+ maxNumActsPerAcct = 256
39
39
)
40
40
41
41
var (
@@ -66,7 +66,7 @@ func TestActPool_validateGenericAction(t *testing.T) {
66
66
_ , err := bc .CreateState (addr1 , big .NewInt (100 ))
67
67
require .NoError (err )
68
68
apConfig := getActPoolCfg ()
69
- Ap , err := NewActPool (bc , apConfig )
69
+ Ap , err := NewActPool (bc , apConfig , EnableExperimentalActions () )
70
70
require .NoError (err )
71
71
ap , ok := Ap .(* actPool )
72
72
require .True (ok )
@@ -132,6 +132,7 @@ func TestActPool_AddActs(t *testing.T) {
132
132
config .Default ,
133
133
blockchain .InMemStateFactoryOption (),
134
134
blockchain .InMemDaoOption (),
135
+ blockchain .EnableExperimentalActions (),
135
136
)
136
137
require .NoError (bc .Start (context .Background ()))
137
138
_ , err := bc .CreateState (addr1 , big .NewInt (100 ))
@@ -140,7 +141,7 @@ func TestActPool_AddActs(t *testing.T) {
140
141
require .NoError (err )
141
142
// Create actpool
142
143
apConfig := getActPoolCfg ()
143
- Ap , err := NewActPool (bc , apConfig )
144
+ Ap , err := NewActPool (bc , apConfig , EnableExperimentalActions () )
144
145
require .NoError (err )
145
146
ap , ok := Ap .(* actPool )
146
147
require .True (ok )
@@ -208,7 +209,7 @@ func TestActPool_AddActs(t *testing.T) {
208
209
require .Error (err )
209
210
// Case II: Pool space/gas space is full
210
211
mockBC := mock_blockchain .NewMockBlockchain (ctrl )
211
- Ap2 , err := NewActPool (mockBC , apConfig )
212
+ Ap2 , err := NewActPool (mockBC , apConfig , EnableExperimentalActions () )
212
213
require .NoError (err )
213
214
ap2 , ok := Ap2 .(* actPool )
214
215
require .True (ok )
@@ -227,15 +228,15 @@ func TestActPool_AddActs(t *testing.T) {
227
228
require .NoError (err )
228
229
ap3 , ok := Ap3 .(* actPool )
229
230
require .True (ok )
230
- for i := uint64 (1 ); i < apConfig .MaxGasLimitPerPool / 10000 ; i ++ {
231
+ for i := uint64 (1 ); i < apConfig .MaxGasLimitPerPool / 10000 ; i ++ {
231
232
nTsf , err := testutil .SignedTransfer (addr2 , priKey2 , i , big .NewInt (50 ), nil , uint64 (10000 ), big .NewInt (0 ))
232
233
require .NoError (err )
233
234
ap3 .allActions [nTsf .Hash ()] = nTsf
234
235
intrinsicGas , err := nTsf .IntrinsicGas ()
235
236
require .NoError (err )
236
237
ap3 .gasInPool += intrinsicGas
237
238
}
238
- tsf10 , err := testutil .SignedTransfer (addr2 , priKey2 , uint64 (apConfig .MaxGasLimitPerPool / 10000 ), big .NewInt (50 ), []byte {1 ,2 , 3 }, uint64 (20000 ), big .NewInt (0 ))
239
+ tsf10 , err := testutil .SignedTransfer (addr2 , priKey2 , uint64 (apConfig .MaxGasLimitPerPool / 10000 ), big .NewInt (50 ), []byte {1 , 2 , 3 }, uint64 (20000 ), big .NewInt (0 ))
239
240
require .NoError (err )
240
241
err = ap3 .Add (tsf10 )
241
242
require .True (strings .Contains (err .Error (), "insufficient gas space for action" ))
@@ -327,7 +328,7 @@ func TestActPool_PickActs(t *testing.T) {
327
328
_ , err = bc .CreateState (addr2 , big .NewInt (10 ))
328
329
require .NoError (err )
329
330
// Create actpool
330
- Ap , err := NewActPool (bc , cfg )
331
+ Ap , err := NewActPool (bc , cfg , EnableExperimentalActions () )
331
332
require .NoError (err )
332
333
ap , ok := Ap .(* actPool )
333
334
require .True (ok )
@@ -402,14 +403,15 @@ func TestActPool_removeConfirmedActs(t *testing.T) {
402
403
config .Default ,
403
404
blockchain .InMemStateFactoryOption (),
404
405
blockchain .InMemDaoOption (),
406
+ blockchain .EnableExperimentalActions (),
405
407
)
406
408
bc .GetFactory ().AddActionHandlers (account .NewProtocol (), vote .NewProtocol (bc ))
407
409
require .NoError (bc .Start (context .Background ()))
408
410
_ , err := bc .CreateState (addr1 , big .NewInt (100 ))
409
411
require .NoError (err )
410
412
// Create actpool
411
413
apConfig := getActPoolCfg ()
412
- Ap , err := NewActPool (bc , apConfig )
414
+ Ap , err := NewActPool (bc , apConfig , EnableExperimentalActions () )
413
415
require .NoError (err )
414
416
ap , ok := Ap .(* actPool )
415
417
require .True (ok )
@@ -471,14 +473,14 @@ func TestActPool_Reset(t *testing.T) {
471
473
require .NoError (err )
472
474
473
475
apConfig := getActPoolCfg ()
474
- Ap1 , err := NewActPool (bc , apConfig )
476
+ Ap1 , err := NewActPool (bc , apConfig , EnableExperimentalActions () )
475
477
require .NoError (err )
476
478
ap1 , ok := Ap1 .(* actPool )
477
479
require .True (ok )
478
480
ap1 .AddActionEnvelopeValidators (protocol .NewGenericValidator (bc , genesis .Default .ActionGasLimit ))
479
481
ap1 .AddActionValidators (account .NewProtocol (), vote .NewProtocol (bc ),
480
482
execution .NewProtocol (bc ))
481
- Ap2 , err := NewActPool (bc , apConfig )
483
+ Ap2 , err := NewActPool (bc , apConfig , EnableExperimentalActions () )
482
484
require .NoError (err )
483
485
ap2 , ok := Ap2 .(* actPool )
484
486
require .True (ok )
@@ -843,13 +845,14 @@ func TestActPool_removeInvalidActs(t *testing.T) {
843
845
config .Default ,
844
846
blockchain .InMemStateFactoryOption (),
845
847
blockchain .InMemDaoOption (),
848
+ blockchain .EnableExperimentalActions (),
846
849
)
847
850
require .NoError (bc .Start (context .Background ()))
848
851
_ , err := bc .CreateState (addr1 , big .NewInt (100 ))
849
852
require .NoError (err )
850
853
// Create actpool
851
854
apConfig := getActPoolCfg ()
852
- Ap , err := NewActPool (bc , apConfig )
855
+ Ap , err := NewActPool (bc , apConfig , EnableExperimentalActions () )
853
856
require .NoError (err )
854
857
ap , ok := Ap .(* actPool )
855
858
require .True (ok )
@@ -890,6 +893,7 @@ func TestActPool_GetPendingNonce(t *testing.T) {
890
893
config .Default ,
891
894
blockchain .InMemStateFactoryOption (),
892
895
blockchain .InMemDaoOption (),
896
+ blockchain .EnableExperimentalActions (),
893
897
)
894
898
require .NoError (bc .Start (context .Background ()))
895
899
_ , err := bc .CreateState (addr1 , big .NewInt (100 ))
@@ -898,7 +902,7 @@ func TestActPool_GetPendingNonce(t *testing.T) {
898
902
require .NoError (err )
899
903
// Create actpool
900
904
apConfig := getActPoolCfg ()
901
- Ap , err := NewActPool (bc , apConfig )
905
+ Ap , err := NewActPool (bc , apConfig , EnableExperimentalActions () )
902
906
require .NoError (err )
903
907
ap , ok := Ap .(* actPool )
904
908
require .True (ok )
@@ -942,7 +946,7 @@ func TestActPool_GetUnconfirmedActs(t *testing.T) {
942
946
require .NoError (err )
943
947
// Create actpool
944
948
apConfig := getActPoolCfg ()
945
- Ap , err := NewActPool (bc , apConfig )
949
+ Ap , err := NewActPool (bc , apConfig , EnableExperimentalActions () )
946
950
require .NoError (err )
947
951
ap , ok := Ap .(* actPool )
948
952
require .True (ok )
@@ -984,7 +988,7 @@ func TestActPool_GetActionByHash(t *testing.T) {
984
988
require .NoError (err )
985
989
// Create actpool
986
990
apConfig := getActPoolCfg ()
987
- Ap , err := NewActPool (bc , apConfig )
991
+ Ap , err := NewActPool (bc , apConfig , EnableExperimentalActions () )
988
992
require .NoError (err )
989
993
ap , ok := Ap .(* actPool )
990
994
require .True (ok )
@@ -1015,7 +1019,7 @@ func TestActPool_GetCapacity(t *testing.T) {
1015
1019
bc := blockchain .NewBlockchain (config .Default , blockchain .InMemStateFactoryOption (), blockchain .InMemDaoOption ())
1016
1020
// Create actpool
1017
1021
apConfig := getActPoolCfg ()
1018
- Ap , err := NewActPool (bc , apConfig )
1022
+ Ap , err := NewActPool (bc , apConfig , EnableExperimentalActions () )
1019
1023
require .NoError (err )
1020
1024
ap , ok := Ap .(* actPool )
1021
1025
require .True (ok )
@@ -1029,14 +1033,15 @@ func TestActPool_GetSize(t *testing.T) {
1029
1033
config .Default ,
1030
1034
blockchain .InMemStateFactoryOption (),
1031
1035
blockchain .InMemDaoOption (),
1036
+ blockchain .EnableExperimentalActions (),
1032
1037
)
1033
1038
bc .GetFactory ().AddActionHandlers (account .NewProtocol (), vote .NewProtocol (bc ))
1034
1039
require .NoError (bc .Start (context .Background ()))
1035
1040
_ , err := bc .CreateState (addr1 , big .NewInt (100 ))
1036
1041
require .NoError (err )
1037
1042
// Create actpool
1038
1043
apConfig := getActPoolCfg ()
1039
- Ap , err := NewActPool (bc , apConfig )
1044
+ Ap , err := NewActPool (bc , apConfig , EnableExperimentalActions () )
1040
1045
require .NoError (err )
1041
1046
ap , ok := Ap .(* actPool )
1042
1047
require .True (ok )
@@ -1085,14 +1090,15 @@ func TestActPool_AddActionNotEnoughGasPride(t *testing.T) {
1085
1090
config .Default ,
1086
1091
blockchain .InMemStateFactoryOption (),
1087
1092
blockchain .InMemDaoOption (),
1093
+ blockchain .EnableExperimentalActions (),
1088
1094
)
1089
1095
require .NoError (t , bc .Start (context .Background ()))
1090
1096
defer func () {
1091
1097
require .NoError (t , bc .Stop (context .Background ()))
1092
1098
}()
1093
1099
1094
1100
cfg := config .Default .ActPool
1095
- ap , err := NewActPool (bc , cfg )
1101
+ ap , err := NewActPool (bc , cfg , EnableExperimentalActions () )
1096
1102
require .NoError (t , err )
1097
1103
tsf , err := testutil .SignedTransfer (
1098
1104
identityset .Address (0 ).String (),
@@ -1126,10 +1132,10 @@ func (ap *actPool) getPendingBalance(addr string) (*big.Int, error) {
1126
1132
1127
1133
func getActPoolCfg () config.ActPool {
1128
1134
return config.ActPool {
1129
- MaxNumActsPerPool : maxNumActsPerPool ,
1135
+ MaxNumActsPerPool : maxNumActsPerPool ,
1130
1136
MaxGasLimitPerPool : maxGasLimitPerPool ,
1131
- MaxNumActsPerAcct : maxNumActsPerAcct ,
1132
- MinGasPriceStr : "0" ,
1137
+ MaxNumActsPerAcct : maxNumActsPerAcct ,
1138
+ MinGasPriceStr : "0" ,
1133
1139
}
1134
1140
}
1135
1141
0 commit comments