Address PR feedback

This commit is contained in:
Elizabeth Engelman 2019-08-19 16:51:17 -05:00
parent 58c23c6632
commit 1b3786338f
5 changed files with 18 additions and 14 deletions

View File

@ -14,7 +14,6 @@
// You should have received a copy of the GNU Affero General Public License // You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
package cmd package cmd
import ( import (

View File

@ -18,8 +18,10 @@ package repositories
import ( import (
"database/sql" "database/sql"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/jmoiron/sqlx" "github.com/jmoiron/sqlx"
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres" "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) { func (AddressRepository) GetAddressById(db *postgres.DB, id int) (string, error) {
var address string var address string
getErr := db.Get(&address, `SELECT address FROM public.addresses WHERE id = $1`, id) getErr := db.Get(&address, `SELECT address FROM public.addresses WHERE id = $1`, id)
if getErr != nil { return address, getErr
return "", getErr
}
return address, nil
} }

View File

@ -17,14 +17,16 @@
package repositories_test package repositories_test
import ( import (
"strings"
"github.com/jmoiron/sqlx" "github.com/jmoiron/sqlx"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres" "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres/repositories" "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres/repositories"
"github.com/vulcanize/vulcanizedb/pkg/fakes" "github.com/vulcanize/vulcanizedb/pkg/fakes"
"github.com/vulcanize/vulcanizedb/test_config" "github.com/vulcanize/vulcanizedb/test_config"
"strings"
) )
var _ = Describe("address lookup", func() { var _ = Describe("address lookup", func() {

View File

@ -18,26 +18,28 @@ package repositories_test
import ( import (
"encoding/json" "encoding/json"
"math/big"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/types"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
"github.com/vulcanize/vulcanizedb/pkg/core" "github.com/vulcanize/vulcanizedb/pkg/core"
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres" "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres/repositories" "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres/repositories"
"github.com/vulcanize/vulcanizedb/test_config" "github.com/vulcanize/vulcanizedb/test_config"
"math/big"
) )
var _ = Describe("Header Sync Receipt Repo", func() { var _ = Describe("Header Sync Receipt Repo", func() {
var ( var (
rawHeader []byte rawHeader []byte
err error err error
timestamp string timestamp string
db *postgres.DB db *postgres.DB
receiptRepo repositories.HeaderSyncReceiptRepository receiptRepo repositories.HeaderSyncReceiptRepository
headerRepo repositories.HeaderRepository headerRepo repositories.HeaderRepository
header core.Header header core.Header
) )
BeforeEach(func() { BeforeEach(func() {

View File

@ -19,6 +19,7 @@ package repositories_test
import ( import (
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
"github.com/vulcanize/vulcanizedb/pkg/core" "github.com/vulcanize/vulcanizedb/pkg/core"
"github.com/vulcanize/vulcanizedb/pkg/datastore" "github.com/vulcanize/vulcanizedb/pkg/datastore"
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres" "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
@ -79,7 +80,8 @@ var _ = Describe("Watched Events Repository", func() {
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
blockId, err := blocksRepository.CreateOrUpdateBlock(core.Block{}) blockId, err := blocksRepository.CreateOrUpdateBlock(core.Block{})
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
tx, _ := db.Beginx() tx, txBeginErr := db.Beginx()
Expect(txBeginErr).NotTo(HaveOccurred())
receiptId, err := receiptRepository.CreateFullSyncReceiptInTx(blockId, core.Receipt{}, tx) receiptId, err := receiptRepository.CreateFullSyncReceiptInTx(blockId, core.Receipt{}, tx)
tx.Commit() tx.Commit()
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())