mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-24 12:27:18 +00:00
d17996f8b0
* Update V3 from V4 * Fix build v3 -> v4 * Update ssz * Update beacon_chain.pb.go * Fix formatter import * Update update-mockgen.sh comment to v4 * Fix conflicts. Pass build and tests * Fix test
37 lines
870 B
Go
37 lines
870 B
Go
package encoder
|
|
|
|
import (
|
|
"bytes"
|
|
"reflect"
|
|
"testing"
|
|
|
|
"github.com/golang/snappy"
|
|
"github.com/prysmaticlabs/prysm/v4/testing/assert"
|
|
)
|
|
|
|
func TestSszNetworkEncoder_BufferedReader(t *testing.T) {
|
|
r := make([]byte, 10)
|
|
bufR := snappy.NewReader(bytes.NewBuffer(r))
|
|
ptr := reflect.ValueOf(bufR).Pointer()
|
|
bufReaderPool.Put(bufR)
|
|
|
|
r2 := make([]byte, 10)
|
|
rdr := newBufferedReader(bytes.NewBuffer(r2))
|
|
|
|
nPtr := reflect.ValueOf(rdr).Pointer()
|
|
assert.Equal(t, ptr, nPtr, "invalid pointer value")
|
|
}
|
|
|
|
func TestSszNetworkEncoder_BufferedWriter(t *testing.T) {
|
|
r := make([]byte, 10)
|
|
bufR := snappy.NewBufferedWriter(bytes.NewBuffer(r))
|
|
ptr := reflect.ValueOf(bufR).Pointer()
|
|
bufWriterPool.Put(bufR)
|
|
|
|
r2 := make([]byte, 10)
|
|
rdr := newBufferedWriter(bytes.NewBuffer(r2))
|
|
|
|
nPtr := reflect.ValueOf(rdr).Pointer()
|
|
assert.Equal(t, ptr, nPtr, "invalid pointer value")
|
|
}
|