@@ -8,6 +8,7 @@ package actpool
8
8
9
9
import (
10
10
"context"
11
+ accountutil "github.com/iotexproject/iotex-core/action/protocol/account/util"
11
12
"math/big"
12
13
"strings"
13
14
"testing"
@@ -107,7 +108,7 @@ func TestActPool_validateGenericAction(t *testing.T) {
107
108
require .NoError (err )
108
109
ap , ok := Ap .(* actPool )
109
110
require .True (ok )
110
- ap .AddActionEnvelopeValidators (protocol .NewGenericValidator (sf .AccountState ))
111
+ ap .AddActionEnvelopeValidators (protocol .NewGenericValidator (sf , accountutil .AccountState ))
111
112
validator := ap .actionEnvelopeValidators [0 ]
112
113
ctx := protocol .WithActionCtx (context .Background (), protocol.ActionCtx {})
113
114
// Case I: Insufficient gas
@@ -183,7 +184,7 @@ func TestActPool_AddActs(t *testing.T) {
183
184
require .NoError (err )
184
185
ap , ok := Ap .(* actPool )
185
186
require .True (ok )
186
- ap .AddActionEnvelopeValidators (protocol .NewGenericValidator (sf .AccountState ))
187
+ ap .AddActionEnvelopeValidators (protocol .NewGenericValidator (sf , accountutil .AccountState ))
187
188
// Test actpool status after adding a sequence of Tsfs/votes: need to check confirmed nonce, pending nonce, and pending balance
188
189
tsf1 , err := testutil .SignedTransfer (addr1 , priKey1 , uint64 (1 ), big .NewInt (10 ), []byte {}, uint64 (100000 ), big .NewInt (0 ))
189
190
require .NoError (err )
@@ -351,7 +352,7 @@ func TestActPool_PickActs(t *testing.T) {
351
352
require .NoError (err )
352
353
ap , ok := Ap .(* actPool )
353
354
require .True (ok )
354
- ap .AddActionEnvelopeValidators (protocol .NewGenericValidator (sf .AccountState ))
355
+ ap .AddActionEnvelopeValidators (protocol .NewGenericValidator (sf , accountutil .AccountState ))
355
356
356
357
tsf1 , err := testutil .SignedTransfer (addr1 , priKey1 , uint64 (1 ), big .NewInt (10 ), []byte {}, uint64 (100000 ), big .NewInt (0 ))
357
358
require .NoError (err )
@@ -435,7 +436,7 @@ func TestActPool_removeConfirmedActs(t *testing.T) {
435
436
require .NoError (err )
436
437
ap , ok := Ap .(* actPool )
437
438
require .True (ok )
438
- ap .AddActionEnvelopeValidators (protocol .NewGenericValidator (sf .AccountState ))
439
+ ap .AddActionEnvelopeValidators (protocol .NewGenericValidator (sf , accountutil .AccountState ))
439
440
440
441
tsf1 , err := testutil .SignedTransfer (addr1 , priKey1 , uint64 (1 ), big .NewInt (10 ), []byte {}, uint64 (100000 ), big .NewInt (0 ))
441
442
require .NoError (err )
@@ -503,12 +504,12 @@ func TestActPool_Reset(t *testing.T) {
503
504
require .NoError (err )
504
505
ap1 , ok := Ap1 .(* actPool )
505
506
require .True (ok )
506
- ap1 .AddActionEnvelopeValidators (protocol .NewGenericValidator (sf .AccountState ))
507
+ ap1 .AddActionEnvelopeValidators (protocol .NewGenericValidator (sf , accountutil .AccountState ))
507
508
Ap2 , err := NewActPool (sf , apConfig , EnableExperimentalActions ())
508
509
require .NoError (err )
509
510
ap2 , ok := Ap2 .(* actPool )
510
511
require .True (ok )
511
- ap2 .AddActionEnvelopeValidators (protocol .NewGenericValidator (sf .AccountState ))
512
+ ap2 .AddActionEnvelopeValidators (protocol .NewGenericValidator (sf , accountutil .AccountState ))
512
513
513
514
// Tsfs to be added to ap1
514
515
tsf1 , err := testutil .SignedTransfer (addr2 , priKey1 , uint64 (1 ), big .NewInt (50 ), []byte {}, uint64 (20000 ), big .NewInt (0 ))
@@ -865,7 +866,7 @@ func TestActPool_removeInvalidActs(t *testing.T) {
865
866
require .NoError (err )
866
867
ap , ok := Ap .(* actPool )
867
868
require .True (ok )
868
- ap .AddActionEnvelopeValidators (protocol .NewGenericValidator (sf .AccountState ))
869
+ ap .AddActionEnvelopeValidators (protocol .NewGenericValidator (sf , accountutil .AccountState ))
869
870
870
871
tsf1 , err := testutil .SignedTransfer (addr1 , priKey1 , uint64 (1 ), big .NewInt (10 ), []byte {}, uint64 (100000 ), big .NewInt (0 ))
871
872
require .NoError (err )
@@ -918,7 +919,7 @@ func TestActPool_GetPendingNonce(t *testing.T) {
918
919
require .NoError (err )
919
920
ap , ok := Ap .(* actPool )
920
921
require .True (ok )
921
- ap .AddActionEnvelopeValidators (protocol .NewGenericValidator (sf .AccountState ))
922
+ ap .AddActionEnvelopeValidators (protocol .NewGenericValidator (sf , accountutil .AccountState ))
922
923
923
924
tsf1 , err := testutil .SignedTransfer (addr1 , priKey1 , uint64 (1 ), big .NewInt (10 ), []byte {}, uint64 (100000 ), big .NewInt (0 ))
924
925
require .NoError (err )
@@ -967,7 +968,8 @@ func TestActPool_GetUnconfirmedActs(t *testing.T) {
967
968
require .NoError (err )
968
969
ap , ok := Ap .(* actPool )
969
970
require .True (ok )
970
- ap .AddActionEnvelopeValidators (protocol .NewGenericValidator (sf .AccountState ))
971
+ ap .AddActionEnvelopeValidators (protocol .NewGenericValidator (sf , accountutil .AccountState ))
972
+
971
973
tsf1 , err := testutil .SignedTransfer (addr1 , priKey1 , uint64 (1 ), big .NewInt (10 ), []byte {}, uint64 (100000 ), big .NewInt (0 ))
972
974
require .NoError (err )
973
975
tsf3 , err := testutil .SignedTransfer (addr1 , priKey1 , uint64 (3 ), big .NewInt (30 ), []byte {}, uint64 (100000 ), big .NewInt (0 ))
@@ -1073,7 +1075,7 @@ func TestActPool_GetSize(t *testing.T) {
1073
1075
require .NoError (err )
1074
1076
ap , ok := Ap .(* actPool )
1075
1077
require .True (ok )
1076
- ap .AddActionEnvelopeValidators (protocol .NewGenericValidator (sf .AccountState ))
1078
+ ap .AddActionEnvelopeValidators (protocol .NewGenericValidator (sf , accountutil .AccountState ))
1077
1079
require .Zero (ap .GetSize ())
1078
1080
require .Zero (ap .GetGasSize ())
1079
1081
@@ -1154,8 +1156,7 @@ func (ap *actPool) getPendingNonce(addr string) (uint64, error) {
1154
1156
if queue , ok := ap .accountActs [addr ]; ok {
1155
1157
return queue .PendingNonce (), nil
1156
1158
}
1157
- committedState , err := ap .sf .AccountState (addr )
1158
-
1159
+ committedState , err := accountutil .AccountState (ap .sf , addr )
1159
1160
return committedState .Nonce + 1 , err
1160
1161
}
1161
1162
@@ -1164,7 +1165,7 @@ func (ap *actPool) getPendingBalance(addr string) (*big.Int, error) {
1164
1165
if queue , ok := ap .accountActs [addr ]; ok {
1165
1166
return queue .PendingBalance (), nil
1166
1167
}
1167
- state , err := ap . sf . AccountState (addr )
1168
+ state , err := accountutil . AccountState (ap . sf , addr )
1168
1169
if err != nil {
1169
1170
return nil , err
1170
1171
}
0 commit comments