forked from cerc-io/ipld-eth-server
Add timestamp to block header
- Enables quickly deriving timestamp from header for log events
This commit is contained in:
parent
5f67161f41
commit
d3df685c46
@ -3,6 +3,7 @@ CREATE TABLE public.headers (
|
||||
hash VARCHAR(66),
|
||||
block_number BIGINT,
|
||||
raw JSONB,
|
||||
block_timestamp NUMERIC,
|
||||
eth_node_id INTEGER,
|
||||
eth_node_fingerprint VARCHAR(128),
|
||||
CONSTRAINT eth_nodes_fk FOREIGN KEY (eth_node_id)
|
||||
|
@ -1098,6 +1098,7 @@ CREATE TABLE public.headers (
|
||||
hash character varying(66),
|
||||
block_number bigint,
|
||||
raw jsonb,
|
||||
block_timestamp numeric,
|
||||
eth_node_id integer,
|
||||
eth_node_fingerprint character varying(128)
|
||||
);
|
||||
|
@ -11,6 +11,7 @@ type Header struct {
|
||||
BlockNumber int64 `db:"block_number"`
|
||||
Hash string
|
||||
Raw []byte
|
||||
Timestamp string `db:"block_timestamp"`
|
||||
}
|
||||
|
||||
type POAHeader struct {
|
||||
|
@ -69,8 +69,8 @@ func (repository HeaderRepository) getHeaderHash(header core.Header) (string, er
|
||||
func (repository HeaderRepository) insertHeader(header core.Header) (int64, error) {
|
||||
var headerId int64
|
||||
err := repository.database.QueryRowx(
|
||||
`INSERT INTO public.headers (block_number, hash, raw, eth_node_id, eth_node_fingerprint) VALUES ($1, $2, $3, $4, $5) RETURNING id`,
|
||||
header.BlockNumber, header.Hash, header.Raw, repository.database.NodeID, repository.database.Node.ID).Scan(&headerId)
|
||||
`INSERT INTO public.headers (block_number, hash, block_timestamp, raw, eth_node_id, eth_node_fingerprint) VALUES ($1, $2, $3::NUMERIC, $4, $5, $6) RETURNING id`,
|
||||
header.BlockNumber, header.Hash, header.Timestamp, header.Raw, repository.database.NodeID, repository.database.Node.ID).Scan(&headerId)
|
||||
return headerId, err
|
||||
}
|
||||
|
||||
|
@ -11,15 +11,20 @@ import (
|
||||
"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("Block header repository", func() {
|
||||
var rawHeader []byte
|
||||
var err error
|
||||
var (
|
||||
rawHeader []byte
|
||||
err error
|
||||
timestamp string
|
||||
)
|
||||
|
||||
BeforeEach(func() {
|
||||
rawHeader, err = json.Marshal(types.Header{})
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
timestamp = big.NewInt(123456789).String()
|
||||
})
|
||||
|
||||
Describe("creating or updating a header", func() {
|
||||
@ -32,17 +37,19 @@ var _ = Describe("Block header repository", func() {
|
||||
BlockNumber: 100,
|
||||
Hash: common.BytesToHash([]byte{1, 2, 3, 4, 5}).Hex(),
|
||||
Raw: rawHeader,
|
||||
Timestamp: timestamp,
|
||||
}
|
||||
|
||||
_, err := repo.CreateOrUpdateHeader(header)
|
||||
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
var dbHeader core.Header
|
||||
err = db.Get(&dbHeader, `SELECT block_number, hash, raw FROM public.headers WHERE block_number = $1`, header.BlockNumber)
|
||||
err = db.Get(&dbHeader, `SELECT block_number, hash, raw, block_timestamp FROM public.headers WHERE block_number = $1`, header.BlockNumber)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(dbHeader.BlockNumber).To(Equal(header.BlockNumber))
|
||||
Expect(dbHeader.Hash).To(Equal(header.Hash))
|
||||
Expect(dbHeader.Raw).To(MatchJSON(header.Raw))
|
||||
Expect(dbHeader.Timestamp).To(Equal(header.Timestamp))
|
||||
})
|
||||
|
||||
It("adds node data to header", func() {
|
||||
@ -53,6 +60,7 @@ var _ = Describe("Block header repository", func() {
|
||||
header := core.Header{
|
||||
BlockNumber: 100,
|
||||
Raw: rawHeader,
|
||||
Timestamp: timestamp,
|
||||
}
|
||||
|
||||
_, err := repo.CreateOrUpdateHeader(header)
|
||||
@ -77,6 +85,7 @@ var _ = Describe("Block header repository", func() {
|
||||
BlockNumber: 100,
|
||||
Hash: common.BytesToHash([]byte{1, 2, 3, 4, 5}).Hex(),
|
||||
Raw: rawHeader,
|
||||
Timestamp: timestamp,
|
||||
}
|
||||
|
||||
_, err := repo.CreateOrUpdateHeader(header)
|
||||
@ -101,6 +110,7 @@ var _ = Describe("Block header repository", func() {
|
||||
BlockNumber: 100,
|
||||
Hash: common.BytesToHash([]byte{1, 2, 3, 4, 5}).Hex(),
|
||||
Raw: rawHeader,
|
||||
Timestamp: timestamp,
|
||||
}
|
||||
_, err := repo.CreateOrUpdateHeader(header)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
@ -108,6 +118,7 @@ var _ = Describe("Block header repository", func() {
|
||||
BlockNumber: header.BlockNumber,
|
||||
Hash: common.BytesToHash([]byte{5, 4, 3, 2, 1}).Hex(),
|
||||
Raw: rawHeader,
|
||||
Timestamp: timestamp,
|
||||
}
|
||||
|
||||
_, err = repo.CreateOrUpdateHeader(headerTwo)
|
||||
@ -129,6 +140,7 @@ var _ = Describe("Block header repository", func() {
|
||||
BlockNumber: 100,
|
||||
Hash: common.BytesToHash([]byte{1, 2, 3, 4, 5}).Hex(),
|
||||
Raw: rawHeader,
|
||||
Timestamp: timestamp,
|
||||
}
|
||||
_, err := repo.CreateOrUpdateHeader(header)
|
||||
nodeTwo := core.Node{ID: "FingerprintTwo"}
|
||||
@ -139,6 +151,7 @@ var _ = Describe("Block header repository", func() {
|
||||
BlockNumber: header.BlockNumber,
|
||||
Hash: common.BytesToHash([]byte{5, 4, 3, 2, 1}).Hex(),
|
||||
Raw: rawHeader,
|
||||
Timestamp: timestamp,
|
||||
}
|
||||
|
||||
_, err = repoTwo.CreateOrUpdateHeader(headerTwo)
|
||||
@ -158,6 +171,7 @@ var _ = Describe("Block header repository", func() {
|
||||
BlockNumber: 100,
|
||||
Hash: common.BytesToHash([]byte{1, 2, 3, 4, 5}).Hex(),
|
||||
Raw: rawHeader,
|
||||
Timestamp: timestamp,
|
||||
}
|
||||
_, err := repo.CreateOrUpdateHeader(header)
|
||||
nodeTwo := core.Node{ID: "FingerprintTwo"}
|
||||
@ -168,12 +182,14 @@ var _ = Describe("Block header repository", func() {
|
||||
BlockNumber: header.BlockNumber,
|
||||
Hash: common.BytesToHash([]byte{5, 4, 3, 2, 1}).Hex(),
|
||||
Raw: rawHeader,
|
||||
Timestamp: timestamp,
|
||||
}
|
||||
_, err = repoTwo.CreateOrUpdateHeader(headerTwo)
|
||||
headerThree := core.Header{
|
||||
BlockNumber: header.BlockNumber,
|
||||
Hash: common.BytesToHash([]byte{1, 1, 1, 1, 1}).Hex(),
|
||||
Raw: rawHeader,
|
||||
Timestamp: timestamp,
|
||||
}
|
||||
|
||||
_, err = repoTwo.CreateOrUpdateHeader(headerThree)
|
||||
@ -200,6 +216,7 @@ var _ = Describe("Block header repository", func() {
|
||||
BlockNumber: 100,
|
||||
Hash: common.BytesToHash([]byte{1, 2, 3, 4, 5}).Hex(),
|
||||
Raw: rawHeader,
|
||||
Timestamp: timestamp,
|
||||
}
|
||||
_, err := repo.CreateOrUpdateHeader(header)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
@ -221,6 +238,7 @@ var _ = Describe("Block header repository", func() {
|
||||
BlockNumber: 100,
|
||||
Hash: common.BytesToHash(rawHeader).Hex(),
|
||||
Raw: rawHeader,
|
||||
Timestamp: timestamp,
|
||||
}
|
||||
_, err := repo.CreateOrUpdateHeader(header)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
@ -245,14 +263,17 @@ var _ = Describe("Block header repository", func() {
|
||||
repo.CreateOrUpdateHeader(core.Header{
|
||||
BlockNumber: 1,
|
||||
Raw: rawHeader,
|
||||
Timestamp: timestamp,
|
||||
})
|
||||
repo.CreateOrUpdateHeader(core.Header{
|
||||
BlockNumber: 3,
|
||||
Raw: rawHeader,
|
||||
Timestamp: timestamp,
|
||||
})
|
||||
repo.CreateOrUpdateHeader(core.Header{
|
||||
BlockNumber: 5,
|
||||
Raw: rawHeader,
|
||||
Timestamp: timestamp,
|
||||
})
|
||||
|
||||
missingBlockNumbers := repo.MissingBlockNumbers(1, 5, node.ID)
|
||||
@ -268,14 +289,17 @@ var _ = Describe("Block header repository", func() {
|
||||
repo.CreateOrUpdateHeader(core.Header{
|
||||
BlockNumber: 1,
|
||||
Raw: rawHeader,
|
||||
Timestamp: timestamp,
|
||||
})
|
||||
repo.CreateOrUpdateHeader(core.Header{
|
||||
BlockNumber: 3,
|
||||
Raw: rawHeader,
|
||||
Timestamp: timestamp,
|
||||
})
|
||||
repo.CreateOrUpdateHeader(core.Header{
|
||||
BlockNumber: 5,
|
||||
Raw: rawHeader,
|
||||
Timestamp: timestamp,
|
||||
})
|
||||
nodeTwo := core.Node{ID: "NodeFingerprintTwo"}
|
||||
dbTwo, err := postgres.NewDB(test_config.DBConfig, nodeTwo)
|
||||
|
@ -1,5 +1,24 @@
|
||||
package fakes
|
||||
|
||||
import "errors"
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/core"
|
||||
)
|
||||
|
||||
var FakeError = errors.New("failed")
|
||||
|
||||
var rawFakeHeader, _ = json.Marshal(types.Header{})
|
||||
var FakeHeader = core.Header{
|
||||
Raw: rawFakeHeader,
|
||||
Timestamp: "111111111",
|
||||
}
|
||||
|
||||
func GetFakeHeader(blockNumber int64) core.Header {
|
||||
return core.Header{
|
||||
BlockNumber: blockNumber,
|
||||
Raw: rawFakeHeader,
|
||||
Timestamp: "111111111",
|
||||
}
|
||||
}
|
||||
|
@ -1,24 +1,23 @@
|
||||
package common
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/ethereum/go-ethereum/rlp"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/core"
|
||||
)
|
||||
|
||||
type HeaderConverter struct{}
|
||||
|
||||
func (converter HeaderConverter) Convert(gethHeader *types.Header) (core.Header, error) {
|
||||
writer := new(bytes.Buffer)
|
||||
err := rlp.Encode(writer, &gethHeader)
|
||||
rawHeader, err := json.Marshal(gethHeader)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
coreHeader := core.Header{
|
||||
Hash: gethHeader.Hash().Hex(),
|
||||
BlockNumber: gethHeader.Number.Int64(),
|
||||
Raw: writer.Bytes(),
|
||||
Raw: rawHeader,
|
||||
Timestamp: gethHeader.Time.String(),
|
||||
}
|
||||
return coreHeader, nil
|
||||
}
|
||||
|
@ -1,14 +1,15 @@
|
||||
package common_test
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"math/big"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/ethereum/go-ethereum/rlp"
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
common2 "github.com/vulcanize/vulcanizedb/pkg/geth/converters/common"
|
||||
"math/big"
|
||||
)
|
||||
|
||||
var _ = Describe("Block header converter", func() {
|
||||
@ -19,7 +20,7 @@ var _ = Describe("Block header converter", func() {
|
||||
ParentHash: common.HexToHash("0xParent"),
|
||||
ReceiptHash: common.HexToHash("0xReceipt"),
|
||||
Root: common.HexToHash("0xRoot"),
|
||||
Time: big.NewInt(3),
|
||||
Time: big.NewInt(123456789),
|
||||
TxHash: common.HexToHash("0xTransaction"),
|
||||
UncleHash: common.HexToHash("0xUncle"),
|
||||
}
|
||||
@ -30,18 +31,18 @@ var _ = Describe("Block header converter", func() {
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(coreHeader.BlockNumber).To(Equal(gethHeader.Number.Int64()))
|
||||
Expect(coreHeader.Hash).To(Equal(gethHeader.Hash().Hex()))
|
||||
Expect(coreHeader.Timestamp).To(Equal(gethHeader.Time.String()))
|
||||
})
|
||||
|
||||
It("includes raw bytes for header", func() {
|
||||
headerRLP := []byte{249, 2, 23, 160, 180, 251, 173, 248, 234, 69, 43, 19, 151, 24, 226, 112, 13, 193, 19, 92, 252, 129, 20, 80, 49, 200, 75, 122, 178, 124, 215, 16, 57, 79, 123, 56, 160, 29, 204, 77, 232, 222, 199, 93, 122, 171, 133, 181, 103, 182, 204, 212, 26, 211, 18, 69, 27, 148, 138, 116, 19, 240, 161, 66, 253, 64, 212, 147, 71, 148, 42, 101, 172, 164, 213, 252, 91, 92, 133, 144, 144, 166, 195, 77, 22, 65, 53, 57, 130, 38, 160, 14, 6, 111, 60, 34, 151, 165, 203, 48, 5, 147, 5, 38, 23, 209, 188, 165, 148, 111, 12, 170, 6, 53, 253, 177, 184, 90, 199, 229, 35, 111, 52, 160, 101, 186, 136, 127, 203, 8, 38, 246, 22, 208, 31, 115, 108, 29, 45, 103, 123, 202, 189, 226, 247, 252, 37, 170, 145, 207, 188, 11, 59, 173, 92, 179, 160, 32, 227, 83, 69, 64, 202, 241, 99, 120, 230, 232, 106, 43, 241, 35, 109, 159, 135, 109, 50, 24, 251, 192, 57, 88, 230, 219, 28, 99, 75, 35, 51, 185, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 134, 11, 105, 222, 129, 162, 43, 131, 15, 66, 64, 131, 47, 239, 216, 130, 196, 68, 132, 86, 191, 180, 21, 152, 215, 131, 1, 3, 3, 132, 71, 101, 116, 104, 135, 103, 111, 49, 46, 53, 46, 49, 133, 108, 105, 110, 117, 120, 160, 146, 196, 18, 154, 10, 226, 54, 27, 69, 42, 158, 222, 236, 229, 92, 18, 236, 238, 171, 134, 99, 22, 25, 94, 61, 135, 252, 27, 0, 91, 102, 69, 136, 205, 76, 85, 185, 65, 207, 144, 21}
|
||||
var gethHeader types.Header
|
||||
err := rlp.Decode(bytes.NewReader(headerRLP), &gethHeader)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
It("includes raw bytes for header as JSON", func() {
|
||||
gethHeader := types.Header{Number: big.NewInt(123)}
|
||||
converter := common2.HeaderConverter{}
|
||||
|
||||
coreHeader, err := converter.Convert(&gethHeader)
|
||||
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(coreHeader.Raw).To(Equal(headerRLP))
|
||||
expectedJSON, err := json.Marshal(gethHeader)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(coreHeader.Raw).To(Equal(expectedJSON))
|
||||
})
|
||||
})
|
||||
|
@ -16,9 +16,7 @@ package bite_test
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
@ -26,6 +24,7 @@ import (
|
||||
"github.com/vulcanize/vulcanizedb/pkg/datastore"
|
||||
"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/pkg/transformers/bite"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
|
||||
"github.com/vulcanize/vulcanizedb/test_config"
|
||||
@ -37,15 +36,12 @@ var _ = Describe("Bite repository", func() {
|
||||
db *postgres.DB
|
||||
err error
|
||||
headerRepository datastore.HeaderRepository
|
||||
rawHeader []byte
|
||||
)
|
||||
|
||||
BeforeEach(func() {
|
||||
db = test_config.NewTestDB(test_config.NewTestNode())
|
||||
test_config.CleanTestDB(db)
|
||||
headerRepository = repositories.NewHeaderRepository(db)
|
||||
rawHeader, err = json.Marshal(types.Header{})
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
biteRepository = bite.NewBiteRepository(db)
|
||||
})
|
||||
|
||||
@ -53,7 +49,7 @@ var _ = Describe("Bite repository", func() {
|
||||
var headerID int64
|
||||
|
||||
BeforeEach(func() {
|
||||
headerID, err = headerRepository.CreateOrUpdateHeader(core.Header{Raw: rawHeader})
|
||||
headerID, err = headerRepository.CreateOrUpdateHeader(fakes.FakeHeader)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
err = biteRepository.Create(headerID, []bite.BiteModel{test_data.BiteModel})
|
||||
@ -116,7 +112,7 @@ var _ = Describe("Bite repository", func() {
|
||||
var headerID int64
|
||||
|
||||
BeforeEach(func() {
|
||||
headerID, err = headerRepository.CreateOrUpdateHeader(core.Header{Raw: rawHeader})
|
||||
headerID, err = headerRepository.CreateOrUpdateHeader(fakes.FakeHeader)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
})
|
||||
|
||||
@ -158,7 +154,7 @@ var _ = Describe("Bite repository", func() {
|
||||
|
||||
headerIDs = []int64{}
|
||||
for _, n := range blockNumbers {
|
||||
headerID, err := headerRepository.CreateOrUpdateHeader(core.Header{BlockNumber: n, Raw: rawHeader})
|
||||
headerID, err := headerRepository.CreateOrUpdateHeader(fakes.GetFakeHeader(n))
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
headerIDs = append(headerIDs, headerID)
|
||||
}
|
||||
@ -195,7 +191,7 @@ var _ = Describe("Bite repository", func() {
|
||||
dbTwo := test_config.NewTestDB(core.Node{ID: "second"})
|
||||
headerRepositoryTwo := repositories.NewHeaderRepository(dbTwo)
|
||||
for _, n := range blockNumbers {
|
||||
_, err = headerRepositoryTwo.CreateOrUpdateHeader(core.Header{BlockNumber: n, Raw: rawHeader})
|
||||
_, err = headerRepositoryTwo.CreateOrUpdateHeader(fakes.GetFakeHeader(n))
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
}
|
||||
biteRepositoryTwo := bite.NewBiteRepository(dbTwo)
|
||||
|
@ -16,9 +16,7 @@ package chop_lump_test
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
@ -26,6 +24,7 @@ import (
|
||||
"github.com/vulcanize/vulcanizedb/pkg/datastore"
|
||||
"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/pkg/transformers/cat_file/chop_lump"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
|
||||
"github.com/vulcanize/vulcanizedb/test_config"
|
||||
@ -37,15 +36,12 @@ var _ = Describe("Cat file chop lump repository", func() {
|
||||
db *postgres.DB
|
||||
err error
|
||||
headerRepository datastore.HeaderRepository
|
||||
rawHeader []byte
|
||||
)
|
||||
|
||||
BeforeEach(func() {
|
||||
db = test_config.NewTestDB(test_config.NewTestNode())
|
||||
test_config.CleanTestDB(db)
|
||||
headerRepository = repositories.NewHeaderRepository(db)
|
||||
rawHeader, err = json.Marshal(types.Header{})
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
catFileRepository = chop_lump.NewCatFileChopLumpRepository(db)
|
||||
})
|
||||
|
||||
@ -53,7 +49,7 @@ var _ = Describe("Cat file chop lump repository", func() {
|
||||
var headerID int64
|
||||
|
||||
BeforeEach(func() {
|
||||
headerID, err = headerRepository.CreateOrUpdateHeader(core.Header{Raw: rawHeader})
|
||||
headerID, err = headerRepository.CreateOrUpdateHeader(fakes.FakeHeader)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
err = catFileRepository.Create(headerID, []chop_lump.CatFileChopLumpModel{test_data.CatFileChopLumpModel})
|
||||
@ -100,7 +96,7 @@ var _ = Describe("Cat file chop lump repository", func() {
|
||||
var headerID int64
|
||||
|
||||
BeforeEach(func() {
|
||||
headerID, err = headerRepository.CreateOrUpdateHeader(core.Header{Raw: rawHeader})
|
||||
headerID, err = headerRepository.CreateOrUpdateHeader(fakes.FakeHeader)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
})
|
||||
|
||||
@ -142,7 +138,7 @@ var _ = Describe("Cat file chop lump repository", func() {
|
||||
|
||||
headerIDs = []int64{}
|
||||
for _, n := range blockNumbers {
|
||||
headerID, err := headerRepository.CreateOrUpdateHeader(core.Header{BlockNumber: n, Raw: rawHeader})
|
||||
headerID, err := headerRepository.CreateOrUpdateHeader(fakes.GetFakeHeader(n))
|
||||
headerIDs = append(headerIDs, headerID)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
}
|
||||
@ -179,7 +175,7 @@ var _ = Describe("Cat file chop lump repository", func() {
|
||||
dbTwo := test_config.NewTestDB(core.Node{ID: "second"})
|
||||
headerRepositoryTwo := repositories.NewHeaderRepository(dbTwo)
|
||||
for _, n := range blockNumbers {
|
||||
_, err = headerRepositoryTwo.CreateOrUpdateHeader(core.Header{BlockNumber: n, Raw: rawHeader})
|
||||
_, err = headerRepositoryTwo.CreateOrUpdateHeader(fakes.GetFakeHeader(n))
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
}
|
||||
catFileRepositoryTwo := chop_lump.NewCatFileChopLumpRepository(dbTwo)
|
||||
|
@ -16,9 +16,7 @@ package flip_test
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
@ -26,6 +24,7 @@ import (
|
||||
"github.com/vulcanize/vulcanizedb/pkg/datastore"
|
||||
"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/pkg/transformers/cat_file/flip"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
|
||||
"github.com/vulcanize/vulcanizedb/test_config"
|
||||
@ -37,15 +36,12 @@ var _ = Describe("Cat file flip repository", func() {
|
||||
db *postgres.DB
|
||||
err error
|
||||
headerRepository datastore.HeaderRepository
|
||||
rawHeader []byte
|
||||
)
|
||||
|
||||
BeforeEach(func() {
|
||||
db = test_config.NewTestDB(test_config.NewTestNode())
|
||||
test_config.CleanTestDB(db)
|
||||
headerRepository = repositories.NewHeaderRepository(db)
|
||||
rawHeader, err = json.Marshal(types.Header{})
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
catFileRepository = flip.NewCatFileFlipRepository(db)
|
||||
})
|
||||
|
||||
@ -53,7 +49,7 @@ var _ = Describe("Cat file flip repository", func() {
|
||||
var headerID int64
|
||||
|
||||
BeforeEach(func() {
|
||||
headerID, err = headerRepository.CreateOrUpdateHeader(core.Header{Raw: rawHeader})
|
||||
headerID, err = headerRepository.CreateOrUpdateHeader(fakes.FakeHeader)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
err = catFileRepository.Create(headerID, []flip.CatFileFlipModel{test_data.CatFileFlipModel})
|
||||
@ -100,7 +96,7 @@ var _ = Describe("Cat file flip repository", func() {
|
||||
var headerID int64
|
||||
|
||||
BeforeEach(func() {
|
||||
headerID, err = headerRepository.CreateOrUpdateHeader(core.Header{Raw: rawHeader})
|
||||
headerID, err = headerRepository.CreateOrUpdateHeader(fakes.FakeHeader)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
})
|
||||
|
||||
@ -142,7 +138,7 @@ var _ = Describe("Cat file flip repository", func() {
|
||||
|
||||
headerIDs = []int64{}
|
||||
for _, n := range blockNumbers {
|
||||
headerID, err := headerRepository.CreateOrUpdateHeader(core.Header{BlockNumber: n, Raw: rawHeader})
|
||||
headerID, err := headerRepository.CreateOrUpdateHeader(fakes.GetFakeHeader(n))
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
headerIDs = append(headerIDs, headerID)
|
||||
}
|
||||
@ -179,7 +175,7 @@ var _ = Describe("Cat file flip repository", func() {
|
||||
dbTwo := test_config.NewTestDB(core.Node{ID: "second"})
|
||||
headerRepositoryTwo := repositories.NewHeaderRepository(dbTwo)
|
||||
for _, n := range blockNumbers {
|
||||
_, err = headerRepositoryTwo.CreateOrUpdateHeader(core.Header{BlockNumber: n, Raw: rawHeader})
|
||||
_, err = headerRepositoryTwo.CreateOrUpdateHeader(fakes.GetFakeHeader(n))
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
}
|
||||
catFileRepositoryTwo := flip.NewCatFileFlipRepository(dbTwo)
|
||||
|
@ -16,9 +16,7 @@ package pit_vow_test
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
@ -26,6 +24,7 @@ import (
|
||||
"github.com/vulcanize/vulcanizedb/pkg/datastore"
|
||||
"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/pkg/transformers/cat_file/pit_vow"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
|
||||
"github.com/vulcanize/vulcanizedb/test_config"
|
||||
@ -37,15 +36,12 @@ var _ = Describe("Cat file pit vow repository", func() {
|
||||
db *postgres.DB
|
||||
err error
|
||||
headerRepository datastore.HeaderRepository
|
||||
rawHeader []byte
|
||||
)
|
||||
|
||||
BeforeEach(func() {
|
||||
db = test_config.NewTestDB(test_config.NewTestNode())
|
||||
test_config.CleanTestDB(db)
|
||||
headerRepository = repositories.NewHeaderRepository(db)
|
||||
rawHeader, err = json.Marshal(types.Header{})
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
catFileRepository = pit_vow.NewCatFilePitVowRepository(db)
|
||||
})
|
||||
|
||||
@ -53,7 +49,7 @@ var _ = Describe("Cat file pit vow repository", func() {
|
||||
var headerID int64
|
||||
|
||||
BeforeEach(func() {
|
||||
headerID, err = headerRepository.CreateOrUpdateHeader(core.Header{Raw: rawHeader})
|
||||
headerID, err = headerRepository.CreateOrUpdateHeader(fakes.FakeHeader)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
err = catFileRepository.Create(headerID, []pit_vow.CatFilePitVowModel{test_data.CatFilePitVowModel})
|
||||
@ -99,7 +95,7 @@ var _ = Describe("Cat file pit vow repository", func() {
|
||||
var headerID int64
|
||||
|
||||
BeforeEach(func() {
|
||||
headerID, err = headerRepository.CreateOrUpdateHeader(core.Header{Raw: rawHeader})
|
||||
headerID, err = headerRepository.CreateOrUpdateHeader(fakes.FakeHeader)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
})
|
||||
|
||||
@ -141,7 +137,7 @@ var _ = Describe("Cat file pit vow repository", func() {
|
||||
|
||||
headerIDs = []int64{}
|
||||
for _, n := range blockNumbers {
|
||||
headerID, err := headerRepository.CreateOrUpdateHeader(core.Header{BlockNumber: n, Raw: rawHeader})
|
||||
headerID, err := headerRepository.CreateOrUpdateHeader(fakes.GetFakeHeader(n))
|
||||
headerIDs = append(headerIDs, headerID)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
}
|
||||
@ -178,7 +174,7 @@ var _ = Describe("Cat file pit vow repository", func() {
|
||||
dbTwo := test_config.NewTestDB(core.Node{ID: "second"})
|
||||
headerRepositoryTwo := repositories.NewHeaderRepository(dbTwo)
|
||||
for _, n := range blockNumbers {
|
||||
_, err = headerRepositoryTwo.CreateOrUpdateHeader(core.Header{BlockNumber: n, Raw: rawHeader})
|
||||
_, err = headerRepositoryTwo.CreateOrUpdateHeader(fakes.GetFakeHeader(n))
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
}
|
||||
catFileRepositoryTwo := pit_vow.NewCatFilePitVowRepository(dbTwo)
|
||||
|
@ -15,15 +15,13 @@
|
||||
package deal_test
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"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/pkg/fakes"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/deal"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
|
||||
"github.com/vulcanize/vulcanizedb/test_config"
|
||||
@ -35,7 +33,6 @@ var _ = Describe("Deal Repository", func() {
|
||||
dealRepository deal.DealRepository
|
||||
headerRepository repositories.HeaderRepository
|
||||
err error
|
||||
rawHeader []byte
|
||||
)
|
||||
|
||||
BeforeEach(func() {
|
||||
@ -43,15 +40,13 @@ var _ = Describe("Deal Repository", func() {
|
||||
test_config.CleanTestDB(db)
|
||||
dealRepository = deal.NewDealRepository(db)
|
||||
headerRepository = repositories.NewHeaderRepository(db)
|
||||
rawHeader, err = json.Marshal(types.Header{})
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
})
|
||||
|
||||
Describe("Create", func() {
|
||||
var headerId int64
|
||||
|
||||
BeforeEach(func() {
|
||||
headerId, err = headerRepository.CreateOrUpdateHeader(core.Header{Raw: rawHeader})
|
||||
headerId, err = headerRepository.CreateOrUpdateHeader(fakes.FakeHeader)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
err := dealRepository.Create(headerId, []deal.DealModel{test_data.DealModel})
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
@ -100,7 +95,7 @@ var _ = Describe("Deal Repository", func() {
|
||||
var headerId int64
|
||||
|
||||
BeforeEach(func() {
|
||||
headerId, err = headerRepository.CreateOrUpdateHeader(core.Header{Raw: rawHeader})
|
||||
headerId, err = headerRepository.CreateOrUpdateHeader(fakes.FakeHeader)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
})
|
||||
|
||||
@ -143,7 +138,7 @@ var _ = Describe("Deal Repository", func() {
|
||||
|
||||
headerIds = []int64{}
|
||||
for _, number := range blockNumbers {
|
||||
headerId, err := headerRepository.CreateOrUpdateHeader(core.Header{BlockNumber: number, Raw: rawHeader})
|
||||
headerId, err := headerRepository.CreateOrUpdateHeader(fakes.GetFakeHeader(number))
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
headerIds = append(headerIds, headerId)
|
||||
}
|
||||
@ -183,7 +178,7 @@ var _ = Describe("Deal Repository", func() {
|
||||
headerRepository2 := repositories.NewHeaderRepository(db2)
|
||||
var node2HeaderIds []int64
|
||||
for _, number := range blockNumbers {
|
||||
id, err := headerRepository2.CreateOrUpdateHeader(core.Header{BlockNumber: number, Raw: rawHeader})
|
||||
id, err := headerRepository2.CreateOrUpdateHeader(fakes.GetFakeHeader(number))
|
||||
node2HeaderIds = append(node2HeaderIds, id)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
}
|
||||
|
@ -15,15 +15,13 @@
|
||||
package dent_test
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"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/pkg/fakes"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/dent"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
|
||||
"github.com/vulcanize/vulcanizedb/test_config"
|
||||
@ -35,7 +33,6 @@ var _ = Describe("Dent Repository", func() {
|
||||
dentRepository dent.DentRepository
|
||||
headerRepository repositories.HeaderRepository
|
||||
err error
|
||||
rawHeader []byte
|
||||
)
|
||||
|
||||
BeforeEach(func() {
|
||||
@ -43,15 +40,13 @@ var _ = Describe("Dent Repository", func() {
|
||||
test_config.CleanTestDB(db)
|
||||
dentRepository = dent.NewDentRepository(db)
|
||||
headerRepository = repositories.NewHeaderRepository(db)
|
||||
rawHeader, err = json.Marshal(types.Header{})
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
})
|
||||
|
||||
Describe("Create", func() {
|
||||
var headerId int64
|
||||
|
||||
BeforeEach(func() {
|
||||
headerId, err = headerRepository.CreateOrUpdateHeader(core.Header{Raw: rawHeader})
|
||||
headerId, err = headerRepository.CreateOrUpdateHeader(fakes.FakeHeader)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
err := dentRepository.Create(headerId, []dent.DentModel{test_data.DentModel})
|
||||
@ -107,7 +102,7 @@ var _ = Describe("Dent Repository", func() {
|
||||
var headerId int64
|
||||
|
||||
BeforeEach(func() {
|
||||
headerId, err = headerRepository.CreateOrUpdateHeader(core.Header{Raw: rawHeader})
|
||||
headerId, err = headerRepository.CreateOrUpdateHeader(fakes.FakeHeader)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
})
|
||||
|
||||
@ -151,7 +146,7 @@ var _ = Describe("Dent Repository", func() {
|
||||
|
||||
headerIds = []int64{}
|
||||
for _, number := range blockNumbers {
|
||||
headerId, err := headerRepository.CreateOrUpdateHeader(core.Header{BlockNumber: number, Raw: rawHeader})
|
||||
headerId, err := headerRepository.CreateOrUpdateHeader(fakes.GetFakeHeader(number))
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
headerIds = append(headerIds, headerId)
|
||||
}
|
||||
@ -188,7 +183,7 @@ var _ = Describe("Dent Repository", func() {
|
||||
headerRepository2 := repositories.NewHeaderRepository(db2)
|
||||
var node2HeaderIds []int64
|
||||
for _, number := range blockNumbers {
|
||||
id, err := headerRepository2.CreateOrUpdateHeader(core.Header{BlockNumber: number, Raw: rawHeader})
|
||||
id, err := headerRepository2.CreateOrUpdateHeader(fakes.GetFakeHeader(number))
|
||||
node2HeaderIds = append(node2HeaderIds, id)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
}
|
||||
|
@ -16,9 +16,7 @@ package drip_drip_test
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
@ -26,6 +24,7 @@ import (
|
||||
"github.com/vulcanize/vulcanizedb/pkg/datastore"
|
||||
"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/pkg/transformers/drip_drip"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
|
||||
"github.com/vulcanize/vulcanizedb/test_config"
|
||||
@ -37,7 +36,6 @@ var _ = Describe("Drip drip repository", func() {
|
||||
dripDripRepository drip_drip.Repository
|
||||
err error
|
||||
headerRepository datastore.HeaderRepository
|
||||
rawHeader []byte
|
||||
)
|
||||
|
||||
BeforeEach(func() {
|
||||
@ -45,15 +43,13 @@ var _ = Describe("Drip drip repository", func() {
|
||||
test_config.CleanTestDB(db)
|
||||
headerRepository = repositories.NewHeaderRepository(db)
|
||||
dripDripRepository = drip_drip.NewDripDripRepository(db)
|
||||
rawHeader, err = json.Marshal(types.Header{})
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
})
|
||||
|
||||
Describe("Create", func() {
|
||||
var headerID int64
|
||||
|
||||
BeforeEach(func() {
|
||||
headerID, err = headerRepository.CreateOrUpdateHeader(core.Header{Raw: rawHeader})
|
||||
headerID, err = headerRepository.CreateOrUpdateHeader(fakes.FakeHeader)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
err = dripDripRepository.Create(headerID, []drip_drip.DripDripModel{test_data.DripDripModel})
|
||||
@ -98,7 +94,7 @@ var _ = Describe("Drip drip repository", func() {
|
||||
var headerID int64
|
||||
|
||||
BeforeEach(func() {
|
||||
headerID, err = headerRepository.CreateOrUpdateHeader(core.Header{Raw: rawHeader})
|
||||
headerID, err = headerRepository.CreateOrUpdateHeader(fakes.FakeHeader)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
})
|
||||
|
||||
@ -140,7 +136,7 @@ var _ = Describe("Drip drip repository", func() {
|
||||
|
||||
headerIDs = []int64{}
|
||||
for _, n := range blockNumbers {
|
||||
headerID, err := headerRepository.CreateOrUpdateHeader(core.Header{BlockNumber: n, Raw: rawHeader})
|
||||
headerID, err := headerRepository.CreateOrUpdateHeader(fakes.GetFakeHeader(n))
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
headerIDs = append(headerIDs, headerID)
|
||||
}
|
||||
@ -178,7 +174,7 @@ var _ = Describe("Drip drip repository", func() {
|
||||
dbTwo := test_config.NewTestDB(core.Node{ID: "second"})
|
||||
headerRepositoryTwo := repositories.NewHeaderRepository(dbTwo)
|
||||
for _, n := range blockNumbers {
|
||||
_, err = headerRepositoryTwo.CreateOrUpdateHeader(core.Header{BlockNumber: n, Raw: rawHeader})
|
||||
_, err = headerRepositoryTwo.CreateOrUpdateHeader(fakes.GetFakeHeader(n))
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
}
|
||||
dripDripRepositoryTwo := drip_drip.NewDripDripRepository(dbTwo)
|
||||
|
@ -16,9 +16,7 @@ package ilk_test
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
@ -26,6 +24,7 @@ import (
|
||||
"github.com/vulcanize/vulcanizedb/pkg/datastore"
|
||||
"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/pkg/transformers/drip_file/ilk"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
|
||||
"github.com/vulcanize/vulcanizedb/test_config"
|
||||
@ -37,7 +36,6 @@ var _ = Describe("Drip file ilk repository", func() {
|
||||
dripFileIlkRepository ilk.Repository
|
||||
err error
|
||||
headerRepository datastore.HeaderRepository
|
||||
rawHeader []byte
|
||||
)
|
||||
|
||||
BeforeEach(func() {
|
||||
@ -45,15 +43,13 @@ var _ = Describe("Drip file ilk repository", func() {
|
||||
test_config.CleanTestDB(db)
|
||||
headerRepository = repositories.NewHeaderRepository(db)
|
||||
dripFileIlkRepository = ilk.NewDripFileIlkRepository(db)
|
||||
rawHeader, err = json.Marshal(types.Header{})
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
})
|
||||
|
||||
Describe("Create", func() {
|
||||
var headerID int64
|
||||
|
||||
BeforeEach(func() {
|
||||
headerID, err = headerRepository.CreateOrUpdateHeader(core.Header{Raw: rawHeader})
|
||||
headerID, err = headerRepository.CreateOrUpdateHeader(fakes.FakeHeader)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
err = dripFileIlkRepository.Create(headerID, []ilk.DripFileIlkModel{test_data.DripFileIlkModel})
|
||||
@ -101,7 +97,7 @@ var _ = Describe("Drip file ilk repository", func() {
|
||||
var headerID int64
|
||||
|
||||
BeforeEach(func() {
|
||||
headerID, err = headerRepository.CreateOrUpdateHeader(core.Header{Raw: rawHeader})
|
||||
headerID, err = headerRepository.CreateOrUpdateHeader(fakes.FakeHeader)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
})
|
||||
|
||||
@ -143,7 +139,7 @@ var _ = Describe("Drip file ilk repository", func() {
|
||||
|
||||
headerIDs = []int64{}
|
||||
for _, n := range blockNumbers {
|
||||
headerID, err := headerRepository.CreateOrUpdateHeader(core.Header{BlockNumber: n, Raw: rawHeader})
|
||||
headerID, err := headerRepository.CreateOrUpdateHeader(fakes.GetFakeHeader(n))
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
headerIDs = append(headerIDs, headerID)
|
||||
}
|
||||
@ -179,7 +175,7 @@ var _ = Describe("Drip file ilk repository", func() {
|
||||
dbTwo := test_config.NewTestDB(core.Node{ID: "second"})
|
||||
headerRepositoryTwo := repositories.NewHeaderRepository(dbTwo)
|
||||
for _, n := range blockNumbers {
|
||||
_, err = headerRepositoryTwo.CreateOrUpdateHeader(core.Header{BlockNumber: n, Raw: rawHeader})
|
||||
_, err = headerRepositoryTwo.CreateOrUpdateHeader(fakes.GetFakeHeader(n))
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
}
|
||||
dripFileIlkRepositoryTwo := ilk.NewDripFileIlkRepository(dbTwo)
|
||||
|
@ -16,9 +16,7 @@ package repo_test
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
@ -26,6 +24,7 @@ import (
|
||||
"github.com/vulcanize/vulcanizedb/pkg/datastore"
|
||||
"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/pkg/transformers/drip_file/repo"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
|
||||
"github.com/vulcanize/vulcanizedb/test_config"
|
||||
@ -37,7 +36,6 @@ var _ = Describe("Drip file repo repository", func() {
|
||||
dripFileRepoRepository repo.Repository
|
||||
err error
|
||||
headerRepository datastore.HeaderRepository
|
||||
rawHeader []byte
|
||||
)
|
||||
|
||||
BeforeEach(func() {
|
||||
@ -45,15 +43,13 @@ var _ = Describe("Drip file repo repository", func() {
|
||||
test_config.CleanTestDB(db)
|
||||
headerRepository = repositories.NewHeaderRepository(db)
|
||||
dripFileRepoRepository = repo.NewDripFileRepoRepository(db)
|
||||
rawHeader, err = json.Marshal(types.Header{})
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
})
|
||||
|
||||
Describe("Create", func() {
|
||||
var headerID int64
|
||||
|
||||
BeforeEach(func() {
|
||||
headerID, err = headerRepository.CreateOrUpdateHeader(core.Header{Raw: rawHeader})
|
||||
headerID, err = headerRepository.CreateOrUpdateHeader(fakes.FakeHeader)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
err = dripFileRepoRepository.Create(headerID, []repo.DripFileRepoModel{test_data.DripFileRepoModel})
|
||||
@ -99,7 +95,7 @@ var _ = Describe("Drip file repo repository", func() {
|
||||
var headerID int64
|
||||
|
||||
BeforeEach(func() {
|
||||
headerID, err = headerRepository.CreateOrUpdateHeader(core.Header{Raw: rawHeader})
|
||||
headerID, err = headerRepository.CreateOrUpdateHeader(fakes.FakeHeader)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
})
|
||||
|
||||
@ -141,7 +137,7 @@ var _ = Describe("Drip file repo repository", func() {
|
||||
|
||||
headerIDs = []int64{}
|
||||
for _, n := range blockNumbers {
|
||||
headerID, err := headerRepository.CreateOrUpdateHeader(core.Header{BlockNumber: n, Raw: rawHeader})
|
||||
headerID, err := headerRepository.CreateOrUpdateHeader(fakes.GetFakeHeader(n))
|
||||
headerIDs = append(headerIDs, headerID)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
}
|
||||
@ -176,7 +172,7 @@ var _ = Describe("Drip file repo repository", func() {
|
||||
dbTwo := test_config.NewTestDB(core.Node{ID: "second"})
|
||||
headerRepositoryTwo := repositories.NewHeaderRepository(dbTwo)
|
||||
for _, n := range blockNumbers {
|
||||
_, err = headerRepositoryTwo.CreateOrUpdateHeader(core.Header{BlockNumber: n, Raw: rawHeader})
|
||||
_, err = headerRepositoryTwo.CreateOrUpdateHeader(fakes.GetFakeHeader(n))
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
}
|
||||
dripFileRepoRepositoryTwo := repo.NewDripFileRepoRepository(dbTwo)
|
||||
|
@ -16,9 +16,7 @@ package vow_test
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
@ -26,6 +24,7 @@ import (
|
||||
"github.com/vulcanize/vulcanizedb/pkg/datastore"
|
||||
"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/pkg/transformers/drip_file/vow"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
|
||||
"github.com/vulcanize/vulcanizedb/test_config"
|
||||
@ -37,7 +36,6 @@ var _ = Describe("Drip file vow repository", func() {
|
||||
dripFileVowRepository vow.Repository
|
||||
err error
|
||||
headerRepository datastore.HeaderRepository
|
||||
rawHeader []byte
|
||||
)
|
||||
|
||||
BeforeEach(func() {
|
||||
@ -45,15 +43,13 @@ var _ = Describe("Drip file vow repository", func() {
|
||||
test_config.CleanTestDB(db)
|
||||
headerRepository = repositories.NewHeaderRepository(db)
|
||||
dripFileVowRepository = vow.NewDripFileVowRepository(db)
|
||||
rawHeader, err = json.Marshal(types.Header{})
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
})
|
||||
|
||||
Describe("Create", func() {
|
||||
var headerID int64
|
||||
|
||||
BeforeEach(func() {
|
||||
headerID, err = headerRepository.CreateOrUpdateHeader(core.Header{Raw: rawHeader})
|
||||
headerID, err = headerRepository.CreateOrUpdateHeader(fakes.FakeHeader)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
err = dripFileVowRepository.Create(headerID, []vow.DripFileVowModel{test_data.DripFileVowModel})
|
||||
@ -99,7 +95,7 @@ var _ = Describe("Drip file vow repository", func() {
|
||||
var headerID int64
|
||||
|
||||
BeforeEach(func() {
|
||||
headerID, err = headerRepository.CreateOrUpdateHeader(core.Header{Raw: rawHeader})
|
||||
headerID, err = headerRepository.CreateOrUpdateHeader(fakes.FakeHeader)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
})
|
||||
|
||||
@ -141,9 +137,9 @@ var _ = Describe("Drip file vow repository", func() {
|
||||
|
||||
headerIDs = []int64{}
|
||||
for _, n := range blockNumbers {
|
||||
headerID, err := headerRepository.CreateOrUpdateHeader(core.Header{BlockNumber: n, Raw: rawHeader})
|
||||
headerIDs = append(headerIDs, headerID)
|
||||
headerID, err := headerRepository.CreateOrUpdateHeader(fakes.GetFakeHeader(n))
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
headerIDs = append(headerIDs, headerID)
|
||||
}
|
||||
})
|
||||
|
||||
@ -176,7 +172,7 @@ var _ = Describe("Drip file vow repository", func() {
|
||||
dbTwo := test_config.NewTestDB(core.Node{ID: "second"})
|
||||
headerRepositoryTwo := repositories.NewHeaderRepository(dbTwo)
|
||||
for _, n := range blockNumbers {
|
||||
_, err = headerRepositoryTwo.CreateOrUpdateHeader(core.Header{BlockNumber: n, Raw: rawHeader})
|
||||
_, err = headerRepositoryTwo.CreateOrUpdateHeader(fakes.GetFakeHeader(n))
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
}
|
||||
dripFileVowRepositoryTwo := vow.NewDripFileVowRepository(dbTwo)
|
||||
|
@ -15,15 +15,13 @@
|
||||
package flip_kick_test
|
||||
|
||||
import (
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
"encoding/json"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"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/pkg/fakes"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/flip_kick"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
|
||||
"github.com/vulcanize/vulcanizedb/test_config"
|
||||
@ -191,18 +189,11 @@ func assertDBRecordCount(db *postgres.DB, dbTable string, expectedCount int) {
|
||||
|
||||
func createHeader(db *postgres.DB, blockNumber int64) (headerId int64) {
|
||||
headerRepository := repositories.NewHeaderRepository(db)
|
||||
rawHeader, err := json.Marshal(types.Header{})
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
header := core.Header{
|
||||
BlockNumber: blockNumber,
|
||||
Hash: common.BytesToHash([]byte{1, 2, 3, 4, 5}).Hex(),
|
||||
Raw: rawHeader,
|
||||
}
|
||||
_, err = headerRepository.CreateOrUpdateHeader(header)
|
||||
_, err := headerRepository.CreateOrUpdateHeader(fakes.GetFakeHeader(blockNumber))
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
var dbHeader core.Header
|
||||
err = db.Get(&dbHeader, `SELECT id, block_number, hash, raw FROM public.headers WHERE block_number = $1 AND eth_node_id = $2`, header.BlockNumber, db.NodeID)
|
||||
err = db.Get(&dbHeader, `SELECT id, block_number, hash, raw FROM public.headers WHERE block_number = $1 AND eth_node_id = $2`, blockNumber, db.NodeID)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
return dbHeader.Id
|
||||
}
|
||||
|
@ -15,15 +15,13 @@
|
||||
package flop_kick_test
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"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/pkg/fakes"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/flop_kick"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
|
||||
"github.com/vulcanize/vulcanizedb/test_config"
|
||||
@ -36,7 +34,6 @@ var _ = Describe("FlopRepository", func() {
|
||||
headerRepository repositories.HeaderRepository
|
||||
err error
|
||||
dbResult test_data.FlopKickDBResult
|
||||
rawHeader []byte
|
||||
)
|
||||
|
||||
BeforeEach(func() {
|
||||
@ -45,15 +42,13 @@ var _ = Describe("FlopRepository", func() {
|
||||
repository = flop_kick.NewFlopKickRepository(db)
|
||||
headerRepository = repositories.NewHeaderRepository(db)
|
||||
dbResult = test_data.FlopKickDBResult{}
|
||||
rawHeader, err = json.Marshal(types.Header{})
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
})
|
||||
|
||||
Describe("Create", func() {
|
||||
var headerId int64
|
||||
|
||||
BeforeEach(func() {
|
||||
headerId, err = headerRepository.CreateOrUpdateHeader(core.Header{Raw: rawHeader})
|
||||
headerId, err = headerRepository.CreateOrUpdateHeader(fakes.FakeHeader)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
err := repository.Create(headerId, []flop_kick.Model{test_data.FlopKickModel})
|
||||
@ -105,7 +100,7 @@ var _ = Describe("FlopRepository", func() {
|
||||
var headerId int64
|
||||
|
||||
BeforeEach(func() {
|
||||
headerId, err = headerRepository.CreateOrUpdateHeader(core.Header{Raw: rawHeader})
|
||||
headerId, err = headerRepository.CreateOrUpdateHeader(fakes.FakeHeader)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
})
|
||||
|
||||
@ -145,7 +140,7 @@ var _ = Describe("FlopRepository", func() {
|
||||
|
||||
headerIds = []int64{}
|
||||
for _, number := range []int64{startingBlock, flopKickBlock, endingBlock, outOfRangeBlock} {
|
||||
headerId, err := headerRepository.CreateOrUpdateHeader(core.Header{BlockNumber: number, Raw: rawHeader})
|
||||
headerId, err := headerRepository.CreateOrUpdateHeader(fakes.GetFakeHeader(number))
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
headerIds = append(headerIds, headerId)
|
||||
}
|
||||
@ -183,7 +178,7 @@ var _ = Describe("FlopRepository", func() {
|
||||
flopKickRepository2 := flop_kick.NewFlopKickRepository(db2)
|
||||
|
||||
for _, number := range []int64{startingBlock, flopKickBlock, endingBlock} {
|
||||
headerRepository2.CreateOrUpdateHeader(core.Header{BlockNumber: number, Raw: rawHeader})
|
||||
headerRepository2.CreateOrUpdateHeader(fakes.GetFakeHeader(number))
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
}
|
||||
|
||||
|
@ -16,9 +16,7 @@ package frob_test
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
@ -26,6 +24,7 @@ import (
|
||||
"github.com/vulcanize/vulcanizedb/pkg/datastore"
|
||||
"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/pkg/transformers/frob"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
|
||||
"github.com/vulcanize/vulcanizedb/test_config"
|
||||
@ -37,7 +36,6 @@ var _ = Describe("Frob repository", func() {
|
||||
frobRepository frob.Repository
|
||||
err error
|
||||
headerRepository datastore.HeaderRepository
|
||||
rawHeader []byte
|
||||
)
|
||||
|
||||
BeforeEach(func() {
|
||||
@ -45,15 +43,13 @@ var _ = Describe("Frob repository", func() {
|
||||
test_config.CleanTestDB(db)
|
||||
headerRepository = repositories.NewHeaderRepository(db)
|
||||
frobRepository = frob.NewFrobRepository(db)
|
||||
rawHeader, err = json.Marshal(types.Header{})
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
})
|
||||
|
||||
Describe("Create", func() {
|
||||
var headerID int64
|
||||
|
||||
BeforeEach(func() {
|
||||
headerID, err = headerRepository.CreateOrUpdateHeader(core.Header{Raw: rawHeader})
|
||||
headerID, err = headerRepository.CreateOrUpdateHeader(fakes.FakeHeader)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
err = frobRepository.Create(headerID, []frob.FrobModel{test_data.FrobModel})
|
||||
@ -104,7 +100,7 @@ var _ = Describe("Frob repository", func() {
|
||||
var headerID int64
|
||||
|
||||
BeforeEach(func() {
|
||||
headerID, err = headerRepository.CreateOrUpdateHeader(core.Header{Raw: rawHeader})
|
||||
headerID, err = headerRepository.CreateOrUpdateHeader(fakes.FakeHeader)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
})
|
||||
|
||||
@ -146,7 +142,7 @@ var _ = Describe("Frob repository", func() {
|
||||
|
||||
headerIDs = []int64{}
|
||||
for _, n := range blockNumbers {
|
||||
headerID, err := headerRepository.CreateOrUpdateHeader(core.Header{BlockNumber: n, Raw: rawHeader})
|
||||
headerID, err := headerRepository.CreateOrUpdateHeader(fakes.GetFakeHeader(n))
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
headerIDs = append(headerIDs, headerID)
|
||||
}
|
||||
@ -181,7 +177,7 @@ var _ = Describe("Frob repository", func() {
|
||||
dbTwo := test_config.NewTestDB(core.Node{ID: "second"})
|
||||
headerRepositoryTwo := repositories.NewHeaderRepository(dbTwo)
|
||||
for _, n := range blockNumbers {
|
||||
_, err = headerRepositoryTwo.CreateOrUpdateHeader(core.Header{BlockNumber: n, Raw: rawHeader})
|
||||
_, err = headerRepositoryTwo.CreateOrUpdateHeader(fakes.GetFakeHeader(n))
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
}
|
||||
frobRepositoryTwo := frob.NewFrobRepository(dbTwo)
|
||||
|
@ -16,9 +16,7 @@ package debt_ceiling_test
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
@ -26,6 +24,7 @@ import (
|
||||
"github.com/vulcanize/vulcanizedb/pkg/datastore"
|
||||
"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/pkg/transformers/pit_file/debt_ceiling"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
|
||||
"github.com/vulcanize/vulcanizedb/test_config"
|
||||
@ -37,7 +36,6 @@ var _ = Describe("Pit file debt ceiling repository", func() {
|
||||
pitFileRepository debt_ceiling.Repository
|
||||
err error
|
||||
headerRepository datastore.HeaderRepository
|
||||
rawHeader []byte
|
||||
)
|
||||
|
||||
BeforeEach(func() {
|
||||
@ -45,15 +43,13 @@ var _ = Describe("Pit file debt ceiling repository", func() {
|
||||
test_config.CleanTestDB(db)
|
||||
headerRepository = repositories.NewHeaderRepository(db)
|
||||
pitFileRepository = debt_ceiling.NewPitFileDebtCeilingRepository(db)
|
||||
rawHeader, err = json.Marshal(types.Header{})
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
})
|
||||
|
||||
Describe("Create", func() {
|
||||
var headerID int64
|
||||
|
||||
BeforeEach(func() {
|
||||
headerID, err = headerRepository.CreateOrUpdateHeader(core.Header{Raw: rawHeader})
|
||||
headerID, err = headerRepository.CreateOrUpdateHeader(fakes.FakeHeader)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
err = pitFileRepository.Create(headerID, []debt_ceiling.PitFileDebtCeilingModel{test_data.PitFileDebtCeilingModel})
|
||||
@ -99,7 +95,7 @@ var _ = Describe("Pit file debt ceiling repository", func() {
|
||||
var headerID int64
|
||||
|
||||
BeforeEach(func() {
|
||||
headerID, err = headerRepository.CreateOrUpdateHeader(core.Header{Raw: rawHeader})
|
||||
headerID, err = headerRepository.CreateOrUpdateHeader(fakes.FakeHeader)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
})
|
||||
|
||||
@ -141,7 +137,7 @@ var _ = Describe("Pit file debt ceiling repository", func() {
|
||||
|
||||
headerIDs = []int64{}
|
||||
for _, n := range blockNumbers {
|
||||
headerID, err := headerRepository.CreateOrUpdateHeader(core.Header{BlockNumber: n, Raw: rawHeader})
|
||||
headerID, err := headerRepository.CreateOrUpdateHeader(fakes.GetFakeHeader(n))
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
headerIDs = append(headerIDs, headerID)
|
||||
}
|
||||
@ -176,7 +172,7 @@ var _ = Describe("Pit file debt ceiling repository", func() {
|
||||
dbTwo := test_config.NewTestDB(core.Node{ID: "second"})
|
||||
headerRepositoryTwo := repositories.NewHeaderRepository(dbTwo)
|
||||
for _, n := range blockNumbers {
|
||||
_, err = headerRepositoryTwo.CreateOrUpdateHeader(core.Header{BlockNumber: n, Raw: rawHeader})
|
||||
_, err = headerRepositoryTwo.CreateOrUpdateHeader(fakes.GetFakeHeader(n))
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
}
|
||||
pitFileRepository := debt_ceiling.NewPitFileDebtCeilingRepository(db)
|
||||
|
@ -16,9 +16,7 @@ package ilk_test
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
@ -26,6 +24,7 @@ import (
|
||||
"github.com/vulcanize/vulcanizedb/pkg/datastore"
|
||||
"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/pkg/transformers/pit_file/ilk"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
|
||||
"github.com/vulcanize/vulcanizedb/test_config"
|
||||
@ -37,7 +36,6 @@ var _ = Describe("Pit file ilk repository", func() {
|
||||
pitFileRepository ilk.Repository
|
||||
err error
|
||||
headerRepository datastore.HeaderRepository
|
||||
rawHeader []byte
|
||||
)
|
||||
|
||||
BeforeEach(func() {
|
||||
@ -45,14 +43,13 @@ var _ = Describe("Pit file ilk repository", func() {
|
||||
test_config.CleanTestDB(db)
|
||||
headerRepository = repositories.NewHeaderRepository(db)
|
||||
pitFileRepository = ilk.NewPitFileIlkRepository(db)
|
||||
rawHeader, err = json.Marshal(types.Header{})
|
||||
})
|
||||
|
||||
Describe("Create", func() {
|
||||
var headerID int64
|
||||
|
||||
BeforeEach(func() {
|
||||
headerID, err = headerRepository.CreateOrUpdateHeader(core.Header{Raw: rawHeader})
|
||||
headerID, err = headerRepository.CreateOrUpdateHeader(fakes.FakeHeader)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
err = pitFileRepository.Create(headerID, []ilk.PitFileIlkModel{test_data.PitFileIlkModel})
|
||||
@ -99,7 +96,7 @@ var _ = Describe("Pit file ilk repository", func() {
|
||||
var headerID int64
|
||||
|
||||
BeforeEach(func() {
|
||||
headerID, err = headerRepository.CreateOrUpdateHeader(core.Header{Raw: rawHeader})
|
||||
headerID, err = headerRepository.CreateOrUpdateHeader(fakes.FakeHeader)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
})
|
||||
|
||||
@ -141,7 +138,7 @@ var _ = Describe("Pit file ilk repository", func() {
|
||||
|
||||
headerIDs = []int64{}
|
||||
for _, n := range blockNumbers {
|
||||
headerID, err := headerRepository.CreateOrUpdateHeader(core.Header{BlockNumber: n, Raw: rawHeader})
|
||||
headerID, err := headerRepository.CreateOrUpdateHeader(fakes.GetFakeHeader(n))
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
headerIDs = append(headerIDs, headerID)
|
||||
}
|
||||
@ -176,7 +173,7 @@ var _ = Describe("Pit file ilk repository", func() {
|
||||
dbTwo := test_config.NewTestDB(core.Node{ID: "second"})
|
||||
headerRepositoryTwo := repositories.NewHeaderRepository(dbTwo)
|
||||
for _, n := range blockNumbers {
|
||||
_, err = headerRepositoryTwo.CreateOrUpdateHeader(core.Header{BlockNumber: n, Raw: rawHeader})
|
||||
_, err = headerRepositoryTwo.CreateOrUpdateHeader(fakes.GetFakeHeader(n))
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
}
|
||||
pitFileRepositoryTwo := ilk.NewPitFileIlkRepository(dbTwo)
|
||||
|
@ -16,9 +16,7 @@ package stability_fee_test
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
@ -26,6 +24,7 @@ import (
|
||||
"github.com/vulcanize/vulcanizedb/pkg/datastore"
|
||||
"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/pkg/transformers/pit_file/stability_fee"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
|
||||
"github.com/vulcanize/vulcanizedb/test_config"
|
||||
@ -37,7 +36,6 @@ var _ = Describe("Pit file stability fee repository", func() {
|
||||
pitFileRepository stability_fee.Repository
|
||||
err error
|
||||
headerRepository datastore.HeaderRepository
|
||||
rawHeader []byte
|
||||
)
|
||||
|
||||
BeforeEach(func() {
|
||||
@ -45,15 +43,13 @@ var _ = Describe("Pit file stability fee repository", func() {
|
||||
test_config.CleanTestDB(db)
|
||||
headerRepository = repositories.NewHeaderRepository(db)
|
||||
pitFileRepository = stability_fee.NewPitFileStabilityFeeRepository(db)
|
||||
rawHeader, err = json.Marshal(types.Header{})
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
})
|
||||
|
||||
Describe("Create", func() {
|
||||
var headerID int64
|
||||
|
||||
BeforeEach(func() {
|
||||
headerID, err = headerRepository.CreateOrUpdateHeader(core.Header{Raw: rawHeader})
|
||||
headerID, err = headerRepository.CreateOrUpdateHeader(fakes.FakeHeader)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
err = pitFileRepository.Create(headerID, []stability_fee.PitFileStabilityFeeModel{test_data.PitFileStabilityFeeModel})
|
||||
@ -99,7 +95,7 @@ var _ = Describe("Pit file stability fee repository", func() {
|
||||
var headerID int64
|
||||
|
||||
BeforeEach(func() {
|
||||
headerID, err = headerRepository.CreateOrUpdateHeader(core.Header{Raw: rawHeader})
|
||||
headerID, err = headerRepository.CreateOrUpdateHeader(fakes.FakeHeader)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
})
|
||||
|
||||
@ -141,7 +137,7 @@ var _ = Describe("Pit file stability fee repository", func() {
|
||||
|
||||
headerIDs = []int64{}
|
||||
for _, n := range blockNumbers {
|
||||
headerID, err := headerRepository.CreateOrUpdateHeader(core.Header{BlockNumber: n, Raw: rawHeader})
|
||||
headerID, err := headerRepository.CreateOrUpdateHeader(fakes.GetFakeHeader(n))
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
headerIDs = append(headerIDs, headerID)
|
||||
}
|
||||
@ -176,7 +172,7 @@ var _ = Describe("Pit file stability fee repository", func() {
|
||||
dbTwo := test_config.NewTestDB(core.Node{ID: "second"})
|
||||
headerRepositoryTwo := repositories.NewHeaderRepository(dbTwo)
|
||||
for _, n := range blockNumbers {
|
||||
_, err = headerRepositoryTwo.CreateOrUpdateHeader(core.Header{BlockNumber: n, Raw: rawHeader})
|
||||
_, err = headerRepositoryTwo.CreateOrUpdateHeader(fakes.GetFakeHeader(n))
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
}
|
||||
pitFileRepositoryTwo := stability_fee.NewPitFileStabilityFeeRepository(dbTwo)
|
||||
|
@ -2,15 +2,16 @@ package price_feeds_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"math/big"
|
||||
"time"
|
||||
|
||||
"encoding/json"
|
||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||
"github.com/ethereum/go-ethereum/ethclient"
|
||||
"github.com/ethereum/go-ethereum/rpc"
|
||||
. "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"
|
||||
@ -139,6 +140,7 @@ func persistHeader(rpcClient client.RpcClient, db *postgres.DB, blockNumber int6
|
||||
BlockNumber: poaHeader.Number.ToInt().Int64(),
|
||||
Hash: poaHeader.Hash.String(),
|
||||
Raw: rawHeader,
|
||||
Timestamp: poaHeader.Time.ToInt().String(),
|
||||
})
|
||||
return err
|
||||
}
|
||||
|
@ -16,9 +16,7 @@ package price_feeds_test
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
@ -26,6 +24,7 @@ import (
|
||||
"github.com/vulcanize/vulcanizedb/pkg/datastore"
|
||||
"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/pkg/transformers/price_feeds"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
|
||||
"github.com/vulcanize/vulcanizedb/test_config"
|
||||
@ -37,7 +36,6 @@ var _ = Describe("Price feeds repository", func() {
|
||||
err error
|
||||
headerRepository datastore.HeaderRepository
|
||||
priceFeedRepository price_feeds.IPriceFeedRepository
|
||||
rawHeader []byte
|
||||
)
|
||||
|
||||
BeforeEach(func() {
|
||||
@ -45,15 +43,13 @@ var _ = Describe("Price feeds repository", func() {
|
||||
test_config.CleanTestDB(db)
|
||||
headerRepository = repositories.NewHeaderRepository(db)
|
||||
priceFeedRepository = price_feeds.NewPriceFeedRepository(db)
|
||||
rawHeader, err = json.Marshal(types.Header{})
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
})
|
||||
|
||||
Describe("Create", func() {
|
||||
var headerID int64
|
||||
|
||||
BeforeEach(func() {
|
||||
headerID, err = headerRepository.CreateOrUpdateHeader(core.Header{Raw: rawHeader})
|
||||
headerID, err = headerRepository.CreateOrUpdateHeader(fakes.FakeHeader)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
err = priceFeedRepository.Create(headerID, []price_feeds.PriceFeedModel{test_data.PriceFeedModel})
|
||||
@ -100,7 +96,7 @@ var _ = Describe("Price feeds repository", func() {
|
||||
var headerID int64
|
||||
|
||||
BeforeEach(func() {
|
||||
headerID, err = headerRepository.CreateOrUpdateHeader(core.Header{Raw: rawHeader})
|
||||
headerID, err = headerRepository.CreateOrUpdateHeader(fakes.FakeHeader)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
})
|
||||
|
||||
@ -142,7 +138,7 @@ var _ = Describe("Price feeds repository", func() {
|
||||
|
||||
headerIDs = []int64{}
|
||||
for _, n := range blockNumbers {
|
||||
headerID, err := headerRepository.CreateOrUpdateHeader(core.Header{BlockNumber: n, Raw: rawHeader})
|
||||
headerID, err := headerRepository.CreateOrUpdateHeader(fakes.GetFakeHeader(n))
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
headerIDs = append(headerIDs, headerID)
|
||||
}
|
||||
@ -178,7 +174,7 @@ var _ = Describe("Price feeds repository", func() {
|
||||
dbTwo := test_config.NewTestDB(core.Node{ID: "second"})
|
||||
headerRepositoryTwo := repositories.NewHeaderRepository(dbTwo)
|
||||
for _, n := range blockNumbers {
|
||||
_, err = headerRepositoryTwo.CreateOrUpdateHeader(core.Header{BlockNumber: n, Raw: rawHeader})
|
||||
_, err = headerRepositoryTwo.CreateOrUpdateHeader(fakes.GetFakeHeader(n))
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
}
|
||||
priceFeedRepositoryTwo := price_feeds.NewPriceFeedRepository(dbTwo)
|
||||
|
@ -15,15 +15,13 @@
|
||||
package tend_test
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"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/pkg/fakes"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/tend"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
|
||||
"github.com/vulcanize/vulcanizedb/test_config"
|
||||
@ -35,7 +33,6 @@ var _ = Describe("TendRepository", func() {
|
||||
tendRepository tend.TendRepository
|
||||
headerRepository repositories.HeaderRepository
|
||||
err error
|
||||
rawHeader []byte
|
||||
)
|
||||
|
||||
BeforeEach(func() {
|
||||
@ -44,15 +41,13 @@ var _ = Describe("TendRepository", func() {
|
||||
test_config.CleanTestDB(db)
|
||||
headerRepository = repositories.NewHeaderRepository(db)
|
||||
tendRepository = tend.NewTendRepository(db)
|
||||
rawHeader, err = json.Marshal(types.Header{})
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
})
|
||||
|
||||
Describe("Create", func() {
|
||||
var headerId int64
|
||||
|
||||
BeforeEach(func() {
|
||||
headerId, err = headerRepository.CreateOrUpdateHeader(core.Header{Raw: rawHeader})
|
||||
headerId, err = headerRepository.CreateOrUpdateHeader(fakes.FakeHeader)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
err := tendRepository.Create(headerId, []tend.TendModel{test_data.TendModel})
|
||||
@ -111,7 +106,7 @@ var _ = Describe("TendRepository", func() {
|
||||
var headerId int64
|
||||
|
||||
BeforeEach(func() {
|
||||
headerId, err = headerRepository.CreateOrUpdateHeader(core.Header{Raw: rawHeader})
|
||||
headerId, err = headerRepository.CreateOrUpdateHeader(fakes.FakeHeader)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
})
|
||||
|
||||
@ -152,7 +147,7 @@ var _ = Describe("TendRepository", func() {
|
||||
|
||||
headerIds = []int64{}
|
||||
for _, number := range []int64{startingBlock, tendBlock, endingBlock, outOfRangeBlock} {
|
||||
headerId, err := headerRepository.CreateOrUpdateHeader(core.Header{BlockNumber: number, Raw: rawHeader})
|
||||
headerId, err := headerRepository.CreateOrUpdateHeader(fakes.GetFakeHeader(number))
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
headerIds = append(headerIds, headerId)
|
||||
}
|
||||
@ -190,7 +185,7 @@ var _ = Describe("TendRepository", func() {
|
||||
tendRepository2 := tend.NewTendRepository(db2)
|
||||
|
||||
for _, number := range []int64{startingBlock, tendBlock, endingBlock} {
|
||||
headerRepository2.CreateOrUpdateHeader(core.Header{BlockNumber: number, Raw: rawHeader})
|
||||
headerRepository2.CreateOrUpdateHeader(fakes.GetFakeHeader(number))
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
}
|
||||
|
||||
|
@ -16,15 +16,14 @@ package vat_fold_test
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
|
||||
"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/pkg/fakes"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/vat_fold"
|
||||
"github.com/vulcanize/vulcanizedb/test_config"
|
||||
@ -36,7 +35,6 @@ var _ = Describe("Vat.fold repository", func() {
|
||||
repository vat_fold.VatFoldRepository
|
||||
headerRepository repositories.HeaderRepository
|
||||
err error
|
||||
rawHeader []byte
|
||||
)
|
||||
|
||||
BeforeEach(func() {
|
||||
@ -45,15 +43,13 @@ var _ = Describe("Vat.fold repository", func() {
|
||||
test_config.CleanTestDB(db)
|
||||
repository = vat_fold.NewVatFoldRepository(db)
|
||||
headerRepository = repositories.NewHeaderRepository(db)
|
||||
rawHeader, err = json.Marshal(types.Header{})
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
})
|
||||
|
||||
Describe("Create", func() {
|
||||
var headerID int64
|
||||
|
||||
BeforeEach(func() {
|
||||
headerID, err = headerRepository.CreateOrUpdateHeader(core.Header{Raw: rawHeader})
|
||||
headerID, err = headerRepository.CreateOrUpdateHeader(fakes.FakeHeader)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
err = repository.Create(headerID, []vat_fold.VatFoldModel{test_data.VatFoldModel})
|
||||
@ -101,7 +97,7 @@ var _ = Describe("Vat.fold repository", func() {
|
||||
var headerID int64
|
||||
|
||||
BeforeEach(func() {
|
||||
headerID, err = headerRepository.CreateOrUpdateHeader(core.Header{Raw: rawHeader})
|
||||
headerID, err = headerRepository.CreateOrUpdateHeader(fakes.FakeHeader)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
})
|
||||
|
||||
@ -152,7 +148,7 @@ var _ = Describe("Vat.fold repository", func() {
|
||||
|
||||
headerIDs = []int64{}
|
||||
for _, n := range blockNumbers {
|
||||
headerID, err := headerRepository.CreateOrUpdateHeader(core.Header{BlockNumber: n, Raw: rawHeader})
|
||||
headerID, err := headerRepository.CreateOrUpdateHeader(fakes.GetFakeHeader(n))
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
headerIDs = append(headerIDs, headerID)
|
||||
}
|
||||
@ -188,7 +184,7 @@ var _ = Describe("Vat.fold repository", func() {
|
||||
headerRepositoryTwo := repositories.NewHeaderRepository(dbTwo)
|
||||
|
||||
for _, n := range blockNumbers {
|
||||
_, err = headerRepositoryTwo.CreateOrUpdateHeader(core.Header{BlockNumber: n, Raw: rawHeader})
|
||||
_, err = headerRepositoryTwo.CreateOrUpdateHeader(fakes.GetFakeHeader(n))
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
}
|
||||
|
||||
|
@ -2,9 +2,7 @@ package vat_grab_test
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
@ -12,6 +10,7 @@ import (
|
||||
"github.com/vulcanize/vulcanizedb/pkg/datastore"
|
||||
"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/pkg/transformers/test_data"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/vat_grab"
|
||||
"github.com/vulcanize/vulcanizedb/test_config"
|
||||
@ -23,7 +22,6 @@ var _ = Describe("Vat grab repository", func() {
|
||||
vatGrabRepository vat_grab.Repository
|
||||
err error
|
||||
headerRepository datastore.HeaderRepository
|
||||
rawHeader []byte
|
||||
)
|
||||
|
||||
BeforeEach(func() {
|
||||
@ -31,15 +29,13 @@ var _ = Describe("Vat grab repository", func() {
|
||||
test_config.CleanTestDB(db)
|
||||
headerRepository = repositories.NewHeaderRepository(db)
|
||||
vatGrabRepository = vat_grab.NewVatGrabRepository(db)
|
||||
rawHeader, err = json.Marshal(types.Header{})
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
})
|
||||
|
||||
Describe("Create", func() {
|
||||
var headerID int64
|
||||
|
||||
BeforeEach(func() {
|
||||
headerID, err = headerRepository.CreateOrUpdateHeader(core.Header{Raw: rawHeader})
|
||||
headerID, err = headerRepository.CreateOrUpdateHeader(fakes.FakeHeader)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
err = vatGrabRepository.Create(headerID, []vat_grab.VatGrabModel{test_data.VatGrabModel})
|
||||
@ -89,7 +85,7 @@ var _ = Describe("Vat grab repository", func() {
|
||||
var headerID int64
|
||||
|
||||
BeforeEach(func() {
|
||||
headerID, err = headerRepository.CreateOrUpdateHeader(core.Header{Raw: rawHeader})
|
||||
headerID, err = headerRepository.CreateOrUpdateHeader(fakes.FakeHeader)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
})
|
||||
|
||||
@ -130,7 +126,7 @@ var _ = Describe("Vat grab repository", func() {
|
||||
|
||||
headerIDs = []int64{}
|
||||
for _, n := range blockNumbers {
|
||||
headerID, err := headerRepository.CreateOrUpdateHeader(core.Header{BlockNumber: n, Raw: rawHeader})
|
||||
headerID, err := headerRepository.CreateOrUpdateHeader(fakes.GetFakeHeader(n))
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
headerIDs = append(headerIDs, headerID)
|
||||
}
|
||||
@ -165,7 +161,7 @@ var _ = Describe("Vat grab repository", func() {
|
||||
dbTwo := test_config.NewTestDB(core.Node{ID: "second"})
|
||||
headerRepositoryTwo := repositories.NewHeaderRepository(dbTwo)
|
||||
for _, n := range blockNumbers {
|
||||
_, err = headerRepositoryTwo.CreateOrUpdateHeader(core.Header{BlockNumber: n, Raw: rawHeader})
|
||||
_, err = headerRepositoryTwo.CreateOrUpdateHeader(fakes.GetFakeHeader(n))
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
}
|
||||
vatGrabRepositoryTwo := vat_grab.NewVatGrabRepository(dbTwo)
|
||||
|
@ -15,15 +15,13 @@
|
||||
package vat_heal_test
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"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/pkg/fakes"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/vat_heal"
|
||||
"github.com/vulcanize/vulcanizedb/test_config"
|
||||
@ -35,7 +33,6 @@ var _ = Describe("VatHeal Repository", func() {
|
||||
repository vat_heal.VatHealRepository
|
||||
headerRepository repositories.HeaderRepository
|
||||
err error
|
||||
rawHeader []byte
|
||||
)
|
||||
|
||||
BeforeEach(func() {
|
||||
@ -43,8 +40,6 @@ var _ = Describe("VatHeal Repository", func() {
|
||||
test_config.CleanTestDB(db)
|
||||
repository = vat_heal.VatHealRepository{DB: db}
|
||||
headerRepository = repositories.NewHeaderRepository(db)
|
||||
rawHeader, err = json.Marshal(types.Header{})
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
})
|
||||
|
||||
type VatHealDBResult struct {
|
||||
@ -61,7 +56,7 @@ var _ = Describe("VatHeal Repository", func() {
|
||||
var headerId int64
|
||||
|
||||
BeforeEach(func() {
|
||||
headerId, err = headerRepository.CreateOrUpdateHeader(core.Header{Raw: rawHeader})
|
||||
headerId, err = headerRepository.CreateOrUpdateHeader(fakes.FakeHeader)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
})
|
||||
|
||||
@ -138,7 +133,7 @@ var _ = Describe("VatHeal Repository", func() {
|
||||
headerIds = []int64{}
|
||||
blockNumbers = []int64{startingBlock, vatHealBlock, endingBlock, outsideRangeBlock}
|
||||
for _, n := range blockNumbers {
|
||||
headerId, err := headerRepository.CreateOrUpdateHeader(core.Header{BlockNumber: n, Raw: rawHeader})
|
||||
headerId, err := headerRepository.CreateOrUpdateHeader(fakes.GetFakeHeader(n))
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
headerIds = append(headerIds, headerId)
|
||||
}
|
||||
@ -175,7 +170,7 @@ var _ = Describe("VatHeal Repository", func() {
|
||||
repository2 := vat_heal.NewVatHealRepository(db2)
|
||||
|
||||
for _, n := range blockNumbers {
|
||||
_, err = headerRepository2.CreateOrUpdateHeader(core.Header{BlockNumber: n, Raw: rawHeader})
|
||||
_, err = headerRepository2.CreateOrUpdateHeader(fakes.GetFakeHeader(n))
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
}
|
||||
|
||||
@ -196,7 +191,7 @@ var _ = Describe("VatHeal Repository", func() {
|
||||
var headerId int64
|
||||
|
||||
BeforeEach(func() {
|
||||
headerId, err = headerRepository.CreateOrUpdateHeader(core.Header{Raw: rawHeader})
|
||||
headerId, err = headerRepository.CreateOrUpdateHeader(fakes.FakeHeader)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
})
|
||||
|
||||
|
@ -20,11 +20,10 @@ import (
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
"encoding/json"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"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/pkg/fakes"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/vat_init"
|
||||
"github.com/vulcanize/vulcanizedb/test_config"
|
||||
@ -36,7 +35,6 @@ var _ = Describe("Vat init repository", func() {
|
||||
vatInitRepository vat_init.Repository
|
||||
headerRepository repositories.HeaderRepository
|
||||
err error
|
||||
rawHeader []byte
|
||||
)
|
||||
|
||||
BeforeEach(func() {
|
||||
@ -44,15 +42,13 @@ var _ = Describe("Vat init repository", func() {
|
||||
test_config.CleanTestDB(db)
|
||||
vatInitRepository = vat_init.NewVatInitRepository(db)
|
||||
headerRepository = repositories.NewHeaderRepository(db)
|
||||
rawHeader, err = json.Marshal(types.Header{})
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
})
|
||||
|
||||
Describe("Create", func() {
|
||||
var headerID int64
|
||||
|
||||
BeforeEach(func() {
|
||||
headerID, err = headerRepository.CreateOrUpdateHeader(core.Header{Raw: rawHeader})
|
||||
headerID, err = headerRepository.CreateOrUpdateHeader(fakes.FakeHeader)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
err = vatInitRepository.Create(headerID, []vat_init.VatInitModel{test_data.VatInitModel})
|
||||
@ -97,7 +93,7 @@ var _ = Describe("Vat init repository", func() {
|
||||
var headerID int64
|
||||
|
||||
BeforeEach(func() {
|
||||
headerID, err = headerRepository.CreateOrUpdateHeader(core.Header{Raw: rawHeader})
|
||||
headerID, err = headerRepository.CreateOrUpdateHeader(fakes.FakeHeader)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
})
|
||||
@ -140,7 +136,7 @@ var _ = Describe("Vat init repository", func() {
|
||||
|
||||
headerIDs = []int64{}
|
||||
for _, n := range blockNumbers {
|
||||
headerID, err := headerRepository.CreateOrUpdateHeader(core.Header{BlockNumber: n, Raw: rawHeader})
|
||||
headerID, err := headerRepository.CreateOrUpdateHeader(fakes.GetFakeHeader(n))
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
headerIDs = append(headerIDs, headerID)
|
||||
}
|
||||
@ -175,7 +171,7 @@ var _ = Describe("Vat init repository", func() {
|
||||
dbTwo := test_config.NewTestDB(core.Node{ID: "second"})
|
||||
headerRepositoryTwo := repositories.NewHeaderRepository(dbTwo)
|
||||
for _, n := range blockNumbers {
|
||||
_, err = headerRepositoryTwo.CreateOrUpdateHeader(core.Header{BlockNumber: n, Raw: rawHeader})
|
||||
_, err = headerRepositoryTwo.CreateOrUpdateHeader(fakes.GetFakeHeader(n))
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
}
|
||||
vatInitRepositoryTwo := vat_init.NewVatInitRepository(dbTwo)
|
||||
|
@ -16,33 +16,29 @@ package vat_move_test
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
"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/pkg/fakes"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/vat_move"
|
||||
"github.com/vulcanize/vulcanizedb/test_config"
|
||||
"math/rand"
|
||||
)
|
||||
|
||||
var _ = Describe("Vat Move", func() {
|
||||
var db *postgres.DB
|
||||
var headerRepository repositories.HeaderRepository
|
||||
var vatMoveRepository vat_move.VatMoveRepository
|
||||
var rawHeader []byte
|
||||
var err error
|
||||
|
||||
BeforeEach(func() {
|
||||
db = test_config.NewTestDB(core.Node{})
|
||||
test_config.CleanTestDB(db)
|
||||
headerRepository = repositories.NewHeaderRepository(db)
|
||||
vatMoveRepository = vat_move.NewVatMoveRepository(db)
|
||||
rawHeader, err = json.Marshal(types.Header{})
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
})
|
||||
|
||||
Describe("Create", func() {
|
||||
@ -50,7 +46,7 @@ var _ = Describe("Vat Move", func() {
|
||||
var err error
|
||||
|
||||
BeforeEach(func() {
|
||||
headerID, err = headerRepository.CreateOrUpdateHeader(core.Header{Raw: rawHeader})
|
||||
headerID, err = headerRepository.CreateOrUpdateHeader(fakes.FakeHeader)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
err = vatMoveRepository.Create(headerID, []vat_move.VatMoveModel{test_data.VatMoveModel})
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
@ -92,7 +88,7 @@ var _ = Describe("Vat Move", func() {
|
||||
})
|
||||
|
||||
Describe("MissingHeaders", func() {
|
||||
var eventBlockNumber = rand.Int63()
|
||||
var eventBlockNumber = GinkgoRandomSeed()
|
||||
var startingBlockNumber = eventBlockNumber - 1
|
||||
var endingBlockNumber = eventBlockNumber + 1
|
||||
var outOfRangeBlockNumber = eventBlockNumber + 2
|
||||
@ -101,7 +97,7 @@ var _ = Describe("Vat Move", func() {
|
||||
var headerIds []int64
|
||||
|
||||
for _, number := range []int64{startingBlockNumber, eventBlockNumber, endingBlockNumber, outOfRangeBlockNumber} {
|
||||
headerId, err := headerRepository.CreateOrUpdateHeader(core.Header{BlockNumber: number, Raw: rawHeader})
|
||||
headerId, err := headerRepository.CreateOrUpdateHeader(fakes.GetFakeHeader(number))
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
headerIds = append(headerIds, headerId)
|
||||
}
|
||||
@ -119,7 +115,7 @@ var _ = Describe("Vat Move", func() {
|
||||
It("only treats headers as checked if vat_move has been checked", func() {
|
||||
var headerIds []int64
|
||||
for _, number := range []int64{startingBlockNumber, eventBlockNumber, endingBlockNumber, outOfRangeBlockNumber} {
|
||||
headerId, err := headerRepository.CreateOrUpdateHeader(core.Header{BlockNumber: number, Raw: rawHeader})
|
||||
headerId, err := headerRepository.CreateOrUpdateHeader(fakes.GetFakeHeader(number))
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
headerIds = append(headerIds, headerId)
|
||||
}
|
||||
@ -143,10 +139,10 @@ var _ = Describe("Vat Move", func() {
|
||||
headerRepositoryTwo := repositories.NewHeaderRepository(dbTwo)
|
||||
var headerIDs []int64
|
||||
for _, n := range blockNumbers {
|
||||
headerID, err := headerRepository.CreateOrUpdateHeader(core.Header{BlockNumber: n, Raw: rawHeader})
|
||||
headerID, err := headerRepository.CreateOrUpdateHeader(fakes.GetFakeHeader(n))
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
headerIDs = append(headerIDs, headerID)
|
||||
_, err = headerRepositoryTwo.CreateOrUpdateHeader(core.Header{BlockNumber: n, Raw: rawHeader})
|
||||
_, err = headerRepositoryTwo.CreateOrUpdateHeader(fakes.GetFakeHeader(n))
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
}
|
||||
vatMoveRepositoryTwo := vat_move.NewVatMoveRepository(dbTwo)
|
||||
@ -169,7 +165,7 @@ var _ = Describe("Vat Move", func() {
|
||||
var err error
|
||||
|
||||
BeforeEach(func() {
|
||||
headerID, err = headerRepository.CreateOrUpdateHeader(core.Header{Raw: rawHeader})
|
||||
headerID, err = headerRepository.CreateOrUpdateHeader(fakes.FakeHeader)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
})
|
||||
|
||||
|
@ -2,9 +2,7 @@ package vat_toll_test
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
@ -12,6 +10,7 @@ import (
|
||||
"github.com/vulcanize/vulcanizedb/pkg/datastore"
|
||||
"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/pkg/transformers/test_data"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/vat_toll"
|
||||
"github.com/vulcanize/vulcanizedb/test_config"
|
||||
@ -23,7 +22,6 @@ var _ = Describe("Vat toll repository", func() {
|
||||
vatTollRepository vat_toll.Repository
|
||||
err error
|
||||
headerRepository datastore.HeaderRepository
|
||||
rawHeader []byte
|
||||
)
|
||||
|
||||
BeforeEach(func() {
|
||||
@ -31,15 +29,13 @@ var _ = Describe("Vat toll repository", func() {
|
||||
test_config.CleanTestDB(db)
|
||||
headerRepository = repositories.NewHeaderRepository(db)
|
||||
vatTollRepository = vat_toll.NewVatTollRepository(db)
|
||||
rawHeader, err = json.Marshal(types.Header{})
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
})
|
||||
|
||||
Describe("Create", func() {
|
||||
var headerID int64
|
||||
|
||||
BeforeEach(func() {
|
||||
headerID, err = headerRepository.CreateOrUpdateHeader(core.Header{Raw: rawHeader})
|
||||
headerID, err = headerRepository.CreateOrUpdateHeader(fakes.FakeHeader)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
err = vatTollRepository.Create(headerID, []vat_toll.VatTollModel{test_data.VatTollModel})
|
||||
@ -86,7 +82,7 @@ var _ = Describe("Vat toll repository", func() {
|
||||
var headerID int64
|
||||
|
||||
BeforeEach(func() {
|
||||
headerID, err = headerRepository.CreateOrUpdateHeader(core.Header{Raw: rawHeader})
|
||||
headerID, err = headerRepository.CreateOrUpdateHeader(fakes.FakeHeader)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
})
|
||||
|
||||
@ -128,7 +124,7 @@ var _ = Describe("Vat toll repository", func() {
|
||||
|
||||
headerIDs = []int64{}
|
||||
for _, n := range blockNumbers {
|
||||
headerID, err := headerRepository.CreateOrUpdateHeader(core.Header{BlockNumber: n, Raw: rawHeader})
|
||||
headerID, err := headerRepository.CreateOrUpdateHeader(fakes.GetFakeHeader(n))
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
headerIDs = append(headerIDs, headerID)
|
||||
}
|
||||
@ -163,7 +159,7 @@ var _ = Describe("Vat toll repository", func() {
|
||||
dbTwo := test_config.NewTestDB(core.Node{ID: "second"})
|
||||
headerRepositoryTwo := repositories.NewHeaderRepository(dbTwo)
|
||||
for _, n := range blockNumbers {
|
||||
_, err = headerRepositoryTwo.CreateOrUpdateHeader(core.Header{BlockNumber: n, Raw: rawHeader})
|
||||
_, err = headerRepositoryTwo.CreateOrUpdateHeader(fakes.GetFakeHeader(n))
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
}
|
||||
vatTollRepositoryTwo := vat_toll.NewVatTollRepository(dbTwo)
|
||||
|
@ -6,12 +6,11 @@ import (
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
"encoding/json"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/core"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/datastore"
|
||||
"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/pkg/transformers/test_data"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/vat_tune"
|
||||
"github.com/vulcanize/vulcanizedb/test_config"
|
||||
@ -23,7 +22,6 @@ var _ = Describe("Vat tune repository", func() {
|
||||
vatTuneRepository vat_tune.Repository
|
||||
err error
|
||||
headerRepository datastore.HeaderRepository
|
||||
rawHeader []byte
|
||||
)
|
||||
|
||||
BeforeEach(func() {
|
||||
@ -31,15 +29,13 @@ var _ = Describe("Vat tune repository", func() {
|
||||
test_config.CleanTestDB(db)
|
||||
headerRepository = repositories.NewHeaderRepository(db)
|
||||
vatTuneRepository = vat_tune.NewVatTuneRepository(db)
|
||||
rawHeader, err = json.Marshal(types.Header{})
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
})
|
||||
|
||||
Describe("Create", func() {
|
||||
var headerID int64
|
||||
|
||||
BeforeEach(func() {
|
||||
headerID, err = headerRepository.CreateOrUpdateHeader(core.Header{Raw: rawHeader})
|
||||
headerID, err = headerRepository.CreateOrUpdateHeader(fakes.FakeHeader)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
err = vatTuneRepository.Create(headerID, []vat_tune.VatTuneModel{test_data.VatTuneModel})
|
||||
@ -89,7 +85,7 @@ var _ = Describe("Vat tune repository", func() {
|
||||
var headerID int64
|
||||
|
||||
BeforeEach(func() {
|
||||
headerID, err = headerRepository.CreateOrUpdateHeader(core.Header{Raw: rawHeader})
|
||||
headerID, err = headerRepository.CreateOrUpdateHeader(fakes.FakeHeader)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
})
|
||||
|
||||
@ -131,7 +127,7 @@ var _ = Describe("Vat tune repository", func() {
|
||||
|
||||
headerIDs = []int64{}
|
||||
for _, n := range blockNumbers {
|
||||
headerID, err := headerRepository.CreateOrUpdateHeader(core.Header{BlockNumber: n, Raw: rawHeader})
|
||||
headerID, err := headerRepository.CreateOrUpdateHeader(fakes.GetFakeHeader(n))
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
headerIDs = append(headerIDs, headerID)
|
||||
}
|
||||
@ -166,7 +162,7 @@ var _ = Describe("Vat tune repository", func() {
|
||||
dbTwo := test_config.NewTestDB(core.Node{ID: "second"})
|
||||
headerRepositoryTwo := repositories.NewHeaderRepository(dbTwo)
|
||||
for _, n := range blockNumbers {
|
||||
_, err = headerRepositoryTwo.CreateOrUpdateHeader(core.Header{BlockNumber: n, Raw: rawHeader})
|
||||
_, err = headerRepositoryTwo.CreateOrUpdateHeader(fakes.GetFakeHeader(n))
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
}
|
||||
vatTuneRepository := vat_tune.NewVatTuneRepository(db)
|
||||
|
Loading…
Reference in New Issue
Block a user