From 101d14d40551c4bf11923d9bcb5feab9e51a647c Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Wed, 24 Mar 2021 09:04:26 +0300 Subject: [PATCH] [#265] reputation: Implement test package with message generators Signed-off-by: Leonard Lyubich --- v2/reputation/test/generate.go | 66 ++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 v2/reputation/test/generate.go diff --git a/v2/reputation/test/generate.go b/v2/reputation/test/generate.go new file mode 100644 index 00000000..9cbf3288 --- /dev/null +++ b/v2/reputation/test/generate.go @@ -0,0 +1,66 @@ +package reputationtest + +import ( + "github.com/nspcc-dev/neofs-api-go/v2/reputation" + sessiontest "github.com/nspcc-dev/neofs-api-go/v2/session/test" +) + +func GenerateTrust(empty bool) *reputation.Trust { + m := new(reputation.Trust) + + if !empty { + m.SetPeer([]byte{1, 2, 3}) + m.SetValue(1) + } + + return m +} + +func GenerateTrusts(empty bool) (res []*reputation.Trust) { + if !empty { + res = append(res, + GenerateTrust(false), + GenerateTrust(false), + ) + } + + return +} + +func GenerateSendLocalTrustRequestBody(empty bool) *reputation.SendLocalTrustRequestBody { + m := new(reputation.SendLocalTrustRequestBody) + + if !empty { + m.SetEpoch(13) + } + + m.SetTrusts(GenerateTrusts(empty)) + + return m +} + +func GenerateSendLocalTrustRequest(empty bool) *reputation.SendLocalTrustRequest { + m := new(reputation.SendLocalTrustRequest) + + m.SetBody(GenerateSendLocalTrustRequestBody(empty)) + m.SetMetaHeader(sessiontest.GenerateRequestMetaHeader(empty)) + m.SetVerificationHeader(sessiontest.GenerateRequestVerificationHeader(empty)) + + return m +} + +func GenerateSendLocalTrustResponseBody(empty bool) *reputation.SendLocalTrustResponseBody { + m := new(reputation.SendLocalTrustResponseBody) + + return m +} + +func GenerateSendLocalTrustResponse(empty bool) *reputation.SendLocalTrustResponse { + m := new(reputation.SendLocalTrustResponse) + + m.SetBody(GenerateSendLocalTrustResponseBody(empty)) + m.SetMetaHeader(sessiontest.GenerateResponseMetaHeader(empty)) + m.SetVerificationHeader(sessiontest.GenerateResponseVerificationHeader(empty)) + + return m +}