all: fix go vet warnings
This commit is contained in:
@ -892,8 +892,7 @@ func (d *Downloader) fetchBlocks61(from uint64) error {
|
||||
// case, the internal state of the downloader and the queue is very wrong so
|
||||
// better hard crash and note the error instead of silently accumulating into
|
||||
// a much bigger issue.
|
||||
panic(fmt.Sprintf("%v: fetch assignment failed, hard panic", peer))
|
||||
d.queue.CancelBlocks(request) // noop for now
|
||||
panic(fmt.Sprintf("%v: fetch assignment failed", peer))
|
||||
}
|
||||
}
|
||||
// Make sure that we have peers available for fetching. If all peers have been tried
|
||||
@ -1525,8 +1524,7 @@ func (d *Downloader) fetchParts(errCancel error, deliveryCh chan dataPack, deliv
|
||||
// case, the internal state of the downloader and the queue is very wrong so
|
||||
// better hard crash and note the error instead of silently accumulating into
|
||||
// a much bigger issue.
|
||||
panic(fmt.Sprintf("%v: %s fetch assignment failed, hard panic", peer, strings.ToLower(kind)))
|
||||
cancel(request) // noop for now
|
||||
panic(fmt.Sprintf("%v: %s fetch assignment failed", peer, strings.ToLower(kind)))
|
||||
}
|
||||
running = true
|
||||
}
|
||||
|
@ -983,7 +983,7 @@ func (q *queue) DeliverNodeData(id string, data [][]byte, callback func(error, i
|
||||
continue
|
||||
}
|
||||
// Inject the next state trie item into the processing queue
|
||||
process = append(process, trie.SyncResult{hash, blob})
|
||||
process = append(process, trie.SyncResult{Hash: hash, Data: blob})
|
||||
accepted++
|
||||
|
||||
delete(request.Hashes, hash)
|
||||
|
@ -331,7 +331,7 @@ func (args *NewFilterArgs) UnmarshalJSON(data []byte) error {
|
||||
if decAddr, err := hex.DecodeString(strAddr); err == nil {
|
||||
addresses = append(addresses, common.BytesToAddress(decAddr))
|
||||
} else {
|
||||
fmt.Errorf("invalid address given")
|
||||
return fmt.Errorf("invalid address given")
|
||||
}
|
||||
} else {
|
||||
return fmt.Errorf("invalid address on index %d", i)
|
||||
@ -344,10 +344,10 @@ func (args *NewFilterArgs) UnmarshalJSON(data []byte) error {
|
||||
if decAddr, err := hex.DecodeString(singleAddr); err == nil {
|
||||
addresses = append(addresses, common.BytesToAddress(decAddr))
|
||||
} else {
|
||||
fmt.Errorf("invalid address given")
|
||||
return fmt.Errorf("invalid address given")
|
||||
}
|
||||
} else {
|
||||
errors.New("invalid address(es) given")
|
||||
return errors.New("invalid address(es) given")
|
||||
}
|
||||
args.Addresses = addresses
|
||||
}
|
||||
@ -394,7 +394,7 @@ func (args *NewFilterArgs) UnmarshalJSON(data []byte) error {
|
||||
parsedTopics[i] = []common.Hash{t}
|
||||
}
|
||||
} else {
|
||||
fmt.Errorf("topic[%d][%d] not a string", i, j)
|
||||
return fmt.Errorf("topic[%d][%d] not a string", i, j)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -76,8 +76,8 @@ func TestCallbacks(t *testing.T) {
|
||||
mux.Post(core.ChainEvent{})
|
||||
mux.Post(core.TxPreEvent{})
|
||||
mux.Post(vm.Logs{&vm.Log{}})
|
||||
mux.Post(core.RemovedLogsEvent{vm.Logs{&vm.Log{}}})
|
||||
mux.Post(core.PendingLogsEvent{vm.Logs{&vm.Log{}}})
|
||||
mux.Post(core.RemovedLogsEvent{Logs: vm.Logs{&vm.Log{}}})
|
||||
mux.Post(core.PendingLogsEvent{Logs: vm.Logs{&vm.Log{}}})
|
||||
|
||||
const dura = 5 * time.Second
|
||||
failTimer := time.NewTimer(dura)
|
||||
|
@ -56,7 +56,7 @@ func BenchmarkMipmaps(b *testing.B) {
|
||||
)
|
||||
defer db.Close()
|
||||
|
||||
genesis := core.WriteGenesisBlockForTesting(db, core.GenesisAccount{addr1, big.NewInt(1000000)})
|
||||
genesis := core.WriteGenesisBlockForTesting(db, core.GenesisAccount{Address: addr1, Balance: big.NewInt(1000000)})
|
||||
chain, receipts := core.GenerateChain(genesis, db, 100010, func(i int, gen *core.BlockGen) {
|
||||
var receipts types.Receipts
|
||||
switch i {
|
||||
@ -132,7 +132,7 @@ func TestFilters(t *testing.T) {
|
||||
)
|
||||
defer db.Close()
|
||||
|
||||
genesis := core.WriteGenesisBlockForTesting(db, core.GenesisAccount{addr, big.NewInt(1000000)})
|
||||
genesis := core.WriteGenesisBlockForTesting(db, core.GenesisAccount{Address: addr, Balance: big.NewInt(1000000)})
|
||||
chain, receipts := core.GenerateChain(genesis, db, 1000, func(i int, gen *core.BlockGen) {
|
||||
var receipts types.Receipts
|
||||
switch i {
|
||||
|
@ -245,7 +245,6 @@ func (pm *ProtocolManager) handle(p *peer) error {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// handleMsg is invoked whenever an inbound message is received from a remote
|
||||
|
@ -17,7 +17,6 @@
|
||||
package eth
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math/big"
|
||||
"math/rand"
|
||||
"testing"
|
||||
@ -448,12 +447,12 @@ func testGetNodeData(t *testing.T, protocol int) {
|
||||
switch i {
|
||||
case 0:
|
||||
// In block 1, the test bank sends account #1 some ether.
|
||||
tx, _ := types.NewTransaction(block.TxNonce(testBankAddress), acc1Addr, big.NewInt(10000), params.TxGas, nil, nil).SignECDSA(testBankKey)
|
||||
tx, _ := types.NewTransaction(block.TxNonce(testBank.Address), acc1Addr, big.NewInt(10000), params.TxGas, nil, nil).SignECDSA(testBankKey)
|
||||
block.AddTx(tx)
|
||||
case 1:
|
||||
// In block 2, the test bank sends some more ether to account #1.
|
||||
// acc1Addr passes it on to account #2.
|
||||
tx1, _ := types.NewTransaction(block.TxNonce(testBankAddress), acc1Addr, big.NewInt(1000), params.TxGas, nil, nil).SignECDSA(testBankKey)
|
||||
tx1, _ := types.NewTransaction(block.TxNonce(testBank.Address), acc1Addr, big.NewInt(1000), params.TxGas, nil, nil).SignECDSA(testBankKey)
|
||||
tx2, _ := types.NewTransaction(block.TxNonce(acc1Addr), acc2Addr, big.NewInt(1000), params.TxGas, nil, nil).SignECDSA(acc1Key)
|
||||
block.AddTx(tx1)
|
||||
block.AddTx(tx2)
|
||||
@ -498,14 +497,14 @@ func testGetNodeData(t *testing.T, protocol int) {
|
||||
// Verify that all hashes correspond to the requested data, and reconstruct a state tree
|
||||
for i, want := range hashes {
|
||||
if hash := crypto.Keccak256Hash(data[i]); hash != want {
|
||||
fmt.Errorf("data hash mismatch: have %x, want %x", hash, want)
|
||||
t.Errorf("data hash mismatch: have %x, want %x", hash, want)
|
||||
}
|
||||
}
|
||||
statedb, _ := ethdb.NewMemDatabase()
|
||||
for i := 0; i < len(data); i++ {
|
||||
statedb.Put(hashes[i].Bytes(), data[i])
|
||||
}
|
||||
accounts := []common.Address{testBankAddress, acc1Addr, acc2Addr}
|
||||
accounts := []common.Address{testBank.Address, acc1Addr, acc2Addr}
|
||||
for i := uint64(0); i <= pm.blockchain.CurrentBlock().NumberU64(); i++ {
|
||||
trie, _ := state.New(pm.blockchain.GetBlockByNumber(i).Root(), statedb)
|
||||
|
||||
@ -539,12 +538,12 @@ func testGetReceipt(t *testing.T, protocol int) {
|
||||
switch i {
|
||||
case 0:
|
||||
// In block 1, the test bank sends account #1 some ether.
|
||||
tx, _ := types.NewTransaction(block.TxNonce(testBankAddress), acc1Addr, big.NewInt(10000), params.TxGas, nil, nil).SignECDSA(testBankKey)
|
||||
tx, _ := types.NewTransaction(block.TxNonce(testBank.Address), acc1Addr, big.NewInt(10000), params.TxGas, nil, nil).SignECDSA(testBankKey)
|
||||
block.AddTx(tx)
|
||||
case 1:
|
||||
// In block 2, the test bank sends some more ether to account #1.
|
||||
// acc1Addr passes it on to account #2.
|
||||
tx1, _ := types.NewTransaction(block.TxNonce(testBankAddress), acc1Addr, big.NewInt(1000), params.TxGas, nil, nil).SignECDSA(testBankKey)
|
||||
tx1, _ := types.NewTransaction(block.TxNonce(testBank.Address), acc1Addr, big.NewInt(1000), params.TxGas, nil, nil).SignECDSA(testBankKey)
|
||||
tx2, _ := types.NewTransaction(block.TxNonce(acc1Addr), acc2Addr, big.NewInt(1000), params.TxGas, nil, nil).SignECDSA(acc1Key)
|
||||
block.AddTx(tx1)
|
||||
block.AddTx(tx2)
|
||||
|
@ -37,9 +37,11 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
testBankKey, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
|
||||
testBankAddress = crypto.PubkeyToAddress(testBankKey.PublicKey)
|
||||
testBankFunds = big.NewInt(1000000)
|
||||
testBankKey, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
|
||||
testBank = core.GenesisAccount{
|
||||
Address: crypto.PubkeyToAddress(testBankKey.PublicKey),
|
||||
Balance: big.NewInt(1000000),
|
||||
}
|
||||
)
|
||||
|
||||
// newTestProtocolManager creates a new protocol manager for testing purposes,
|
||||
@ -50,7 +52,7 @@ func newTestProtocolManager(fastSync bool, blocks int, generator func(int, *core
|
||||
evmux = new(event.TypeMux)
|
||||
pow = new(core.FakePow)
|
||||
db, _ = ethdb.NewMemDatabase()
|
||||
genesis = core.WriteGenesisBlockForTesting(db, core.GenesisAccount{testBankAddress, testBankFunds})
|
||||
genesis = core.WriteGenesisBlockForTesting(db, testBank)
|
||||
chainConfig = &core.ChainConfig{HomesteadBlock: big.NewInt(0)} // homestead set to 0 because of chain maker
|
||||
blockchain, _ = core.NewBlockChain(db, chainConfig, pow, evmux)
|
||||
)
|
||||
|
@ -78,7 +78,7 @@ func testStatusMsgErrors(t *testing.T, protocol int) {
|
||||
select {
|
||||
case err := <-errc:
|
||||
if err == nil {
|
||||
t.Errorf("test %d: protocol returned nil error, want %q", test.wantError)
|
||||
t.Errorf("test %d: protocol returned nil error, want %q", i, test.wantError)
|
||||
} else if err.Error() != test.wantError.Error() {
|
||||
t.Errorf("test %d: wrong error: got %q, want %q", i, err, test.wantError)
|
||||
}
|
||||
|
Reference in New Issue
Block a user