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