2022-01-31 12:32:51 +00:00
|
|
|
package audit
|
2020-12-21 13:47:19 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
|
2023-03-07 13:38:26 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client"
|
|
|
|
auditAPI "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/audit"
|
|
|
|
cidtest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id/test"
|
2021-05-31 08:55:40 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
2020-12-21 13:47:19 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestAuditResults(t *testing.T) {
|
|
|
|
t.Skip()
|
2020-12-25 10:20:09 +00:00
|
|
|
const epoch = 11
|
2020-12-21 13:47:19 +00:00
|
|
|
|
2022-12-23 17:35:35 +00:00
|
|
|
endpoint := "http://morph_chain.frostfs.devenv:30333"
|
2020-12-25 10:20:09 +00:00
|
|
|
sAuditHash := "cdfb3dab86e6d60e8a143d9e2ecb0b188f3dc2eb"
|
2020-12-21 13:47:19 +00:00
|
|
|
irKeyWIF := "L3o221BojgcCPYgdbXsm6jn7ayTZ72xwREvBHXKknR8VJ3G4WmjB"
|
|
|
|
|
2021-05-31 08:55:40 +00:00
|
|
|
key, err := keys.NewPrivateKeyFromWIF(irKeyWIF)
|
2020-12-21 13:47:19 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
auditHash, err := util.Uint160DecodeStringLE(sAuditHash)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
2022-07-18 13:41:35 +00:00
|
|
|
morphClient, err := client.New(key, client.WithEndpoints(client.Endpoint{Address: endpoint}))
|
2020-12-21 13:47:19 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
|
2022-01-31 12:32:51 +00:00
|
|
|
auditClientWrapper, err := NewFromMorph(morphClient, auditHash, 0)
|
2020-12-21 13:47:19 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
|
2021-12-01 13:56:48 +00:00
|
|
|
id := cidtest.ID()
|
2020-12-21 13:47:19 +00:00
|
|
|
|
2022-05-11 10:26:22 +00:00
|
|
|
var auditRes auditAPI.Result
|
|
|
|
auditRes.ForEpoch(epoch)
|
|
|
|
auditRes.SetAuditorKey(key.PublicKey().Bytes())
|
2022-05-12 16:37:46 +00:00
|
|
|
auditRes.ForContainer(id)
|
2020-12-21 13:47:19 +00:00
|
|
|
|
2022-01-31 12:32:51 +00:00
|
|
|
prm := PutPrm{}
|
2022-05-11 10:26:22 +00:00
|
|
|
prm.SetResult(&auditRes)
|
2021-11-16 20:56:41 +00:00
|
|
|
|
|
|
|
require.NoError(t, auditClientWrapper.PutAuditResult(prm))
|
2020-12-21 13:47:19 +00:00
|
|
|
|
|
|
|
time.Sleep(5 * time.Second)
|
|
|
|
|
2022-05-31 17:00:41 +00:00
|
|
|
list, err := auditClientWrapper.ListAuditResultIDByCID(epoch, id)
|
2020-12-21 13:47:19 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
require.Len(t, list, 1)
|
2020-12-25 10:20:09 +00:00
|
|
|
|
|
|
|
savedAuditRes, err := auditClientWrapper.GetAuditResult(list[0])
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
require.Equal(t, auditRes, savedAuditRes)
|
2020-12-21 13:47:19 +00:00
|
|
|
}
|