From 1b3786338f649fe7d0faa7f77b9d76cf94f4b9f5 Mon Sep 17 00:00:00 2001 From: Elizabeth Engelman Date: Mon, 19 Aug 2019 16:51:17 -0500 Subject: [PATCH] Address PR feedback --- cmd/composeAndExecute.go | 1 - .../postgres/repositories/address_repository.go | 7 +++---- .../repositories/address_repository_test.go | 4 +++- .../header_sync_receipt_repository_test.go | 16 +++++++++------- .../watched_events_repository_test.go | 4 +++- 5 files changed, 18 insertions(+), 14 deletions(-) diff --git a/cmd/composeAndExecute.go b/cmd/composeAndExecute.go index 4dc113857..d3e0e0b9a 100644 --- a/cmd/composeAndExecute.go +++ b/cmd/composeAndExecute.go @@ -14,7 +14,6 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . - package cmd import ( diff --git a/pkg/datastore/postgres/repositories/address_repository.go b/pkg/datastore/postgres/repositories/address_repository.go index 860017647..3976fa280 100644 --- a/pkg/datastore/postgres/repositories/address_repository.go +++ b/pkg/datastore/postgres/repositories/address_repository.go @@ -18,8 +18,10 @@ package repositories import ( "database/sql" + "github.com/ethereum/go-ethereum/common" "github.com/jmoiron/sqlx" + "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres" ) @@ -56,8 +58,5 @@ func (AddressRepository) GetOrCreateAddressInTransaction(tx *sqlx.Tx, address st func (AddressRepository) GetAddressById(db *postgres.DB, id int) (string, error) { var address string getErr := db.Get(&address, `SELECT address FROM public.addresses WHERE id = $1`, id) - if getErr != nil { - return "", getErr - } - return address, nil + return address, getErr } diff --git a/pkg/datastore/postgres/repositories/address_repository_test.go b/pkg/datastore/postgres/repositories/address_repository_test.go index baa2fcb73..5b67cfd00 100644 --- a/pkg/datastore/postgres/repositories/address_repository_test.go +++ b/pkg/datastore/postgres/repositories/address_repository_test.go @@ -17,14 +17,16 @@ package repositories_test import ( + "strings" + "github.com/jmoiron/sqlx" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" + "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres" "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres/repositories" "github.com/vulcanize/vulcanizedb/pkg/fakes" "github.com/vulcanize/vulcanizedb/test_config" - "strings" ) var _ = Describe("address lookup", func() { diff --git a/pkg/datastore/postgres/repositories/header_sync_receipt_repository_test.go b/pkg/datastore/postgres/repositories/header_sync_receipt_repository_test.go index 2f6bc9108..f88abdc0f 100644 --- a/pkg/datastore/postgres/repositories/header_sync_receipt_repository_test.go +++ b/pkg/datastore/postgres/repositories/header_sync_receipt_repository_test.go @@ -18,26 +18,28 @@ package repositories_test import ( "encoding/json" + "math/big" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" + "github.com/vulcanize/vulcanizedb/pkg/core" "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres" "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres/repositories" "github.com/vulcanize/vulcanizedb/test_config" - "math/big" ) var _ = Describe("Header Sync Receipt Repo", func() { var ( - rawHeader []byte - err error - timestamp string - db *postgres.DB + rawHeader []byte + err error + timestamp string + db *postgres.DB receiptRepo repositories.HeaderSyncReceiptRepository - headerRepo repositories.HeaderRepository - header core.Header + headerRepo repositories.HeaderRepository + header core.Header ) BeforeEach(func() { diff --git a/pkg/datastore/postgres/repositories/watched_events_repository_test.go b/pkg/datastore/postgres/repositories/watched_events_repository_test.go index 6e170e899..23ff8af6d 100644 --- a/pkg/datastore/postgres/repositories/watched_events_repository_test.go +++ b/pkg/datastore/postgres/repositories/watched_events_repository_test.go @@ -19,6 +19,7 @@ package repositories_test import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" + "github.com/vulcanize/vulcanizedb/pkg/core" "github.com/vulcanize/vulcanizedb/pkg/datastore" "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres" @@ -79,7 +80,8 @@ var _ = Describe("Watched Events Repository", func() { Expect(err).ToNot(HaveOccurred()) blockId, err := blocksRepository.CreateOrUpdateBlock(core.Block{}) Expect(err).NotTo(HaveOccurred()) - tx, _ := db.Beginx() + tx, txBeginErr := db.Beginx() + Expect(txBeginErr).NotTo(HaveOccurred()) receiptId, err := receiptRepository.CreateFullSyncReceiptInTx(blockId, core.Receipt{}, tx) tx.Commit() Expect(err).NotTo(HaveOccurred())