Skip to content

Commit

Permalink
adjust all for review, create test files
Browse files Browse the repository at this point in the history
  • Loading branch information
rauljordan committed Feb 7, 2018
1 parent 56f35f0 commit 9f11c36
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
2 changes: 1 addition & 1 deletion sharding/collator.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"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
// 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
Expand Down
26 changes: 18 additions & 8 deletions sharding/collator_test.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,29 @@
package sharding

import (
"github.com/ethereum/go-ethereum/common/hexutil"
"sync"
"context"
"fmt"
"testing"

"github.com/ethereum/go-ethereum/core/types"
)

// FakeEthService based on implementation of internal/ethapi.Client
type FakeEthService struct {
mu sync.Mutex
type FakeClient struct {
client *FakeEthClient
}

type FakeEthClient struct{}

getCodeResp hexutil.Bytes
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) {

client := &FakeClient{client: &FakeEthClient{}}
err := subscribeBlockHeaders(client)
if err != nil {
t.Errorf("subscribe new headers should work", "no error", err)
}
}

0 comments on commit 9f11c36

Please sign in to comment.