2020-06-02 19:02:21 +00:00
|
|
|
package encoder
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
|
|
|
"reflect"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/golang/snappy"
|
2023-03-17 18:52:56 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/v4/testing/assert"
|
2020-06-02 19:02:21 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
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()
|
2020-07-14 16:51:39 +00:00
|
|
|
assert.Equal(t, ptr, nPtr, "invalid pointer value")
|
2020-06-02 19:02:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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()
|
2020-07-14 16:51:39 +00:00
|
|
|
assert.Equal(t, ptr, nPtr, "invalid pointer value")
|
2020-06-02 19:02:21 +00:00
|
|
|
}
|