From 8ce1c5efcc6e49646b3fcfb2798e5e6ce651b001 Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Thu, 1 Apr 2021 17:39:29 +0300 Subject: [PATCH] [#265] reputation: Implement generators of new RPC messages Signed-off-by: Leonard Lyubich --- v2/reputation/test/generate.go | 71 +++++++++++++++++++++++++++++++++- 1 file changed, 70 insertions(+), 1 deletion(-) diff --git a/v2/reputation/test/generate.go b/v2/reputation/test/generate.go index 9cbf3288..4cb525f2 100644 --- a/v2/reputation/test/generate.go +++ b/v2/reputation/test/generate.go @@ -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 +}