forked from TrueCloudLab/frostfs-node
54 lines
1.9 KiB
Go
54 lines
1.9 KiB
Go
package innerring
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
"time"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client"
|
|
control "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/control/ir"
|
|
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestServerState(t *testing.T) {
|
|
keyStr := "03ff65b6ae79134a4dce9d0d39d3851e9bab4ee97abf86e81e1c5bbc50cd2826ae"
|
|
commiteeKeys, err := keys.NewPublicKeysFromStrings([]string{keyStr})
|
|
require.NoError(t, err, "convert string to commitee public keys failed")
|
|
cf := &testCommiteeFetcher{
|
|
keys: commiteeKeys,
|
|
}
|
|
|
|
irKeys, err := keys.NewPublicKeysFromStrings([]string{keyStr})
|
|
require.NoError(t, err, "convert string to IR public keys failed")
|
|
irf := &testIRFetcher{
|
|
keys: irKeys,
|
|
}
|
|
|
|
key, err := keys.NewPublicKeyFromString(keyStr)
|
|
require.NoError(t, err, "convert string to public key failed")
|
|
|
|
require.NoError(t, err, "failed to create morph client")
|
|
srv := &Server{
|
|
statusIndex: newInnerRingIndexer(cf, irf, key, time.Second),
|
|
morphClient: &client.Client{},
|
|
}
|
|
|
|
var epoch uint64 = 100
|
|
srv.SetEpochCounter(epoch)
|
|
require.Equal(t, epoch, srv.EpochCounter(), "invalid epoch counter")
|
|
|
|
var epochDuration uint64 = 15
|
|
srv.SetEpochDuration(epochDuration)
|
|
require.Equal(t, epochDuration, srv.EpochDuration(), "invalid epoch duration")
|
|
|
|
var healthStatus control.HealthStatus = control.HealthStatus_READY
|
|
srv.setHealthStatus(context.Background(), healthStatus)
|
|
require.Equal(t, healthStatus, srv.HealthStatus(), "invalid health status")
|
|
|
|
require.True(t, srv.IsActive(context.Background()), "invalid IsActive result")
|
|
require.True(t, srv.IsAlphabet(context.Background()), "invalid IsAlphabet result")
|
|
require.Equal(t, 0, srv.InnerRingIndex(context.Background()), "invalid IR index")
|
|
require.Equal(t, 1, srv.InnerRingSize(context.Background()), "invalid IR index")
|
|
require.Equal(t, 0, srv.AlphabetIndex(context.Background()), "invalid alphabet index")
|
|
}
|