status-go/services/shhext/dedup/utils_test.go
Igor Mandrigin f4cd8d27b5 Add shhext_getNewFilterMessages function to RPC APIs.
This function returns only the new messages from the filter, never
returns the same message for the same user twice.
2018-04-27 15:24:37 +02:00

27 lines
482 B
Go

package dedup
import (
"crypto/rand"
whisper "github.com/ethereum/go-ethereum/whisper/whisperv6"
)
func generateMessages(count int) []*whisper.Message {
result := []*whisper.Message{}
for ; count > 0; count-- {
content := mustGenerateRandomBytes()
result = append(result, &whisper.Message{Payload: content})
}
return result
}
func mustGenerateRandomBytes() []byte {
c := 2048
b := make([]byte, c)
_, err := rand.Read(b)
if err != nil {
panic(err)
}
return b
}