mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-03 00:27:38 +00:00
sharding/client: Fixing Tests (#92)
Former-commit-id: 85e659f3ea43c983f8df54ab8a3150a560b2dbf8 [formerly 2c0a181754a07dbda855d1da8042a09c9e9a040d] Former-commit-id: 0198766ea1336efff88b9292b6ee1b53ef86b000
This commit is contained in:
parent
1df5683734
commit
4e5c535426
@ -146,7 +146,7 @@ func Serialize(rawtx []interface{}) ([]byte, error) {
|
||||
}
|
||||
|
||||
// Deserializebody results in the Collation body being deserialised and separated into its respective interfaces.
|
||||
func Deserializebody(collationbody []byte, rawtx []interface{}) error {
|
||||
func Deserializebody(collationbody []byte, rawtx interface{}) error {
|
||||
|
||||
length := int64(len(collationbody))
|
||||
chunksNumber := length / chunkSize
|
||||
@ -155,7 +155,7 @@ func Deserializebody(collationbody []byte, rawtx []interface{}) error {
|
||||
deserializedblob := []byte{}
|
||||
|
||||
// This separates the collation body into its respective transaction blobs
|
||||
for i := int64(1); i <= chunksNumber+1; i++ {
|
||||
for i := int64(1); i <= chunksNumber; i++ {
|
||||
indicatorIndex := (i - 1) * chunkSize
|
||||
// Tests if the chunk delimiter is zero, if it is it will append the data chunk
|
||||
// to tempbody
|
||||
@ -166,7 +166,7 @@ func Deserializebody(collationbody []byte, rawtx []interface{}) error {
|
||||
// add it and append to the rawtx slice. The tempbody signifies a deserialized blob
|
||||
} else {
|
||||
terminalIndex := int64(collationbody[indicatorIndex])
|
||||
tempbody = append(tempbody, collationbody[(indicatorIndex+1):(indicatorIndex+2+terminalIndex)]...)
|
||||
tempbody = append(tempbody, collationbody[(indicatorIndex+1):(indicatorIndex+1+terminalIndex)]...)
|
||||
deserializedblob = append(deserializedblob, tempbody...)
|
||||
tempbody = []byte{}
|
||||
|
||||
|
@ -3,16 +3,16 @@ package client
|
||||
import (
|
||||
"math/rand"
|
||||
"reflect"
|
||||
"runtime"
|
||||
//"runtime"
|
||||
"testing"
|
||||
)
|
||||
|
||||
var testbody []interface{}
|
||||
var testbody interface{}
|
||||
|
||||
func buildblob() []byte {
|
||||
func buildblob(size int64) []byte {
|
||||
|
||||
tempbody := make([]byte, 500)
|
||||
for i := int64(0); i < 500; i++ {
|
||||
tempbody := make([]byte, size)
|
||||
for i := int64(0); i < size; i++ {
|
||||
tempbody[i] = byte(rand.Int())
|
||||
|
||||
}
|
||||
@ -32,22 +32,23 @@ func TestConvertInterface(t *testing.T) {
|
||||
|
||||
func TestSerializeblob(t *testing.T) {
|
||||
|
||||
blob := buildblob()
|
||||
blob := buildblob(20)
|
||||
|
||||
serializedblob, err := serializeBlob(blob)
|
||||
|
||||
if err != nil {
|
||||
t.Fatalf("Error Serializing blob:%v %v", err, serializedblob)
|
||||
}
|
||||
runtime.Breakpoint()
|
||||
err2 := Deserializebody(serializedblob, testbody)
|
||||
test := &testbody
|
||||
//runtime.Breakpoint()
|
||||
err2 := Deserializebody(serializedblob, &testbody)
|
||||
if err2 != nil {
|
||||
t.Fatalf("Error Serializing blob:%v", err2)
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(blob, testbody) {
|
||||
|
||||
t.Fatalf("Error Serializing blob with %v %v", blob, testbody)
|
||||
t.Fatalf("Error Serializing blob with %v %v %v", blob, test, &testbody)
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user