planetmint-go/util/mqtt_test.go
Jürgen Eckel 3ca10dfff1
Verifying the availability of PoP participants (#274)
* feat: verify the availability of PoP participants

* simplified and improved logging
* added MQTT-based availability check for PoP participants
* extended MQTT mocking
* Only the block proposer will send out the MQTT messages to the pop participants
* Added a configuration value for the MQTT response timeout
* removed parallel execution of one test case
* added r/w locking to the MQTT response processing
* set MQTT timeout unit to ms

Signed-off-by: Julian Strobl <jmastr@mailbox.org>
2024-01-12 10:02:09 +01:00

34 lines
863 B
Go

package util
import (
"testing"
"github.com/planetmint/planetmint-go/util/mocks"
"github.com/planetmint/planetmint-go/x/dao/types"
"github.com/stretchr/testify/assert"
)
func init() {
// Use MQTT mock client
MQTTClient = &mocks.MockMQTTClient{}
}
func TestSendMqttPopInitMessages(t *testing.T) {
t.Parallel()
var challenge types.Challenge
challenge.Initiator = ""
challenge.Challengee = "plmnt15gdanx0nm2lwsx30a6wft7429p32dhzaq37c06"
challenge.Challenger = "plmnt1683t0us0r85840nsepx6jrk2kjxw7zrcnkf0rp"
challenge.Height = 58
err := sendMqttPopInitMessages(challenge)
assert.NoError(t, err)
}
func TestGetMqttStatusOfParticipantMocked(t *testing.T) {
t.Parallel()
participant := "plmnt15gdanx0nm2lwsx30a6wft7429p32dhzaq37c06"
isAvailable, err := GetMqttStatusOfParticipant(participant)
assert.NoError(t, err)
assert.True(t, isAvailable)
}