Skip to content
Snippets Groups Projects
Commit f0f9c588 authored by Richard T. Carback III's avatar Richard T. Carback III
Browse files

make partitioning tests not crash

parent 387b4919
No related branches found
No related tags found
3 merge requests!510Release,!226WIP: Api2.0,!207WIP: Client Restructure
......@@ -9,10 +9,11 @@ package parse
import (
"bytes"
"gitlab.com/elixxir/client/catalog"
"reflect"
"testing"
"time"
"gitlab.com/elixxir/client/catalog"
)
// Expected firstMessagePart for checking against, generated by fmp in
......@@ -36,12 +37,14 @@ var expectedFMP = firstMessagePart{
// Test that newFirstMessagePart returns a correctly made firstMessagePart.
func Test_newFirstMessagePart(t *testing.T) {
testStr := []byte{'t', 'e', 's', 't', 'i', 'n', 'g', 's', 't', 'r', 'i', 'n', 'g'}
fmp := newFirstMessagePart(
catalog.XxMessage,
1077,
2,
time.Unix(1609786229, 0).UTC(),
[]byte{'t', 'e', 's', 't', 'i', 'n', 'g', 's', 't', 'r', 'i', 'n', 'g'},
testStr,
len(testStr),
)
gotTime := fmp.getTimestamp()
......
......@@ -26,7 +26,8 @@ var expectedMP = messagePart{
// Tests that a new function part is successfully created.
func Test_newMessagePart(t *testing.T) {
goTmp := newMessagePart(32, 6, []byte{'t', 'e', 's', 't', 'i', 'n', 'g'})
testStr := []byte{'t', 'e', 's', 't', 'i', 'n', 'g'}
goTmp := newMessagePart(32, 6, testStr, len(testStr))
if !reflect.DeepEqual(goTmp, expectedMP) {
t.Errorf("MessagePart received and MessagePart expected do not match."+
"\nexpected: %#v\nreceived: %#v", expectedMP, goTmp)
......
......@@ -8,12 +8,13 @@
package parse
import (
"testing"
"gitlab.com/elixxir/client/catalog"
"gitlab.com/elixxir/client/storage/versioned"
"gitlab.com/elixxir/ekv"
"gitlab.com/xx_network/primitives/id"
"gitlab.com/xx_network/primitives/netTime"
"testing"
)
var ipsumTestStr = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras sit amet euismod est. Donec dolor " +
......@@ -68,8 +69,8 @@ func TestPartitioner_Partition(t *testing.T) {
// Test that Partitioner.HandlePartition can handle a message part.
func TestPartitioner_HandlePartition(t *testing.T) {
p := NewPartitioner(versioned.NewKV(ekv.MakeMemstore()), len(ipsumTestStr))
m := newMessagePart(1107, 1, []byte(ipsumTestStr))
p := NewPartitioner(versioned.NewKV(ekv.MakeMemstore()), 256)
m := newMessagePart(1107, 1, []byte(ipsumTestStr), 256)
_, _ = p.HandlePartition(
&id.DummyUser,
......@@ -80,9 +81,9 @@ func TestPartitioner_HandlePartition(t *testing.T) {
// Test that HandlePartition can handle a first message part
func TestPartitioner_HandleFirstPartition(t *testing.T) {
p := NewPartitioner(versioned.NewKV(ekv.MakeMemstore()), len(ipsumTestStr))
p := NewPartitioner(versioned.NewKV(ekv.MakeMemstore()), 256)
m := newFirstMessagePart(
catalog.XxMessage, 1107, 1, netTime.Now(), []byte(ipsumTestStr))
catalog.XxMessage, 1107, 1, netTime.Now(), []byte(ipsumTestStr), 256)
_, _ = p.HandlePartition(
&id.DummyUser,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment