forked from ethereum/go-ethereum
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adjust all for review, create test files
- Loading branch information
1 parent
56f35f0
commit 9f11c36
Showing
2 changed files
with
19 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
} |