planetmint-go/monitor/mocks/mqtt_monitor.go
Jürgen Eckel 1f2b1702ea
Eckelj/mqtt monitoring fix (#398)
* set keepalive ping
* made mutex more granular
* avoid using app.Logger to have a consistent log from the beginning
* made lazyLoading local to the module
* fixed ticker bug so that the tasks are executed in an endless loop
* fixed timezone bug of Add Participant. only validator local time is used not the timestamp from the mqtt messages as these might come from a different time zone (resulted in delayed deletion from the activeActors DB)
* improved connection management for the monitor
* added a watchdog task to restart the monitor in case of connection loss (every 2 min)
* removed obsolete SetContext function/interface
* removed obsolete time conversion method

Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com>
2024-05-15 13:23:06 +02:00

30 lines
789 B
Go

package mocks
// MockMQTTMonitorClientI is a mock of MQTTMonitorClientI interface.
type MockMQTTMonitorClientI struct {
myStringList []string
}
// AddParticipant mocks base method.
func (m *MockMQTTMonitorClientI) AddParticipant(address string, _ int64) error {
m.myStringList = append(m.myStringList, address)
return nil
}
// SelectPoPParticipantsOutOfActiveActors mocks base method.
func (m *MockMQTTMonitorClientI) SelectPoPParticipantsOutOfActiveActors() (string, string, error) {
var challenger, challengee string
amount := len(m.myStringList)
if amount >= 2 {
challenger = m.myStringList[amount-2]
challengee = m.myStringList[amount-1]
}
return challenger, challengee, nil
}
// Start mocks base method.
func (m *MockMQTTMonitorClientI) Start() error {
return nil
}