forked from TrueCloudLab/frostfs-node
[#452] Use API structures for reputation PeerID and GlobalTrust
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
7cf48d4d91
commit
27cf6f5112
6 changed files with 116 additions and 36 deletions
|
@ -5,19 +5,34 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
|
||||
"github.com/nspcc-dev/neofs-api-go/pkg/reputation"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/morph/event"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/services/reputation"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestParsePut(t *testing.T) {
|
||||
var (
|
||||
peerID reputation.PeerID
|
||||
|
||||
value reputation.GlobalTrust
|
||||
trust reputation.Trust
|
||||
trustValue float64 = 64
|
||||
|
||||
epoch uint64 = 42
|
||||
|
||||
peerID = reputation.PeerIDFromBytes([]byte("peerID"))
|
||||
value = []byte("There should be marshalled structure")
|
||||
rawPeerID = [33]byte{1, 2, 3, 4, 5, 6}
|
||||
)
|
||||
|
||||
peerID.SetPublicKey(rawPeerID)
|
||||
|
||||
trust.SetValue(trustValue)
|
||||
trust.SetPeer(&peerID)
|
||||
|
||||
value.SetTrust(&trust)
|
||||
|
||||
rawValue, err := value.Marshal()
|
||||
require.NoError(t, err)
|
||||
|
||||
t.Run("wrong number of parameters", func(t *testing.T) {
|
||||
prms := []stackitem.Item{
|
||||
stackitem.NewMap(),
|
||||
|
@ -48,7 +63,7 @@ func TestParsePut(t *testing.T) {
|
|||
t.Run("wrong value parameter", func(t *testing.T) {
|
||||
_, err := ParsePut([]stackitem.Item{
|
||||
stackitem.NewBigInteger(new(big.Int).SetUint64(epoch)),
|
||||
stackitem.NewByteArray(peerID.Bytes()),
|
||||
stackitem.NewByteArray(rawPeerID[:]),
|
||||
stackitem.NewMap(),
|
||||
})
|
||||
|
||||
|
@ -58,8 +73,8 @@ func TestParsePut(t *testing.T) {
|
|||
t.Run("correct behavior", func(t *testing.T) {
|
||||
ev, err := ParsePut([]stackitem.Item{
|
||||
stackitem.NewBigInteger(new(big.Int).SetUint64(epoch)),
|
||||
stackitem.NewByteArray(peerID.Bytes()),
|
||||
stackitem.NewByteArray(value),
|
||||
stackitem.NewByteArray(rawPeerID[:]),
|
||||
stackitem.NewByteArray(rawValue),
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue