mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-27 21:57:16 +00:00
d9fd2521af
* applies assertion funcs to p2p/encoder tests * applies assertion funcs to p2p/peers tests * addr_factory_test + broadcaster_test updated * connection_gater_test updated * applies assertion funcs to p2p/service tests * Merge branch 'master' into p2p-apply-testutils-assertions * minor fixes * Merge branch 'master' into p2p-apply-testutils-assertions * Merge refs/heads/master into p2p-apply-testutils-assertions
37 lines
875 B
Go
37 lines
875 B
Go
package encoder
|
|
|
|
import (
|
|
"bytes"
|
|
"reflect"
|
|
"testing"
|
|
|
|
"github.com/golang/snappy"
|
|
"github.com/prysmaticlabs/prysm/shared/testutil/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")
|
|
}
|