@@ -3584,9 +3584,9 @@ func Test_UpdateContextForReplacedHeader(t *testing.T) {
35843584 0 ,
35853585 )
35863586 require .Nil (t , err )
3587- require .True (t , setExecutedCalled )
3588- require .True (t , setExecutionResultCalled )
3589- require .True (t , removePendingCalled )
3587+ require .False (t , setExecutedCalled )
3588+ require .False (t , setExecutionResultCalled )
3589+ require .False (t , removePendingCalled )
35903590 })
35913591
35923592 t .Run ("nil storage should error" , func (t * testing.T ) {
@@ -3767,6 +3767,13 @@ func Test_UpdateContextForReplacedHeader(t *testing.T) {
37673767 t .Run ("successful path with lastNotarizedResult" , func (t * testing.T ) {
37683768 t .Parallel ()
37693769
3770+ prevNotarizedResult := & block.BaseExecutionResult {
3771+ HeaderHash : []byte ("prevNotarizedHash" ),
3772+ HeaderNonce : 4 ,
3773+ HeaderRound : 4 ,
3774+ RootHash : []byte ("prevNotarizedRoot" ),
3775+ }
3776+
37703777 lastNotarizedResult := & block.BaseExecutionResult {
37713778 HeaderHash : []byte ("lastNotarizedHash" ),
37723779 HeaderNonce : 5 ,
@@ -3776,9 +3783,6 @@ func Test_UpdateContextForReplacedHeader(t *testing.T) {
37763783
37773784 removePendingCalled := false
37783785 executionManager := & processMocks.ExecutionManagerMock {
3779- GetPendingExecutionResultsCalled : func () ([]data.BaseExecutionResultHandler , error ) {
3780- return []data.BaseExecutionResultHandler {}, nil
3781- },
37823786 GetLastNotarizedExecutionResultCalled : func () (data.BaseExecutionResultHandler , error ) {
37833787 return lastNotarizedResult , nil
37843788 },
@@ -3789,15 +3793,14 @@ func Test_UpdateContextForReplacedHeader(t *testing.T) {
37893793 },
37903794 }
37913795
3796+ headerToSet := & block.HeaderV3 {
3797+ Nonce : 5 ,
3798+ }
37923799 header := & block.HeaderV3 {
37933800 Nonce : 6 ,
37943801 PrevHash : []byte ("lastNotarizedHash" ),
37953802 }
37963803
3797- headerToSet := & block.HeaderV3 {
3798- Nonce : 5 ,
3799- }
3800-
38013804 setLastExecutedCalled := false
38023805 setLastExecutionResultCalled := false
38033806 blockChain := & testscommon.ChainHandlerStub {
@@ -3813,7 +3816,7 @@ func Test_UpdateContextForReplacedHeader(t *testing.T) {
38133816 },
38143817 GetLastExecutionResultCalled : func () data.BaseExecutionResultHandler {
38153818 return & block.ExecutionResult {
3816- BaseExecutionResult : lastNotarizedResult ,
3819+ BaseExecutionResult : prevNotarizedResult ,
38173820 }
38183821 },
38193822 }
@@ -3941,12 +3944,19 @@ func Test_UpdateContextForReplacedHeader(t *testing.T) {
39413944 RootHash : []byte ("lastNotarizedRoot" ),
39423945 }
39433946
3947+ currentExecResult := & block.BaseExecutionResult {
3948+ HeaderHash : []byte ("currentExecResultHash" ),
3949+ HeaderNonce : 6 ,
3950+ HeaderRound : 6 ,
3951+ RootHash : []byte ("currentExecResultRootHash" ),
3952+ }
3953+
39443954 executionManager := & processMocks.ExecutionManagerMock {
39453955 GetPendingExecutionResultsCalled : func () ([]data.BaseExecutionResultHandler , error ) {
39463956 return []data.BaseExecutionResultHandler {}, nil
39473957 },
39483958 GetLastNotarizedExecutionResultCalled : func () (data.BaseExecutionResultHandler , error ) {
3949- return lastNotarizedResult , nil
3959+ return currentExecResult , nil
39503960 },
39513961 RemovePendingExecutionResultsFromNonceCalled : func (nonce uint64 ) error {
39523962 return errExpected
@@ -3955,7 +3965,7 @@ func Test_UpdateContextForReplacedHeader(t *testing.T) {
39553965
39563966 header := & block.HeaderV3 {
39573967 Nonce : 6 ,
3958- PrevHash : []byte ("lastNotarizedHash " ),
3968+ PrevHash : []byte ("currentExecResultHash " ),
39593969 }
39603970
39613971 headerToSet := & block.HeaderV3 {
@@ -3976,7 +3986,7 @@ func Test_UpdateContextForReplacedHeader(t *testing.T) {
39763986
39773987 headersPool := & mock.HeadersCacherStub {
39783988 GetHeaderByHashCalled : func (hash []byte ) (data.HeaderHandler , error ) {
3979- if bytes .Equal (hash , []byte ("lastNotarizedHash " )) {
3989+ if bytes .Equal (hash , []byte ("currentExecResultHash " )) {
39803990 return headerToSet , nil
39813991 }
39823992 return nil , errors .New ("not found" )
0 commit comments