frostfs-node/pkg/morph/client/audit/result_test.go
Pavel Karpy 923f84722a Move to frostfs-node
Signed-off-by: Pavel Karpy <p.karpy@yadro.com>
2022-12-28 15:04:29 +03:00

57 lines
1.5 KiB
Go

package audit
import (
"testing"
"time"
"github.com/TrueCloudLab/frostfs-node/pkg/morph/client"
auditAPI "github.com/TrueCloudLab/frostfs-sdk-go/audit"
cidtest "github.com/TrueCloudLab/frostfs-sdk-go/container/id/test"
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
"github.com/nspcc-dev/neo-go/pkg/util"
"github.com/stretchr/testify/require"
)
func TestAuditResults(t *testing.T) {
t.Skip()
const epoch = 11
endpoint := "http://morph_chain.frostfs.devenv:30333"
sAuditHash := "cdfb3dab86e6d60e8a143d9e2ecb0b188f3dc2eb"
irKeyWIF := "L3o221BojgcCPYgdbXsm6jn7ayTZ72xwREvBHXKknR8VJ3G4WmjB"
key, err := keys.NewPrivateKeyFromWIF(irKeyWIF)
require.NoError(t, err)
auditHash, err := util.Uint160DecodeStringLE(sAuditHash)
require.NoError(t, err)
morphClient, err := client.New(key, client.WithEndpoints(client.Endpoint{Address: endpoint}))
require.NoError(t, err)
auditClientWrapper, err := NewFromMorph(morphClient, auditHash, 0)
require.NoError(t, err)
id := cidtest.ID()
var auditRes auditAPI.Result
auditRes.ForEpoch(epoch)
auditRes.SetAuditorKey(key.PublicKey().Bytes())
auditRes.ForContainer(id)
prm := PutPrm{}
prm.SetResult(&auditRes)
require.NoError(t, auditClientWrapper.PutAuditResult(prm))
time.Sleep(5 * time.Second)
list, err := auditClientWrapper.ListAuditResultIDByCID(epoch, id)
require.NoError(t, err)
require.Len(t, list, 1)
savedAuditRes, err := auditClientWrapper.GetAuditResult(list[0])
require.NoError(t, err)
require.Equal(t, auditRes, savedAuditRes)
}