From 99e7b7bf2b11cce7eb081dadfd081aee01cdd589 Mon Sep 17 00:00:00 2001 From: cce <51567+cce@users.noreply.github.com> Date: Thu, 12 Sep 2024 14:16:12 -0400 Subject: [PATCH 1/3] use linter for tests --- .golangci.yml | 4 +-- api/app_boxes_fixtures_test.go | 7 ++--- api/handlers_e2e_test.go | 5 ++-- api/handlers_test.go | 9 ++++--- api/util_test.go | 4 +-- cmd/algorand-indexer/daemon_test.go | 17 ++++++------ cmd/validator/core/validator_test.go | 4 +-- idb/idb_test.go | 3 ++- .../internal/encoding/encoding_test.go | 9 ++++--- .../migrations/convert_account_data/m_test.go | 3 ++- idb/postgres/postgres_boxes_test.go | 2 +- .../postgres_integration_common_test.go | 7 ++--- idb/postgres/postgres_integration_test.go | 20 +++++++------- idb/postgres/postgres_migrations_test.go | 3 ++- idb/postgres/postgres_rand_test.go | 4 +-- idb/postgres/postgres_test.go | 26 +++++++++---------- types/min_balance_test.go | 6 +++-- util/util_test.go | 4 +-- 18 files changed, 74 insertions(+), 63 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 1854949cd..c9ccc8849 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,6 +1,6 @@ run: timeout: 5m - tests: false + tests: true linters: disable-all: true @@ -66,4 +66,4 @@ issues: # revive: ignore some rules - "^unused-parameter: parameter" - - "^package-comments: should have a package comment" \ No newline at end of file + - "^package-comments: should have a package comment" diff --git a/api/app_boxes_fixtures_test.go b/api/app_boxes_fixtures_test.go index 8d067b25e..df05e2f38 100644 --- a/api/app_boxes_fixtures_test.go +++ b/api/app_boxes_fixtures_test.go @@ -6,13 +6,14 @@ import ( "fmt" "testing" - "github.com/algorand/indexer/v3/idb/postgres" "github.com/stretchr/testify/require" "github.com/algorand/avm-abi/apps" + "github.com/algorand/indexer/v3/idb/postgres" + "github.com/algorand/indexer/v3/util/test" + "github.com/algorand/go-algorand-sdk/v2/crypto" sdk "github.com/algorand/go-algorand-sdk/v2/types" - "github.com/algorand/indexer/v3/util/test" ) func goalEncode(t *testing.T, s string) string { @@ -23,7 +24,7 @@ func goalEncode(t *testing.T, s string) string { return string(b2) } -var goalEncodingExamples map[string]string = map[string]string{ +var goalEncodingExamples = map[string]string{ "str": "str", "string": "string", "int": "42", diff --git a/api/handlers_e2e_test.go b/api/handlers_e2e_test.go index 0808b60cd..a581bcc47 100644 --- a/api/handlers_e2e_test.go +++ b/api/handlers_e2e_test.go @@ -19,6 +19,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "github.com/algorand/avm-abi/apps" "github.com/algorand/indexer/v3/api/generated/v2" "github.com/algorand/indexer/v3/idb" "github.com/algorand/indexer/v3/idb/postgres" @@ -27,7 +28,6 @@ import ( "github.com/algorand/indexer/v3/util" "github.com/algorand/indexer/v3/util/test" - "github.com/algorand/avm-abi/apps" "github.com/algorand/go-algorand-sdk/v2/crypto" "github.com/algorand/go-algorand-sdk/v2/encoding/json" sdk "github.com/algorand/go-algorand-sdk/v2/types" @@ -80,7 +80,7 @@ func setupIdb(t *testing.T, genesis sdk.Genesis) (*postgres.IndexerDb, func()) { Block: test.MakeGenesisBlock(), Delta: sdk.LedgerStateDelta{}, } - db.AddBlock(&vb) + require.NoError(t, db.AddBlock(&vb)) require.NoError(t, err) return db, newShutdownFunc @@ -1738,6 +1738,7 @@ func TestGetBlockWithCompression(t *testing.T) { // we now make sure that compression flag works with other flags. notCompressedBlock = getBlockFunc(t, true, false) compressedBlock = getBlockFunc(t, true, true) + require.Equal(t, notCompressedBlock, compressedBlock) require.Equal(t, len(*notCompressedBlock.Transactions), 0) } diff --git a/api/handlers_test.go b/api/handlers_test.go index 18c152698..9feff8a22 100644 --- a/api/handlers_test.go +++ b/api/handlers_test.go @@ -18,13 +18,14 @@ import ( "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" - sdkcrypto "github.com/algorand/go-algorand-sdk/v2/crypto" - "github.com/algorand/go-algorand-sdk/v2/encoding/msgpack" - sdk "github.com/algorand/go-algorand-sdk/v2/types" "github.com/algorand/indexer/v3/api/generated/v2" "github.com/algorand/indexer/v3/idb" "github.com/algorand/indexer/v3/idb/mocks" "github.com/algorand/indexer/v3/types" + + sdkcrypto "github.com/algorand/go-algorand-sdk/v2/crypto" + "github.com/algorand/go-algorand-sdk/v2/encoding/msgpack" + sdk "github.com/algorand/go-algorand-sdk/v2/types" ) func TestTransactionParamToTransactionFilter(t *testing.T) { @@ -1222,7 +1223,7 @@ func TestBigNumbers(t *testing.T) { c := e.NewContext(req, rec1) // call handler - tc.callHandler(c, *si) + require.NoError(t, tc.callHandler(c, *si)) assert.Equal(t, http.StatusNotFound, rec1.Code) bodyStr := rec1.Body.String() require.Contains(t, bodyStr, tc.errString) diff --git a/api/util_test.go b/api/util_test.go index 95d4ab39a..8fa07b1af 100644 --- a/api/util_test.go +++ b/api/util_test.go @@ -9,9 +9,9 @@ import ( "github.com/sirupsen/logrus/hooks/test" "github.com/stretchr/testify/require" - "github.com/algorand/go-algorand-sdk/v2/types" - "github.com/algorand/indexer/v3/idb" + + "github.com/algorand/go-algorand-sdk/v2/types" ) func TestCallWithTimeoutTimesOut(t *testing.T) { diff --git a/cmd/algorand-indexer/daemon_test.go b/cmd/algorand-indexer/daemon_test.go index 62262d3f8..36aa887e4 100644 --- a/cmd/algorand-indexer/daemon_test.go +++ b/cmd/algorand-indexer/daemon_test.go @@ -12,6 +12,7 @@ import ( log "github.com/sirupsen/logrus" "github.com/spf13/pflag" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" "github.com/algorand/indexer/v3/config" "github.com/algorand/indexer/v3/util" @@ -23,7 +24,7 @@ func TestParameterConfigErrorWhenBothFileTypesArePresent(t *testing.T) { indexerDataDir := t.TempDir() for _, configFiletype := range config.FileTypes { autoloadPath := filepath.Join(indexerDataDir, autoLoadParameterConfigFileName+"."+configFiletype) - os.WriteFile(autoloadPath, []byte{}, fs.ModePerm) + require.NoError(t, os.WriteFile(autoloadPath, []byte{}, fs.ModePerm)) } daemonConfig := &daemonConfig{} @@ -41,7 +42,7 @@ func TestIndexerConfigErrorWhenBothFileTypesArePresent(t *testing.T) { indexerDataDir := t.TempDir() for _, configFiletype := range config.FileTypes { autoloadPath := filepath.Join(indexerDataDir, autoLoadIndexerConfigFileName+"."+configFiletype) - os.WriteFile(autoloadPath, []byte{}, fs.ModePerm) + require.NoError(t, os.WriteFile(autoloadPath, []byte{}, fs.ModePerm)) } daemonConfig := &daemonConfig{} @@ -59,7 +60,7 @@ func TestConfigWithEnableAllParamsExpectError(t *testing.T) { for _, configFiletype := range config.FileTypes { indexerDataDir := t.TempDir() autoloadPath := filepath.Join(indexerDataDir, autoLoadIndexerConfigFileName+"."+configFiletype) - os.WriteFile(autoloadPath, []byte{}, fs.ModePerm) + require.NoError(t, os.WriteFile(autoloadPath, []byte{}, fs.ModePerm)) daemonConfig := &daemonConfig{} daemonConfig.flags = pflag.NewFlagSet("indexer", 0) daemonConfig.indexerDataDir = indexerDataDir @@ -88,7 +89,7 @@ func TestConfigInvalidExpectError(t *testing.T) { b := bytes.NewBufferString("") indexerDataDir := t.TempDir() tempConfigFile := indexerDataDir + "/indexer-alt.yml" - os.WriteFile(tempConfigFile, []byte(";;;"), fs.ModePerm) + require.NoError(t, os.WriteFile(tempConfigFile, []byte(";;;"), fs.ModePerm)) daemonConfig := &daemonConfig{} daemonConfig.flags = pflag.NewFlagSet("indexer", 0) daemonConfig.indexerDataDir = indexerDataDir @@ -102,7 +103,7 @@ func TestConfigInvalidExpectError(t *testing.T) { func TestConfigSpecifiedTwiceExpectError(t *testing.T) { indexerDataDir := t.TempDir() tempConfigFile := indexerDataDir + "/indexer.yml" - os.WriteFile(tempConfigFile, []byte{}, fs.ModePerm) + require.NoError(t, os.WriteFile(tempConfigFile, []byte{}, fs.ModePerm)) daemonConfig := &daemonConfig{} daemonConfig.flags = pflag.NewFlagSet("indexer", 0) daemonConfig.indexerDataDir = indexerDataDir @@ -120,7 +121,7 @@ func TestLoadAPIConfigGivenAutoLoadAndUserSuppliedExpectError(t *testing.T) { autoloadPath := filepath.Join(indexerDataDir, autoLoadParameterConfigFileName+"."+configFiletype) userSuppliedPath := filepath.Join(indexerDataDir, "foobar.yml") - os.WriteFile(autoloadPath, []byte{}, fs.ModePerm) + require.NoError(t, os.WriteFile(autoloadPath, []byte{}, fs.ModePerm)) cfg := &daemonConfig{} cfg.indexerDataDir = indexerDataDir cfg.suppliedAPIConfigFile = userSuppliedPath @@ -149,7 +150,7 @@ func TestLoadAPIConfigGivenAutoLoadExpectSuccess(t *testing.T) { indexerDataDir := t.TempDir() autoloadPath := filepath.Join(indexerDataDir, autoLoadParameterConfigFileName+"."+configFiletype) - os.WriteFile(autoloadPath, []byte{}, fs.ModePerm) + require.NoError(t, os.WriteFile(autoloadPath, []byte{}, fs.ModePerm)) cfg := &daemonConfig{} cfg.indexerDataDir = indexerDataDir @@ -180,7 +181,7 @@ func TestIndexerPidFileCreateFailExpectError(t *testing.T) { for _, configFiletype := range config.FileTypes { indexerDataDir := t.TempDir() autoloadPath := filepath.Join(indexerDataDir, autoLoadIndexerConfigFileName+"."+configFiletype) - os.WriteFile(autoloadPath, []byte{}, fs.ModePerm) + require.NoError(t, os.WriteFile(autoloadPath, []byte{}, fs.ModePerm)) invalidDir := filepath.Join(indexerDataDir, "foo", "bar") cfg := &daemonConfig{} diff --git a/cmd/validator/core/validator_test.go b/cmd/validator/core/validator_test.go index deb8b26ef..c7755b956 100644 --- a/cmd/validator/core/validator_test.go +++ b/cmd/validator/core/validator_test.go @@ -7,9 +7,9 @@ import ( "github.com/jarcoal/httpmock" "github.com/stretchr/testify/require" - "github.com/algorand/go-algorand-sdk/v2/types" - "github.com/algorand/indexer/v3/api" + + "github.com/algorand/go-algorand-sdk/v2/types" ) type mockProcessor struct { diff --git a/idb/idb_test.go b/idb/idb_test.go index 0fa7af7a2..51653ce68 100644 --- a/idb/idb_test.go +++ b/idb/idb_test.go @@ -6,9 +6,10 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - sdk "github.com/algorand/go-algorand-sdk/v2/types" "github.com/algorand/indexer/v3/idb" "github.com/algorand/indexer/v3/util/test" + + sdk "github.com/algorand/go-algorand-sdk/v2/types" ) func TestTxnRowNext(t *testing.T) { diff --git a/idb/postgres/internal/encoding/encoding_test.go b/idb/postgres/internal/encoding/encoding_test.go index 50ca9ff76..8b8e1b6ed 100644 --- a/idb/postgres/internal/encoding/encoding_test.go +++ b/idb/postgres/internal/encoding/encoding_test.go @@ -4,14 +4,15 @@ import ( "fmt" "testing" - "github.com/algorand/go-algorand-sdk/v2/encoding/msgpack" - sdk "github.com/algorand/go-algorand-sdk/v2/types" - itypes "github.com/algorand/indexer/v3/types" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/algorand/indexer/v3/idb" "github.com/algorand/indexer/v3/idb/postgres/internal/types" + itypes "github.com/algorand/indexer/v3/types" + + "github.com/algorand/go-algorand-sdk/v2/encoding/msgpack" + sdk "github.com/algorand/go-algorand-sdk/v2/types" ) func TestEncodeSignedTxnWithAD(t *testing.T) { @@ -42,7 +43,7 @@ func TestEncodeSignedTxnWithAD(t *testing.T) { var stxn sdk.SignedTxnWithAD for _, mt := range testTxns { t.Run(mt.name, func(t *testing.T) { - msgpack.Decode(mt.msgpack, &stxn) + require.NoError(t, msgpack.Decode(mt.msgpack, &stxn)) js := EncodeSignedTxnWithAD(stxn) require.Equal(t, mt.json, string(js)) }) diff --git a/idb/postgres/internal/migrations/convert_account_data/m_test.go b/idb/postgres/internal/migrations/convert_account_data/m_test.go index a00fd27c5..f4a97fb39 100644 --- a/idb/postgres/internal/migrations/convert_account_data/m_test.go +++ b/idb/postgres/internal/migrations/convert_account_data/m_test.go @@ -5,7 +5,6 @@ import ( "fmt" "testing" - sdk "github.com/algorand/go-algorand-sdk/v2/types" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -16,6 +15,8 @@ import ( cad "github.com/algorand/indexer/v3/idb/postgres/internal/migrations/convert_account_data" pgtest "github.com/algorand/indexer/v3/idb/postgres/internal/testing" pgutil "github.com/algorand/indexer/v3/idb/postgres/internal/util" + + sdk "github.com/algorand/go-algorand-sdk/v2/types" ) func makeAddress(i int) sdk.Address { diff --git a/idb/postgres/postgres_boxes_test.go b/idb/postgres/postgres_boxes_test.go index 3f77d18d9..dfa51ec59 100644 --- a/idb/postgres/postgres_boxes_test.go +++ b/idb/postgres/postgres_boxes_test.go @@ -11,7 +11,6 @@ import ( "github.com/stretchr/testify/require" "github.com/algorand/avm-abi/apps" - sdk "github.com/algorand/go-algorand-sdk/v2/types" "github.com/algorand/indexer/v3/idb" "github.com/algorand/indexer/v3/idb/postgres/internal/encoding" "github.com/algorand/indexer/v3/idb/postgres/internal/writer" @@ -19,6 +18,7 @@ import ( "github.com/algorand/go-algorand-sdk/v2/protocol" "github.com/algorand/go-algorand-sdk/v2/protocol/config" + sdk "github.com/algorand/go-algorand-sdk/v2/types" ) type boxTestComparator func(t *testing.T, db *IndexerDb, appBoxes map[sdk.AppIndex]map[string]string, diff --git a/idb/postgres/postgres_integration_common_test.go b/idb/postgres/postgres_integration_common_test.go index 9392cd9ef..4c17c446e 100644 --- a/idb/postgres/postgres_integration_common_test.go +++ b/idb/postgres/postgres_integration_common_test.go @@ -4,14 +4,15 @@ import ( "context" "testing" - sdk "github.com/algorand/go-algorand-sdk/v2/types" - "github.com/algorand/indexer/v3/types" "github.com/jackc/pgx/v4/pgxpool" "github.com/stretchr/testify/require" "github.com/algorand/indexer/v3/idb" pgtest "github.com/algorand/indexer/v3/idb/postgres/internal/testing" + "github.com/algorand/indexer/v3/types" "github.com/algorand/indexer/v3/util/test" + + sdk "github.com/algorand/go-algorand-sdk/v2/types" ) func setupIdbWithConnectionString(t *testing.T, connStr string, genesis sdk.Genesis) *IndexerDb { @@ -37,7 +38,7 @@ func setupIdb(t *testing.T, genesis sdk.Genesis) (*IndexerDb, func()) { Block: test.MakeGenesisBlock(), Delta: sdk.LedgerStateDelta{}, } - db.AddBlock(&vb) + require.NoError(t, db.AddBlock(&vb)) return db, newShutdownFunc } diff --git a/idb/postgres/postgres_integration_test.go b/idb/postgres/postgres_integration_test.go index ac3414407..4171c0cf2 100644 --- a/idb/postgres/postgres_integration_test.go +++ b/idb/postgres/postgres_integration_test.go @@ -11,27 +11,27 @@ import ( "testing" "time" - "github.com/algorand/indexer/v3/types" "github.com/jackc/pgx/v4" "github.com/jackc/pgx/v4/pgxpool" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - crypto2 "github.com/algorand/go-algorand-sdk/v2/crypto" - "github.com/algorand/go-algorand-sdk/v2/encoding/msgpack" - sdk "github.com/algorand/go-algorand-sdk/v2/types" + "github.com/algorand/go-codec/codec" "github.com/algorand/indexer/v3/api/generated/v2" "github.com/algorand/indexer/v3/idb" "github.com/algorand/indexer/v3/idb/postgres/internal/encoding" "github.com/algorand/indexer/v3/idb/postgres/internal/schema" pgtest "github.com/algorand/indexer/v3/idb/postgres/internal/testing" pgutil "github.com/algorand/indexer/v3/idb/postgres/internal/util" + "github.com/algorand/indexer/v3/types" "github.com/algorand/indexer/v3/util" "github.com/algorand/indexer/v3/util/test" + crypto2 "github.com/algorand/go-algorand-sdk/v2/crypto" "github.com/algorand/go-algorand-sdk/v2/encoding/json" + "github.com/algorand/go-algorand-sdk/v2/encoding/msgpack" "github.com/algorand/go-algorand-sdk/v2/protocol" - "github.com/algorand/go-codec/codec" + sdk "github.com/algorand/go-algorand-sdk/v2/types" ) // TestMaxRoundOnUninitializedDB makes sure we return 0 when getting the max round on a new DB. @@ -1334,7 +1334,7 @@ func TestAddBlockIncrementsMaxRoundAccounted(t *testing.T) { Block: block, Delta: sdk.LedgerStateDelta{}, } - db.AddBlock(&vb) + require.NoError(t, db.AddBlock(&vb)) round, err = db.GetNextRoundToAccount() require.NoError(t, err) @@ -1347,7 +1347,7 @@ func TestAddBlockIncrementsMaxRoundAccounted(t *testing.T) { Block: block, Delta: sdk.LedgerStateDelta{}, } - db.AddBlock(&vb) + require.NoError(t, db.AddBlock(&vb)) require.NoError(t, err) round, err = db.GetNextRoundToAccount() @@ -1361,7 +1361,7 @@ func TestAddBlockIncrementsMaxRoundAccounted(t *testing.T) { Block: block, Delta: sdk.LedgerStateDelta{}, } - db.AddBlock(&vb) + require.NoError(t, db.AddBlock(&vb)) round, err = db.GetNextRoundToAccount() require.NoError(t, err) @@ -1626,7 +1626,7 @@ func TestSearchForInnerTransactionReturnsRootTransaction(t *testing.T) { Block: test.MakeGenesisBlock(), Delta: sdk.LedgerStateDelta{}, } - db.AddBlock(&genblk) + require.NoError(t, db.AddBlock(&genblk)) return db.AddBlock(&vb) }, nil) require.NoError(t, err) @@ -2190,7 +2190,7 @@ func TestDeleteTransactions(t *testing.T) { Block: test.MakeGenesisBlock(), Delta: sdk.LedgerStateDelta{}, } - db.AddBlock(&genBlock) + require.NoError(t, db.AddBlock(&genBlock)) // add 4 rounds of txns // txnA := test.MakeCreateAppTxn(test.AccountA) // txnB := test.MakeCreateAppTxn(test.AccountB) diff --git a/idb/postgres/postgres_migrations_test.go b/idb/postgres/postgres_migrations_test.go index 6837ceacb..afb4c22c9 100644 --- a/idb/postgres/postgres_migrations_test.go +++ b/idb/postgres/postgres_migrations_test.go @@ -7,9 +7,10 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - sdk "github.com/algorand/go-algorand-sdk/v2/types" pgtest "github.com/algorand/indexer/v3/idb/postgres/internal/testing" "github.com/algorand/indexer/v3/idb/postgres/internal/types" + + sdk "github.com/algorand/go-algorand-sdk/v2/types" ) func TestConvertAccountDataIncrementsMigrationNumber(t *testing.T) { diff --git a/idb/postgres/postgres_rand_test.go b/idb/postgres/postgres_rand_test.go index bcf433ac7..c6bcdae9a 100644 --- a/idb/postgres/postgres_rand_test.go +++ b/idb/postgres/postgres_rand_test.go @@ -11,12 +11,12 @@ import ( "github.com/jackc/pgx/v4" "github.com/stretchr/testify/require" - sdk "github.com/algorand/go-algorand-sdk/v2/types" - models "github.com/algorand/indexer/v3/api/generated/v2" "github.com/algorand/indexer/v3/idb" "github.com/algorand/indexer/v3/idb/postgres/internal/writer" "github.com/algorand/indexer/v3/util/test" + + sdk "github.com/algorand/go-algorand-sdk/v2/types" ) func generateAddress(t *testing.T) sdk.Address { diff --git a/idb/postgres/postgres_test.go b/idb/postgres/postgres_test.go index c797b1b55..d034a02d3 100644 --- a/idb/postgres/postgres_test.go +++ b/idb/postgres/postgres_test.go @@ -8,10 +8,10 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - sdk "github.com/algorand/go-algorand-sdk/v2/types" - "github.com/algorand/indexer/v3/idb" "github.com/algorand/indexer/v3/types" + + sdk "github.com/algorand/go-algorand-sdk/v2/types" ) func Test_txnFilterOptimization(t *testing.T) { @@ -76,11 +76,11 @@ func Test_UnknownProtocol(t *testing.T) { } func Test_buildTransactionQueryTime(t *testing.T) { - us_east_tz, err := time.LoadLocation("America/New_York") + usEastTZ, err := time.LoadLocation("America/New_York") require.NoError(t, err) - us_west_tz, err := time.LoadLocation("America/Los_Angeles") + usWestTZ, err := time.LoadLocation("America/Los_Angeles") require.NoError(t, err) - random_date_utc := time.Date(1000, time.December, 25, 1, 2, 3, 4, time.UTC) + randomDateUTC := time.Date(1000, time.December, 25, 1, 2, 3, 4, time.UTC) tests := []struct { name string arg idb.TransactionFilter @@ -89,26 +89,26 @@ func Test_buildTransactionQueryTime(t *testing.T) { { "BeforeTime UTC to UTC", idb.TransactionFilter{ - BeforeTime: random_date_utc, + BeforeTime: randomDateUTC, }, - []interface{}{random_date_utc}, + []interface{}{randomDateUTC}, }, { "AfterTime UTC to UTC", idb.TransactionFilter{ - AfterTime: random_date_utc, + AfterTime: randomDateUTC, }, - []interface{}{random_date_utc}, + []interface{}{randomDateUTC}, }, { "BeforeTime AfterTime Conversion", idb.TransactionFilter{ - BeforeTime: time.Date(1000, time.December, 25, 1, 2, 3, 4, us_east_tz), - AfterTime: time.Date(1000, time.December, 25, 1, 2, 3, 4, us_west_tz), + BeforeTime: time.Date(1000, time.December, 25, 1, 2, 3, 4, usEastTZ), + AfterTime: time.Date(1000, time.December, 25, 1, 2, 3, 4, usWestTZ), }, []interface{}{ - time.Date(1000, time.December, 25, 1, 2, 3, 4, us_east_tz).UTC(), - time.Date(1000, time.December, 25, 1, 2, 3, 4, us_west_tz).UTC(), + time.Date(1000, time.December, 25, 1, 2, 3, 4, usEastTZ).UTC(), + time.Date(1000, time.December, 25, 1, 2, 3, 4, usWestTZ).UTC(), }, }, } diff --git a/types/min_balance_test.go b/types/min_balance_test.go index 485deae5f..8f97d028e 100644 --- a/types/min_balance_test.go +++ b/types/min_balance_test.go @@ -1,10 +1,12 @@ package types import ( + "testing" + + "github.com/stretchr/testify/assert" + "github.com/algorand/go-algorand-sdk/v2/protocol/config" sdk "github.com/algorand/go-algorand-sdk/v2/types" - "github.com/stretchr/testify/assert" - "testing" ) func TestMinBalance(t *testing.T) { diff --git a/util/util_test.go b/util/util_test.go index d20997d19..5a4bbd271 100644 --- a/util/util_test.go +++ b/util/util_test.go @@ -101,7 +101,7 @@ func TestDecodeSignedTxnErrors(t *testing.T) { // v16.RequireGenesisHash = true b.BlockHeader.CurrentProtocol = "https://github.com/algorand/spec/tree/22726c9dcd12d9cddce4a8bd7e8ccaa707f74101" txib.HasGenesisHash = true - _, ad, err := DecodeSignedTxn(b.BlockHeader, txib) + _, _, err = DecodeSignedTxn(b.BlockHeader, txib) require.Contains(t, err.Error(), "HasGenesisHash set to true but RequireGenesisHash obviates the flag") // gh not empty @@ -112,7 +112,7 @@ func TestDecodeSignedTxnErrors(t *testing.T) { // if !proto.SupportSignedTxnInBlock, applyData is empty b.BlockHeader.CurrentProtocol = "v10" - _, ad, err = DecodeSignedTxn(b.BlockHeader, txib) + _, ad, err := DecodeSignedTxn(b.BlockHeader, txib) require.Equal(t, sdk.ApplyData{}, ad) // genesisID not empty From 6fbbbf494a1a4fc9f1e0d2562b97047ac56717f7 Mon Sep 17 00:00:00 2001 From: cce <51567+cce@users.noreply.github.com> Date: Mon, 16 Sep 2024 10:31:40 -0400 Subject: [PATCH 2/3] fix lint --- api/handlers_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/handlers_test.go b/api/handlers_test.go index ab50ad94b..6a2938900 100644 --- a/api/handlers_test.go +++ b/api/handlers_test.go @@ -1235,7 +1235,7 @@ func TestRewindRoundParameterRejected(t *testing.T) { c := e.NewContext(req, rec1) // call handler - tc.callHandler(c, *si) + require.NoError(t, tc.callHandler(c, *si)) assert.Equal(t, http.StatusBadRequest, rec1.Code) bodyStr := rec1.Body.String() require.Contains(t, bodyStr, tc.errString) From cf7bbd7cb1513062e68b42493937e987451fe1c6 Mon Sep 17 00:00:00 2001 From: cce <51567+cce@users.noreply.github.com> Date: Wed, 18 Sep 2024 13:16:18 -0400 Subject: [PATCH 3/3] remove failing AddBlock(&genBlock) from TestDeleteTransactions --- idb/postgres/postgres_integration_test.go | 5 ----- 1 file changed, 5 deletions(-) diff --git a/idb/postgres/postgres_integration_test.go b/idb/postgres/postgres_integration_test.go index 4171c0cf2..b2c991d86 100644 --- a/idb/postgres/postgres_integration_test.go +++ b/idb/postgres/postgres_integration_test.go @@ -2186,11 +2186,6 @@ func TestDeleteTransactions(t *testing.T) { txns := []sdk.SignedTxn{} - genBlock := types.ValidatedBlock{ - Block: test.MakeGenesisBlock(), - Delta: sdk.LedgerStateDelta{}, - } - require.NoError(t, db.AddBlock(&genBlock)) // add 4 rounds of txns // txnA := test.MakeCreateAppTxn(test.AccountA) // txnB := test.MakeCreateAppTxn(test.AccountB)