-
Notifications
You must be signed in to change notification settings - Fork 199
/
testIntermediateResult.go
55 lines (47 loc) · 2.06 KB
/
testIntermediateResult.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package postprocess
import (
"github.com/ElrondNetwork/elrond-go/core"
"github.com/ElrondNetwork/elrond-go/data"
"github.com/ElrondNetwork/elrond-go/data/block"
"github.com/ElrondNetwork/elrond-go/dataRetriever"
"github.com/ElrondNetwork/elrond-go/hashing"
"github.com/ElrondNetwork/elrond-go/marshal"
"github.com/ElrondNetwork/elrond-go/process"
"github.com/ElrondNetwork/elrond-go/sharding"
)
// TestIntermediateResProc extends intermediateResultsProcessor and is used in integration tests
// as it exposes some functions that are not supposed to be used in production code
// Exported functions simplify the reproduction of edge cases
type TestIntermediateResProc struct {
*intermediateResultsProcessor
}
// NewTestIntermediateResultsProcessor creates a new instance of TestIntermediateResProc
func NewTestIntermediateResultsProcessor(
hasher hashing.Hasher,
marshalizer marshal.Marshalizer,
coordinator sharding.Coordinator,
pubkeyConv core.PubkeyConverter,
store dataRetriever.StorageService,
blockType block.Type,
currTxs dataRetriever.TransactionCacher,
economicsFee process.FeeHandler,
) (*TestIntermediateResProc, error) {
interimProc, err := NewIntermediateResultsProcessor(hasher, marshalizer, coordinator, pubkeyConv, store, blockType, currTxs, economicsFee)
return &TestIntermediateResProc{interimProc}, err
}
// GetIntermediateTransactions returns all the intermediate transactions from the underlying map
func (tirp *TestIntermediateResProc) GetIntermediateTransactions() []data.TransactionHandler {
tirp.mutInterResultsForBlock.Lock()
defer tirp.mutInterResultsForBlock.Unlock()
intermediateTxs := make([]data.TransactionHandler, 0)
for _, val := range tirp.interResultsForBlock {
intermediateTxs = append(intermediateTxs, val.tx)
}
return intermediateTxs
}
// CleanIntermediateTransactions removes the intermediate transactions from the underlying map
func (tirp *TestIntermediateResProc) CleanIntermediateTransactions() {
tirp.mutInterResultsForBlock.Lock()
defer tirp.mutInterResultsForBlock.Unlock()
tirp.interResultsForBlock = map[string]*txInfo{}
}