From b9b3efb09f9281a5859646d2dcf36b5813132efb Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Mon, 9 Jan 2017 11:16:06 +0100 Subject: all: fix ineffectual assignments and remove uses of crypto.Sha3 go get github.com/gordonklaus/ineffassign ineffassign . --- swarm/network/kademlia/kademlia_test.go | 6 +++--- swarm/network/syncdb_test.go | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'swarm/network') diff --git a/swarm/network/kademlia/kademlia_test.go b/swarm/network/kademlia/kademlia_test.go index 66edfe654..417ccecae 100644 --- a/swarm/network/kademlia/kademlia_test.go +++ b/swarm/network/kademlia/kademlia_test.go @@ -58,9 +58,9 @@ func (n *testNode) LastActive() time.Time { } func TestOn(t *testing.T) { - addr, ok := gen(Address{}, quickrand).(Address) - other, ok := gen(Address{}, quickrand).(Address) - if !ok { + addr, ok1 := gen(Address{}, quickrand).(Address) + other, ok2 := gen(Address{}, quickrand).(Address) + if !ok1 || !ok2 { t.Errorf("oops") } kad := New(addr, NewKadParams()) diff --git a/swarm/network/syncdb_test.go b/swarm/network/syncdb_test.go index ed43fbd06..21453a110 100644 --- a/swarm/network/syncdb_test.go +++ b/swarm/network/syncdb_test.go @@ -63,7 +63,7 @@ func newTestSyncDb(priority, bufferSize, batchSize int, dbdir string, t *testing dbdir: dbdir, t: t, } - h := crypto.Sha3Hash([]byte{0}) + h := crypto.Keccak256Hash([]byte{0}) key := storage.Key(h[:]) self.syncDb = newSyncDb(db, key, uint(priority), uint(bufferSize), uint(batchSize), self.deliver) // kick off db iterator right away, if no items on db this will allow @@ -79,7 +79,7 @@ func (self *testSyncDb) close() { func (self *testSyncDb) push(n int) { for i := 0; i < n; i++ { - self.buffer <- storage.Key(crypto.Sha3([]byte{byte(self.c)})) + self.buffer <- storage.Key(crypto.Keccak256([]byte{byte(self.c)})) self.sent = append(self.sent, self.c) self.c++ } @@ -126,7 +126,7 @@ func (self *testSyncDb) expect(n int, db bool) { if self.at+1 > len(self.delivered) { self.t.Fatalf("expected %v, got %v", self.at+1, len(self.delivered)) } - if len(self.sent) > self.at && !bytes.Equal(crypto.Sha3([]byte{byte(self.sent[self.at])}), self.delivered[self.at]) { + if len(self.sent) > self.at && !bytes.Equal(crypto.Keccak256([]byte{byte(self.sent[self.at])}), self.delivered[self.at]) { self.t.Fatalf("expected delivery %v/%v/%v to be hash of %v, from db: %v = %v", i, n, self.at, self.sent[self.at], ok, db) glog.V(logger.Debug).Infof("%v/%v/%v to be hash of %v, from db: %v = %v", i, n, self.at, self.sent[self.at], ok, db) } @@ -195,7 +195,7 @@ func TestSaveSyncDb(t *testing.T) { go s.dbRead(false, 0, s.deliver) s.expect(amount, true) for i, key := range s.delivered { - expKey := crypto.Sha3([]byte{byte(i)}) + expKey := crypto.Keccak256([]byte{byte(i)}) if !bytes.Equal(key, expKey) { t.Fatalf("delivery %v expected to be key %x, got %x", i, expKey, key) } @@ -204,7 +204,7 @@ func TestSaveSyncDb(t *testing.T) { s.expect(amount, false) for i := amount; i < 2*amount; i++ { key := s.delivered[i] - expKey := crypto.Sha3([]byte{byte(i - amount)}) + expKey := crypto.Keccak256([]byte{byte(i - amount)}) if !bytes.Equal(key, expKey) { t.Fatalf("delivery %v expected to be key %x, got %x", i, expKey, key) } -- cgit v1.2.3