Skip to content

Commit 0ff23dc

Browse files
committed
fix some tests
1 parent 93c0501 commit 0ff23dc

40 files changed

+156
-1235
lines changed

accounts/abi/bind/backends/simulated_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ func TestNewSimulatedBackend(t *testing.T) {
129129
t.Errorf("expected sim blockchain config to equal params.AllEthashProtocolChanges, got %v", sim.config)
130130
}
131131

132-
stateDB, _, _ := sim.blockchain.State()
132+
stateDB, _ := sim.blockchain.State()
133133
bal := stateDB.GetBalance(testAddr)
134134
if bal.Cmp(expectedBal) != 0 {
135135
t.Errorf("expected balance for test address not received. expected: %v actual: %v", expectedBal, bal)

cmd/clef/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,6 @@ Response
225225
- `value` [number:optional]: amount of Wei to send with the transaction
226226
- `data` [data:optional]: input data (transaction manager hash if transaction is private)
227227
- `nonce` [number]: account nonce
228-
- `isPrivate` [boolean:optional]: whether the transaction is a Quorum private transaction
229228
3. method signature [string:optional]
230229
- The method signature, if present, is to aid decoding the calldata. Should consist of `methodname(paramtype,...)`, e.g. `transfer(uint256,address)`. The signer may use this data to parse the supplied calldata, and show the user. The data, however, is considered totally untrusted, and reliability is not expected.
231230

cmd/geth/accountcmd_test.go

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,6 @@ Fatal: could not decrypt key with given password
190190
}
191191

192192
func TestUnlockFlag(t *testing.T) {
193-
defer SetResetPrivateConfig("ignore")()
194193
geth := runMinimalGethWithRaftConsensus(t, "--port", "0", "--ipcdisable", "--datadir", tmpDatadirWithKeystore(t),
195194
"--unlock", "f466859ead1932d743d622cb74fc058882e8648a", "js", "testdata/empty.js")
196195
geth.Expect(`
@@ -212,8 +211,6 @@ Password: {{.InputLine "foobar"}}
212211
}
213212

214213
func TestGethDoesntStartWithoutConfiguredConsensus(t *testing.T) {
215-
defer SetResetPrivateConfig("ignore")()
216-
217214
datadir := tmpDatadirWithKeystore(t)
218215
geth := runGeth(t,
219216
"--datadir", datadir, "--nat", "none", "--nodiscover", "--maxpeers", "0", "--port", "0")
@@ -225,8 +222,6 @@ func TestGethDoesntStartWithoutConfiguredConsensus(t *testing.T) {
225222
}
226223

227224
func TestGethStartsWhenConsensusAndPrivateConfigAreConfigured(t *testing.T) {
228-
defer SetResetPrivateConfig("ignore")()
229-
230225
datadir := tmpDatadirWithKeystore(t)
231226
geth := runGeth(t,
232227
"--datadir", datadir, "--nat", "none", "--nodiscover", "--maxpeers", "0", "--port", "0", "--raft")
@@ -235,7 +230,6 @@ func TestGethStartsWhenConsensusAndPrivateConfigAreConfigured(t *testing.T) {
235230
}
236231

237232
func TestUnlockFlagWrongPassword(t *testing.T) {
238-
defer SetResetPrivateConfig("ignore")()
239233
geth := runMinimalGeth(t, "--port", "0", "--ipcdisable", "--datadir", tmpDatadirWithKeystore(t),
240234
"--unlock", "f466859ead1932d743d622cb74fc058882e8648a", "js", "testdata/empty.js")
241235
defer geth.ExpectExit()
@@ -253,7 +247,6 @@ Fatal: Failed to unlock account f466859ead1932d743d622cb74fc058882e8648a (could
253247

254248
// https://github.com/ethereum/go-ethereum/issues/1785
255249
func TestUnlockFlagMultiIndex(t *testing.T) {
256-
defer SetResetPrivateConfig("ignore")()
257250
geth := runMinimalGethWithRaftConsensus(t, "--port", "0", "--ipcdisable", "--datadir", tmpDatadirWithKeystore(t),
258251
"--unlock", "f466859ead1932d743d622cb74fc058882e8648a", "--unlock", "0,2", "js", "testdata/empty.js")
259252
geth.Expect(`
@@ -278,7 +271,6 @@ Password: {{.InputLine "foobar"}}
278271
}
279272

280273
func TestUnlockFlagPasswordFile(t *testing.T) {
281-
defer SetResetPrivateConfig("ignore")()
282274
geth := runMinimalGethWithRaftConsensus(t, "--port", "0", "--ipcdisable", "--datadir", tmpDatadirWithKeystore(t),
283275
"--unlock", "f466859ead1932d743d622cb74fc058882e8648a", "--password", "testdata/passwords.txt", "--unlock", "0,2", "js", "testdata/empty.js")
284276
geth.ExpectExit()
@@ -296,7 +288,6 @@ func TestUnlockFlagPasswordFile(t *testing.T) {
296288
}
297289

298290
func TestUnlockFlagPasswordFileWrongPassword(t *testing.T) {
299-
defer SetResetPrivateConfig("ignore")()
300291
geth := runMinimalGeth(t, "--port", "0", "--ipcdisable", "--datadir", tmpDatadirWithKeystore(t),
301292
"--unlock", "f466859ead1932d743d622cb74fc058882e8648a", "--password",
302293
"testdata/wrong-passwords.txt", "--unlock", "0,2")
@@ -307,7 +298,6 @@ Fatal: Failed to unlock account 0 (could not decrypt key with given password)
307298
}
308299

309300
func TestUnlockFlagAmbiguous(t *testing.T) {
310-
defer SetResetPrivateConfig("ignore")()
311301
datadir := tmpDatadirWithKeystore(t)
312302
store := filepath.Join("..", "..", "accounts", "keystore", "testdata", "dupes")
313303
geth := runMinimalGethWithRaftConsensus(t, "--datadir", datadir, "--port", "0", "--ipcdisable", "--datadir", tmpDatadirWithKeystore(t),
@@ -347,7 +337,6 @@ In order to avoid this warning, you need to remove the following duplicate key f
347337
}
348338

349339
func TestUnlockFlagAmbiguousWrongPassword(t *testing.T) {
350-
defer SetResetPrivateConfig("ignore")()
351340
store := filepath.Join("..", "..", "accounts", "keystore", "testdata", "dupes")
352341
geth := runMinimalGeth(t, "--port", "0", "--ipcdisable", "--datadir", tmpDatadirWithKeystore(t),
353342
"--unlock", "f466859ead1932d743d622cb74fc058882e8648a", "--keystore",

cmd/geth/consolecmd_test.go

Lines changed: 0 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ package main
1818

1919
import (
2020
"crypto/rand"
21-
"crypto/tls"
22-
"flag"
2321
"io/ioutil"
2422
"math/big"
2523
"os"
@@ -30,10 +28,7 @@ import (
3028
"testing"
3129
"time"
3230

33-
"github.com/ethereum/go-ethereum/cmd/utils"
3431
"github.com/ethereum/go-ethereum/params"
35-
testifyassert "github.com/stretchr/testify/assert"
36-
"gopkg.in/urfave/cli.v1"
3732
)
3833

3934
const (
@@ -87,7 +82,6 @@ func runMinimalGeth(t *testing.T, args ...string) *testgeth {
8782
// Tests that a node embedded within a console can be started up properly and
8883
// then terminated by closing the input stream.
8984
func TestConsoleWelcome(t *testing.T) {
90-
defer SetResetPrivateConfig("ignore")()
9185
coinbase := "0x491937757d1b26e29c507b8d4c0b233c2747e68d"
9286

9387
datadir := setupIstanbul(t)
@@ -130,7 +124,6 @@ func TestAttachWelcome(t *testing.T) {
130124
httpPort string
131125
wsPort string
132126
)
133-
defer SetResetPrivateConfig("ignore")()
134127
// Configure the instance for IPC attachment
135128
coinbase := "0x491937757d1b26e29c507b8d4c0b233c2747e68d"
136129

@@ -166,7 +159,6 @@ func TestAttachWelcome(t *testing.T) {
166159
}
167160

168161
func TestHTTPAttachWelcome(t *testing.T) {
169-
defer SetResetPrivateConfig("ignore")()
170162
coinbase := "0x491937757d1b26e29c507b8d4c0b233c2747e68d"
171163
port := strconv.Itoa(trulyRandInt(1024, 65536)) // Yeah, sometimes this will fail, sorry :P
172164

@@ -183,7 +175,6 @@ func TestHTTPAttachWelcome(t *testing.T) {
183175
}
184176

185177
func TestWSAttachWelcome(t *testing.T) {
186-
defer SetResetPrivateConfig("ignore")()
187178
coinbase := "0x491937757d1b26e29c507b8d4c0b233c2747e68d"
188179
port := strconv.Itoa(trulyRandInt(1024, 65536)) // Yeah, sometimes this will fail, sorry :P
189180

@@ -266,57 +257,3 @@ func setupIstanbul(t *testing.T) string {
266257

267258
return datadir
268259
}
269-
270-
func TestReadTLSClientConfig_whenCustomizeTLSCipherSuites(t *testing.T) {
271-
assert := testifyassert.New(t)
272-
273-
flagSet := new(flag.FlagSet)
274-
flagSet.Bool(utils.RPCClientTLSInsecureSkipVerify.Name, true, "")
275-
flagSet.String(utils.RPCClientTLSCipherSuites.Name, "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384", "")
276-
ctx := cli.NewContext(nil, flagSet, nil)
277-
278-
tlsConf, ok, err := readTLSClientConfig("https://arbitraryendpoint", ctx)
279-
280-
assert.NoError(err)
281-
assert.True(ok, "has custom TLS client configuration")
282-
assert.True(tlsConf.InsecureSkipVerify)
283-
assert.Len(tlsConf.CipherSuites, 2)
284-
assert.Contains(tlsConf.CipherSuites, tls.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384)
285-
assert.Contains(tlsConf.CipherSuites, tls.TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384)
286-
}
287-
288-
func TestReadTLSClientConfig_whenTypicalTLS(t *testing.T) {
289-
assert := testifyassert.New(t)
290-
291-
flagSet := new(flag.FlagSet)
292-
ctx := cli.NewContext(nil, flagSet, nil)
293-
294-
tlsConf, ok, err := readTLSClientConfig("https://arbitraryendpoint", ctx)
295-
296-
assert.NoError(err)
297-
assert.False(ok, "no custom TLS client configuration")
298-
assert.Nil(tlsConf, "no custom TLS config is set")
299-
}
300-
301-
func TestReadTLSClientConfig_whenTLSInsecureFlagSet(t *testing.T) {
302-
assert := testifyassert.New(t)
303-
304-
flagSet := new(flag.FlagSet)
305-
flagSet.Bool(utils.RPCClientTLSInsecureSkipVerify.Name, true, "")
306-
ctx := cli.NewContext(nil, flagSet, nil)
307-
308-
tlsConf, ok, err := readTLSClientConfig("https://arbitraryendpoint", ctx)
309-
310-
assert.NoError(err)
311-
assert.True(ok, "has custom TLS client configuration")
312-
assert.True(tlsConf.InsecureSkipVerify)
313-
assert.Len(tlsConf.CipherSuites, 0)
314-
}
315-
316-
func SetResetPrivateConfig(value string) func() {
317-
existingValue := os.Getenv("PRIVATE_CONFIG")
318-
os.Setenv("PRIVATE_CONFIG", value)
319-
return func() {
320-
os.Setenv("PRIVATE_CONFIG", existingValue)
321-
}
322-
}

cmd/geth/dao_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ func TestDAOForkBlockNewChain(t *testing.T) {
105105
}
106106

107107
func testDAOForkBlockNewChain(t *testing.T, test int, genesis string, expectBlock *big.Int, expectVote bool) {
108-
defer SetResetPrivateConfig("ignore")()
109108
// Create a temporary data directory to use and inspect later
110109
datadir := tmpdir(t)
111110
defer os.RemoveAll(datadir)

cmd/geth/genesis_test.go

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import (
2020
"io/ioutil"
2121
"os"
2222
"path/filepath"
23-
"strings"
2423
"testing"
2524

2625
"github.com/cespare/cp"
@@ -75,7 +74,6 @@ var customGenesisTests = []struct {
7574
// Tests that initializing Geth with a custom genesis block and chain definitions
7675
// work properly.
7776
func TestCustomGenesis(t *testing.T) {
78-
defer SetResetPrivateConfig("ignore")()
7977
for i, tt := range customGenesisTests {
8078
// Create a temporary data directory to use and inspect later
8179
datadir := tmpdir(t)
@@ -107,7 +105,6 @@ func TestCustomGenesis(t *testing.T) {
107105
}
108106

109107
func TestCustomGenesisUpgradeWithPrivacyEnhancementsBlock(t *testing.T) {
110-
defer SetResetPrivateConfig("ignore")()
111108
// Create a temporary data directory to use and inspect later
112109
datadir := tmpdir(t)
113110
defer os.RemoveAll(datadir)
@@ -145,45 +142,4 @@ func TestCustomGenesisUpgradeWithPrivacyEnhancementsBlock(t *testing.T) {
145142
}
146143
geth := runGeth(t, "--datadir", datadir, "init", json)
147144
geth.WaitExit()
148-
149-
genesisContentWithPrivacyEnhancements :=
150-
`{
151-
"alloc" : {},
152-
"coinbase" : "0x0000000000000000000000000000000000000000",
153-
"difficulty" : "0x20000",
154-
"extraData" : "",
155-
"gasLimit" : "0x2fefd8",
156-
"nonce" : "0x0000000000000042",
157-
"mixhash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
158-
"parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
159-
"timestamp" : "0x00",
160-
"config" : {
161-
"homesteadBlock" : 42,
162-
"daoForkBlock" : 141,
163-
"privacyEnhancementsBlock" : 1000,
164-
"daoForkSupport" : true,
165-
"isQuorum" : false
166-
}
167-
}`
168-
169-
if err := ioutil.WriteFile(json, []byte(genesisContentWithPrivacyEnhancements), 0600); err != nil {
170-
t.Fatalf("failed to write genesis file: %v", err)
171-
}
172-
geth = runGeth(t, "--datadir", datadir, "init", json)
173-
geth.WaitExit()
174-
175-
expectedText := "Privacy enhancements have been enabled from block height 1000. Please ensure your privacy manager is upgraded and supports privacy enhancements"
176-
177-
result := strings.TrimSpace(geth.StderrText())
178-
if !strings.Contains(result, expectedText) {
179-
geth.Fatalf("bad stderr text. want '%s', got '%s'", expectedText, result)
180-
}
181-
182-
// start quorum - it should fail the transaction manager PrivacyEnhancements feature validation
183-
geth = runGeth(t,
184-
"--datadir", datadir, "--maxpeers", "0", "--port", "0",
185-
"--nodiscover", "--nat", "none", "--ipcdisable",
186-
"--raft", "console")
187-
geth.ExpectRegexp("Cannot start quorum with privacy enhancements enabled while the transaction manager does not support it")
188-
geth.ExpectExit()
189145
}

consensus/clique/snapshot_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ func TestClique(t *testing.T) {
448448
batches[len(batches)-1] = append(batches[len(batches)-1], block)
449449
}
450450
// Pass all the headers through clique and ensure tallying succeeds
451-
chain, err := core.NewBlockChain(db, nil, &config, engine, vm.Config{}, nil, nil, nil)
451+
chain, err := core.NewBlockChain(db, nil, &config, engine, vm.Config{}, nil, nil)
452452
if err != nil {
453453
t.Errorf("test %d: failed to create test chain: %v", i, err)
454454
continue

core/bench_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ func benchInsertChain(b *testing.B, disk bool, gen func(int, *BlockGen)) {
176176

177177
// Time the insertion of the new chain.
178178
// State and blocks are stored in the same DB.
179-
chainman, _ := NewBlockChain(db, nil, gspec.Config, ethash.NewFaker(), vm.Config{}, nil, nil, nil)
179+
chainman, _ := NewBlockChain(db, nil, gspec.Config, ethash.NewFaker(), vm.Config{}, nil, nil)
180180
defer chainman.Stop()
181181
b.ReportAllocs()
182182
b.ResetTimer()
@@ -288,7 +288,7 @@ func benchReadChain(b *testing.B, full bool, count uint64) {
288288
if err != nil {
289289
b.Fatalf("error opening database at %v: %v", dir, err)
290290
}
291-
chain, err := NewBlockChain(db, nil, params.TestChainConfig, ethash.NewFaker(), vm.Config{}, nil, nil, nil)
291+
chain, err := NewBlockChain(db, nil, params.TestChainConfig, ethash.NewFaker(), vm.Config{}, nil, nil)
292292
if err != nil {
293293
b.Fatalf("error creating chain: %v", err)
294294
}

core/block_validator_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func TestHeaderVerification(t *testing.T) {
4242
headers[i] = block.Header()
4343
}
4444
// Run the header checker for blocks one-by-one, checking for both valid and invalid nonces
45-
chain, _ := NewBlockChain(testdb, nil, params.TestChainConfig, ethash.NewFaker(), vm.Config{}, nil, nil, nil)
45+
chain, _ := NewBlockChain(testdb, nil, params.TestChainConfig, ethash.NewFaker(), vm.Config{}, nil, nil)
4646
defer chain.Stop()
4747

4848
for i := 0; i < len(blocks); i++ {
@@ -106,11 +106,11 @@ func testHeaderConcurrentVerification(t *testing.T, threads int) {
106106
var results <-chan error
107107

108108
if valid {
109-
chain, _ := NewBlockChain(testdb, nil, params.TestChainConfig, ethash.NewFaker(), vm.Config{}, nil, nil, nil)
109+
chain, _ := NewBlockChain(testdb, nil, params.TestChainConfig, ethash.NewFaker(), vm.Config{}, nil, nil)
110110
_, results = chain.engine.VerifyHeaders(chain, headers, seals)
111111
chain.Stop()
112112
} else {
113-
chain, _ := NewBlockChain(testdb, nil, params.TestChainConfig, ethash.NewFakeFailer(uint64(len(headers)-1)), vm.Config{}, nil, nil, nil)
113+
chain, _ := NewBlockChain(testdb, nil, params.TestChainConfig, ethash.NewFakeFailer(uint64(len(headers)-1)), vm.Config{}, nil, nil)
114114
_, results = chain.engine.VerifyHeaders(chain, headers, seals)
115115
chain.Stop()
116116
}
@@ -173,7 +173,7 @@ func testHeaderConcurrentAbortion(t *testing.T, threads int) {
173173
defer runtime.GOMAXPROCS(old)
174174

175175
// Start the verifications and immediately abort
176-
chain, _ := NewBlockChain(testdb, nil, params.TestChainConfig, ethash.NewFakeDelayer(time.Millisecond), vm.Config{}, nil, nil, nil)
176+
chain, _ := NewBlockChain(testdb, nil, params.TestChainConfig, ethash.NewFakeDelayer(time.Millisecond), vm.Config{}, nil, nil)
177177
defer chain.Stop()
178178

179179
abort, results := chain.engine.VerifyHeaders(chain, headers, seals)

core/blockchain_repair_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1752,7 +1752,7 @@ func testLongReorgedFastSyncingDeepRepair(t *testing.T, snapshots bool) {
17521752

17531753
func testRepair(t *testing.T, tt *rewindTest, snapshots bool) {
17541754
// It's hard to follow the test case, visualize the input
1755-
//log.Root().SetHandler(log.LvlFilterHandler(log.LvlTrace, log.StreamHandler(os.Stderr, log.TerminalFormat(true))))
1755+
// log.Root().SetHandler(log.LvlFilterHandler(log.LvlTrace, log.StreamHandler(os.Stderr, log.TerminalFormat(true))))
17561756
// fmt.Println(tt.dump(true))
17571757

17581758
// Create a temporary persistent database
@@ -1783,7 +1783,7 @@ func testRepair(t *testing.T, tt *rewindTest, snapshots bool) {
17831783
config.SnapshotLimit = 256
17841784
config.SnapshotWait = true
17851785
}
1786-
chain, err := NewBlockChain(db, config, params.AllEthashProtocolChanges, engine, vm.Config{}, nil, nil, nil)
1786+
chain, err := NewBlockChain(db, config, params.AllEthashProtocolChanges, engine, vm.Config{}, nil, nil)
17871787
if err != nil {
17881788
t.Fatalf("Failed to create chain: %v", err)
17891789
}
@@ -1836,7 +1836,7 @@ func testRepair(t *testing.T, tt *rewindTest, snapshots bool) {
18361836
}
18371837
defer db.Close()
18381838

1839-
chain, err = NewBlockChain(db, nil, params.AllEthashProtocolChanges, engine, vm.Config{}, nil, nil, nil)
1839+
chain, err = NewBlockChain(db, nil, params.AllEthashProtocolChanges, engine, vm.Config{}, nil, nil)
18401840
if err != nil {
18411841
t.Fatalf("Failed to recreate chain: %v", err)
18421842
}

0 commit comments

Comments
 (0)