diff --git a/README.md b/README.md index 61391f51e..8caf846e3 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Or [Blockchain](), for shor [![version](https://img.shields.io/github/tag/tendermint/tendermint.svg)](https://github.com/tendermint/tendermint/releases/latest) [![API Reference](https://camo.githubusercontent.com/915b7be44ada53c290eb157634330494ebe3e30a/68747470733a2f2f676f646f632e6f72672f6769746875622e636f6d2f676f6c616e672f6764646f3f7374617475732e737667)](https://godoc.org/github.com/tendermint/tendermint) -[![Go version](https://img.shields.io/badge/go-1.13-blue.svg)](https://github.com/moovweb/gvm) +[![Go version](https://img.shields.io/badge/go-1.14-blue.svg)](https://github.com/moovweb/gvm) [![riot.im](https://img.shields.io/badge/riot.im-JOIN%20CHAT-green.svg)](https://riot.im/app/#/room/#tendermint:matrix.org) [![license](https://img.shields.io/github/license/tendermint/tendermint.svg)](https://github.com/tendermint/tendermint/blob/master/LICENSE) [![](https://tokei.rs/b1/github/tendermint/tendermint?category=lines)](https://github.com/tendermint/tendermint) @@ -49,7 +49,7 @@ For examples of the kinds of bugs we're looking for, see [SECURITY.md](SECURITY. | Requirement | Notes | | ----------- | ---------------- | -| Go version | Go1.13 or higher | +| Go version | Go1.14 or higher | ## Documentation diff --git a/consensus/byzantine_test.go b/consensus/byzantine_test.go index bbf9cbf8f..5f3fff0cd 100644 --- a/consensus/byzantine_test.go +++ b/consensus/byzantine_test.go @@ -27,7 +27,7 @@ func TestByzantine(t *testing.T) { N := 4 logger := consensusLogger().With("test", "byzantine") css, cleanup := randConsensusNet(N, "consensus_byzantine_test", newMockTickerFunc(false), newCounter) - defer cleanup() + t.Cleanup(cleanup) // give the byzantine validator a normal ticker ticker := NewTimeoutTicker() @@ -85,7 +85,7 @@ func TestByzantine(t *testing.T) { sm.SaveState(css[i].blockExec.DB(), css[i].state) //for save height 1's validators info } - defer func() { + t.Cleanup(func() { for _, r := range reactors { if rr, ok := r.(*ByzantineReactor); ok { rr.reactor.Switch.Stop() @@ -93,7 +93,7 @@ func TestByzantine(t *testing.T) { r.(*Reactor).Switch.Stop() } } - }() + }) p2p.MakeConnectedSwitches(config.P2P, N, func(i int, s *p2p.Switch) *p2p.Switch { // ignore new switch s, we already made ours diff --git a/consensus/mempool_test.go b/consensus/mempool_test.go index c7fdbd578..2ade0c067 100644 --- a/consensus/mempool_test.go +++ b/consensus/mempool_test.go @@ -24,7 +24,7 @@ func assertMempool(txn txNotifier) mempl.Mempool { func TestMempoolNoProgressUntilTxsAvailable(t *testing.T) { config := ResetConfig("consensus_mempool_txs_available_test") - defer os.RemoveAll(config.RootDir) + t.Cleanup(func() { os.RemoveAll(config.RootDir) }) config.Consensus.CreateEmptyBlocks = false state, privVals := randGenesisState(1, false, 10) cs := newStateWithConfig(config, state, privVals[0], NewCounterApplication()) @@ -43,7 +43,7 @@ func TestMempoolNoProgressUntilTxsAvailable(t *testing.T) { func TestMempoolProgressAfterCreateEmptyBlocksInterval(t *testing.T) { config := ResetConfig("consensus_mempool_txs_available_test") - defer os.RemoveAll(config.RootDir) + t.Cleanup(func() { os.RemoveAll(config.RootDir) }) config.Consensus.CreateEmptyBlocksInterval = ensureTimeout state, privVals := randGenesisState(1, false, 10) cs := newStateWithConfig(config, state, privVals[0], NewCounterApplication()) @@ -59,7 +59,7 @@ func TestMempoolProgressAfterCreateEmptyBlocksInterval(t *testing.T) { func TestMempoolProgressInHigherRound(t *testing.T) { config := ResetConfig("consensus_mempool_txs_available_test") - defer os.RemoveAll(config.RootDir) + t.Cleanup(func() { os.RemoveAll(config.RootDir) }) config.Consensus.CreateEmptyBlocks = false state, privVals := randGenesisState(1, false, 10) cs := newStateWithConfig(config, state, privVals[0], NewCounterApplication()) diff --git a/consensus/reactor_test.go b/consensus/reactor_test.go index 32c638d3a..a18b04020 100644 --- a/consensus/reactor_test.go +++ b/consensus/reactor_test.go @@ -96,9 +96,9 @@ func stopConsensusNet(logger log.Logger, reactors []*Reactor, eventBuses []*type func TestReactorBasic(t *testing.T) { N := 4 css, cleanup := randConsensusNet(N, "consensus_reactor_test", newMockTickerFunc(true), newCounter) - defer cleanup() + t.Cleanup(cleanup) reactors, blocksSubs, eventBuses := startConsensusNet(t, css, N) - defer stopConsensusNet(log.TestingLogger(), reactors, eventBuses) + t.Cleanup(func() { stopConsensusNet(log.TestingLogger(), reactors, eventBuses) }) // wait till everyone makes the first new block timeoutWaitGroup(t, N, func(j int) { <-blocksSubs[j].Out() @@ -126,7 +126,7 @@ func TestReactorWithEvidence(t *testing.T) { stateDB := dbm.NewMemDB() // each state needs its own db state, _ := sm.LoadStateFromDBOrGenesisDoc(stateDB, genDoc) thisConfig := ResetConfig(fmt.Sprintf("%s_%d", testName, i)) - defer os.RemoveAll(thisConfig.RootDir) + t.Cleanup(func() { os.RemoveAll(thisConfig.RootDir) }) ensureDir(path.Dir(thisConfig.Consensus.WalFile()), 0700) // dir for wal app := appFunc() vals := types.TM2PB.ValidatorUpdates(state.Validators) @@ -175,7 +175,7 @@ func TestReactorWithEvidence(t *testing.T) { } reactors, blocksSubs, eventBuses := startConsensusNet(t, css, nValidators) - defer stopConsensusNet(log.TestingLogger(), reactors, eventBuses) + t.Cleanup(func() { stopConsensusNet(log.TestingLogger(), reactors, eventBuses) }) // wait till everyone makes the first new block with no evidence timeoutWaitGroup(t, nValidators, func(j int) { @@ -233,9 +233,9 @@ func TestReactorCreatesBlockWhenEmptyBlocksFalse(t *testing.T) { func(c *cfg.Config) { c.Consensus.CreateEmptyBlocks = false }) - defer cleanup() + t.Cleanup(cleanup) reactors, blocksSubs, eventBuses := startConsensusNet(t, css, N) - defer stopConsensusNet(log.TestingLogger(), reactors, eventBuses) + t.Cleanup(func() { stopConsensusNet(log.TestingLogger(), reactors, eventBuses) }) // send a tx if err := assertMempool(css[3].txNotifier).CheckTx([]byte{1, 2, 3}, nil, mempl.TxInfo{}); err != nil { @@ -251,9 +251,9 @@ func TestReactorCreatesBlockWhenEmptyBlocksFalse(t *testing.T) { func TestReactorReceiveDoesNotPanicIfAddPeerHasntBeenCalledYet(t *testing.T) { N := 1 css, cleanup := randConsensusNet(N, "consensus_reactor_test", newMockTickerFunc(true), newCounter) - defer cleanup() + t.Cleanup(cleanup) reactors, _, eventBuses := startConsensusNet(t, css, N) - defer stopConsensusNet(log.TestingLogger(), reactors, eventBuses) + t.Cleanup(func() { stopConsensusNet(log.TestingLogger(), reactors, eventBuses) }) var ( reactor = reactors[0] @@ -273,9 +273,9 @@ func TestReactorReceiveDoesNotPanicIfAddPeerHasntBeenCalledYet(t *testing.T) { func TestReactorReceivePanicsIfInitPeerHasntBeenCalledYet(t *testing.T) { N := 1 css, cleanup := randConsensusNet(N, "consensus_reactor_test", newMockTickerFunc(true), newCounter) - defer cleanup() + t.Cleanup(cleanup) reactors, _, eventBuses := startConsensusNet(t, css, N) - defer stopConsensusNet(log.TestingLogger(), reactors, eventBuses) + t.Cleanup(func() { stopConsensusNet(log.TestingLogger(), reactors, eventBuses) }) var ( reactor = reactors[0] @@ -295,9 +295,9 @@ func TestReactorReceivePanicsIfInitPeerHasntBeenCalledYet(t *testing.T) { func TestReactorRecordsVotesAndBlockParts(t *testing.T) { N := 4 css, cleanup := randConsensusNet(N, "consensus_reactor_test", newMockTickerFunc(true), newCounter) - defer cleanup() + t.Cleanup(cleanup) reactors, blocksSubs, eventBuses := startConsensusNet(t, css, N) - defer stopConsensusNet(log.TestingLogger(), reactors, eventBuses) + t.Cleanup(func() { stopConsensusNet(log.TestingLogger(), reactors, eventBuses) }) // wait till everyone makes the first new block timeoutWaitGroup(t, N, func(j int) { @@ -324,9 +324,9 @@ func TestReactorVotingPowerChange(t *testing.T) { "consensus_voting_power_changes_test", newMockTickerFunc(true), newPersistentKVStore) - defer cleanup() + t.Cleanup(cleanup) reactors, blocksSubs, eventBuses := startConsensusNet(t, css, nVals) - defer stopConsensusNet(logger, reactors, eventBuses) + t.Cleanup(func() { stopConsensusNet(logger, reactors, eventBuses) }) // map of active validators activeVals := make(map[string]struct{}) @@ -401,11 +401,11 @@ func TestReactorValidatorSetChanges(t *testing.T) { newMockTickerFunc(true), newPersistentKVStoreWithPath) - defer cleanup() + t.Cleanup(cleanup) logger := log.TestingLogger() reactors, blocksSubs, eventBuses := startConsensusNet(t, css, nPeers) - defer stopConsensusNet(logger, reactors, eventBuses) + t.Cleanup(func() { stopConsensusNet(logger, reactors, eventBuses) }) // map of active validators activeVals := make(map[string]struct{}) @@ -502,14 +502,14 @@ func TestReactorValidatorSetChanges(t *testing.T) { func TestReactorWithTimeoutCommit(t *testing.T) { N := 4 css, cleanup := randConsensusNet(N, "consensus_reactor_with_timeout_commit_test", newMockTickerFunc(false), newCounter) - defer cleanup() + t.Cleanup(cleanup) // override default SkipTimeoutCommit == true for tests for i := 0; i < N; i++ { css[i].config.SkipTimeoutCommit = false } reactors, blocksSubs, eventBuses := startConsensusNet(t, css, N-1) - defer stopConsensusNet(log.TestingLogger(), reactors, eventBuses) + t.Cleanup(func() { stopConsensusNet(log.TestingLogger(), reactors, eventBuses) }) // wait till everyone makes the first new block timeoutWaitGroup(t, N-1, func(j int) { diff --git a/consensus/replay_test.go b/consensus/replay_test.go index aca6a9f10..18931c2aa 100644 --- a/consensus/replay_test.go +++ b/consensus/replay_test.go @@ -82,7 +82,7 @@ func startNewStateAndWaitForBlock(t *testing.T, consensusReplayConfig *cfg.Confi err := cs.Start() require.NoError(t, err) - defer cs.Stop() + t.Cleanup(func() { cs.Stop() }) // This is just a signal that we haven't halted; its not something contained // in the WAL itself. Assuming the consensus state is running, replay of any @@ -808,7 +808,7 @@ func TestHandshakePanicsIfAppReturnsWrongAppHash(t *testing.T) { // - 0x02 // - 0x03 config := ResetConfig("handshake_test_") - defer os.RemoveAll(config.RootDir) + t.Cleanup(func() { os.RemoveAll(config.RootDir) }) privVal := privval.LoadFilePV(config.PrivValidatorKeyFile(), config.PrivValidatorStateFile()) const appVersion = 0x0 stateDB, state, store := stateAndStore(config, privVal.GetPubKey(), appVersion) @@ -1093,7 +1093,7 @@ func TestHandshakeUpdatesValidators(t *testing.T) { clientCreator := proxy.NewLocalClientCreator(app) config := ResetConfig("handshake_test_") - defer os.RemoveAll(config.RootDir) + t.Cleanup(func() { os.RemoveAll(config.RootDir) }) privVal := privval.LoadFilePV(config.PrivValidatorKeyFile(), config.PrivValidatorStateFile()) stateDB, state, store := stateAndStore(config, privVal.GetPubKey(), 0x0) @@ -1106,7 +1106,7 @@ func TestHandshakeUpdatesValidators(t *testing.T) { if err := proxyApp.Start(); err != nil { t.Fatalf("Error starting proxy app connections: %v", err) } - defer proxyApp.Stop() + t.Cleanup(func() { proxyApp.Stop() }) if err := handshaker.Handshake(proxyApp); err != nil { t.Fatalf("Error on abci handshake: %v", err) } diff --git a/consensus/wal_test.go b/consensus/wal_test.go index 6871f534d..c4ce6092d 100644 --- a/consensus/wal_test.go +++ b/consensus/wal_test.go @@ -29,7 +29,7 @@ const ( func TestWALTruncate(t *testing.T) { walDir, err := ioutil.TempDir("", "wal") require.NoError(t, err) - defer os.RemoveAll(walDir) + t.Cleanup(func() { os.RemoveAll(walDir) }) walFile := filepath.Join(walDir, "wal") @@ -45,12 +45,12 @@ func TestWALTruncate(t *testing.T) { wal.SetLogger(log.TestingLogger()) err = wal.Start() require.NoError(t, err) - defer func() { + t.Cleanup(func() { wal.Stop() // wait for the wal to finish shutting down so we // can safely remove the directory wal.Wait() - }() + }) // 60 block's size nearly 70K, greater than group's headBuf size(4096 * 10), // when headBuf is full, truncate content will Flush to the file. at this @@ -67,7 +67,7 @@ func TestWALTruncate(t *testing.T) { assert.NoError(t, err, "expected not to err on height %d", h) assert.True(t, found, "expected to find end height for %d", h) assert.NotNil(t, gr) - defer gr.Close() + t.Cleanup(func() { gr.Close() }) dec := NewWALDecoder(gr) msg, err := dec.Decode() @@ -107,19 +107,19 @@ func TestWALEncoderDecoder(t *testing.T) { func TestWALWrite(t *testing.T) { walDir, err := ioutil.TempDir("", "wal") require.NoError(t, err) - defer os.RemoveAll(walDir) + t.Cleanup(func() { os.RemoveAll(walDir) }) walFile := filepath.Join(walDir, "wal") wal, err := NewWAL(walFile) require.NoError(t, err) err = wal.Start() require.NoError(t, err) - defer func() { + t.Cleanup(func() { wal.Stop() // wait for the wal to finish shutting down so we // can safely remove the directory wal.Wait() - }() + }) // 1) Write returns an error if msg is too big msg := &BlockPartMessage{ @@ -157,7 +157,7 @@ func TestWALSearchForEndHeight(t *testing.T) { assert.NoError(t, err, "expected not to err on height %d", h) assert.True(t, found, "expected to find end height for %d", h) assert.NotNil(t, gr) - defer gr.Close() + t.Cleanup(func() { gr.Close() }) dec := NewWALDecoder(gr) msg, err := dec.Decode() @@ -170,7 +170,7 @@ func TestWALSearchForEndHeight(t *testing.T) { func TestWALPeriodicSync(t *testing.T) { walDir, err := ioutil.TempDir("", "wal") require.NoError(t, err) - defer os.RemoveAll(walDir) + t.Cleanup(func() { os.RemoveAll(walDir) }) walFile := filepath.Join(walDir, "wal") wal, err := NewWAL(walFile, autofile.GroupCheckDuration(1*time.Millisecond)) @@ -187,10 +187,10 @@ func TestWALPeriodicSync(t *testing.T) { assert.NotZero(t, wal.Group().Buffered()) require.NoError(t, wal.Start()) - defer func() { + t.Cleanup(func() { wal.Stop() wal.Wait() - }() + }) time.Sleep(walTestFlushInterval + (10 * time.Millisecond)) diff --git a/go.mod b/go.mod index dd2b444fc..ccd7b4929 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/tendermint/tendermint -go 1.13 +go 1.14 require ( github.com/ChainSafe/go-schnorrkel v0.0.0-20200102211924-4bcbc698314f diff --git a/libs/autofile/autofile_test.go b/libs/autofile/autofile_test.go index 24ca6343d..55c6cceba 100644 --- a/libs/autofile/autofile_test.go +++ b/libs/autofile/autofile_test.go @@ -17,12 +17,12 @@ import ( func TestSIGHUP(t *testing.T) { origDir, err := os.Getwd() require.NoError(t, err) - defer os.Chdir(origDir) + t.Cleanup(func() { os.Chdir(origDir) }) // First, create a temporary directory and move into it dir, err := ioutil.TempDir("", "sighup_test") require.NoError(t, err) - defer os.RemoveAll(dir) + t.Cleanup(func() { os.RemoveAll(dir) }) err = os.Chdir(dir) require.NoError(t, err) @@ -45,7 +45,7 @@ func TestSIGHUP(t *testing.T) { // Move into a different temporary directory otherDir, err := ioutil.TempDir("", "sighup_test_other") require.NoError(t, err) - defer os.RemoveAll(otherDir) + t.Cleanup(func() { os.RemoveAll(otherDir) }) err = os.Chdir(otherDir) require.NoError(t, err) diff --git a/libs/autofile/group_test.go b/libs/autofile/group_test.go index de29a0fba..1022b8512 100644 --- a/libs/autofile/group_test.go +++ b/libs/autofile/group_test.go @@ -111,11 +111,11 @@ func TestRotateFile(t *testing.T) { // relative paths are resolved at Group creation origDir, err := os.Getwd() require.NoError(t, err) - defer os.Chdir(origDir) + t.Cleanup(func() { os.Chdir(origDir) }) dir, err := ioutil.TempDir("", "rotate_test") require.NoError(t, err) - defer os.RemoveAll(dir) + t.Cleanup(func() { os.RemoveAll(dir) }) err = os.Chdir(dir) require.NoError(t, err) diff --git a/mempool/bench_test.go b/mempool/bench_test.go index d6f2d9ed2..c5991038f 100644 --- a/mempool/bench_test.go +++ b/mempool/bench_test.go @@ -12,7 +12,7 @@ func BenchmarkReap(b *testing.B) { app := kvstore.NewApplication() cc := proxy.NewLocalClientCreator(app) mempool, cleanup := newMempoolWithApp(cc) - defer cleanup() + b.Cleanup(cleanup) size := 10000 for i := 0; i < size; i++ { @@ -30,7 +30,7 @@ func BenchmarkCheckTx(b *testing.B) { app := kvstore.NewApplication() cc := proxy.NewLocalClientCreator(app) mempool, cleanup := newMempoolWithApp(cc) - defer cleanup() + b.Cleanup(cleanup) for i := 0; i < b.N; i++ { tx := make([]byte, 8) diff --git a/mempool/cache_test.go b/mempool/cache_test.go index 99bbba406..08b5ee9ad 100644 --- a/mempool/cache_test.go +++ b/mempool/cache_test.go @@ -39,7 +39,7 @@ func TestCacheAfterUpdate(t *testing.T) { app := kvstore.NewApplication() cc := proxy.NewLocalClientCreator(app) mempool, cleanup := newMempoolWithApp(cc) - defer cleanup() + t.Cleanup(cleanup) // reAddIndices & txsInCache can have elements > numTxsToCreate // also assumes max index is 255 for convenience diff --git a/mempool/clist_mempool_test.go b/mempool/clist_mempool_test.go index 17ab83f33..bd6ed25e9 100644 --- a/mempool/clist_mempool_test.go +++ b/mempool/clist_mempool_test.go @@ -94,7 +94,7 @@ func TestReapMaxBytesMaxGas(t *testing.T) { app := kvstore.NewApplication() cc := proxy.NewLocalClientCreator(app) mempool, cleanup := newMempoolWithApp(cc) - defer cleanup() + t.Cleanup(cleanup) // Ensure gas calculation behaves as expected checkTxs(t, mempool, 1, UnknownPeerID) @@ -143,7 +143,7 @@ func TestMempoolFilters(t *testing.T) { app := kvstore.NewApplication() cc := proxy.NewLocalClientCreator(app) mempool, cleanup := newMempoolWithApp(cc) - defer cleanup() + t.Cleanup(cleanup) emptyTxArr := []types.Tx{[]byte{}} nopPreFilter := func(tx types.Tx) error { return nil } @@ -182,7 +182,7 @@ func TestMempoolUpdate(t *testing.T) { app := kvstore.NewApplication() cc := proxy.NewLocalClientCreator(app) mempool, cleanup := newMempoolWithApp(cc) - defer cleanup() + t.Cleanup(cleanup) // 1. Adds valid txs to the cache { @@ -217,7 +217,7 @@ func TestTxsAvailable(t *testing.T) { app := kvstore.NewApplication() cc := proxy.NewLocalClientCreator(app) mempool, cleanup := newMempoolWithApp(cc) - defer cleanup() + t.Cleanup(cleanup) mempool.EnableTxsAvailable() timeoutMS := 500 @@ -263,7 +263,7 @@ func TestSerialReap(t *testing.T) { cc := proxy.NewLocalClientCreator(app) mempool, cleanup := newMempoolWithApp(cc) - defer cleanup() + t.Cleanup(cleanup) appConnCon, _ := cc.NewABCIClient() appConnCon.SetLogger(log.TestingLogger().With("module", "abci-client", "connection", "consensus")) @@ -384,7 +384,7 @@ func TestMempoolCloseWAL(t *testing.T) { app := kvstore.NewApplication() cc := proxy.NewLocalClientCreator(app) mempool, cleanup := newMempoolWithAppAndConfig(cc, wcfg) - defer cleanup() + t.Cleanup(cleanup) mempool.height = 10 mempool.InitWAL() @@ -425,7 +425,7 @@ func TestMempoolMaxMsgSize(t *testing.T) { app := kvstore.NewApplication() cc := proxy.NewLocalClientCreator(app) mempl, cleanup := newMempoolWithApp(cc) - defer cleanup() + t.Cleanup(cleanup) maxTxSize := mempl.config.MaxTxBytes maxMsgSize := calcMaxMsgSize(maxTxSize) @@ -478,7 +478,7 @@ func TestMempoolTxsBytes(t *testing.T) { config := cfg.ResetTestRoot("mempool_test") config.Mempool.MaxTxsBytes = 10 mempool, cleanup := newMempoolWithAppAndConfig(cc, config) - defer cleanup() + t.Cleanup(cleanup) // 1. zero by default assert.EqualValues(t, 0, mempool.TxsBytes()) @@ -512,7 +512,7 @@ func TestMempoolTxsBytes(t *testing.T) { app2 := counter.NewApplication(true) cc = proxy.NewLocalClientCreator(app2) mempool, cleanup = newMempoolWithApp(cc) - defer cleanup() + t.Cleanup(cleanup) txBytes := make([]byte, 8) binary.BigEndian.PutUint64(txBytes, uint64(0)) @@ -525,7 +525,7 @@ func TestMempoolTxsBytes(t *testing.T) { appConnCon.SetLogger(log.TestingLogger().With("module", "abci-client", "connection", "consensus")) err = appConnCon.Start() require.Nil(t, err) - defer appConnCon.Stop() + t.Cleanup(func() { appConnCon.Stop() }) res, err := appConnCon.DeliverTxSync(abci.RequestDeliverTx{Tx: txBytes}) require.NoError(t, err) require.EqualValues(t, 0, res.Code) @@ -546,10 +546,10 @@ func TestMempoolRemoteAppConcurrency(t *testing.T) { sockPath := fmt.Sprintf("unix:///tmp/echo_%v.sock", tmrand.Str(6)) app := kvstore.NewApplication() cc, server := newRemoteApp(t, sockPath, app) - defer server.Stop() + t.Cleanup(func() { server.Stop() }) config := cfg.ResetTestRoot("mempool_test") mempool, cleanup := newMempoolWithAppAndConfig(cc, config) - defer cleanup() + t.Cleanup(cleanup) // generate small number of txs nTxs := 10 diff --git a/privval/file_deprecated_test.go b/privval/file_deprecated_test.go index ca0e1e508..498c04bd4 100644 --- a/privval/file_deprecated_test.go +++ b/privval/file_deprecated_test.go @@ -36,12 +36,12 @@ const oldPrivvalContent = `{ func TestLoadAndUpgrade(t *testing.T) { oldFilePath := initTmpOldFile(t) - defer os.Remove(oldFilePath) + t.Cleanup(func(){os.Remove(oldFilePath)}) newStateFile, err := ioutil.TempFile("", "priv_validator_state*.json") - defer os.Remove(newStateFile.Name()) + t.Cleanup(func(){os.Remove(newStateFile.Name())}) require.NoError(t, err) newKeyFile, err := ioutil.TempFile("", "priv_validator_key*.json") - defer os.Remove(newKeyFile.Name()) + t.Cleanup(func(){os.Remove(newKeyFile.Name())}) require.NoError(t, err) oldPV, err := privval.LoadOldFilePV(oldFilePath) diff --git a/privval/signer_client_test.go b/privval/signer_client_test.go index 3c578f401..1776e6efe 100644 --- a/privval/signer_client_test.go +++ b/privval/signer_client_test.go @@ -61,8 +61,8 @@ func TestSignerClose(t *testing.T) { func TestSignerPing(t *testing.T) { for _, tc := range getSignerTestCases(t) { - defer tc.signerServer.Stop() - defer tc.signerClient.Close() + t.Cleanup(func() { tc.signerServer.Stop() }) + t.Cleanup(func() { tc.signerClient.Close() }) err := tc.signerClient.Ping() assert.NoError(t, err) @@ -71,8 +71,8 @@ func TestSignerPing(t *testing.T) { func TestSignerGetPubKey(t *testing.T) { for _, tc := range getSignerTestCases(t) { - defer tc.signerServer.Stop() - defer tc.signerClient.Close() + t.Cleanup(func() { tc.signerServer.Stop() }) + t.Cleanup(func() { tc.signerClient.Close() }) pubKey := tc.signerClient.GetPubKey() expectedPubKey := tc.mockPV.GetPubKey() @@ -92,8 +92,8 @@ func TestSignerProposal(t *testing.T) { want := &types.Proposal{Timestamp: ts} have := &types.Proposal{Timestamp: ts} - defer tc.signerServer.Stop() - defer tc.signerClient.Close() + t.Cleanup(func() { tc.signerServer.Stop() }) + t.Cleanup(func() { tc.signerClient.Close() }) require.NoError(t, tc.mockPV.SignProposal(tc.chainID, want)) require.NoError(t, tc.signerClient.SignProposal(tc.chainID, have)) @@ -108,8 +108,8 @@ func TestSignerVote(t *testing.T) { want := &types.Vote{Timestamp: ts, Type: types.PrecommitType} have := &types.Vote{Timestamp: ts, Type: types.PrecommitType} - defer tc.signerServer.Stop() - defer tc.signerClient.Close() + t.Cleanup(func() { tc.signerServer.Stop() }) + t.Cleanup(func() { tc.signerClient.Close() }) require.NoError(t, tc.mockPV.SignVote(tc.chainID, want)) require.NoError(t, tc.signerClient.SignVote(tc.chainID, have)) @@ -124,8 +124,8 @@ func TestSignerVoteResetDeadline(t *testing.T) { want := &types.Vote{Timestamp: ts, Type: types.PrecommitType} have := &types.Vote{Timestamp: ts, Type: types.PrecommitType} - defer tc.signerServer.Stop() - defer tc.signerClient.Close() + t.Cleanup(func() { tc.signerServer.Stop() }) + t.Cleanup(func() { tc.signerClient.Close() }) time.Sleep(testTimeoutReadWrite2o3) @@ -150,8 +150,8 @@ func TestSignerVoteKeepAlive(t *testing.T) { want := &types.Vote{Timestamp: ts, Type: types.PrecommitType} have := &types.Vote{Timestamp: ts, Type: types.PrecommitType} - defer tc.signerServer.Stop() - defer tc.signerClient.Close() + t.Cleanup(func() { tc.signerServer.Stop() }) + t.Cleanup(func() { tc.signerClient.Close() }) // Check that even if the client does not request a // signature for a long time. The service is still available @@ -175,8 +175,8 @@ func TestSignerSignProposalErrors(t *testing.T) { tc.signerServer.privVal = types.NewErroringMockPV() tc.mockPV = types.NewErroringMockPV() - defer tc.signerServer.Stop() - defer tc.signerClient.Close() + t.Cleanup(func() { tc.signerServer.Stop() }) + t.Cleanup(func() { tc.signerClient.Close() }) ts := time.Now() proposal := &types.Proposal{Timestamp: ts} @@ -200,8 +200,8 @@ func TestSignerSignVoteErrors(t *testing.T) { tc.signerServer.privVal = types.NewErroringMockPV() tc.mockPV = types.NewErroringMockPV() - defer tc.signerServer.Stop() - defer tc.signerClient.Close() + t.Cleanup(func() { tc.signerServer.Stop() }) + t.Cleanup(func() { tc.signerClient.Close() }) err := tc.signerClient.SignVote(tc.chainID, vote) require.Equal(t, err.(*RemoteSignerError).Description, types.ErroringMockPVErr.Error()) @@ -245,8 +245,8 @@ func TestSignerUnexpectedResponse(t *testing.T) { tc.signerServer.SetRequestHandler(brokenHandler) - defer tc.signerServer.Stop() - defer tc.signerClient.Close() + t.Cleanup(func() { tc.signerServer.Stop() }) + t.Cleanup(func() { tc.signerClient.Close() }) ts := time.Now() want := &types.Vote{Timestamp: ts, Type: types.PrecommitType} diff --git a/privval/signer_listener_endpoint_test.go b/privval/signer_listener_endpoint_test.go index fbb511d24..1b33653b2 100644 --- a/privval/signer_listener_endpoint_test.go +++ b/privval/signer_listener_endpoint_test.go @@ -73,7 +73,7 @@ func TestSignerRemoteRetryTCPOnly(t *testing.T) { err = signerServer.Start() require.NoError(t, err) - defer signerServer.Stop() + t.Cleanup(func() { signerServer.Stop() }) select { case attempts := <-attemptCh: @@ -104,7 +104,7 @@ func TestRetryConnToRemoteSigner(t *testing.T) { signerServer := NewSignerServer(dialerEndpoint, chainID, mockPV) startListenerEndpointAsync(t, listenerEndpoint, endpointIsOpenCh) - defer listenerEndpoint.Stop() + t.Cleanup(func() { listenerEndpoint.Stop() }) require.NoError(t, signerServer.Start()) assert.True(t, signerServer.IsRunning()) @@ -120,7 +120,7 @@ func TestRetryConnToRemoteSigner(t *testing.T) { // let some pings pass require.NoError(t, signerServer2.Start()) assert.True(t, signerServer2.IsRunning()) - defer signerServer2.Stop() + t.Cleanup(func() { signerServer2.Stop() }) // give the client some time to re-establish the conn to the remote signer // should see sth like this in the logs: diff --git a/proxy/app_conn_test.go b/proxy/app_conn_test.go index ca15f8977..989b292e9 100644 --- a/proxy/app_conn_test.go +++ b/proxy/app_conn_test.go @@ -55,7 +55,7 @@ func TestEcho(t *testing.T) { if err := s.Start(); err != nil { t.Fatalf("Error starting socket server: %v", err.Error()) } - defer s.Stop() + t.Cleanup(func() { s.Stop() }) // Start client cli, err := clientCreator.NewABCIClient() @@ -89,7 +89,7 @@ func BenchmarkEcho(b *testing.B) { if err := s.Start(); err != nil { b.Fatalf("Error starting socket server: %v", err.Error()) } - defer s.Stop() + b.Cleanup(func() { s.Stop() }) // Start client cli, err := clientCreator.NewABCIClient() @@ -128,7 +128,7 @@ func TestInfo(t *testing.T) { if err := s.Start(); err != nil { t.Fatalf("Error starting socket server: %v", err.Error()) } - defer s.Stop() + t.Cleanup(func() { s.Stop() }) // Start client cli, err := clientCreator.NewABCIClient() diff --git a/scripts/gitian-build.sh b/scripts/gitian-build.sh index 7471b472f..00059ca6c 100755 --- a/scripts/gitian-build.sh +++ b/scripts/gitian-build.sh @@ -8,7 +8,7 @@ set -euo pipefail GITIAN_CACHE_DIRNAME='.gitian-builder-cache' -GO_RELEASE='1.13.3' +GO_RELEASE='1.14' GO_TARBALL="go${GO_RELEASE}.linux-amd64.tar.gz" GO_TARBALL_URL="https://dl.google.com/go/${GO_TARBALL}" diff --git a/scripts/gitian-descriptors/gitian-darwin.yml b/scripts/gitian-descriptors/gitian-darwin.yml index 90a9fb9d4..66e145e65 100644 --- a/scripts/gitian-descriptors/gitian-darwin.yml +++ b/scripts/gitian-descriptors/gitian-darwin.yml @@ -23,11 +23,11 @@ remotes: - "url": "https://github.com/tendermint/tendermint.git" "dir": "tendermint" files: -- "go1.13.3.linux-amd64.tar.gz" +- "go1.14.linux-amd64.tar.gz" script: | set -e -o pipefail - GO_SRC_RELEASE=go1.13.3.linux-amd64 + GO_SRC_RELEASE=go1.14.linux-amd64 GO_SRC_TARBALL="${GO_SRC_RELEASE}.tar.gz" # Compile go and configure the environment export TAR_OPTIONS="--mtime="$REFERENCE_DATE\\\ $REFERENCE_TIME"" diff --git a/scripts/gitian-descriptors/gitian-linux.yml b/scripts/gitian-descriptors/gitian-linux.yml index 8aab869ee..4f23a05ed 100644 --- a/scripts/gitian-descriptors/gitian-linux.yml +++ b/scripts/gitian-descriptors/gitian-linux.yml @@ -23,11 +23,11 @@ remotes: - "url": "https://github.com/tendermint/tendermint.git" "dir": "tendermint" files: -- "go1.13.3.linux-amd64.tar.gz" +- "go1.14.linux-amd64.tar.gz" script: | set -e -o pipefail - GO_SRC_RELEASE=go1.13.3.linux-amd64 + GO_SRC_RELEASE=go1.14.linux-amd64 GO_SRC_TARBALL="${GO_SRC_RELEASE}.tar.gz" # Compile go and configure the environment export TAR_OPTIONS="--mtime="$REFERENCE_DATE\\\ $REFERENCE_TIME"" diff --git a/scripts/gitian-descriptors/gitian-windows.yml b/scripts/gitian-descriptors/gitian-windows.yml index 23dbdab2f..f83b82ff2 100644 --- a/scripts/gitian-descriptors/gitian-windows.yml +++ b/scripts/gitian-descriptors/gitian-windows.yml @@ -23,11 +23,11 @@ remotes: - "url": "https://github.com/tendermint/tendermint.git" "dir": "tendermint" files: -- "go1.13.3.linux-amd64.tar.gz" +- "go1.14.linux-amd64.tar.gz" script: | set -e -o pipefail - GO_SRC_RELEASE=go1.13.3.linux-amd64 + GO_SRC_RELEASE=go1.14.linux-amd64 GO_SRC_TARBALL="${GO_SRC_RELEASE}.tar.gz" # Compile go and configure the environment export TAR_OPTIONS="--mtime="$REFERENCE_DATE\\\ $REFERENCE_TIME"" diff --git a/test/docker/Dockerfile b/test/docker/Dockerfile index fb5458e82..3479aa441 100644 --- a/test/docker/Dockerfile +++ b/test/docker/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.13 +FROM golang:1.14 # Add testing deps for curl RUN echo 'deb http://httpredir.debian.org/debian testing main non-free contrib' >> /etc/apt/sources.list diff --git a/tools/build/Makefile b/tools/build/Makefile index 1c2094427..48e591e97 100644 --- a/tools/build/Makefile +++ b/tools/build/Makefile @@ -4,7 +4,7 @@ requirements_check = true gpg_check = false -go_min_version = 1.13 +go_min_version = 1.14 gpg_key = 2122CBE9 ifeq ($(requirements_check),true)