forked from TrueCloudLab/frostfs-api-go
[#265] reputation: Implement test package with message generators
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
40505a523d
commit
101d14d405
1 changed files with 66 additions and 0 deletions
66
v2/reputation/test/generate.go
Normal file
66
v2/reputation/test/generate.go
Normal file
|
@ -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
|
||||
}
|
Loading…
Reference in a new issue