Skip to content

Commit 6db3f93

Browse files
authored
Fix tests, set up CircleCI (ethereum#25)
1 parent 0858817 commit 6db3f93

11 files changed

Lines changed: 75 additions & 67 deletions

File tree

.circleci/config.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
version: 2
2+
jobs:
3+
build:
4+
docker:
5+
- image: circleci/golang:1.9
6+
7+
working_directory: /go/src/github.com/celo-org/geth
8+
steps:
9+
- checkout
10+
- run: make lint
11+
# TODO(celo): Use testing.Skip instead
12+
- run: build/env.sh go run build/ci.go test --skip "github.com/ethereum/go-ethereum/cmd/swarm,github.com/ethereum/go-ethereum/swarm/network/simulations/discovery"

build/ci.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,13 +315,25 @@ func goToolArch(arch string, cc string, subcmd string, args ...string) *exec.Cmd
315315
return cmd
316316
}
317317

318+
func Filter(vs []string, pred func(string) bool) []string {
319+
filtered := make([]string, 0)
320+
for _, v := range vs {
321+
if pred(v) {
322+
filtered = append(filtered, v)
323+
}
324+
}
325+
return filtered
326+
}
327+
318328
// Running The Tests
319329
//
320330
// "tests" also includes static analysis tools such as vet.
321331

322332
func doTest(cmdline []string) {
323333
var (
324334
coverage = flag.Bool("coverage", false, "Whether to record code coverage")
335+
// TODO(celo): Use testing.Skip instead.
336+
skip = flag.String("skip", "", "Comma separated list of packages to skip")
325337
)
326338
flag.CommandLine.Parse(cmdline)
327339
env := build.Env()
@@ -332,6 +344,14 @@ func doTest(cmdline []string) {
332344
}
333345
packages = build.ExpandPackagesNoVendor(packages)
334346

347+
skipPackage := make(map[string]bool)
348+
for _, skippedPackage := range strings.Split(*skip, ",") {
349+
skipPackage[skippedPackage] = true
350+
}
351+
packages = Filter(packages, func(p string) bool {
352+
return !skipPackage[p]
353+
})
354+
335355
// Run analysis tools before the tests.
336356
build.MustRun(goTool("vet", packages...))
337357

circle.yml

Lines changed: 0 additions & 32 deletions
This file was deleted.

core/vm/contracts.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ func (c *textmsg) RequiredGas(input []byte) uint64 {
374374

375375
func (c *textmsg) Run(input []byte) ([]byte, error) {
376376
// TODO(asa): Allow international phone numbers.
377-
r, _ := regexp.Compile("\\+1[0-9]{10}")
377+
r, _ := regexp.Compile(`\+1[0-9]{10}`)
378378
if r.MatchString(string(input)) {
379379
return input, nil
380380
} else {

miner/miner.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"sync/atomic"
2323
"time"
2424

25+
"github.com/ethereum/go-ethereum/accounts"
2526
"github.com/ethereum/go-ethereum/common"
2627
"github.com/ethereum/go-ethereum/consensus"
2728
"github.com/ethereum/go-ethereum/core"
@@ -35,6 +36,7 @@ import (
3536

3637
// Backend wraps all methods required for mining.
3738
type Backend interface {
39+
AccountManager() *accounts.Manager
3840
BlockChain() *core.BlockChain
3941
TxPool() *core.TxPool
4042
}

miner/worker.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ import (
2424
"sync/atomic"
2525
"time"
2626

27-
"github.com/ethereum/go-ethereum/abe"
2827
mapset "github.com/deckarep/golang-set"
28+
"github.com/ethereum/go-ethereum/abe"
2929
"github.com/ethereum/go-ethereum/common"
3030
"github.com/ethereum/go-ethereum/consensus"
3131
"github.com/ethereum/go-ethereum/consensus/misc"
@@ -931,7 +931,7 @@ func (w *worker) commit(uncles []*types.Header, interval func(), update bool, st
931931

932932
log.Info("Commit new mining work", "number", block.Number(), "uncles", len(uncles), "txs", w.current.tcount,
933933
"gas", block.GasUsed(), "fees", feesEth, "elapsed", common.PrettyDuration(time.Since(start)))
934-
abe.SendVerificationTexts(w.current.receipts, block, self.coinbase, self.eth.AccountManager())
934+
abe.SendVerificationTexts(w.current.receipts, block, w.coinbase, w.eth.AccountManager())
935935

936936
case <-w.exitCh:
937937
log.Info("Worker has exited")

miner/worker_test.go

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"testing"
2222
"time"
2323

24+
"github.com/ethereum/go-ethereum/accounts"
2425
"github.com/ethereum/go-ethereum/common"
2526
"github.com/ethereum/go-ethereum/consensus"
2627
"github.com/ethereum/go-ethereum/consensus/clique"
@@ -70,11 +71,12 @@ func init() {
7071

7172
// testWorkerBackend implements worker.Backend interfaces and wraps all information needed during the testing.
7273
type testWorkerBackend struct {
73-
db ethdb.Database
74-
txPool *core.TxPool
75-
chain *core.BlockChain
76-
testTxFeed event.Feed
77-
uncleBlock *types.Block
74+
accountManager *accounts.Manager
75+
db ethdb.Database
76+
txPool *core.TxPool
77+
chain *core.BlockChain
78+
testTxFeed event.Feed
79+
uncleBlock *types.Block
7880
}
7981

8082
func newTestWorkerBackend(t *testing.T, chainConfig *params.ChainConfig, engine consensus.Engine) *testWorkerBackend {
@@ -101,17 +103,21 @@ func newTestWorkerBackend(t *testing.T, chainConfig *params.ChainConfig, engine
101103
blocks, _ := core.GenerateChain(chainConfig, genesis, engine, db, 1, func(i int, gen *core.BlockGen) {
102104
gen.SetCoinbase(acc1Addr)
103105
})
106+
var backends []accounts.Backend
107+
accountManager := accounts.NewManager(backends...)
104108

105109
return &testWorkerBackend{
106-
db: db,
107-
chain: chain,
108-
txPool: txpool,
109-
uncleBlock: blocks[0],
110+
accountManager: accountManager,
111+
db: db,
112+
chain: chain,
113+
txPool: txpool,
114+
uncleBlock: blocks[0],
110115
}
111116
}
112117

113-
func (b *testWorkerBackend) BlockChain() *core.BlockChain { return b.chain }
114-
func (b *testWorkerBackend) TxPool() *core.TxPool { return b.txPool }
118+
func (b *testWorkerBackend) AccountManager() *accounts.Manager { return b.accountManager }
119+
func (b *testWorkerBackend) BlockChain() *core.BlockChain { return b.chain }
120+
func (b *testWorkerBackend) TxPool() *core.TxPool { return b.txPool }
115121
func (b *testWorkerBackend) PostChainEvents(events []interface{}) {
116122
b.chain.PostChainEvents(events, nil)
117123
}

p2p/dial.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ const (
4040

4141
// If no peers are found for this amount of time, the initial bootnodes are
4242
// attempted to be connected.
43-
fallbackInterval = 20 * time.Second
43+
fallbackInterval = 6 * time.Second
4444

4545
// Endpoint resolution is throttled with bounded backoff.
4646
initialResolveDelay = 60 * time.Second

p2p/dial_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ func runDialTest(t *testing.T, test dialtest) {
7070
i, spew.Sdump(new), spew.Sdump(round.new), spew.Sdump(test.init), spew.Sdump(running))
7171
}
7272

73-
// Time advances by 16 seconds on every round.
74-
vtime = vtime.Add(16 * time.Second)
73+
// Time advances by 6 seconds on every round.
74+
vtime = vtime.Add(6 * time.Second)
7575
running += len(new)
7676
}
7777
}
@@ -151,7 +151,7 @@ func TestDialStateDynDial(t *testing.T) {
151151
&dialTask{flags: dynDialedConn, dest: &discover.Node{ID: uintID(5)}},
152152
},
153153
new: []task{
154-
&waitExpireTask{Duration: 14 * time.Second},
154+
&waitExpireTask{Duration: 4 * time.Second},
155155
},
156156
},
157157
// In this round, the peer with id 2 drops off. The query
@@ -485,7 +485,7 @@ func TestDialStateStaticDial(t *testing.T) {
485485
&dialTask{flags: staticDialedConn, dest: &discover.Node{ID: uintID(5)}},
486486
},
487487
new: []task{
488-
&waitExpireTask{Duration: 14 * time.Second},
488+
&waitExpireTask{Duration: 4 * time.Second},
489489
},
490490
},
491491
// Wait a round for dial history to expire, no new tasks should spawn.
@@ -542,7 +542,7 @@ func TestDialStaticAfterReset(t *testing.T) {
542542
&dialTask{flags: staticDialedConn, dest: &discover.Node{ID: uintID(2)}},
543543
},
544544
new: []task{
545-
&waitExpireTask{Duration: 30 * time.Second},
545+
&waitExpireTask{Duration: 10 * time.Second},
546546
},
547547
},
548548
}
@@ -603,7 +603,7 @@ func TestDialStateCache(t *testing.T) {
603603
&dialTask{flags: staticDialedConn, dest: &discover.Node{ID: uintID(3)}},
604604
},
605605
new: []task{
606-
&waitExpireTask{Duration: 14 * time.Second},
606+
&waitExpireTask{Duration: 4 * time.Second},
607607
},
608608
},
609609
// Still waiting for node 3's entry to expire in the cache.

params/protocol_params.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -66,19 +66,19 @@ const (
6666

6767
// Precompiled contract gas prices
6868

69-
EcrecoverGas uint64 = 3000 // Elliptic curve sender recovery gas price
70-
Sha256BaseGas uint64 = 60 // Base price for a SHA256 operation
71-
Sha256PerWordGas uint64 = 12 // Per-word price for a SHA256 operation
72-
Ripemd160BaseGas uint64 = 600 // Base price for a RIPEMD160 operation
73-
Ripemd160PerWordGas uint64 = 120 // Per-word price for a RIPEMD160 operation
74-
IdentityBaseGas uint64 = 15 // Base price for a data copy operation
75-
IdentityPerWordGas uint64 = 3 // Per-work price for a data copy operation
76-
ModExpQuadCoeffDiv uint64 = 20 // Divisor for the quadratic particle of the big int modular exponentiation
77-
Bn256AddGas uint64 = 500 // Gas needed for an elliptic curve addition
78-
Bn256ScalarMulGas uint64 = 40000 // Gas needed for an elliptic curve scalar multiplication
79-
Bn256PairingBaseGas uint64 = 100000 // Base price for an elliptic curve pairing check
80-
Bn256PairingPerPointGas uint64 = 80000 // Per-point price for an elliptic curve pairing check
81-
TextmsgGas uint64 = 1000000 // Per-message price for sending an SMS. Not an accurate representation of the real cost of sending an SMS.
69+
EcrecoverGas uint64 = 3000 // Elliptic curve sender recovery gas price
70+
Sha256BaseGas uint64 = 60 // Base price for a SHA256 operation
71+
Sha256PerWordGas uint64 = 12 // Per-word price for a SHA256 operation
72+
Ripemd160BaseGas uint64 = 600 // Base price for a RIPEMD160 operation
73+
Ripemd160PerWordGas uint64 = 120 // Per-word price for a RIPEMD160 operation
74+
IdentityBaseGas uint64 = 15 // Base price for a data copy operation
75+
IdentityPerWordGas uint64 = 3 // Per-work price for a data copy operation
76+
ModExpQuadCoeffDiv uint64 = 20 // Divisor for the quadratic particle of the big int modular exponentiation
77+
Bn256AddGas uint64 = 500 // Gas needed for an elliptic curve addition
78+
Bn256ScalarMulGas uint64 = 40000 // Gas needed for an elliptic curve scalar multiplication
79+
Bn256PairingBaseGas uint64 = 100000 // Base price for an elliptic curve pairing check
80+
Bn256PairingPerPointGas uint64 = 80000 // Per-point price for an elliptic curve pairing check
81+
TextmsgGas uint64 = 1000000 // Per-message price for sending an SMS. Not an accurate representation of the real cost of sending an SMS.
8282
)
8383

8484
var (

0 commit comments

Comments
 (0)