2021-03-24 06:04:26 +00:00
|
|
|
package reputationtest
|
|
|
|
|
|
|
|
import (
|
2023-03-07 10:38:56 +00:00
|
|
|
refstest "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/refs/test"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/reputation"
|
|
|
|
sessiontest "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/session/test"
|
2021-03-24 06:04:26 +00:00
|
|
|
)
|
|
|
|
|
2021-04-01 14:39:29 +00:00
|
|
|
func GeneratePeerID(empty bool) *reputation.PeerID {
|
|
|
|
m := new(reputation.PeerID)
|
|
|
|
|
|
|
|
if !empty {
|
2021-05-07 09:34:24 +00:00
|
|
|
m.SetPublicKey([]byte{1, 2, 3})
|
2021-04-01 14:39:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-03-24 06:04:26 +00:00
|
|
|
func GenerateTrust(empty bool) *reputation.Trust {
|
|
|
|
m := new(reputation.Trust)
|
|
|
|
|
|
|
|
if !empty {
|
|
|
|
m.SetValue(1)
|
2021-06-11 11:49:52 +00:00
|
|
|
m.SetPeer(GeneratePeerID(false))
|
2021-03-24 06:04:26 +00:00
|
|
|
}
|
|
|
|
|
2021-04-01 14:39:29 +00:00
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-04-09 08:28:06 +00:00
|
|
|
func GeneratePeerToPeerTrust(empty bool) *reputation.PeerToPeerTrust {
|
|
|
|
m := new(reputation.PeerToPeerTrust)
|
|
|
|
|
2021-06-11 11:49:52 +00:00
|
|
|
if !empty {
|
|
|
|
m.SetTrustingPeer(GeneratePeerID(false))
|
|
|
|
m.SetTrust(GenerateTrust(false))
|
|
|
|
}
|
2021-04-09 08:28:06 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-04-01 14:39:29 +00:00
|
|
|
func GenerateGlobalTrustBody(empty bool) *reputation.GlobalTrustBody {
|
|
|
|
m := new(reputation.GlobalTrustBody)
|
|
|
|
|
2021-06-11 11:49:52 +00:00
|
|
|
if !empty {
|
|
|
|
m.SetManager(GeneratePeerID(false))
|
|
|
|
m.SetTrust(GenerateTrust(false))
|
|
|
|
}
|
2021-04-01 14:39:29 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
func GenerateGlobalTrust(empty bool) *reputation.GlobalTrust {
|
|
|
|
m := new(reputation.GlobalTrust)
|
|
|
|
|
2021-06-11 11:49:52 +00:00
|
|
|
if !empty {
|
|
|
|
m.SetVersion(refstest.GenerateVersion(false))
|
|
|
|
m.SetBody(GenerateGlobalTrustBody(false))
|
|
|
|
m.SetSignature(refstest.GenerateSignature(empty))
|
|
|
|
}
|
2021-04-01 14:39:29 +00:00
|
|
|
|
2021-03-24 06:04:26 +00:00
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2022-03-02 08:40:47 +00:00
|
|
|
func GenerateTrusts(empty bool) []reputation.Trust {
|
|
|
|
var res []reputation.Trust
|
2021-06-11 11:49:52 +00:00
|
|
|
|
2021-03-24 06:04:26 +00:00
|
|
|
if !empty {
|
|
|
|
res = append(res,
|
2022-03-02 08:40:47 +00:00
|
|
|
*GenerateTrust(false),
|
|
|
|
*GenerateTrust(false),
|
2021-03-24 06:04:26 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2021-06-11 11:49:52 +00:00
|
|
|
return res
|
2021-03-24 06:04:26 +00:00
|
|
|
}
|
|
|
|
|
2021-05-07 09:34:24 +00:00
|
|
|
func GenerateAnnounceLocalTrustRequestBody(empty bool) *reputation.AnnounceLocalTrustRequestBody {
|
|
|
|
m := new(reputation.AnnounceLocalTrustRequestBody)
|
2021-03-24 06:04:26 +00:00
|
|
|
|
|
|
|
if !empty {
|
|
|
|
m.SetEpoch(13)
|
2021-06-11 11:49:52 +00:00
|
|
|
m.SetTrusts(GenerateTrusts(false))
|
2021-03-24 06:04:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-05-07 09:34:24 +00:00
|
|
|
func GenerateAnnounceLocalTrustRequest(empty bool) *reputation.AnnounceLocalTrustRequest {
|
|
|
|
m := new(reputation.AnnounceLocalTrustRequest)
|
2021-03-24 06:04:26 +00:00
|
|
|
|
2021-06-11 11:49:52 +00:00
|
|
|
if !empty {
|
|
|
|
m.SetBody(GenerateAnnounceLocalTrustRequestBody(false))
|
|
|
|
m.SetMetaHeader(sessiontest.GenerateRequestMetaHeader(empty))
|
|
|
|
m.SetVerificationHeader(sessiontest.GenerateRequestVerificationHeader(empty))
|
|
|
|
}
|
2021-03-24 06:04:26 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-05-07 09:34:24 +00:00
|
|
|
func GenerateAnnounceLocalTrustResponseBody(empty bool) *reputation.AnnounceLocalTrustResponseBody {
|
|
|
|
m := new(reputation.AnnounceLocalTrustResponseBody)
|
2021-03-24 06:04:26 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-05-07 09:34:24 +00:00
|
|
|
func GenerateAnnounceLocalTrustResponse(empty bool) *reputation.AnnounceLocalTrustResponse {
|
|
|
|
m := new(reputation.AnnounceLocalTrustResponse)
|
2021-03-24 06:04:26 +00:00
|
|
|
|
2021-06-11 11:49:52 +00:00
|
|
|
if !empty {
|
|
|
|
m.SetBody(GenerateAnnounceLocalTrustResponseBody(false))
|
|
|
|
m.SetMetaHeader(sessiontest.GenerateResponseMetaHeader(empty))
|
|
|
|
m.SetVerificationHeader(sessiontest.GenerateResponseVerificationHeader(empty))
|
|
|
|
}
|
2021-03-24 06:04:26 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
2021-04-01 14:39:29 +00:00
|
|
|
|
2021-05-07 09:34:24 +00:00
|
|
|
func GenerateAnnounceIntermediateResultRequestBody(empty bool) *reputation.AnnounceIntermediateResultRequestBody {
|
|
|
|
m := new(reputation.AnnounceIntermediateResultRequestBody)
|
2021-04-01 14:39:29 +00:00
|
|
|
|
|
|
|
if !empty {
|
2021-04-22 07:40:12 +00:00
|
|
|
m.SetEpoch(123)
|
2021-04-01 14:39:29 +00:00
|
|
|
m.SetIteration(564)
|
2021-06-11 11:49:52 +00:00
|
|
|
m.SetTrust(GeneratePeerToPeerTrust(false))
|
2021-04-01 14:39:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-05-07 09:34:24 +00:00
|
|
|
func GenerateAnnounceIntermediateResultRequest(empty bool) *reputation.AnnounceIntermediateResultRequest {
|
|
|
|
m := new(reputation.AnnounceIntermediateResultRequest)
|
2021-04-01 14:39:29 +00:00
|
|
|
|
2021-06-11 11:49:52 +00:00
|
|
|
if !empty {
|
|
|
|
m.SetBody(GenerateAnnounceIntermediateResultRequestBody(false))
|
|
|
|
}
|
|
|
|
|
2021-04-01 14:39:29 +00:00
|
|
|
m.SetMetaHeader(sessiontest.GenerateRequestMetaHeader(empty))
|
|
|
|
m.SetVerificationHeader(sessiontest.GenerateRequestVerificationHeader(empty))
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-05-07 09:34:24 +00:00
|
|
|
func GenerateAnnounceIntermediateResultResponseBody(empty bool) *reputation.AnnounceIntermediateResultResponseBody {
|
|
|
|
m := new(reputation.AnnounceIntermediateResultResponseBody)
|
2021-04-01 14:39:29 +00:00
|
|
|
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2021-05-07 09:34:24 +00:00
|
|
|
func GenerateAnnounceIntermediateResultResponse(empty bool) *reputation.AnnounceIntermediateResultResponse {
|
|
|
|
m := new(reputation.AnnounceIntermediateResultResponse)
|
2021-04-01 14:39:29 +00:00
|
|
|
|
2021-06-11 11:49:52 +00:00
|
|
|
if !empty {
|
|
|
|
m.SetBody(GenerateAnnounceIntermediateResultResponseBody(false))
|
|
|
|
}
|
|
|
|
|
2021-04-01 14:39:29 +00:00
|
|
|
m.SetMetaHeader(sessiontest.GenerateResponseMetaHeader(empty))
|
|
|
|
m.SetVerificationHeader(sessiontest.GenerateResponseVerificationHeader(empty))
|
|
|
|
|
|
|
|
return m
|
|
|
|
}
|