From 6c37b8b094eb172e9643aa692c0ad97f5664b1d4 Mon Sep 17 00:00:00 2001 From: Christopher Tarry Date: Sat, 21 Sep 2024 15:54:30 -0400 Subject: [PATCH] linter fixes --- api/api_test.go | 2 +- internal/testutil/chain.go | 5 +++-- internal/testutil/check.go | 3 +++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/api/api_test.go b/api/api_test.go index 129bc7bf..81d72820 100644 --- a/api/api_test.go +++ b/api/api_test.go @@ -81,7 +81,7 @@ func newServer(t *testing.T, cm *chain.Manager, e *explorer.Explorer, listenAddr go func() { if err := server.Serve(httpListener); err != nil && !errors.Is(err, http.ErrServerClosed) && !errors.Is(err, net.ErrClosed) { - t.Fatal(err) + return } }() diff --git a/internal/testutil/chain.go b/internal/testutil/chain.go index 8a5334a7..ccbaaf8f 100644 --- a/internal/testutil/chain.go +++ b/internal/testutil/chain.go @@ -120,7 +120,7 @@ func MineBlock(state consensus.State, txns []types.Transaction, minerAddr types. return b } -// SignTransactionWithRevisions signs a transaction using the specified private +// SignTransactionWithContracts signs a transaction using the specified private // keys, including contract revisions. func SignTransactionWithContracts(cs consensus.State, pk, renterPK, hostPK types.PrivateKey, txn *types.Transaction) { appendSig := func(key types.PrivateKey, pubkeyIndex uint64, parentID types.Hash256) { @@ -144,7 +144,8 @@ func SignTransactionWithContracts(cs consensus.State, pk, renterPK, hostPK types } } -// SignTransaction signs a transaction using the specified private keys. +// SignTransaction signs a transaction that does not have any revisions with +// the specified private key. func SignTransaction(cs consensus.State, pk types.PrivateKey, txn *types.Transaction) { if len(txn.FileContractRevisions) > 0 { panic("use SignTransactionWithContracts instead") diff --git a/internal/testutil/check.go b/internal/testutil/check.go index 2be6231b..f9bb218a 100644 --- a/internal/testutil/check.go +++ b/internal/testutil/check.go @@ -9,6 +9,7 @@ import ( "go.sia.tech/explored/explorer" ) +// Check checks if two values of the same type are equal and fails otherwise. func Check[T any](t *testing.T, desc string, expect, got T) { if !reflect.DeepEqual(expect, got) { t.Fatalf("expected %v %s, got %v", expect, desc, got) @@ -145,6 +146,8 @@ func CheckMetrics(t *testing.T, db explorer.Store, cm *chain.Manager, expected e // don't check circulating supply here because it requires a lot of accounting } +// CheckChainIndices checks that the chain indices that a transaction was in +// from the explorer match the expected chain indices. func CheckChainIndices(t *testing.T, db explorer.Store, txnID types.TransactionID, expected []types.ChainIndex) { indices, err := db.TransactionChainIndices(txnID, 0, 100) switch {