mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 12:57: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
29 lines
899 B
Go
29 lines
899 B
Go
package sync
|
|
|
|
import (
|
|
"bytes"
|
|
"testing"
|
|
|
|
p2ptest "github.com/prysmaticlabs/prysm/v4/beacon-chain/p2p/testing"
|
|
"github.com/prysmaticlabs/prysm/v4/beacon-chain/p2p/types"
|
|
"github.com/prysmaticlabs/prysm/v4/testing/assert"
|
|
"github.com/prysmaticlabs/prysm/v4/testing/require"
|
|
)
|
|
|
|
func TestRegularSync_generateErrorResponse(t *testing.T) {
|
|
r := &Service{
|
|
cfg: &config{p2p: p2ptest.NewTestP2P(t)},
|
|
}
|
|
data, err := r.generateErrorResponse(responseCodeServerError, "something bad happened")
|
|
require.NoError(t, err)
|
|
|
|
buf := bytes.NewBuffer(data)
|
|
b := make([]byte, 1)
|
|
_, err = buf.Read(b)
|
|
require.NoError(t, err)
|
|
assert.Equal(t, responseCodeServerError, b[0], "The first byte was not the status code")
|
|
msg := &types.ErrorMessage{}
|
|
require.NoError(t, r.cfg.p2p.Encoding().DecodeWithMaxLength(buf, msg))
|
|
assert.Equal(t, "something bad happened", string(*msg), "Received the wrong message")
|
|
}
|