mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-09 23:48:06 -05:00
adjust all for review, create test files
Former-commit-id: ff13be57aab24129a97f359464fb5b8154c5a206 [formerly ff9566d3bd5653b23fc2846b26e1b07a15fdc159] Former-commit-id: 371821f0ad0bb76640eed2199f5dc49f979d14d8
This commit is contained in:
@@ -9,7 +9,7 @@ import (
|
|||||||
"math/big"
|
"math/big"
|
||||||
)
|
)
|
||||||
|
|
||||||
// subscribeBlockHeaders checks incoming block headers and determines if
|
// SubscribeBlockHeaders checks incoming block headers and determines if
|
||||||
// we are an eligible proposer for collations. Then, it finds the pending tx's
|
// we are an eligible proposer for collations. Then, it finds the pending tx's
|
||||||
// from the running geth node and sorts them by descending order of gas price,
|
// from the running geth node and sorts them by descending order of gas price,
|
||||||
// eliminates those that ask for too much gas, and routes them over
|
// eliminates those that ask for too much gas, and routes them over
|
||||||
|
|||||||
@@ -1,19 +1,29 @@
|
|||||||
package sharding
|
package sharding
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
"context"
|
||||||
"sync"
|
"fmt"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
// FakeEthService based on implementation of internal/ethapi.Client
|
type FakeClient struct {
|
||||||
type FakeEthService struct {
|
client *FakeEthClient
|
||||||
mu sync.Mutex
|
}
|
||||||
|
|
||||||
getCodeResp hexutil.Bytes
|
type FakeEthClient struct{}
|
||||||
getCodeErr error
|
|
||||||
|
type FakeSubscription struct{}
|
||||||
|
|
||||||
|
func (ec *FakeEthClient) SubscribeNewHead(ctx context.Context, ch chan<- *types.Header) (FakeSubscription, error) {
|
||||||
|
return FakeSubscription{}, fmt.Errorf("error, network disconnected!")
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSubscribeHeaders(t *testing.T) {
|
func TestSubscribeHeaders(t *testing.T) {
|
||||||
|
client := &FakeClient{client: &FakeEthClient{}}
|
||||||
|
err := subscribeBlockHeaders(client)
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("subscribe new headers should work", "no error", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user