mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-03 00:27:38 +00:00
Add Golint (#344)
This commit is contained in:
parent
9cf375267e
commit
bb29e367d5
@ -7,6 +7,9 @@
|
|||||||
"nakedret",
|
"nakedret",
|
||||||
"unparam",
|
"unparam",
|
||||||
"megacheck",
|
"megacheck",
|
||||||
"gosec"
|
"gosec",
|
||||||
|
"varcheck",
|
||||||
|
"structcheck",
|
||||||
|
"golint"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ matrix:
|
|||||||
- lint
|
- lint
|
||||||
script:
|
script:
|
||||||
-
|
-
|
||||||
go get github.com/alecthomas/gometalinter && gometalinter --install && gometalinter ./... --deadline=10m
|
go get github.com/alecthomas/gometalinter && gometalinter --install && gometalinter ./... --deadline=10m --exclude=client/internal/client_helper.go
|
||||||
- os: linux
|
- os: linux
|
||||||
env: V=0.15.0
|
env: V=0.15.0
|
||||||
before_install:
|
before_install:
|
||||||
|
@ -2,6 +2,7 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
|||||||
|
|
||||||
go_library(
|
go_library(
|
||||||
name = "go_default_library",
|
name = "go_default_library",
|
||||||
|
testonly = True,
|
||||||
srcs = ["client_helper.go"],
|
srcs = ["client_helper.go"],
|
||||||
importpath = "github.com/prysmaticlabs/prysm/client/internal",
|
importpath = "github.com/prysmaticlabs/prysm/client/internal",
|
||||||
visibility = ["//client:__subpackages__"],
|
visibility = ["//client:__subpackages__"],
|
||||||
|
@ -33,81 +33,99 @@ type MockClient struct {
|
|||||||
BlockNumber int64
|
BlockNumber int64
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Account returns a mock account.
|
||||||
func (m *MockClient) Account() *accounts.Account {
|
func (m *MockClient) Account() *accounts.Account {
|
||||||
return &accounts.Account{Address: addr}
|
return &accounts.Account{Address: addr}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SMCCaller returns a mock SMCCaller.
|
||||||
func (m *MockClient) SMCCaller() *contracts.SMCCaller {
|
func (m *MockClient) SMCCaller() *contracts.SMCCaller {
|
||||||
return &m.SMC.SMCCaller
|
return &m.SMC.SMCCaller
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ChainReader returns a mock chain reader.
|
||||||
func (m *MockClient) ChainReader() ethereum.ChainReader {
|
func (m *MockClient) ChainReader() ethereum.ChainReader {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SMCTransactor returns a mock SMCTransactor.
|
||||||
func (m *MockClient) SMCTransactor() *contracts.SMCTransactor {
|
func (m *MockClient) SMCTransactor() *contracts.SMCTransactor {
|
||||||
return &m.SMC.SMCTransactor
|
return &m.SMC.SMCTransactor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SMCFilterer returns a mock SMCFilterer.
|
||||||
func (m *MockClient) SMCFilterer() *contracts.SMCFilterer {
|
func (m *MockClient) SMCFilterer() *contracts.SMCFilterer {
|
||||||
return &m.SMC.SMCFilterer
|
return &m.SMC.SMCFilterer
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WaitForTransaction waits for a transaction.
|
||||||
func (m *MockClient) WaitForTransaction(ctx context.Context, hash common.Hash, durationInSeconds time.Duration) error {
|
func (m *MockClient) WaitForTransaction(ctx context.Context, hash common.Hash, durationInSeconds time.Duration) error {
|
||||||
m.CommitWithBlock()
|
m.CommitWithBlock()
|
||||||
m.FastForward(1)
|
m.FastForward(1)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TransactionReceipt returns the transaction receipt from the mock backend.
|
||||||
func (m *MockClient) TransactionReceipt(hash common.Hash) (*gethTypes.Receipt, error) {
|
func (m *MockClient) TransactionReceipt(hash common.Hash) (*gethTypes.Receipt, error) {
|
||||||
return m.Backend.TransactionReceipt(context.Background(), hash)
|
return m.Backend.TransactionReceipt(context.Background(), hash)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CreateTXOpts returns transaction opts with the value assigned.
|
||||||
func (m *MockClient) CreateTXOpts(value *big.Int) (*bind.TransactOpts, error) {
|
func (m *MockClient) CreateTXOpts(value *big.Int) (*bind.TransactOpts, error) {
|
||||||
txOpts := TransactOpts()
|
txOpts := TransactOpts()
|
||||||
txOpts.Value = value
|
txOpts.Value = value
|
||||||
return txOpts, nil
|
return txOpts, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetDepositFlag sets the deposit flag to the boolean value.
|
||||||
func (m *MockClient) SetDepositFlag(value bool) {
|
func (m *MockClient) SetDepositFlag(value bool) {
|
||||||
m.depositFlag = value
|
m.depositFlag = value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DepositFlag value.
|
||||||
func (m *MockClient) DepositFlag() bool {
|
func (m *MockClient) DepositFlag() bool {
|
||||||
return m.depositFlag
|
return m.depositFlag
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sign does nothing?
|
||||||
func (m *MockClient) Sign(hash common.Hash) ([]byte, error) {
|
func (m *MockClient) Sign(hash common.Hash) ([]byte, error) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetShardCount returns constant shard count.
|
||||||
func (m *MockClient) GetShardCount() (int64, error) {
|
func (m *MockClient) GetShardCount() (int64, error) {
|
||||||
return 100, nil
|
return 100, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CommitWithBlock commits a block to the backend.
|
||||||
func (m *MockClient) CommitWithBlock() {
|
func (m *MockClient) CommitWithBlock() {
|
||||||
m.Backend.Commit()
|
m.Backend.Commit()
|
||||||
m.BlockNumber = m.BlockNumber + 1
|
m.BlockNumber = m.BlockNumber + 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FastForward by iterating the mock backend p times.
|
||||||
func (m *MockClient) FastForward(p int) {
|
func (m *MockClient) FastForward(p int) {
|
||||||
for i := 0; i < p*int(shardparams.DefaultPeriodLength); i++ {
|
for i := 0; i < p*int(shardparams.DefaultPeriodLength); i++ {
|
||||||
m.CommitWithBlock()
|
m.CommitWithBlock()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SubscribeNewHead does nothing.
|
||||||
func (m *MockClient) SubscribeNewHead(ctx context.Context, ch chan<- *gethTypes.Header) (ethereum.Subscription, error) {
|
func (m *MockClient) SubscribeNewHead(ctx context.Context, ch chan<- *gethTypes.Header) (ethereum.Subscription, error) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// BlockByNumber creates a block with a given number.
|
||||||
func (m *MockClient) BlockByNumber(ctx context.Context, number *big.Int) (*gethTypes.Block, error) {
|
func (m *MockClient) BlockByNumber(ctx context.Context, number *big.Int) (*gethTypes.Block, error) {
|
||||||
return gethTypes.NewBlockWithHeader(&gethTypes.Header{Number: big.NewInt(m.BlockNumber)}), nil
|
return gethTypes.NewBlockWithHeader(&gethTypes.Header{Number: big.NewInt(m.BlockNumber)}), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TransactOpts Creates a new transaction options.
|
||||||
func TransactOpts() *bind.TransactOpts {
|
func TransactOpts() *bind.TransactOpts {
|
||||||
return bind.NewKeyedTransactor(key)
|
return bind.NewKeyedTransactor(key)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetupMockClient sets up the mock client.
|
||||||
func SetupMockClient(t *testing.T) (*backends.SimulatedBackend, *contracts.SMC) {
|
func SetupMockClient(t *testing.T) (*backends.SimulatedBackend, *contracts.SMC) {
|
||||||
backend := backends.NewSimulatedBackend(core.GenesisAlloc{addr: {Balance: accountBalance}})
|
backend := backends.NewSimulatedBackend(core.GenesisAlloc{addr: {Balance: accountBalance}})
|
||||||
_, _, SMC, err := contracts.DeploySMC(TransactOpts(), backend)
|
_, _, SMC, err := contracts.DeploySMC(TransactOpts(), backend)
|
||||||
|
@ -54,7 +54,7 @@ VERSION:
|
|||||||
app.Usage = `launches a sharding client that interacts with a beacon chain, starts proposer services, shardp2p connections, and more
|
app.Usage = `launches a sharding client that interacts with a beacon chain, starts proposer services, shardp2p connections, and more
|
||||||
`
|
`
|
||||||
app.Action = startNode
|
app.Action = startNode
|
||||||
app.Flags = []cli.Flag{utils.ActorFlag, cmd.VerbosityFlag, cmd.DataDirFlag, cmd.PasswordFileFlag, cmd.NetworkIdFlag, cmd.IPCPathFlag, cmd.RPCProviderFlag, utils.DepositFlag, utils.ShardIDFlag, debug.PProfFlag, debug.PProfAddrFlag, debug.PProfPortFlag, debug.MemProfileRateFlag, debug.CPUProfileFlag, debug.TraceFlag}
|
app.Flags = []cli.Flag{utils.ActorFlag, cmd.VerbosityFlag, cmd.DataDirFlag, cmd.PasswordFileFlag, cmd.NetworkIDFlag, cmd.IPCPathFlag, cmd.RPCProviderFlag, utils.DepositFlag, utils.ShardIDFlag, debug.PProfFlag, debug.PProfAddrFlag, debug.PProfPortFlag, debug.MemProfileRateFlag, debug.CPUProfileFlag, debug.TraceFlag}
|
||||||
|
|
||||||
app.Before = func(ctx *cli.Context) error {
|
app.Before = func(ctx *cli.Context) error {
|
||||||
runtime.GOMAXPROCS(runtime.NumCPU())
|
runtime.GOMAXPROCS(runtime.NumCPU())
|
||||||
|
@ -49,6 +49,7 @@ type EthClient interface {
|
|||||||
DepositFlag() bool
|
DepositFlag() bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FullClient defines the method that will be used for full client usage.
|
||||||
type FullClient interface {
|
type FullClient interface {
|
||||||
EthClient
|
EthClient
|
||||||
Reader
|
Reader
|
||||||
|
@ -136,10 +136,13 @@ func (s *SMCClient) ChainReader() ethereum.ChainReader {
|
|||||||
return ethereum.ChainReader(s.client)
|
return ethereum.ChainReader(s.client)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// BlockByNumber helper function for fetching a mainchain block by its block
|
||||||
|
// number.
|
||||||
func (s *SMCClient) BlockByNumber(ctx context.Context, number *big.Int) (*gethTypes.Block, error) {
|
func (s *SMCClient) BlockByNumber(ctx context.Context, number *big.Int) (*gethTypes.Block, error) {
|
||||||
return s.ChainReader().BlockByNumber(ctx, number)
|
return s.ChainReader().BlockByNumber(ctx, number)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SubscribeNewHead helper function for subscribing to new mainchain headers.
|
||||||
func (s *SMCClient) SubscribeNewHead(ctx context.Context, ch chan<- *gethTypes.Header) (ethereum.Subscription, error) {
|
func (s *SMCClient) SubscribeNewHead(ctx context.Context, ch chan<- *gethTypes.Header) (ethereum.Subscription, error) {
|
||||||
return s.ChainReader().SubscribeNewHead(ctx, ch)
|
return s.ChainReader().SubscribeNewHead(ctx, ch)
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,10 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
DefaultPeriodLength = 5
|
// DefaultPeriodLength is the default value for period lengths in sharding.
|
||||||
|
DefaultPeriodLength = 5
|
||||||
|
// DefaultAttesterLockupLength is the default number of blocks to lock up
|
||||||
|
// an attesters deposit before they can withdraw it.
|
||||||
DefaultAttesterLockupLength = 16128
|
DefaultAttesterLockupLength = 16128
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -30,10 +33,13 @@ func DefaultConfig() *Config {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DefaultAttesterDeposit required to be an attester.
|
||||||
func DefaultAttesterDeposit() *big.Int {
|
func DefaultAttesterDeposit() *big.Int {
|
||||||
return new(big.Int).Exp(big.NewInt(10), big.NewInt(21), nil) // 1000 ETH
|
return new(big.Int).Exp(big.NewInt(10), big.NewInt(21), nil) // 1000 ETH
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DefaultCollationSizeLimit is the integer value representing the maximum
|
||||||
|
// number of bytes allowed in a given collation.
|
||||||
func DefaultCollationSizeLimit() int64 {
|
func DefaultCollationSizeLimit() int64 {
|
||||||
return int64(math.Pow(float64(2), float64(20)))
|
return int64(math.Pow(float64(2), float64(20)))
|
||||||
}
|
}
|
||||||
|
@ -9,19 +9,20 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Custom type which is registered in the flags library which cli uses for
|
// DirectoryString -- Custom type which is registered in the flags library
|
||||||
// argument parsing. This allows us to expand Value to an absolute path when
|
// which cli uses for argument parsing. This allows us to expand Value to
|
||||||
// the argument is parsed
|
// an absolute path when the argument is parsed.
|
||||||
type DirectoryString struct {
|
type DirectoryString struct {
|
||||||
Value string
|
Value string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *DirectoryString) String() string {
|
func (d *DirectoryString) String() string {
|
||||||
return self.Value
|
return d.Value
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *DirectoryString) Set(value string) error {
|
// Set directory string value
|
||||||
self.Value = expandPath(value)
|
func (d *DirectoryString) Set(value string) error {
|
||||||
|
d.Value = expandPath(value)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,7 +47,7 @@ func prefixedNames(fullName string) (prefixed string) {
|
|||||||
return prefixed
|
return prefixed
|
||||||
}
|
}
|
||||||
|
|
||||||
// Custom cli.Flag type which expand the received string to an absolute path.
|
// DirectoryFlag expands the received string to an absolute path.
|
||||||
// e.g. ~/.ethereum -> /home/username/.ethereum
|
// e.g. ~/.ethereum -> /home/username/.ethereum
|
||||||
type DirectoryFlag struct {
|
type DirectoryFlag struct {
|
||||||
Name string
|
Name string
|
||||||
@ -54,12 +55,12 @@ type DirectoryFlag struct {
|
|||||||
Usage string
|
Usage string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self DirectoryFlag) String() string {
|
func (d DirectoryFlag) String() string {
|
||||||
fmtString := "%s %v\t%v"
|
fmtString := "%s %v\t%v"
|
||||||
if len(self.Value.Value) > 0 {
|
if len(d.Value.Value) > 0 {
|
||||||
fmtString = "%s \"%v\"\t%v"
|
fmtString = "%s \"%v\"\t%v"
|
||||||
}
|
}
|
||||||
return fmt.Sprintf(fmtString, prefixedNames(self.Name), self.Value.Value, self.Usage)
|
return fmt.Sprintf(fmtString, prefixedNames(d.Name), d.Value.Value, d.Usage)
|
||||||
}
|
}
|
||||||
|
|
||||||
func eachName(longName string, fn func(string)) {
|
func eachName(longName string, fn func(string)) {
|
||||||
@ -70,20 +71,22 @@ func eachName(longName string, fn func(string)) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// called by cli library, grabs variable from environment (if in env)
|
// Apply is called by cli library, grabs variable from environment (if in env)
|
||||||
// and adds variable to flag set for parsing.
|
// and adds variable to flag set for parsing.
|
||||||
func (self DirectoryFlag) Apply(set *flag.FlagSet) {
|
func (d DirectoryFlag) Apply(set *flag.FlagSet) {
|
||||||
eachName(self.Name, func(name string) {
|
eachName(d.Name, func(name string) {
|
||||||
set.Var(&self.Value, self.Name, self.Usage)
|
set.Var(&d.Value, d.Name, d.Usage)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self DirectoryFlag) GetName() string {
|
// GetName of directory.
|
||||||
return self.Name
|
func (d DirectoryFlag) GetName() string {
|
||||||
|
return d.Name
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *DirectoryFlag) Set(value string) {
|
// Set flag value.
|
||||||
self.Value.Value = value
|
func (d *DirectoryFlag) Set(value string) {
|
||||||
|
d.Value.Value = value
|
||||||
}
|
}
|
||||||
|
|
||||||
// Expands a file path
|
// Expands a file path
|
||||||
|
@ -23,8 +23,8 @@ var (
|
|||||||
Usage: "Data directory for the databases and keystore",
|
Usage: "Data directory for the databases and keystore",
|
||||||
Value: DirectoryString{node.DefaultDataDir()},
|
Value: DirectoryString{node.DefaultDataDir()},
|
||||||
}
|
}
|
||||||
// NetworkIdFlag defines the specific network identifier.
|
// NetworkIDFlag defines the specific network identifier.
|
||||||
NetworkIdFlag = cli.Uint64Flag{
|
NetworkIDFlag = cli.Uint64Flag{
|
||||||
Name: "networkid",
|
Name: "networkid",
|
||||||
Usage: "Network identifier (integer, 1=Frontier, 2=Morden (disused), 3=Ropsten, 4=Rinkeby)",
|
Usage: "Network identifier (integer, 1=Frontier, 2=Morden (disused), 3=Ropsten, 4=Rinkeby)",
|
||||||
Value: 1,
|
Value: 1,
|
||||||
|
@ -40,32 +40,39 @@ import (
|
|||||||
|
|
||||||
// Handler is the global debugging handler.
|
// Handler is the global debugging handler.
|
||||||
var Handler = new(HandlerT)
|
var Handler = new(HandlerT)
|
||||||
|
|
||||||
|
// Memsize is the memsizeui Handler(?).
|
||||||
var Memsize memsizeui.Handler
|
var Memsize memsizeui.Handler
|
||||||
var (
|
var (
|
||||||
// Debug Flags
|
// PProfFlag to enable pprof HTTP server.
|
||||||
PProfFlag = cli.BoolFlag{
|
PProfFlag = cli.BoolFlag{
|
||||||
Name: "pprof",
|
Name: "pprof",
|
||||||
Usage: "Enable the pprof HTTP server",
|
Usage: "Enable the pprof HTTP server",
|
||||||
}
|
}
|
||||||
|
// PProfPortFlag to specify HTTP server listening port.
|
||||||
PProfPortFlag = cli.IntFlag{
|
PProfPortFlag = cli.IntFlag{
|
||||||
Name: "pprofport",
|
Name: "pprofport",
|
||||||
Usage: "pprof HTTP server listening port",
|
Usage: "pprof HTTP server listening port",
|
||||||
Value: 6060,
|
Value: 6060,
|
||||||
}
|
}
|
||||||
|
// PProfAddrFlag to specify HTTP server address.
|
||||||
PProfAddrFlag = cli.StringFlag{
|
PProfAddrFlag = cli.StringFlag{
|
||||||
Name: "pprofaddr",
|
Name: "pprofaddr",
|
||||||
Usage: "pprof HTTP server listening interface",
|
Usage: "pprof HTTP server listening interface",
|
||||||
Value: "127.0.0.1",
|
Value: "127.0.0.1",
|
||||||
}
|
}
|
||||||
|
// MemProfileRateFlag to specify the mem profiling rate.
|
||||||
MemProfileRateFlag = cli.IntFlag{
|
MemProfileRateFlag = cli.IntFlag{
|
||||||
Name: "memprofilerate",
|
Name: "memprofilerate",
|
||||||
Usage: "Turn on memory profiling with the given rate",
|
Usage: "Turn on memory profiling with the given rate",
|
||||||
Value: runtime.MemProfileRate,
|
Value: runtime.MemProfileRate,
|
||||||
}
|
}
|
||||||
|
// CPUProfileFlag to specify where to write the CPU profile.
|
||||||
CPUProfileFlag = cli.StringFlag{
|
CPUProfileFlag = cli.StringFlag{
|
||||||
Name: "cpuprofile",
|
Name: "cpuprofile",
|
||||||
Usage: "Write CPU profile to the given file",
|
Usage: "Write CPU profile to the given file",
|
||||||
}
|
}
|
||||||
|
// TraceFlag to specify where to write the trace execution profile.
|
||||||
TraceFlag = cli.StringFlag{
|
TraceFlag = cli.StringFlag{
|
||||||
Name: "trace",
|
Name: "trace",
|
||||||
Usage: "Write execution trace to the given file",
|
Usage: "Write execution trace to the given file",
|
||||||
@ -343,12 +350,12 @@ func Setup(ctx *cli.Context) error {
|
|||||||
// pprof server
|
// pprof server
|
||||||
if ctx.GlobalBool(PProfFlag.Name) {
|
if ctx.GlobalBool(PProfFlag.Name) {
|
||||||
address := fmt.Sprintf("%s:%d", ctx.GlobalString(PProfAddrFlag.Name), ctx.GlobalInt(PProfPortFlag.Name))
|
address := fmt.Sprintf("%s:%d", ctx.GlobalString(PProfAddrFlag.Name), ctx.GlobalInt(PProfPortFlag.Name))
|
||||||
StartPProf(address)
|
startPProf(address)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func StartPProf(address string) {
|
func startPProf(address string) {
|
||||||
http.Handle("/memsize/", http.StripPrefix("/memsize", &Memsize))
|
http.Handle("/memsize/", http.StripPrefix("/memsize", &Memsize))
|
||||||
log.Info("Starting pprof server", "addr", fmt.Sprintf("http://%s/debug/pprof", address))
|
log.Info("Starting pprof server", "addr", fmt.Sprintf("http://%s/debug/pprof", address))
|
||||||
go func() {
|
go func() {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// This package exists to convert Ethererum 2.0 types to go-ethereum or
|
// Package legacyutil exists to convert Ethererum 2.0 types to go-ethereum or
|
||||||
// Ethereum 1.0 types.
|
// Ethereum 1.0 types.
|
||||||
package legacyutil
|
package legacyutil
|
||||||
|
|
||||||
|
@ -153,7 +153,7 @@ func Deserialize(data []byte) ([]RawBlob, error) {
|
|||||||
|
|
||||||
// if indicator is non-terminal, increase partitions counter
|
// if indicator is non-terminal, increase partitions counter
|
||||||
if databyteLength == 0 {
|
if databyteLength == 0 {
|
||||||
numPartitions += 1
|
numPartitions++
|
||||||
} else {
|
} else {
|
||||||
// if indicator is terminal, append blob info and reset partitions counter
|
// if indicator is terminal, append blob info and reset partitions counter
|
||||||
serializedBlob := SerializedBlob{
|
serializedBlob := SerializedBlob{
|
||||||
|
@ -91,7 +91,7 @@ func TestSubscribeToTopic(t *testing.T) {
|
|||||||
sub := feed.Subscribe(ch)
|
sub := feed.Subscribe(ch)
|
||||||
defer sub.Unsubscribe()
|
defer sub.Unsubscribe()
|
||||||
|
|
||||||
testSubscribe(t, s, gsub, ch, ctx)
|
testSubscribe(ctx, t, s, gsub, ch)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSubscribe(t *testing.T) {
|
func TestSubscribe(t *testing.T) {
|
||||||
@ -116,10 +116,10 @@ func TestSubscribe(t *testing.T) {
|
|||||||
sub := s.Subscribe(pb.CollationBodyRequest{}, ch)
|
sub := s.Subscribe(pb.CollationBodyRequest{}, ch)
|
||||||
defer sub.Unsubscribe()
|
defer sub.Unsubscribe()
|
||||||
|
|
||||||
testSubscribe(t, s, gsub, ch, ctx)
|
testSubscribe(ctx, t, s, gsub, ch)
|
||||||
}
|
}
|
||||||
|
|
||||||
func testSubscribe(t *testing.T, s Server, gsub *floodsub.PubSub, ch chan Message, ctx context.Context) {
|
func testSubscribe(ctx context.Context, t *testing.T, s Server, gsub *floodsub.PubSub, ch chan Message) {
|
||||||
topic := pb.Topic_COLLATION_BODY_REQUEST
|
topic := pb.Topic_COLLATION_BODY_REQUEST
|
||||||
msgType := topicTypeMapping[topic]
|
msgType := topicTypeMapping[topic]
|
||||||
go s.subscribeToTopic(topic, msgType)
|
go s.subscribeToTopic(topic, msgType)
|
||||||
|
Loading…
Reference in New Issue
Block a user