2018-02-06 00:50:32 +00:00
|
|
|
package sharding
|
|
|
|
|
|
|
|
import (
|
2018-02-07 01:06:47 +00:00
|
|
|
"context"
|
|
|
|
"fmt"
|
2018-02-06 00:50:32 +00:00
|
|
|
"testing"
|
2018-02-07 01:06:47 +00:00
|
|
|
|
|
|
|
"github.com/ethereum/go-ethereum/core/types"
|
2018-02-06 00:50:32 +00:00
|
|
|
)
|
|
|
|
|
2018-02-07 01:06:47 +00:00
|
|
|
type FakeClient struct {
|
|
|
|
client *FakeEthClient
|
|
|
|
}
|
|
|
|
|
|
|
|
type FakeEthClient struct{}
|
2018-02-06 04:41:40 +00:00
|
|
|
|
2018-02-07 01:06:47 +00:00
|
|
|
type FakeSubscription struct{}
|
|
|
|
|
|
|
|
func (ec *FakeEthClient) SubscribeNewHead(ctx context.Context, ch chan<- *types.Header) (FakeSubscription, error) {
|
|
|
|
return FakeSubscription{}, fmt.Errorf("error, network disconnected!")
|
2018-02-06 04:41:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestSubscribeHeaders(t *testing.T) {
|
2018-02-07 01:06:47 +00:00
|
|
|
client := &FakeClient{client: &FakeEthClient{}}
|
|
|
|
err := subscribeBlockHeaders(client)
|
|
|
|
if err != nil {
|
|
|
|
t.Errorf("subscribe new headers should work", "no error", err)
|
|
|
|
}
|
2018-02-06 00:50:32 +00:00
|
|
|
}
|