2020-12-21 13:47:19 +00:00
|
|
|
package audit_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
|
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/nspcc-dev/neofs-node/pkg/morph/client"
|
|
|
|
auditWrapper "github.com/nspcc-dev/neofs-node/pkg/morph/client/audit/wrapper"
|
2021-11-10 07:08:33 +00:00
|
|
|
auditAPI "github.com/nspcc-dev/neofs-sdk-go/audit"
|
|
|
|
cidtest "github.com/nspcc-dev/neofs-sdk-go/container/id/test"
|
2020-12-21 13:47:19 +00:00
|
|
|
"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
|
|
|
|
|
|
|
endpoint := "http://morph_chain.neofs.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)
|
|
|
|
|
|
|
|
morphClient, err := client.New(key, endpoint)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
2021-05-21 11:02:46 +00:00
|
|
|
auditClientWrapper, err := auditWrapper.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
|
|
|
|
|
|
|
auditRes := auditAPI.NewResult()
|
2020-12-25 10:20:09 +00:00
|
|
|
auditRes.SetAuditEpoch(epoch)
|
2021-05-31 08:55:40 +00:00
|
|
|
auditRes.SetPublicKey(key.PublicKey().Bytes())
|
2021-05-31 11:03:17 +00:00
|
|
|
auditRes.SetContainerID(id)
|
2020-12-21 13:47:19 +00:00
|
|
|
|
2021-11-16 20:56:41 +00:00
|
|
|
prm := auditWrapper.PutPrm{}
|
|
|
|
prm.SetResult(auditRes)
|
|
|
|
|
|
|
|
require.NoError(t, auditClientWrapper.PutAuditResult(prm))
|
2020-12-21 13:47:19 +00:00
|
|
|
|
|
|
|
time.Sleep(5 * time.Second)
|
|
|
|
|
2021-05-31 11:03:17 +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
|
|
|
}
|