mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-31 23:41:22 +00:00
10d3275638
* applies assertion funcs to beacon-chain/rpc tests * Merge branch 'master' into rpc-apply-testutils-assertions * applies assertion funcs to beacon-chain/rpc/beacon tests * Merge branch 'master' into rpc-apply-testutils-assertions * applies assertion funcs to beacon-chain/rpc/debug tests * applies assertion funcs to beacon-chain/rpc/validator tests * Merge branch 'master' into rpc-apply-testutils-assertions * Merge refs/heads/master into rpc-apply-testutils-assertions
43 lines
1.1 KiB
Go
43 lines
1.1 KiB
Go
package debug
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
|
|
dbTest "github.com/prysmaticlabs/prysm/beacon-chain/db/testing"
|
|
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateutil"
|
|
pbrpc "github.com/prysmaticlabs/prysm/proto/beacon/rpc/v1"
|
|
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
|
|
"github.com/prysmaticlabs/prysm/shared/testutil/require"
|
|
)
|
|
|
|
func TestServer_GetBlock(t *testing.T) {
|
|
db, _ := dbTest.SetupDB(t)
|
|
ctx := context.Background()
|
|
b := ðpb.SignedBeaconBlock{Block: ðpb.BeaconBlock{
|
|
Slot: 100,
|
|
}}
|
|
require.NoError(t, db.SaveBlock(ctx, b))
|
|
blockRoot, err := stateutil.BlockRoot(b.Block)
|
|
require.NoError(t, err)
|
|
bs := &Server{
|
|
BeaconDB: db,
|
|
}
|
|
res, err := bs.GetBlock(ctx, &pbrpc.BlockRequest{
|
|
BlockRoot: blockRoot[:],
|
|
})
|
|
require.NoError(t, err)
|
|
wanted, err := b.MarshalSSZ()
|
|
require.NoError(t, err)
|
|
assert.DeepEqual(t, wanted, res.Encoded)
|
|
|
|
// Checking for nil block.
|
|
blockRoot = [32]byte{}
|
|
res, err = bs.GetBlock(ctx, &pbrpc.BlockRequest{
|
|
BlockRoot: blockRoot[:],
|
|
})
|
|
require.NoError(t, err)
|
|
assert.DeepEqual(t, []byte{}, res.Encoded)
|
|
}
|