Skip to content

Commit

Permalink
fix etc && geth v1.8.16
Browse files Browse the repository at this point in the history
  • Loading branch information
kimmyeonghun committed Sep 27, 2018
1 parent c06eb98 commit 51f1470
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 90 deletions.
4 changes: 3 additions & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@

[submodule "tests"]
path = tests/testdata
url = https://github.com/ethereum/tests
2 changes: 1 addition & 1 deletion circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ test:
- cp ./build/bin/geth $HOME/geth

# Run hive and move all generated logs into the public artifacts folder
- (cd ~/.go_workspace/src/github.com/karalabe/hive && hive --docker-noshell --client=go-esn:local --override=$HOME/geth --test=. --sim=.)
- (cd ~/.go_workspace/src/github.com/karalabe/hive && hive --docker-noshell --client=go-ethereum:local --override=$HOME/geth --test=. --sim=.)
- cp -r ~/.go_workspace/src/github.com/karalabe/hive/workspace/logs/* $CIRCLE_ARTIFACTS
4 changes: 2 additions & 2 deletions mobile/shhclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
package geth

import (
"github.com/ethereum/go-ethereum/whisper/shhclient"
whisper "github.com/ethereum/go-ethereum/whisper/whisperv6"
"github.com/ethersocial/go-esn/whisper/shhclient"
whisper "github.com/ethersocial/go-esn/whisper/whisperv6"
)

// WhisperClient provides access to the Ethereum APIs.
Expand Down
2 changes: 1 addition & 1 deletion params/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
const (
VersionMajor = 0 // Major version component of the current release
VersionMinor = 3 // Minor version component of the current release
VersionPatch = 5 // Patch version component of the current release
VersionPatch = 6 // Patch version component of the current release
VersionMeta = "stable" // Version metadata to append to the version string
)

Expand Down
2 changes: 1 addition & 1 deletion swarm/network/priorityqueue/priorityqueue.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
"context"
"errors"

"github.com/ethereum/go-ethereum/log"
"github.com/ethersocial/go-esn/log"
)

var (
Expand Down
14 changes: 4 additions & 10 deletions swarm/network/stream/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
bv "github.com/ethersocial/go-esn/swarm/network/bitvector"
"github.com/ethersocial/go-esn/swarm/spancontext"
"github.com/ethersocial/go-esn/swarm/storage"
"github.com/opentracing/opentracing-go"
opentracing "github.com/opentracing/opentracing-go"
)

var syncBatchTimeout = 30 * time.Second
Expand Down Expand Up @@ -195,24 +195,18 @@ func (p *Peer) handleOfferedHashesMsg(ctx context.Context, req *OfferedHashesMsg
if err != nil {
return err
}

hashes := req.Hashes
lenHashes := len(hashes)
if lenHashes%HashSize != 0 {
return fmt.Errorf("error invalid hashes length (len: %v)", lenHashes)
}

want, err := bv.New(lenHashes / HashSize)
want, err := bv.New(len(hashes) / HashSize)
if err != nil {
return fmt.Errorf("error initiaising bitvector of length %v: %v", lenHashes/HashSize, err)
return fmt.Errorf("error initiaising bitvector of length %v: %v", len(hashes)/HashSize, err)
}

ctr := 0
errC := make(chan error)
ctx, cancel := context.WithTimeout(ctx, syncBatchTimeout)

ctx = context.WithValue(ctx, "source", p.ID().String())
for i := 0; i < lenHashes; i += HashSize {
for i := 0; i < len(hashes); i += HashSize {
hash := hashes[i : i+HashSize]

if wait := c.NeedData(ctx, hash); wait != nil {
Expand Down
77 changes: 5 additions & 72 deletions swarm/network/stream/streamer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package stream
import (
"bytes"
"context"
"errors"
"testing"
"time"

Expand Down Expand Up @@ -56,12 +55,11 @@ func TestStreamerRequestSubscription(t *testing.T) {
}

var (
hash0 = sha3.Sum256([]byte{0})
hash1 = sha3.Sum256([]byte{1})
hash2 = sha3.Sum256([]byte{2})
hashesTmp = append(hash0[:], hash1[:]...)
hashes = append(hashesTmp, hash2[:]...)
corruptHashes = append(hashes[:40])
hash0 = sha3.Sum256([]byte{0})
hash1 = sha3.Sum256([]byte{1})
hash2 = sha3.Sum256([]byte{2})
hashesTmp = append(hash0[:], hash1[:]...)
hashes = append(hashesTmp, hash2[:]...)
)

type testClient struct {
Expand Down Expand Up @@ -461,71 +459,6 @@ func TestStreamerUpstreamSubscribeLiveAndHistory(t *testing.T) {
}
}

func TestStreamerDownstreamCorruptHashesMsgExchange(t *testing.T) {
tester, streamer, _, teardown, err := newStreamerTester(t)
defer teardown()
if err != nil {
t.Fatal(err)
}

stream := NewStream("foo", "", true)

var tc *testClient

streamer.RegisterClientFunc("foo", func(p *Peer, t string, live bool) (Client, error) {
tc = newTestClient(t)
return tc, nil
})

peerID := tester.IDs[0]

err = streamer.Subscribe(peerID, stream, NewRange(5, 8), Top)
if err != nil {
t.Fatalf("Expected no error, got %v", err)
}

err = tester.TestExchanges(p2ptest.Exchange{
Label: "Subscribe message",
Expects: []p2ptest.Expect{
{
Code: 4,
Msg: &SubscribeMsg{
Stream: stream,
History: NewRange(5, 8),
Priority: Top,
},
Peer: peerID,
},
},
},
p2ptest.Exchange{
Label: "Corrupt offered hash message",
Triggers: []p2ptest.Trigger{
{
Code: 1,
Msg: &OfferedHashesMsg{
HandoverProof: &HandoverProof{
Handover: &Handover{},
},
Hashes: corruptHashes,
From: 5,
To: 8,
Stream: stream,
},
Peer: peerID,
},
},
})
if err != nil {
t.Fatal(err)
}

expectedError := errors.New("Message handler error: (msg code 1): error invalid hashes length (len: 40)")
if err := tester.TestDisconnected(&p2ptest.Disconnect{Peer: tester.IDs[0], Error: expectedError}); err != nil {
t.Fatal(err)
}
}

func TestStreamerDownstreamOfferedHashesMsgExchange(t *testing.T) {
tester, streamer, _, teardown, err := newStreamerTester(t)
defer teardown()
Expand Down
2 changes: 1 addition & 1 deletion swarm/storage/mru/testutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"path/filepath"
"sync"

"github.com/ethereum/go-ethereum/p2p/discover"
"github.com/ethersocial/go-esn/p2p/discover"

"github.com/ethersocial/go-esn/swarm/storage"
)
Expand Down
2 changes: 1 addition & 1 deletion swarm/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
const (
VersionMajor = 0 // Major version component of the current release
VersionMinor = 3 // Minor version component of the current release
VersionPatch = 3 // Patch version component of the current release
VersionPatch = 4 // Patch version component of the current release
VersionMeta = "stable" // Version metadata to append to the version string
)

Expand Down

0 comments on commit 51f1470

Please sign in to comment.