2018-04-20 11:26:54 +00:00
|
|
|
package dedup
|
|
|
|
|
|
|
|
import (
|
|
|
|
"crypto/rand"
|
|
|
|
|
2019-11-23 17:57:05 +00:00
|
|
|
"github.com/status-im/status-go/eth-node/types"
|
2018-04-20 11:26:54 +00:00
|
|
|
)
|
|
|
|
|
2019-11-23 17:57:05 +00:00
|
|
|
func generateMessages(count int) []*types.Message {
|
|
|
|
result := []*types.Message{}
|
2018-04-20 11:26:54 +00:00
|
|
|
for ; count > 0; count-- {
|
|
|
|
content := mustGenerateRandomBytes()
|
2019-11-23 17:57:05 +00:00
|
|
|
result = append(result, &types.Message{Payload: content})
|
2018-04-20 11:26:54 +00:00
|
|
|
}
|
|
|
|
return result
|
|
|
|
}
|
|
|
|
|
2019-08-20 11:20:25 +00:00
|
|
|
func generateDedupMessages(count int) []*DeduplicateMessage {
|
|
|
|
result := []*DeduplicateMessage{}
|
|
|
|
for ; count > 0; count-- {
|
|
|
|
content := mustGenerateRandomBytes()
|
|
|
|
result = append(result, &DeduplicateMessage{
|
|
|
|
Metadata: Metadata{},
|
2019-11-23 17:57:05 +00:00
|
|
|
Message: &types.Message{Payload: content},
|
2019-08-20 11:20:25 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
return result
|
|
|
|
}
|
|
|
|
|
2018-04-20 11:26:54 +00:00
|
|
|
func mustGenerateRandomBytes() []byte {
|
|
|
|
c := 2048
|
|
|
|
b := make([]byte, c)
|
|
|
|
_, err := rand.Read(b)
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
return b
|
|
|
|
}
|