-
Notifications
You must be signed in to change notification settings - Fork 178
/
mock_orchestrator.go
28 lines (24 loc) · 1.01 KB
/
mock_orchestrator.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
package test
import (
"github.com/onflow/flow-go/insecure"
)
// mockOrchestrator represents a mock orchestrator that is utilized for composability testing.
type mockOrchestrator struct {
attackNetwork insecure.AttackNetwork
// eventCorrupter is an injectable function that tampers with the given event.
eventCorrupter func(event *insecure.Event)
}
// HandleEventFromCorruptedNode implements logic of processing the events received from a corrupted node.
//
// In Corruptible Conduit Framework for BFT testing, corrupted nodes relay their outgoing events to
// the attacker instead of dispatching them to the network.
//
// In this mock orchestrator, the event corrupter is invoked on the event, and the altered event is sent back to
// the flow network.
func (m *mockOrchestrator) HandleEventFromCorruptedNode(event *insecure.Event) error {
m.eventCorrupter(event)
return m.attackNetwork.Send(event)
}
func (m *mockOrchestrator) WithAttackNetwork(attackNetwork insecure.AttackNetwork) {
m.attackNetwork = attackNetwork
}