Skip to content

Commit 107f2b0

Browse files
committed
fix: fix error in test cases
1 parent 449c55f commit 107f2b0

2 files changed

Lines changed: 37 additions & 5 deletions

File tree

consensus/polybft/consensus_runtime_test.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"testing"
99
"time"
1010

11+
"github.com/0xPolygon/polygon-edge/chain"
1112
"github.com/0xPolygon/polygon-edge/consensus"
1213
"github.com/0xPolygon/polygon-edge/consensus/polybft/bitmap"
1314
"github.com/0xPolygon/polygon-edge/consensus/polybft/contractsapi"
@@ -434,6 +435,11 @@ func TestConsensusRuntime_FSM_NotEndOfEpoch_NotEndOfSprint(t *testing.T) {
434435
},
435436
Key: wallet.NewKey(validators.GetPrivateIdentities()[0]),
436437
blockchain: blockchainMock,
438+
consensusConfig: &consensus.Config{
439+
Params: &chain.Params{
440+
Forks: &chain.Forks{},
441+
},
442+
},
437443
}
438444
runtime := &consensusRuntime{
439445
proposerCalculator: NewProposerCalculatorFromSnapshot(
@@ -452,6 +458,10 @@ func TestConsensusRuntime_FSM_NotEndOfEpoch_NotEndOfSprint(t *testing.T) {
452458
state: newTestState(t),
453459
stateSyncManager: &dummyStateSyncManager{},
454460
checkpointManager: &dummyCheckpointManager{},
461+
stakeManager: &dummyStakeManager{},
462+
rewardWalletCalculator: &rewardWalletCalculator{
463+
blockchain: blockchainMock,
464+
},
455465
}
456466
runtime.setIsActiveValidator(true)
457467

@@ -518,6 +528,11 @@ func TestConsensusRuntime_FSM_EndOfEpoch_BuildCommitEpoch(t *testing.T) {
518528
},
519529
Key: validatorAccounts.GetValidator("A").Key(),
520530
blockchain: blockchainMock,
531+
consensusConfig: &consensus.Config{
532+
Params: &chain.Params{
533+
Forks: &chain.Forks{},
534+
},
535+
},
521536
}
522537

523538
snapshot := NewProposerSnapshot(1, nil)

consensus/polybft/fsm_test.go

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"time"
1010

1111
"github.com/0xPolygon/polygon-edge/bls"
12+
"github.com/0xPolygon/polygon-edge/chain"
1213
"github.com/0xPolygon/polygon-edge/consensus"
1314
"github.com/0xPolygon/polygon-edge/consensus/polybft/bitmap"
1415
"github.com/0xPolygon/polygon-edge/consensus/polybft/contractsapi"
@@ -590,6 +591,7 @@ func TestFSM_VerifyStateTransactions_MiddleOfEpochWithoutTransaction(t *testing.
590591
fsm := &fsm{
591592
commitEpochInput: createTestCommitEpochInput(t, 0, allAccounts, 10),
592593
parent: &types.Header{},
594+
forks: &chain.Forks{},
593595
}
594596
err := fsm.VerifyStateTransactions([]*types.Transaction{})
595597
assert.NoError(t, err)
@@ -604,6 +606,8 @@ func TestFSM_VerifyStateTransactions_EndOfEpochWithoutTransaction(t *testing.T)
604606
fsm := &fsm{
605607
isEndOfEpoch: true,
606608
commitEpochInput: createTestCommitEpochInput(t, 0, allAccounts, 10),
609+
forks: &chain.Forks{},
610+
parent: &types.Header{},
607611
}
608612
assert.EqualError(t, fsm.VerifyStateTransactions([]*types.Transaction{}),
609613
"commit epoch transaction is not found in the epoch ending block")
@@ -857,6 +861,7 @@ func TestFSM_VerifyStateTransactions_EndOfEpochMissingFundRewardWalletTx(t *test
857861
commitEpochInput: createTestCommitEpochInput(t, 0, allAccounts, 10),
858862
rewardWalletFundAmount: common.GetTwoThirdOfMaxUint256(),
859863
logger: hclog.NewNullLogger(),
864+
forks: &chain.Forks{},
860865
}
861866

862867
// create commit epoch transaction in order to add it to the transactions list
@@ -899,6 +904,7 @@ func TestFSM_VerifyStateTransactions_EndOfEpochWithoutFundRewardWalletTx(t *test
899904
),
900905
distributeDAOIncentiveInput: createTestDistributeDAOIncentiveInput(t),
901906
logger: hclog.NewNullLogger(),
907+
forks: &chain.Forks{},
902908
}
903909

904910
// create commit epoch transaction in order to add it to the transactions list
@@ -1008,6 +1014,7 @@ func TestFSM_VerifyStateTransactions_EndOfEpochMissingDistributeVaultFundsTx(t *
10081014
),
10091015
distributeDAOIncentiveInput: createTestDistributeDAOIncentiveInput(t),
10101016
logger: hclog.NewNullLogger(),
1017+
forks: &chain.Forks{},
10111018
}
10121019

10131020
// create commit epoch transaction in order to add it to the transactions list
@@ -1202,6 +1209,7 @@ func TestFSM_VerifyStateTransactions_StateTransactionPass(t *testing.T) {
12021209
),
12031210
distributeDAOIncentiveInput: createTestDistributeDAOIncentiveInput(t),
12041211
logger: hclog.NewNullLogger(),
1212+
forks: &chain.Forks{},
12051213
}
12061214

12071215
// create commit epoch transaction in order to add it to the transactions list
@@ -1251,6 +1259,7 @@ func TestFSM_VerifyStateTransaction_StartOfEpochInvalidSyncValidatorsDataTxIndex
12511259
syncValidatorsDataInput: createTestSyncValidatorsDataInput(t, allAccounts),
12521260
newValidatorsDelta: newValidatorDelta,
12531261
logger: hclog.NewNullLogger(),
1262+
forks: &chain.Forks{},
12541263
}
12551264

12561265
// create sync validators data transaction to add it in the list of state transactions to verify
@@ -1303,6 +1312,7 @@ func TestFSM_VerifyStateTransaction_StartOfEpochInvalidSyncValidatorsDataTxErr(t
13031312
syncValidatorsDataInput: createTestSyncValidatorsDataInput(t, allAccounts),
13041313
newValidatorsDelta: newValidatorDelta,
13051314
logger: hclog.NewNullLogger(),
1315+
forks: &chain.Forks{},
13061316
}
13071317

13081318
syncValidatorsDataInputEncoded, err := fsm.syncValidatorsDataInput.EncodeAbi()
@@ -1349,6 +1359,7 @@ func TestFSM_VerifyStateTransaction_StartOfEpochSingleSyncValidatorsDataTxRequir
13491359
syncValidatorsDataInput: createTestSyncValidatorsDataInput(t, allAccounts),
13501360
newValidatorsDelta: newValidatorDelta,
13511361
logger: hclog.NewNullLogger(),
1362+
forks: &chain.Forks{},
13521363
}
13531364

13541365
// create sync validators data transaction to add it in the list of state transactions to verify
@@ -1383,6 +1394,7 @@ func TestFSM_VerifyStateTransaction_StartOfEpochUnexpectedSyncValidatorsDataTxEr
13831394
validators: validatorSet,
13841395
syncValidatorsDataInput: createTestSyncValidatorsDataInput(t, allAccounts),
13851396
logger: hclog.NewNullLogger(),
1397+
forks: &chain.Forks{},
13861398
}
13871399

13881400
// create sync validators data transaction to add it in the list of state transactions to verify
@@ -1452,6 +1464,7 @@ func TestFSM_VerifyStateTransaction_StartOfEpochMissingSyncValidatorsDataTx(t *t
14521464
syncValidatorsDataInput: createTestSyncValidatorsDataInput(t, validators),
14531465
newValidatorsDelta: newDelta,
14541466
logger: hclog.NewNullLogger(),
1467+
forks: &chain.Forks{},
14551468
}
14561469

14571470
assert.ErrorContains(
@@ -1483,6 +1496,7 @@ func TestFSM_VerifyStateTransaction_SyncValidatorsData(t *testing.T) {
14831496
syncValidatorsDataInput: createTestSyncValidatorsDataInput(t, allAccounts),
14841497
newValidatorsDelta: newValidatorDelta,
14851498
logger: hclog.NewNullLogger(),
1499+
forks: &chain.Forks{},
14861500
}
14871501

14881502
// create sync validators data transaction to add it in the list of state transactions to verify
@@ -1791,6 +1805,7 @@ func TestFSM_Validate_ExitEventRootNotExpected(t *testing.T) {
17911805
exitEventRootHash: types.BytesToHash(
17921806
[]byte{0, 1, 2, 3, 4},
17931807
), // expect this to be in proposal extra
1808+
forks: &chain.Forks{},
17941809
}
17951810

17961811
err = fsm.Validate(proposal)
@@ -1928,6 +1943,7 @@ func TestFSM_Validate_EpochEndingBlock_MismatchInDeltas(t *testing.T) {
19281943
polybftBackend: polybftBackendMock,
19291944
newValidatorsDelta: newValidatorDelta,
19301945
config: &PolyBFTConfig{BlockTimeDrift: 1},
1946+
forks: &chain.Forks{},
19311947
}
19321948

19331949
err = fsm.Validate(proposal)
@@ -2027,6 +2043,7 @@ func TestFSM_Validate_EpochEndingBlock_UpdatingValidatorSetInNonEpochEndingBlock
20272043
logger: hclog.NewNullLogger(),
20282044
polybftBackend: polybftBackendMock,
20292045
config: &PolyBFTConfig{BlockTimeDrift: 1},
2046+
forks: &chain.Forks{},
20302047
}
20312048

20322049
err = fsm.Validate(proposal)
@@ -2485,11 +2502,11 @@ func TestFSM_DecodeCommitEpochStateTx(t *testing.T) {
24852502
// func TestFSM_VerifyStateTransaction_ValidBothTypesOfStateTransactions(t *testing.T) {
24862503
// t.Parallel()
24872504

2488-
// var (
2489-
// commitments [2]*PendingCommitment
2490-
// stateSyncs [2][]*contractsapi.StateSyncedEvent
2491-
// signedCommitments [2]*CommitmentMessageSigned
2492-
// )
2505+
// var (
2506+
// commitments [2]*PendingCommitment
2507+
// stateSyncs [2][]*contractsapi.StateSyncedEvent
2508+
// signedCommitments [2]*CommitmentMessageSigned
2509+
// )
24932510

24942511
// validators := validator.NewTestValidatorsWithAliases(t, []string{"A", "B", "C", "D", "E"})
24952512
// commitments[0], signedCommitments[0], stateSyncs[0] = buildCommitmentAndStateSyncs(t, 10, uint64(3), 2)

0 commit comments

Comments
 (0)