[#265] reputation: Implement generators of new RPC messages

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2021-04-01 17:39:29 +03:00 committed by Leonard Lyubich
parent 46b3feabe1
commit 8ce1c5efcc

View file

@ -1,18 +1,49 @@
package reputationtest
import (
refstest "github.com/nspcc-dev/neofs-api-go/v2/refs/test"
"github.com/nspcc-dev/neofs-api-go/v2/reputation"
sessiontest "github.com/nspcc-dev/neofs-api-go/v2/session/test"
)
func GeneratePeerID(empty bool) *reputation.PeerID {
m := new(reputation.PeerID)
if !empty {
m.SetValue([]byte{1, 2, 3})
}
return m
}
func GenerateTrust(empty bool) *reputation.Trust {
m := new(reputation.Trust)
if !empty {
m.SetPeer([]byte{1, 2, 3})
m.SetValue(1)
}
m.SetPeer(GeneratePeerID(empty))
return m
}
func GenerateGlobalTrustBody(empty bool) *reputation.GlobalTrustBody {
m := new(reputation.GlobalTrustBody)
m.SetManager(GeneratePeerID(empty))
m.SetTrust(GenerateTrust(empty))
return m
}
func GenerateGlobalTrust(empty bool) *reputation.GlobalTrust {
m := new(reputation.GlobalTrust)
m.SetVersion(refstest.GenerateVersion(empty))
m.SetBody(GenerateGlobalTrustBody(empty))
m.SetSignature(refstest.GenerateSignature(empty))
return m
}
@ -64,3 +95,41 @@ func GenerateSendLocalTrustResponse(empty bool) *reputation.SendLocalTrustRespon
return m
}
func GenerateSendIntermediateResultRequestBody(empty bool) *reputation.SendIntermediateResultRequestBody {
m := new(reputation.SendIntermediateResultRequestBody)
if !empty {
m.SetIteration(564)
}
m.SetTrust(GenerateTrust(empty))
return m
}
func GenerateSendIntermediateResultRequest(empty bool) *reputation.SendIntermediateResultRequest {
m := new(reputation.SendIntermediateResultRequest)
m.SetBody(GenerateSendIntermediateResultRequestBody(empty))
m.SetMetaHeader(sessiontest.GenerateRequestMetaHeader(empty))
m.SetVerificationHeader(sessiontest.GenerateRequestVerificationHeader(empty))
return m
}
func GenerateSendIntermediateResultResponseBody(empty bool) *reputation.SendIntermediateResultResponseBody {
m := new(reputation.SendIntermediateResultResponseBody)
return m
}
func GenerateSendIntermediateResultResponse(empty bool) *reputation.SendIntermediateResultResponse {
m := new(reputation.SendIntermediateResultResponse)
m.SetBody(GenerateSendIntermediateResultResponseBody(empty))
m.SetMetaHeader(sessiontest.GenerateResponseMetaHeader(empty))
m.SetVerificationHeader(sessiontest.GenerateResponseVerificationHeader(empty))
return m
}