Add Pit file stability fee event
- file event on the pit contract is overloaded and each implementation logs a note - existing Pit file transformer now specified as dealing with ilks
This commit is contained in:
parent
a30e5036fd
commit
e1f609528d
@ -1 +1,2 @@
|
|||||||
DROP TABLE maker.pit_file;
|
DROP TABLE maker.pit_file_ilk;
|
||||||
|
DROP TABLE maker.pit_file_stability_fee;
|
@ -1,10 +1,20 @@
|
|||||||
CREATE TABLE maker.pit_file (
|
CREATE TABLE maker.pit_file_ilk (
|
||||||
id SERIAL PRIMARY KEY,
|
id SERIAL PRIMARY KEY,
|
||||||
header_id INTEGER NOT NULL REFERENCES headers (id) ON DELETE CASCADE,
|
header_id INTEGER NOT NULL REFERENCES headers (id) ON DELETE CASCADE,
|
||||||
ilk TEXT,
|
ilk TEXT,
|
||||||
what TEXT,
|
what TEXT,
|
||||||
risk NUMERIC,
|
data NUMERIC,
|
||||||
tx_idx INTEGER NOT NUll,
|
tx_idx INTEGER NOT NUll,
|
||||||
raw_log JSONB,
|
raw_log JSONB,
|
||||||
UNIQUE (header_id, tx_idx)
|
UNIQUE (header_id, tx_idx)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
CREATE TABLE maker.pit_file_stability_fee (
|
||||||
|
id SERIAL PRIMARY KEY,
|
||||||
|
header_id INTEGER NOT NULL REFERENCES headers (id) ON DELETE CASCADE,
|
||||||
|
what TEXT,
|
||||||
|
data TEXT,
|
||||||
|
tx_idx INTEGER NOT NULL,
|
||||||
|
raw_log JSONB,
|
||||||
|
UNIQUE (header_id, tx_idx)
|
||||||
|
)
|
101
db/schema.sql
101
db/schema.sql
@ -157,25 +157,25 @@ ALTER SEQUENCE maker.frob_id_seq OWNED BY maker.frob.id;
|
|||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Name: pit_file; Type: TABLE; Schema: maker; Owner: -
|
-- Name: pit_file_ilk; Type: TABLE; Schema: maker; Owner: -
|
||||||
--
|
--
|
||||||
|
|
||||||
CREATE TABLE maker.pit_file (
|
CREATE TABLE maker.pit_file_ilk (
|
||||||
id integer NOT NULL,
|
id integer NOT NULL,
|
||||||
header_id integer NOT NULL,
|
header_id integer NOT NULL,
|
||||||
ilk text,
|
ilk text,
|
||||||
what text,
|
what text,
|
||||||
risk numeric,
|
data numeric,
|
||||||
tx_idx integer NOT NULL,
|
tx_idx integer NOT NULL,
|
||||||
raw_log jsonb
|
raw_log jsonb
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Name: pit_file_id_seq; Type: SEQUENCE; Schema: maker; Owner: -
|
-- Name: pit_file_ilk_id_seq; Type: SEQUENCE; Schema: maker; Owner: -
|
||||||
--
|
--
|
||||||
|
|
||||||
CREATE SEQUENCE maker.pit_file_id_seq
|
CREATE SEQUENCE maker.pit_file_ilk_id_seq
|
||||||
AS integer
|
AS integer
|
||||||
START WITH 1
|
START WITH 1
|
||||||
INCREMENT BY 1
|
INCREMENT BY 1
|
||||||
@ -185,10 +185,44 @@ CREATE SEQUENCE maker.pit_file_id_seq
|
|||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Name: pit_file_id_seq; Type: SEQUENCE OWNED BY; Schema: maker; Owner: -
|
-- Name: pit_file_ilk_id_seq; Type: SEQUENCE OWNED BY; Schema: maker; Owner: -
|
||||||
--
|
--
|
||||||
|
|
||||||
ALTER SEQUENCE maker.pit_file_id_seq OWNED BY maker.pit_file.id;
|
ALTER SEQUENCE maker.pit_file_ilk_id_seq OWNED BY maker.pit_file_ilk.id;
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: pit_file_stability_fee; Type: TABLE; Schema: maker; Owner: -
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE maker.pit_file_stability_fee (
|
||||||
|
id integer NOT NULL,
|
||||||
|
header_id integer NOT NULL,
|
||||||
|
what text,
|
||||||
|
data text,
|
||||||
|
tx_idx integer NOT NULL,
|
||||||
|
raw_log jsonb
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: pit_file_stability_fee_id_seq; Type: SEQUENCE; Schema: maker; Owner: -
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE SEQUENCE maker.pit_file_stability_fee_id_seq
|
||||||
|
AS integer
|
||||||
|
START WITH 1
|
||||||
|
INCREMENT BY 1
|
||||||
|
NO MINVALUE
|
||||||
|
NO MAXVALUE
|
||||||
|
CACHE 1;
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: pit_file_stability_fee_id_seq; Type: SEQUENCE OWNED BY; Schema: maker; Owner: -
|
||||||
|
--
|
||||||
|
|
||||||
|
ALTER SEQUENCE maker.pit_file_stability_fee_id_seq OWNED BY maker.pit_file_stability_fee.id;
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
@ -656,10 +690,17 @@ ALTER TABLE ONLY maker.frob ALTER COLUMN id SET DEFAULT nextval('maker.frob_id_s
|
|||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Name: pit_file id; Type: DEFAULT; Schema: maker; Owner: -
|
-- Name: pit_file_ilk id; Type: DEFAULT; Schema: maker; Owner: -
|
||||||
--
|
--
|
||||||
|
|
||||||
ALTER TABLE ONLY maker.pit_file ALTER COLUMN id SET DEFAULT nextval('maker.pit_file_id_seq'::regclass);
|
ALTER TABLE ONLY maker.pit_file_ilk ALTER COLUMN id SET DEFAULT nextval('maker.pit_file_ilk_id_seq'::regclass);
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: pit_file_stability_fee id; Type: DEFAULT; Schema: maker; Owner: -
|
||||||
|
--
|
||||||
|
|
||||||
|
ALTER TABLE ONLY maker.pit_file_stability_fee ALTER COLUMN id SET DEFAULT nextval('maker.pit_file_stability_fee_id_seq'::regclass);
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
@ -788,19 +829,35 @@ ALTER TABLE ONLY maker.frob
|
|||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Name: pit_file pit_file_header_id_tx_idx_key; Type: CONSTRAINT; Schema: maker; Owner: -
|
-- Name: pit_file_ilk pit_file_ilk_header_id_tx_idx_key; Type: CONSTRAINT; Schema: maker; Owner: -
|
||||||
--
|
--
|
||||||
|
|
||||||
ALTER TABLE ONLY maker.pit_file
|
ALTER TABLE ONLY maker.pit_file_ilk
|
||||||
ADD CONSTRAINT pit_file_header_id_tx_idx_key UNIQUE (header_id, tx_idx);
|
ADD CONSTRAINT pit_file_ilk_header_id_tx_idx_key UNIQUE (header_id, tx_idx);
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Name: pit_file pit_file_pkey; Type: CONSTRAINT; Schema: maker; Owner: -
|
-- Name: pit_file_ilk pit_file_ilk_pkey; Type: CONSTRAINT; Schema: maker; Owner: -
|
||||||
--
|
--
|
||||||
|
|
||||||
ALTER TABLE ONLY maker.pit_file
|
ALTER TABLE ONLY maker.pit_file_ilk
|
||||||
ADD CONSTRAINT pit_file_pkey PRIMARY KEY (id);
|
ADD CONSTRAINT pit_file_ilk_pkey PRIMARY KEY (id);
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: pit_file_stability_fee pit_file_stability_fee_header_id_tx_idx_key; Type: CONSTRAINT; Schema: maker; Owner: -
|
||||||
|
--
|
||||||
|
|
||||||
|
ALTER TABLE ONLY maker.pit_file_stability_fee
|
||||||
|
ADD CONSTRAINT pit_file_stability_fee_header_id_tx_idx_key UNIQUE (header_id, tx_idx);
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: pit_file_stability_fee pit_file_stability_fee_pkey; Type: CONSTRAINT; Schema: maker; Owner: -
|
||||||
|
--
|
||||||
|
|
||||||
|
ALTER TABLE ONLY maker.pit_file_stability_fee
|
||||||
|
ADD CONSTRAINT pit_file_stability_fee_pkey PRIMARY KEY (id);
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
@ -999,11 +1056,19 @@ ALTER TABLE ONLY maker.price_feeds
|
|||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Name: pit_file pit_file_header_id_fkey; Type: FK CONSTRAINT; Schema: maker; Owner: -
|
-- Name: pit_file_ilk pit_file_ilk_header_id_fkey; Type: FK CONSTRAINT; Schema: maker; Owner: -
|
||||||
--
|
--
|
||||||
|
|
||||||
ALTER TABLE ONLY maker.pit_file
|
ALTER TABLE ONLY maker.pit_file_ilk
|
||||||
ADD CONSTRAINT pit_file_header_id_fkey FOREIGN KEY (header_id) REFERENCES public.headers(id) ON DELETE CASCADE;
|
ADD CONSTRAINT pit_file_ilk_header_id_fkey FOREIGN KEY (header_id) REFERENCES public.headers(id) ON DELETE CASCADE;
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: pit_file_stability_fee pit_file_stability_fee_header_id_fkey; Type: FK CONSTRAINT; Schema: maker; Owner: -
|
||||||
|
--
|
||||||
|
|
||||||
|
ALTER TABLE ONLY maker.pit_file_stability_fee
|
||||||
|
ADD CONSTRAINT pit_file_stability_fee_header_id_fkey FOREIGN KEY (header_id) REFERENCES public.headers(id) ON DELETE CASCADE;
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
|
@ -7,7 +7,7 @@ import (
|
|||||||
var PitFileConfig = shared.TransformerConfig{
|
var PitFileConfig = shared.TransformerConfig{
|
||||||
ContractAddress: "0xff3f2400f1600f3f493a9a92704a29b96795af1a", // temporary address from Ganache deploy
|
ContractAddress: "0xff3f2400f1600f3f493a9a92704a29b96795af1a", // temporary address from Ganache deploy
|
||||||
ContractAbi: shared.PitABI,
|
ContractAbi: shared.PitABI,
|
||||||
Topics: []string{shared.PitFileSignatureOne},
|
Topics: []string{shared.PitFileIlkSignature, shared.PitFileDebtCeilingSignature, shared.PitFileStabilityFeeSignature},
|
||||||
StartingBlockNumber: 0,
|
StartingBlockNumber: 0,
|
||||||
EndingBlockNumber: 100,
|
EndingBlockNumber: 100,
|
||||||
}
|
}
|
||||||
|
@ -1,20 +0,0 @@
|
|||||||
package pit_file_test
|
|
||||||
|
|
||||||
import (
|
|
||||||
. "github.com/onsi/ginkgo"
|
|
||||||
. "github.com/onsi/gomega"
|
|
||||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/pit_file"
|
|
||||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
|
|
||||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
|
|
||||||
)
|
|
||||||
|
|
||||||
var _ = Describe("Pit file converter", func() {
|
|
||||||
It("converts a log to an entity", func() {
|
|
||||||
converter := pit_file.PitFileConverter{}
|
|
||||||
|
|
||||||
model, err := converter.ToModel(test_data.PitAddress, shared.PitABI, test_data.EthPitFileLog)
|
|
||||||
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
|
||||||
Expect(model).To(Equal(test_data.PitFileModel))
|
|
||||||
})
|
|
||||||
})
|
|
@ -0,0 +1,13 @@
|
|||||||
|
package debt_ceiling_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
. "github.com/onsi/ginkgo"
|
||||||
|
. "github.com/onsi/gomega"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestDebtCeiling(t *testing.T) {
|
||||||
|
RegisterFailHandler(Fail)
|
||||||
|
RunSpecs(t, "DebtCeiling Suite")
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package pit_file
|
package ilk
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
@ -8,13 +8,12 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Converter interface {
|
type Converter interface {
|
||||||
ToModel(contractAddress string, contractAbi string, ethLog types.Log) (PitFileModel, error)
|
ToModel(contractAddress string, contractAbi string, ethLog types.Log) (PitFileIlkModel, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type PitFileConverter struct {
|
type PitFileIlkConverter struct{}
|
||||||
}
|
|
||||||
|
|
||||||
func (PitFileConverter) ToModel(contractAddress string, contractAbi string, ethLog types.Log) (entity PitFileModel, err error) {
|
func (PitFileIlkConverter) ToModel(contractAddress string, contractAbi string, ethLog types.Log) (entity PitFileIlkModel, err error) {
|
||||||
ilk := string(bytes.Trim(ethLog.Topics[2].Bytes(), "\x00"))
|
ilk := string(bytes.Trim(ethLog.Topics[2].Bytes(), "\x00"))
|
||||||
what := string(bytes.Trim(ethLog.Topics[3].Bytes(), "\x00"))
|
what := string(bytes.Trim(ethLog.Topics[3].Bytes(), "\x00"))
|
||||||
itemByteLength := 32
|
itemByteLength := 32
|
||||||
@ -22,10 +21,10 @@ func (PitFileConverter) ToModel(contractAddress string, contractAbi string, ethL
|
|||||||
risk := big.NewInt(0).SetBytes(riskBytes).String()
|
risk := big.NewInt(0).SetBytes(riskBytes).String()
|
||||||
|
|
||||||
raw, err := json.Marshal(ethLog)
|
raw, err := json.Marshal(ethLog)
|
||||||
return PitFileModel{
|
return PitFileIlkModel{
|
||||||
Ilk: ilk,
|
Ilk: ilk,
|
||||||
What: what,
|
What: what,
|
||||||
Risk: risk,
|
Data: risk,
|
||||||
TransactionIndex: ethLog.TxIndex,
|
TransactionIndex: ethLog.TxIndex,
|
||||||
Raw: raw,
|
Raw: raw,
|
||||||
}, err
|
}, err
|
20
pkg/transformers/pit_file/ilk/converter_test.go
Normal file
20
pkg/transformers/pit_file/ilk/converter_test.go
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
package ilk_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
. "github.com/onsi/ginkgo"
|
||||||
|
. "github.com/onsi/gomega"
|
||||||
|
"github.com/vulcanize/vulcanizedb/pkg/transformers/pit_file/ilk"
|
||||||
|
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
|
||||||
|
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
|
||||||
|
)
|
||||||
|
|
||||||
|
var _ = Describe("Pit file ilk converter", func() {
|
||||||
|
It("converts a log to an model", func() {
|
||||||
|
converter := ilk.PitFileIlkConverter{}
|
||||||
|
|
||||||
|
model, err := converter.ToModel(test_data.PitAddress, shared.PitABI, test_data.EthPitFileIlkLog)
|
||||||
|
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
Expect(model).To(Equal(test_data.PitFileIlkModel))
|
||||||
|
})
|
||||||
|
})
|
@ -1,4 +1,4 @@
|
|||||||
package pit_file_test
|
package ilk_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
@ -7,7 +7,7 @@ import (
|
|||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestPitFile(t *testing.T) {
|
func TestIlk(t *testing.T) {
|
||||||
RegisterFailHandler(Fail)
|
RegisterFailHandler(Fail)
|
||||||
RunSpecs(t, "PitFile Suite")
|
RunSpecs(t, "Ilk Suite")
|
||||||
}
|
}
|
@ -1,9 +1,9 @@
|
|||||||
package pit_file
|
package ilk
|
||||||
|
|
||||||
type PitFileModel struct {
|
type PitFileIlkModel struct {
|
||||||
Ilk string
|
Ilk string
|
||||||
What string
|
What string
|
||||||
Risk string
|
Data string
|
||||||
TransactionIndex uint `db:"tx_idx"`
|
TransactionIndex uint `db:"tx_idx"`
|
||||||
Raw []byte `db:"raw_log"`
|
Raw []byte `db:"raw_log"`
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package pit_file
|
package ilk
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/vulcanize/vulcanizedb/pkg/core"
|
"github.com/vulcanize/vulcanizedb/pkg/core"
|
||||||
@ -6,35 +6,35 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Repository interface {
|
type Repository interface {
|
||||||
Create(headerID int64, transactionIndex uint, model PitFileModel) error
|
Create(headerID int64, model PitFileIlkModel) error
|
||||||
MissingHeaders(startingBlockNumber, endingBlockNumber int64) ([]core.Header, error)
|
MissingHeaders(startingBlockNumber, endingBlockNumber int64) ([]core.Header, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type PitFileRepository struct {
|
type PitFileIlkRepository struct {
|
||||||
db *postgres.DB
|
db *postgres.DB
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewPitFileRepository(db *postgres.DB) PitFileRepository {
|
func NewPitFileIlkRepository(db *postgres.DB) PitFileIlkRepository {
|
||||||
return PitFileRepository{
|
return PitFileIlkRepository{
|
||||||
db: db,
|
db: db,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (repository PitFileRepository) Create(headerID int64, transactionIndex uint, model PitFileModel) error {
|
func (repository PitFileIlkRepository) Create(headerID int64, model PitFileIlkModel) error {
|
||||||
_, err := repository.db.Exec(
|
_, err := repository.db.Exec(
|
||||||
`INSERT into maker.pit_file (header_id, ilk, what, risk, tx_idx, raw_log)
|
`INSERT into maker.pit_file_ilk (header_id, ilk, what, data, tx_idx, raw_log)
|
||||||
VALUES($1, $2, $3, $4::NUMERIC, $5, $6)`,
|
VALUES($1, $2, $3, $4::NUMERIC, $5, $6)`,
|
||||||
headerID, model.Ilk, model.What, model.Risk, model.TransactionIndex, model.Raw,
|
headerID, model.Ilk, model.What, model.Data, model.TransactionIndex, model.Raw,
|
||||||
)
|
)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (repository PitFileRepository) MissingHeaders(startingBlockNumber, endingBlockNumber int64) ([]core.Header, error) {
|
func (repository PitFileIlkRepository) MissingHeaders(startingBlockNumber, endingBlockNumber int64) ([]core.Header, error) {
|
||||||
var result []core.Header
|
var result []core.Header
|
||||||
err := repository.db.Select(
|
err := repository.db.Select(
|
||||||
&result,
|
&result,
|
||||||
`SELECT headers.id, headers.block_number FROM headers
|
`SELECT headers.id, headers.block_number FROM headers
|
||||||
LEFT JOIN maker.pit_file on headers.id = header_id
|
LEFT JOIN maker.pit_file_ilk on headers.id = header_id
|
||||||
WHERE header_id ISNULL
|
WHERE header_id ISNULL
|
||||||
AND headers.block_number >= $1
|
AND headers.block_number >= $1
|
||||||
AND headers.block_number <= $2
|
AND headers.block_number <= $2
|
129
pkg/transformers/pit_file/ilk/repository_test.go
Normal file
129
pkg/transformers/pit_file/ilk/repository_test.go
Normal file
@ -0,0 +1,129 @@
|
|||||||
|
package ilk_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
"database/sql"
|
||||||
|
. "github.com/onsi/ginkgo"
|
||||||
|
. "github.com/onsi/gomega"
|
||||||
|
"github.com/vulcanize/vulcanizedb/pkg/core"
|
||||||
|
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres/repositories"
|
||||||
|
"github.com/vulcanize/vulcanizedb/pkg/transformers/pit_file/ilk"
|
||||||
|
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
|
||||||
|
"github.com/vulcanize/vulcanizedb/test_config"
|
||||||
|
)
|
||||||
|
|
||||||
|
var _ = Describe("Pit file ilk repository", func() {
|
||||||
|
Describe("Create", func() {
|
||||||
|
It("adds a pit file ilk event", func() {
|
||||||
|
db := test_config.NewTestDB(core.Node{})
|
||||||
|
test_config.CleanTestDB(db)
|
||||||
|
headerRepository := repositories.NewHeaderRepository(db)
|
||||||
|
headerID, err := headerRepository.CreateOrUpdateHeader(core.Header{})
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
pitFileRepository := ilk.NewPitFileIlkRepository(db)
|
||||||
|
|
||||||
|
err = pitFileRepository.Create(headerID, test_data.PitFileIlkModel)
|
||||||
|
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
var dbPitFile ilk.PitFileIlkModel
|
||||||
|
err = db.Get(&dbPitFile, `SELECT ilk, what, data, tx_idx, raw_log FROM maker.pit_file_ilk WHERE header_id = $1`, headerID)
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
Expect(dbPitFile.Ilk).To(Equal(test_data.PitFileIlkModel.Ilk))
|
||||||
|
Expect(dbPitFile.What).To(Equal(test_data.PitFileIlkModel.What))
|
||||||
|
Expect(dbPitFile.Data).To(Equal(test_data.PitFileIlkModel.Data))
|
||||||
|
Expect(dbPitFile.TransactionIndex).To(Equal(test_data.PitFileIlkModel.TransactionIndex))
|
||||||
|
Expect(dbPitFile.Raw).To(MatchJSON(test_data.PitFileIlkModel.Raw))
|
||||||
|
})
|
||||||
|
|
||||||
|
It("does not duplicate pit file ilk events", func() {
|
||||||
|
db := test_config.NewTestDB(core.Node{})
|
||||||
|
test_config.CleanTestDB(db)
|
||||||
|
headerRepository := repositories.NewHeaderRepository(db)
|
||||||
|
headerID, err := headerRepository.CreateOrUpdateHeader(core.Header{})
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
pitFileRepository := ilk.NewPitFileIlkRepository(db)
|
||||||
|
err = pitFileRepository.Create(headerID, test_data.PitFileIlkModel)
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
|
||||||
|
err = pitFileRepository.Create(headerID, test_data.PitFileIlkModel)
|
||||||
|
|
||||||
|
Expect(err).To(HaveOccurred())
|
||||||
|
Expect(err.Error()).To(ContainSubstring("pq: duplicate key value violates unique constraint"))
|
||||||
|
})
|
||||||
|
|
||||||
|
It("removes pit file ilk if corresponding header is deleted", func() {
|
||||||
|
db := test_config.NewTestDB(core.Node{})
|
||||||
|
test_config.CleanTestDB(db)
|
||||||
|
headerRepository := repositories.NewHeaderRepository(db)
|
||||||
|
headerID, err := headerRepository.CreateOrUpdateHeader(core.Header{})
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
pitFileRepository := ilk.NewPitFileIlkRepository(db)
|
||||||
|
err = pitFileRepository.Create(headerID, test_data.PitFileIlkModel)
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
|
||||||
|
_, err = db.Exec(`DELETE FROM headers WHERE id = $1`, headerID)
|
||||||
|
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
var dbPitFile ilk.PitFileIlkModel
|
||||||
|
err = db.Get(&dbPitFile, `SELECT ilk, what, data, tx_idx, raw_log FROM maker.pit_file_ilk WHERE header_id = $1`, headerID)
|
||||||
|
Expect(err).To(HaveOccurred())
|
||||||
|
Expect(err).To(MatchError(sql.ErrNoRows))
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
Describe("MissingHeaders", func() {
|
||||||
|
It("returns headers with no associated pit file ilk event", func() {
|
||||||
|
db := test_config.NewTestDB(core.Node{})
|
||||||
|
test_config.CleanTestDB(db)
|
||||||
|
headerRepository := repositories.NewHeaderRepository(db)
|
||||||
|
startingBlockNumber := int64(1)
|
||||||
|
pitFileBlockNumber := int64(2)
|
||||||
|
endingBlockNumber := int64(3)
|
||||||
|
blockNumbers := []int64{startingBlockNumber, pitFileBlockNumber, endingBlockNumber, endingBlockNumber + 1}
|
||||||
|
var headerIDs []int64
|
||||||
|
for _, n := range blockNumbers {
|
||||||
|
headerID, err := headerRepository.CreateOrUpdateHeader(core.Header{BlockNumber: n})
|
||||||
|
headerIDs = append(headerIDs, headerID)
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
}
|
||||||
|
pitFileRepository := ilk.NewPitFileIlkRepository(db)
|
||||||
|
err := pitFileRepository.Create(headerIDs[1], test_data.PitFileIlkModel)
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
|
||||||
|
headers, err := pitFileRepository.MissingHeaders(startingBlockNumber, endingBlockNumber)
|
||||||
|
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
Expect(len(headers)).To(Equal(2))
|
||||||
|
Expect(headers[0].BlockNumber).To(Or(Equal(startingBlockNumber), Equal(endingBlockNumber)))
|
||||||
|
Expect(headers[1].BlockNumber).To(Or(Equal(startingBlockNumber), Equal(endingBlockNumber)))
|
||||||
|
})
|
||||||
|
|
||||||
|
It("only returns headers associated with the current node", func() {
|
||||||
|
db := test_config.NewTestDB(core.Node{})
|
||||||
|
test_config.CleanTestDB(db)
|
||||||
|
blockNumbers := []int64{1, 2, 3}
|
||||||
|
headerRepository := repositories.NewHeaderRepository(db)
|
||||||
|
dbTwo := test_config.NewTestDB(core.Node{ID: "second"})
|
||||||
|
headerRepositoryTwo := repositories.NewHeaderRepository(dbTwo)
|
||||||
|
var headerIDs []int64
|
||||||
|
for _, n := range blockNumbers {
|
||||||
|
headerID, err := headerRepository.CreateOrUpdateHeader(core.Header{BlockNumber: n})
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
headerIDs = append(headerIDs, headerID)
|
||||||
|
_, err = headerRepositoryTwo.CreateOrUpdateHeader(core.Header{BlockNumber: n})
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
}
|
||||||
|
pitFileRepository := ilk.NewPitFileIlkRepository(db)
|
||||||
|
pitFileRepositoryTwo := ilk.NewPitFileIlkRepository(dbTwo)
|
||||||
|
err := pitFileRepository.Create(headerIDs[0], test_data.PitFileIlkModel)
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
|
||||||
|
nodeOneMissingHeaders, err := pitFileRepository.MissingHeaders(blockNumbers[0], blockNumbers[len(blockNumbers)-1])
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
Expect(len(nodeOneMissingHeaders)).To(Equal(len(blockNumbers) - 1))
|
||||||
|
|
||||||
|
nodeTwoMissingHeaders, err := pitFileRepositoryTwo.MissingHeaders(blockNumbers[0], blockNumbers[len(blockNumbers)-1])
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
Expect(len(nodeTwoMissingHeaders)).To(Equal(len(blockNumbers)))
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
@ -1,28 +1,29 @@
|
|||||||
package pit_file
|
package ilk
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"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/transformers/pit_file"
|
||||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
|
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
|
||||||
)
|
)
|
||||||
|
|
||||||
type PitFileTransformer struct {
|
type PitFileIlkTransformer struct {
|
||||||
Config shared.TransformerConfig
|
Config shared.TransformerConfig
|
||||||
Converter Converter
|
Converter Converter
|
||||||
Fetcher shared.LogFetcher
|
Fetcher shared.LogFetcher
|
||||||
Repository Repository
|
Repository Repository
|
||||||
}
|
}
|
||||||
|
|
||||||
type PitFileTransformerInitializer struct {
|
type PitFileIlkTransformerInitializer struct {
|
||||||
Config shared.TransformerConfig
|
Config shared.TransformerConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
func (initializer PitFileTransformerInitializer) NewPitFileTransformer(db *postgres.DB, blockChain core.BlockChain) shared.Transformer {
|
func (initializer PitFileIlkTransformerInitializer) NewPitFileIlkTransformer(db *postgres.DB, blockChain core.BlockChain) shared.Transformer {
|
||||||
converter := PitFileConverter{}
|
converter := PitFileIlkConverter{}
|
||||||
fetcher := shared.NewFetcher(blockChain)
|
fetcher := shared.NewFetcher(blockChain)
|
||||||
repository := NewPitFileRepository(db)
|
repository := NewPitFileIlkRepository(db)
|
||||||
return PitFileTransformer{
|
return PitFileIlkTransformer{
|
||||||
Config: initializer.Config,
|
Config: initializer.Config,
|
||||||
Converter: converter,
|
Converter: converter,
|
||||||
Fetcher: fetcher,
|
Fetcher: fetcher,
|
||||||
@ -30,23 +31,23 @@ func (initializer PitFileTransformerInitializer) NewPitFileTransformer(db *postg
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (transformer PitFileTransformer) Execute() error {
|
func (transformer PitFileIlkTransformer) Execute() error {
|
||||||
missingHeaders, err := transformer.Repository.MissingHeaders(transformer.Config.StartingBlockNumber, transformer.Config.EndingBlockNumber)
|
missingHeaders, err := transformer.Repository.MissingHeaders(transformer.Config.StartingBlockNumber, transformer.Config.EndingBlockNumber)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
for _, header := range missingHeaders {
|
for _, header := range missingHeaders {
|
||||||
topics := [][]common.Hash{{common.HexToHash(shared.PitFileSignatureOne)}}
|
topics := [][]common.Hash{{common.HexToHash(shared.PitFileIlkSignature)}}
|
||||||
matchingLogs, err := transformer.Fetcher.FetchLogs(PitFileConfig.ContractAddress, topics, header.BlockNumber)
|
matchingLogs, err := transformer.Fetcher.FetchLogs(pit_file.PitFileConfig.ContractAddress, topics, header.BlockNumber)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
for _, log := range matchingLogs {
|
for _, log := range matchingLogs {
|
||||||
model, err := transformer.Converter.ToModel(PitFileConfig.ContractAddress, shared.PitABI, log)
|
model, err := transformer.Converter.ToModel(pit_file.PitFileConfig.ContractAddress, shared.PitABI, log)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
err = transformer.Repository.Create(header.Id, log.TxIndex, model)
|
err = transformer.Repository.Create(header.Id, model)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package pit_file_test
|
package ilk_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
@ -8,19 +8,20 @@ import (
|
|||||||
"github.com/vulcanize/vulcanizedb/pkg/core"
|
"github.com/vulcanize/vulcanizedb/pkg/core"
|
||||||
"github.com/vulcanize/vulcanizedb/pkg/fakes"
|
"github.com/vulcanize/vulcanizedb/pkg/fakes"
|
||||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/pit_file"
|
"github.com/vulcanize/vulcanizedb/pkg/transformers/pit_file"
|
||||||
|
"github.com/vulcanize/vulcanizedb/pkg/transformers/pit_file/ilk"
|
||||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
|
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
|
||||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
|
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
|
||||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data/mocks"
|
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data/mocks"
|
||||||
pit_file_mocks "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data/mocks/pit_file"
|
pit_file_ilk_mocks "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data/mocks/pit_file/ilk"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ = Describe("Pit file transformer", func() {
|
var _ = Describe("Pit file ilk transformer", func() {
|
||||||
It("gets missing headers for block numbers specified in config", func() {
|
It("gets missing headers for block numbers specified in config", func() {
|
||||||
repository := &pit_file_mocks.MockPitFileRepository{}
|
repository := &pit_file_ilk_mocks.MockPitFileIlkRepository{}
|
||||||
transformer := pit_file.PitFileTransformer{
|
transformer := ilk.PitFileIlkTransformer{
|
||||||
Config: pit_file.PitFileConfig,
|
Config: pit_file.PitFileConfig,
|
||||||
Fetcher: &mocks.MockLogFetcher{},
|
Fetcher: &mocks.MockLogFetcher{},
|
||||||
Converter: &pit_file_mocks.MockPitFileConverter{},
|
Converter: &pit_file_ilk_mocks.MockPitFileIlkConverter{},
|
||||||
Repository: repository,
|
Repository: repository,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -32,11 +33,11 @@ var _ = Describe("Pit file transformer", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
It("returns error if repository returns error for missing headers", func() {
|
It("returns error if repository returns error for missing headers", func() {
|
||||||
repository := &pit_file_mocks.MockPitFileRepository{}
|
repository := &pit_file_ilk_mocks.MockPitFileIlkRepository{}
|
||||||
repository.SetMissingHeadersErr(fakes.FakeError)
|
repository.SetMissingHeadersErr(fakes.FakeError)
|
||||||
transformer := pit_file.PitFileTransformer{
|
transformer := ilk.PitFileIlkTransformer{
|
||||||
Fetcher: &mocks.MockLogFetcher{},
|
Fetcher: &mocks.MockLogFetcher{},
|
||||||
Converter: &pit_file_mocks.MockPitFileConverter{},
|
Converter: &pit_file_ilk_mocks.MockPitFileIlkConverter{},
|
||||||
Repository: repository,
|
Repository: repository,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,11 +49,11 @@ var _ = Describe("Pit file transformer", func() {
|
|||||||
|
|
||||||
It("fetches logs for missing headers", func() {
|
It("fetches logs for missing headers", func() {
|
||||||
fetcher := &mocks.MockLogFetcher{}
|
fetcher := &mocks.MockLogFetcher{}
|
||||||
repository := &pit_file_mocks.MockPitFileRepository{}
|
repository := &pit_file_ilk_mocks.MockPitFileIlkRepository{}
|
||||||
repository.SetMissingHeaders([]core.Header{{BlockNumber: 1}, {BlockNumber: 2}})
|
repository.SetMissingHeaders([]core.Header{{BlockNumber: 1}, {BlockNumber: 2}})
|
||||||
transformer := pit_file.PitFileTransformer{
|
transformer := ilk.PitFileIlkTransformer{
|
||||||
Fetcher: fetcher,
|
Fetcher: fetcher,
|
||||||
Converter: &pit_file_mocks.MockPitFileConverter{},
|
Converter: &pit_file_ilk_mocks.MockPitFileIlkConverter{},
|
||||||
Repository: repository,
|
Repository: repository,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,17 +62,17 @@ var _ = Describe("Pit file transformer", func() {
|
|||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(fetcher.FetchedBlocks).To(Equal([]int64{1, 2}))
|
Expect(fetcher.FetchedBlocks).To(Equal([]int64{1, 2}))
|
||||||
Expect(fetcher.FetchedContractAddress).To(Equal(pit_file.PitFileConfig.ContractAddress))
|
Expect(fetcher.FetchedContractAddress).To(Equal(pit_file.PitFileConfig.ContractAddress))
|
||||||
Expect(fetcher.FetchedTopics).To(Equal([][]common.Hash{{common.HexToHash(shared.PitFileSignatureOne)}}))
|
Expect(fetcher.FetchedTopics).To(Equal([][]common.Hash{{common.HexToHash(shared.PitFileIlkSignature)}}))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("returns error if fetcher returns error", func() {
|
It("returns error if fetcher returns error", func() {
|
||||||
fetcher := &mocks.MockLogFetcher{}
|
fetcher := &mocks.MockLogFetcher{}
|
||||||
fetcher.SetFetcherError(fakes.FakeError)
|
fetcher.SetFetcherError(fakes.FakeError)
|
||||||
repository := &pit_file_mocks.MockPitFileRepository{}
|
repository := &pit_file_ilk_mocks.MockPitFileIlkRepository{}
|
||||||
repository.SetMissingHeaders([]core.Header{{BlockNumber: 1}})
|
repository.SetMissingHeaders([]core.Header{{BlockNumber: 1}})
|
||||||
transformer := pit_file.PitFileTransformer{
|
transformer := ilk.PitFileIlkTransformer{
|
||||||
Fetcher: fetcher,
|
Fetcher: fetcher,
|
||||||
Converter: &pit_file_mocks.MockPitFileConverter{},
|
Converter: &pit_file_ilk_mocks.MockPitFileIlkConverter{},
|
||||||
Repository: repository,
|
Repository: repository,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,12 +83,12 @@ var _ = Describe("Pit file transformer", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
It("converts matching logs", func() {
|
It("converts matching logs", func() {
|
||||||
converter := &pit_file_mocks.MockPitFileConverter{}
|
converter := &pit_file_ilk_mocks.MockPitFileIlkConverter{}
|
||||||
fetcher := &mocks.MockLogFetcher{}
|
fetcher := &mocks.MockLogFetcher{}
|
||||||
fetcher.SetFetchedLogs([]types.Log{test_data.EthPitFileLog})
|
fetcher.SetFetchedLogs([]types.Log{test_data.EthPitFileIlkLog})
|
||||||
repository := &pit_file_mocks.MockPitFileRepository{}
|
repository := &pit_file_ilk_mocks.MockPitFileIlkRepository{}
|
||||||
repository.SetMissingHeaders([]core.Header{{BlockNumber: 1}})
|
repository.SetMissingHeaders([]core.Header{{BlockNumber: 1}})
|
||||||
transformer := pit_file.PitFileTransformer{
|
transformer := ilk.PitFileIlkTransformer{
|
||||||
Fetcher: fetcher,
|
Fetcher: fetcher,
|
||||||
Converter: converter,
|
Converter: converter,
|
||||||
Repository: repository,
|
Repository: repository,
|
||||||
@ -98,17 +99,17 @@ var _ = Describe("Pit file transformer", func() {
|
|||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(converter.PassedContractAddress).To(Equal(pit_file.PitFileConfig.ContractAddress))
|
Expect(converter.PassedContractAddress).To(Equal(pit_file.PitFileConfig.ContractAddress))
|
||||||
Expect(converter.PassedContractABI).To(Equal(pit_file.PitFileConfig.ContractAbi))
|
Expect(converter.PassedContractABI).To(Equal(pit_file.PitFileConfig.ContractAbi))
|
||||||
Expect(converter.PassedLog).To(Equal(test_data.EthPitFileLog))
|
Expect(converter.PassedLog).To(Equal(test_data.EthPitFileIlkLog))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("returns error if converter returns error", func() {
|
It("returns error if converter returns error", func() {
|
||||||
converter := &pit_file_mocks.MockPitFileConverter{}
|
converter := &pit_file_ilk_mocks.MockPitFileIlkConverter{}
|
||||||
converter.SetConverterError(fakes.FakeError)
|
converter.SetConverterError(fakes.FakeError)
|
||||||
fetcher := &mocks.MockLogFetcher{}
|
fetcher := &mocks.MockLogFetcher{}
|
||||||
fetcher.SetFetchedLogs([]types.Log{test_data.EthPitFileLog})
|
fetcher.SetFetchedLogs([]types.Log{test_data.EthPitFileIlkLog})
|
||||||
repository := &pit_file_mocks.MockPitFileRepository{}
|
repository := &pit_file_ilk_mocks.MockPitFileIlkRepository{}
|
||||||
repository.SetMissingHeaders([]core.Header{{BlockNumber: 1}})
|
repository.SetMissingHeaders([]core.Header{{BlockNumber: 1}})
|
||||||
transformer := pit_file.PitFileTransformer{
|
transformer := ilk.PitFileIlkTransformer{
|
||||||
Fetcher: fetcher,
|
Fetcher: fetcher,
|
||||||
Converter: converter,
|
Converter: converter,
|
||||||
Repository: repository,
|
Repository: repository,
|
||||||
@ -121,13 +122,13 @@ var _ = Describe("Pit file transformer", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
It("persists pit file model", func() {
|
It("persists pit file model", func() {
|
||||||
converter := &pit_file_mocks.MockPitFileConverter{}
|
converter := &pit_file_ilk_mocks.MockPitFileIlkConverter{}
|
||||||
fetcher := &mocks.MockLogFetcher{}
|
fetcher := &mocks.MockLogFetcher{}
|
||||||
fetcher.SetFetchedLogs([]types.Log{test_data.EthPitFileLog})
|
fetcher.SetFetchedLogs([]types.Log{test_data.EthPitFileIlkLog})
|
||||||
repository := &pit_file_mocks.MockPitFileRepository{}
|
repository := &pit_file_ilk_mocks.MockPitFileIlkRepository{}
|
||||||
fakeHeader := core.Header{BlockNumber: 1, Id: 2}
|
fakeHeader := core.Header{BlockNumber: 1, Id: 2}
|
||||||
repository.SetMissingHeaders([]core.Header{fakeHeader})
|
repository.SetMissingHeaders([]core.Header{fakeHeader})
|
||||||
transformer := pit_file.PitFileTransformer{
|
transformer := ilk.PitFileIlkTransformer{
|
||||||
Fetcher: fetcher,
|
Fetcher: fetcher,
|
||||||
Converter: converter,
|
Converter: converter,
|
||||||
Repository: repository,
|
Repository: repository,
|
||||||
@ -137,18 +138,17 @@ var _ = Describe("Pit file transformer", func() {
|
|||||||
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(repository.PassedHeaderID).To(Equal(fakeHeader.Id))
|
Expect(repository.PassedHeaderID).To(Equal(fakeHeader.Id))
|
||||||
Expect(repository.PassedTransactionIndex).To(Equal(test_data.EthPitFileLog.TxIndex))
|
Expect(repository.PassedModel).To(Equal(test_data.PitFileIlkModel))
|
||||||
Expect(repository.PassedModel).To(Equal(test_data.PitFileModel))
|
|
||||||
})
|
})
|
||||||
|
|
||||||
It("returns error if repository returns error for create", func() {
|
It("returns error if repository returns error for create", func() {
|
||||||
converter := &pit_file_mocks.MockPitFileConverter{}
|
converter := &pit_file_ilk_mocks.MockPitFileIlkConverter{}
|
||||||
fetcher := &mocks.MockLogFetcher{}
|
fetcher := &mocks.MockLogFetcher{}
|
||||||
fetcher.SetFetchedLogs([]types.Log{test_data.EthPitFileLog})
|
fetcher.SetFetchedLogs([]types.Log{test_data.EthPitFileIlkLog})
|
||||||
repository := &pit_file_mocks.MockPitFileRepository{}
|
repository := &pit_file_ilk_mocks.MockPitFileIlkRepository{}
|
||||||
repository.SetMissingHeaders([]core.Header{{BlockNumber: 1, Id: 2}})
|
repository.SetMissingHeaders([]core.Header{{BlockNumber: 1, Id: 2}})
|
||||||
repository.SetCreateError(fakes.FakeError)
|
repository.SetCreateError(fakes.FakeError)
|
||||||
transformer := pit_file.PitFileTransformer{
|
transformer := ilk.PitFileIlkTransformer{
|
||||||
Fetcher: fetcher,
|
Fetcher: fetcher,
|
||||||
Converter: converter,
|
Converter: converter,
|
||||||
Repository: repository,
|
Repository: repository,
|
27
pkg/transformers/pit_file/stability_fee/converter.go
Normal file
27
pkg/transformers/pit_file/stability_fee/converter.go
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
package stability_fee
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"encoding/json"
|
||||||
|
"github.com/ethereum/go-ethereum/common"
|
||||||
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Converter interface {
|
||||||
|
ToModel(contractAddress string, contractAbi string, ethLog types.Log) (PitFileStabilityFeeModel, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
type PitFileStabilityFeeConverter struct{}
|
||||||
|
|
||||||
|
func (PitFileStabilityFeeConverter) ToModel(contractAddress string, contractAbi string, ethLog types.Log) (PitFileStabilityFeeModel, error) {
|
||||||
|
what := string(bytes.Trim(ethLog.Topics[2].Bytes(), "\x00"))
|
||||||
|
data := common.HexToAddress(ethLog.Topics[1].String()).Hex()
|
||||||
|
|
||||||
|
raw, err := json.Marshal(ethLog)
|
||||||
|
return PitFileStabilityFeeModel{
|
||||||
|
What: what,
|
||||||
|
Data: data,
|
||||||
|
TransactionIndex: ethLog.TxIndex,
|
||||||
|
Raw: raw,
|
||||||
|
}, err
|
||||||
|
}
|
20
pkg/transformers/pit_file/stability_fee/converter_test.go
Normal file
20
pkg/transformers/pit_file/stability_fee/converter_test.go
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
package stability_fee_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
. "github.com/onsi/ginkgo"
|
||||||
|
. "github.com/onsi/gomega"
|
||||||
|
"github.com/vulcanize/vulcanizedb/pkg/transformers/pit_file/stability_fee"
|
||||||
|
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
|
||||||
|
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
|
||||||
|
)
|
||||||
|
|
||||||
|
var _ = Describe("Pit file stability fee converter", func() {
|
||||||
|
It("converts a log to an model", func() {
|
||||||
|
converter := stability_fee.PitFileStabilityFeeConverter{}
|
||||||
|
|
||||||
|
model, err := converter.ToModel(test_data.PitAddress, shared.PitABI, test_data.EthPitFileStabilityFeeLog)
|
||||||
|
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
Expect(model).To(Equal(test_data.PitFileStabilityFeeModel))
|
||||||
|
})
|
||||||
|
})
|
8
pkg/transformers/pit_file/stability_fee/model.go
Normal file
8
pkg/transformers/pit_file/stability_fee/model.go
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
package stability_fee
|
||||||
|
|
||||||
|
type PitFileStabilityFeeModel struct {
|
||||||
|
What string
|
||||||
|
Data string
|
||||||
|
TransactionIndex uint `db:"tx_idx"`
|
||||||
|
Raw []byte `db:"raw_log"`
|
||||||
|
}
|
48
pkg/transformers/pit_file/stability_fee/repository.go
Normal file
48
pkg/transformers/pit_file/stability_fee/repository.go
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
package stability_fee
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/vulcanize/vulcanizedb/pkg/core"
|
||||||
|
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Repository interface {
|
||||||
|
Create(headerID int64, model PitFileStabilityFeeModel) error
|
||||||
|
MissingHeaders(startingBlockNumber, endingBlockNumber int64) ([]core.Header, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
type PitFileStabilityFeeRepository struct {
|
||||||
|
db *postgres.DB
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewPitFileStabilityFeeRepository(db *postgres.DB) PitFileStabilityFeeRepository {
|
||||||
|
return PitFileStabilityFeeRepository{
|
||||||
|
db: db,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (repository PitFileStabilityFeeRepository) Create(headerID int64, model PitFileStabilityFeeModel) error {
|
||||||
|
_, err := repository.db.Exec(
|
||||||
|
`INSERT into maker.pit_file_stability_fee (header_id, what, data, tx_idx, raw_log)
|
||||||
|
VALUES($1, $2, $3, $4, $5)`,
|
||||||
|
headerID, model.What, model.Data, model.TransactionIndex, model.Raw,
|
||||||
|
)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (repository PitFileStabilityFeeRepository) MissingHeaders(startingBlockNumber, endingBlockNumber int64) ([]core.Header, error) {
|
||||||
|
var result []core.Header
|
||||||
|
err := repository.db.Select(
|
||||||
|
&result,
|
||||||
|
`SELECT headers.id, headers.block_number FROM headers
|
||||||
|
LEFT JOIN maker.pit_file_stability_fee on headers.id = header_id
|
||||||
|
WHERE header_id ISNULL
|
||||||
|
AND headers.block_number >= $1
|
||||||
|
AND headers.block_number <= $2
|
||||||
|
AND headers.eth_node_fingerprint = $3`,
|
||||||
|
startingBlockNumber,
|
||||||
|
endingBlockNumber,
|
||||||
|
repository.db.Node.ID,
|
||||||
|
)
|
||||||
|
|
||||||
|
return result, err
|
||||||
|
}
|
@ -1,37 +1,38 @@
|
|||||||
package pit_file_test
|
package stability_fee_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"database/sql"
|
"database/sql"
|
||||||
|
|
||||||
. "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/repositories"
|
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres/repositories"
|
||||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/pit_file"
|
"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"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ = Describe("Pit file repository", func() {
|
var _ = Describe("", func() {
|
||||||
Describe("Create", func() {
|
Describe("Create", func() {
|
||||||
It("adds a pit file event", func() {
|
It("adds a pit file stability fee event", 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)
|
||||||
headerID, err := headerRepository.CreateOrUpdateHeader(core.Header{})
|
headerID, err := headerRepository.CreateOrUpdateHeader(core.Header{})
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
pitFileRepository := pit_file.NewPitFileRepository(db)
|
pitFileRepository := stability_fee.NewPitFileStabilityFeeRepository(db)
|
||||||
|
|
||||||
err = pitFileRepository.Create(headerID, 123, test_data.PitFileModel)
|
err = pitFileRepository.Create(headerID, test_data.PitFileStabilityFeeModel)
|
||||||
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
var dbPitFile pit_file.PitFileModel
|
var dbPitFile stability_fee.PitFileStabilityFeeModel
|
||||||
err = db.Get(&dbPitFile, `SELECT ilk, what, risk, tx_idx, raw_log FROM maker.pit_file WHERE header_id = $1`, headerID)
|
err = db.Get(&dbPitFile, `SELECT what, data, tx_idx, raw_log FROM maker.pit_file_stability_fee WHERE header_id = $1`, headerID)
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(dbPitFile.Ilk).To(Equal(test_data.PitFileModel.Ilk))
|
Expect(dbPitFile.What).To(Equal(test_data.PitFileStabilityFeeModel.What))
|
||||||
Expect(dbPitFile.What).To(Equal(test_data.PitFileModel.What))
|
Expect(dbPitFile.Data).To(Equal(test_data.PitFileStabilityFeeModel.Data))
|
||||||
Expect(dbPitFile.Risk).To(Equal(test_data.PitFileModel.Risk))
|
Expect(dbPitFile.TransactionIndex).To(Equal(test_data.PitFileStabilityFeeModel.TransactionIndex))
|
||||||
Expect(dbPitFile.TransactionIndex).To(Equal(test_data.PitFileModel.TransactionIndex))
|
Expect(dbPitFile.Raw).To(MatchJSON(test_data.PitFileStabilityFeeModel.Raw))
|
||||||
Expect(dbPitFile.Raw).To(MatchJSON(test_data.PitFileModel.Raw))
|
|
||||||
})
|
})
|
||||||
|
|
||||||
It("does not duplicate pit file events", func() {
|
It("does not duplicate pit file events", func() {
|
||||||
@ -40,11 +41,11 @@ var _ = Describe("Pit file repository", func() {
|
|||||||
headerRepository := repositories.NewHeaderRepository(db)
|
headerRepository := repositories.NewHeaderRepository(db)
|
||||||
headerID, err := headerRepository.CreateOrUpdateHeader(core.Header{})
|
headerID, err := headerRepository.CreateOrUpdateHeader(core.Header{})
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
pitFileRepository := pit_file.NewPitFileRepository(db)
|
pitFileRepository := stability_fee.NewPitFileStabilityFeeRepository(db)
|
||||||
err = pitFileRepository.Create(headerID, 123, test_data.PitFileModel)
|
err = pitFileRepository.Create(headerID, test_data.PitFileStabilityFeeModel)
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
|
||||||
err = pitFileRepository.Create(headerID, 123, test_data.PitFileModel)
|
err = pitFileRepository.Create(headerID, test_data.PitFileStabilityFeeModel)
|
||||||
|
|
||||||
Expect(err).To(HaveOccurred())
|
Expect(err).To(HaveOccurred())
|
||||||
Expect(err.Error()).To(ContainSubstring("pq: duplicate key value violates unique constraint"))
|
Expect(err.Error()).To(ContainSubstring("pq: duplicate key value violates unique constraint"))
|
||||||
@ -56,15 +57,15 @@ var _ = Describe("Pit file repository", func() {
|
|||||||
headerRepository := repositories.NewHeaderRepository(db)
|
headerRepository := repositories.NewHeaderRepository(db)
|
||||||
headerID, err := headerRepository.CreateOrUpdateHeader(core.Header{})
|
headerID, err := headerRepository.CreateOrUpdateHeader(core.Header{})
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
pitFileRepository := pit_file.NewPitFileRepository(db)
|
pitFileRepository := stability_fee.NewPitFileStabilityFeeRepository(db)
|
||||||
err = pitFileRepository.Create(headerID, 123, test_data.PitFileModel)
|
err = pitFileRepository.Create(headerID, test_data.PitFileStabilityFeeModel)
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
|
||||||
_, err = db.Exec(`DELETE FROM headers WHERE id = $1`, headerID)
|
_, err = db.Exec(`DELETE FROM headers WHERE id = $1`, headerID)
|
||||||
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
var dbPitFile pit_file.PitFileModel
|
var dbPitFile stability_fee.PitFileStabilityFeeModel
|
||||||
err = db.Get(&dbPitFile, `SELECT ilk, what, risk, tx_idx, raw_log FROM maker.pit_file WHERE header_id = $1`, headerID)
|
err = db.Get(&dbPitFile, `SELECT what, data, tx_idx, raw_log FROM maker.pit_file_stability_fee WHERE header_id = $1`, headerID)
|
||||||
Expect(err).To(HaveOccurred())
|
Expect(err).To(HaveOccurred())
|
||||||
Expect(err).To(MatchError(sql.ErrNoRows))
|
Expect(err).To(MatchError(sql.ErrNoRows))
|
||||||
})
|
})
|
||||||
@ -85,8 +86,8 @@ var _ = Describe("Pit file repository", func() {
|
|||||||
headerIDs = append(headerIDs, headerID)
|
headerIDs = append(headerIDs, headerID)
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
}
|
}
|
||||||
pitFileRepository := pit_file.NewPitFileRepository(db)
|
pitFileRepository := stability_fee.NewPitFileStabilityFeeRepository(db)
|
||||||
err := pitFileRepository.Create(headerIDs[1], 123, test_data.PitFileModel)
|
err := pitFileRepository.Create(headerIDs[1], test_data.PitFileStabilityFeeModel)
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
|
||||||
headers, err := pitFileRepository.MissingHeaders(startingBlockNumber, endingBlockNumber)
|
headers, err := pitFileRepository.MissingHeaders(startingBlockNumber, endingBlockNumber)
|
||||||
@ -112,9 +113,9 @@ var _ = Describe("Pit file repository", func() {
|
|||||||
_, err = headerRepositoryTwo.CreateOrUpdateHeader(core.Header{BlockNumber: n})
|
_, err = headerRepositoryTwo.CreateOrUpdateHeader(core.Header{BlockNumber: n})
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
}
|
}
|
||||||
pitFileRepository := pit_file.NewPitFileRepository(db)
|
pitFileRepository := stability_fee.NewPitFileStabilityFeeRepository(db)
|
||||||
pitFileRepositoryTwo := pit_file.NewPitFileRepository(dbTwo)
|
pitFileRepositoryTwo := stability_fee.NewPitFileStabilityFeeRepository(dbTwo)
|
||||||
err := pitFileRepository.Create(headerIDs[0], 0, test_data.PitFileModel)
|
err := pitFileRepository.Create(headerIDs[0], test_data.PitFileStabilityFeeModel)
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
|
||||||
nodeOneMissingHeaders, err := pitFileRepository.MissingHeaders(blockNumbers[0], blockNumbers[len(blockNumbers)-1])
|
nodeOneMissingHeaders, err := pitFileRepository.MissingHeaders(blockNumbers[0], blockNumbers[len(blockNumbers)-1])
|
@ -0,0 +1,13 @@
|
|||||||
|
package stability_fee_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
. "github.com/onsi/ginkgo"
|
||||||
|
. "github.com/onsi/gomega"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestStabilityFee(t *testing.T) {
|
||||||
|
RegisterFailHandler(Fail)
|
||||||
|
RunSpecs(t, "StabilityFee Suite")
|
||||||
|
}
|
57
pkg/transformers/pit_file/stability_fee/transformer.go
Normal file
57
pkg/transformers/pit_file/stability_fee/transformer.go
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
package stability_fee
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/ethereum/go-ethereum/common"
|
||||||
|
"github.com/vulcanize/vulcanizedb/pkg/core"
|
||||||
|
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
|
||||||
|
"github.com/vulcanize/vulcanizedb/pkg/transformers/pit_file"
|
||||||
|
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
|
||||||
|
)
|
||||||
|
|
||||||
|
type PitFileStabilityFeeTransformer struct {
|
||||||
|
Config shared.TransformerConfig
|
||||||
|
Converter Converter
|
||||||
|
Fetcher shared.LogFetcher
|
||||||
|
Repository Repository
|
||||||
|
}
|
||||||
|
|
||||||
|
type PitFileStabilityFeeTransformerInitializer struct {
|
||||||
|
Config shared.TransformerConfig
|
||||||
|
}
|
||||||
|
|
||||||
|
func (initializer PitFileStabilityFeeTransformerInitializer) NewPitFileStabilityFeeTransformer(db *postgres.DB, blockChain core.BlockChain) shared.Transformer {
|
||||||
|
converter := PitFileStabilityFeeConverter{}
|
||||||
|
fetcher := shared.NewFetcher(blockChain)
|
||||||
|
repository := NewPitFileStabilityFeeRepository(db)
|
||||||
|
return PitFileStabilityFeeTransformer{
|
||||||
|
Config: initializer.Config,
|
||||||
|
Converter: converter,
|
||||||
|
Fetcher: fetcher,
|
||||||
|
Repository: repository,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (transformer PitFileStabilityFeeTransformer) Execute() error {
|
||||||
|
missingHeaders, err := transformer.Repository.MissingHeaders(transformer.Config.StartingBlockNumber, transformer.Config.EndingBlockNumber)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
for _, header := range missingHeaders {
|
||||||
|
topics := [][]common.Hash{{common.HexToHash(shared.PitFileStabilityFeeSignature)}}
|
||||||
|
matchingLogs, err := transformer.Fetcher.FetchLogs(pit_file.PitFileConfig.ContractAddress, topics, header.BlockNumber)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
for _, log := range matchingLogs {
|
||||||
|
model, err := transformer.Converter.ToModel(pit_file.PitFileConfig.ContractAddress, shared.PitABI, log)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
err = transformer.Repository.Create(header.Id, model)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
163
pkg/transformers/pit_file/stability_fee/transformer_test.go
Normal file
163
pkg/transformers/pit_file/stability_fee/transformer_test.go
Normal file
@ -0,0 +1,163 @@
|
|||||||
|
package stability_fee_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/ethereum/go-ethereum/common"
|
||||||
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
|
. "github.com/onsi/ginkgo"
|
||||||
|
. "github.com/onsi/gomega"
|
||||||
|
|
||||||
|
"github.com/vulcanize/vulcanizedb/pkg/core"
|
||||||
|
"github.com/vulcanize/vulcanizedb/pkg/fakes"
|
||||||
|
"github.com/vulcanize/vulcanizedb/pkg/transformers/pit_file"
|
||||||
|
"github.com/vulcanize/vulcanizedb/pkg/transformers/pit_file/stability_fee"
|
||||||
|
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
|
||||||
|
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
|
||||||
|
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data/mocks"
|
||||||
|
stability_fee_mocks "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data/mocks/pit_file/stability_fee"
|
||||||
|
)
|
||||||
|
|
||||||
|
var _ = Describe("", func() {
|
||||||
|
It("gets missing headers for block numbers specified in config", func() {
|
||||||
|
repository := &stability_fee_mocks.MockPitFileStabilityFeeRepository{}
|
||||||
|
transformer := stability_fee.PitFileStabilityFeeTransformer{
|
||||||
|
Config: pit_file.PitFileConfig,
|
||||||
|
Fetcher: &mocks.MockLogFetcher{},
|
||||||
|
Converter: &stability_fee_mocks.MockPitFileStabilityFeeConverter{},
|
||||||
|
Repository: repository,
|
||||||
|
}
|
||||||
|
|
||||||
|
err := transformer.Execute()
|
||||||
|
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
Expect(repository.PassedStartingBlockNumber).To(Equal(pit_file.PitFileConfig.StartingBlockNumber))
|
||||||
|
Expect(repository.PassedEndingBlockNumber).To(Equal(pit_file.PitFileConfig.EndingBlockNumber))
|
||||||
|
})
|
||||||
|
|
||||||
|
It("returns error if repository returns error for missing headers", func() {
|
||||||
|
repository := &stability_fee_mocks.MockPitFileStabilityFeeRepository{}
|
||||||
|
repository.SetMissingHeadersErr(fakes.FakeError)
|
||||||
|
transformer := stability_fee.PitFileStabilityFeeTransformer{
|
||||||
|
Fetcher: &mocks.MockLogFetcher{},
|
||||||
|
Converter: &stability_fee_mocks.MockPitFileStabilityFeeConverter{},
|
||||||
|
Repository: repository,
|
||||||
|
}
|
||||||
|
|
||||||
|
err := transformer.Execute()
|
||||||
|
|
||||||
|
Expect(err).To(HaveOccurred())
|
||||||
|
Expect(err).To(MatchError(fakes.FakeError))
|
||||||
|
})
|
||||||
|
|
||||||
|
It("fetches logs for missing headers", func() {
|
||||||
|
fetcher := &mocks.MockLogFetcher{}
|
||||||
|
repository := &stability_fee_mocks.MockPitFileStabilityFeeRepository{}
|
||||||
|
repository.SetMissingHeaders([]core.Header{{BlockNumber: 1}, {BlockNumber: 2}})
|
||||||
|
transformer := stability_fee.PitFileStabilityFeeTransformer{
|
||||||
|
Fetcher: fetcher,
|
||||||
|
Converter: &stability_fee_mocks.MockPitFileStabilityFeeConverter{},
|
||||||
|
Repository: repository,
|
||||||
|
}
|
||||||
|
|
||||||
|
err := transformer.Execute()
|
||||||
|
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
Expect(fetcher.FetchedBlocks).To(Equal([]int64{1, 2}))
|
||||||
|
Expect(fetcher.FetchedContractAddress).To(Equal(pit_file.PitFileConfig.ContractAddress))
|
||||||
|
Expect(fetcher.FetchedTopics).To(Equal([][]common.Hash{{common.HexToHash(shared.PitFileStabilityFeeSignature)}}))
|
||||||
|
})
|
||||||
|
|
||||||
|
It("returns error if fetcher returns error", func() {
|
||||||
|
fetcher := &mocks.MockLogFetcher{}
|
||||||
|
fetcher.SetFetcherError(fakes.FakeError)
|
||||||
|
repository := &stability_fee_mocks.MockPitFileStabilityFeeRepository{}
|
||||||
|
repository.SetMissingHeaders([]core.Header{{BlockNumber: 1}})
|
||||||
|
transformer := stability_fee.PitFileStabilityFeeTransformer{
|
||||||
|
Fetcher: fetcher,
|
||||||
|
Converter: &stability_fee_mocks.MockPitFileStabilityFeeConverter{},
|
||||||
|
Repository: repository,
|
||||||
|
}
|
||||||
|
|
||||||
|
err := transformer.Execute()
|
||||||
|
|
||||||
|
Expect(err).To(HaveOccurred())
|
||||||
|
Expect(err).To(MatchError(fakes.FakeError))
|
||||||
|
})
|
||||||
|
|
||||||
|
It("converts matching logs", func() {
|
||||||
|
converter := &stability_fee_mocks.MockPitFileStabilityFeeConverter{}
|
||||||
|
fetcher := &mocks.MockLogFetcher{}
|
||||||
|
fetcher.SetFetchedLogs([]types.Log{test_data.EthPitFileStabilityFeeLog})
|
||||||
|
repository := &stability_fee_mocks.MockPitFileStabilityFeeRepository{}
|
||||||
|
repository.SetMissingHeaders([]core.Header{{BlockNumber: 1}})
|
||||||
|
transformer := stability_fee.PitFileStabilityFeeTransformer{
|
||||||
|
Fetcher: fetcher,
|
||||||
|
Converter: converter,
|
||||||
|
Repository: repository,
|
||||||
|
}
|
||||||
|
|
||||||
|
err := transformer.Execute()
|
||||||
|
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
Expect(converter.PassedContractAddress).To(Equal(pit_file.PitFileConfig.ContractAddress))
|
||||||
|
Expect(converter.PassedContractABI).To(Equal(pit_file.PitFileConfig.ContractAbi))
|
||||||
|
Expect(converter.PassedLog).To(Equal(test_data.EthPitFileStabilityFeeLog))
|
||||||
|
})
|
||||||
|
|
||||||
|
It("returns error if converter returns error", func() {
|
||||||
|
converter := &stability_fee_mocks.MockPitFileStabilityFeeConverter{}
|
||||||
|
converter.SetConverterError(fakes.FakeError)
|
||||||
|
fetcher := &mocks.MockLogFetcher{}
|
||||||
|
fetcher.SetFetchedLogs([]types.Log{test_data.EthPitFileStabilityFeeLog})
|
||||||
|
repository := &stability_fee_mocks.MockPitFileStabilityFeeRepository{}
|
||||||
|
repository.SetMissingHeaders([]core.Header{{BlockNumber: 1}})
|
||||||
|
transformer := stability_fee.PitFileStabilityFeeTransformer{
|
||||||
|
Fetcher: fetcher,
|
||||||
|
Converter: converter,
|
||||||
|
Repository: repository,
|
||||||
|
}
|
||||||
|
|
||||||
|
err := transformer.Execute()
|
||||||
|
|
||||||
|
Expect(err).To(HaveOccurred())
|
||||||
|
Expect(err).To(MatchError(fakes.FakeError))
|
||||||
|
})
|
||||||
|
|
||||||
|
It("persists pit file model", func() {
|
||||||
|
converter := &stability_fee_mocks.MockPitFileStabilityFeeConverter{}
|
||||||
|
fetcher := &mocks.MockLogFetcher{}
|
||||||
|
fetcher.SetFetchedLogs([]types.Log{test_data.EthPitFileStabilityFeeLog})
|
||||||
|
repository := &stability_fee_mocks.MockPitFileStabilityFeeRepository{}
|
||||||
|
fakeHeader := core.Header{BlockNumber: 1, Id: 2}
|
||||||
|
repository.SetMissingHeaders([]core.Header{fakeHeader})
|
||||||
|
transformer := stability_fee.PitFileStabilityFeeTransformer{
|
||||||
|
Fetcher: fetcher,
|
||||||
|
Converter: converter,
|
||||||
|
Repository: repository,
|
||||||
|
}
|
||||||
|
|
||||||
|
err := transformer.Execute()
|
||||||
|
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
Expect(repository.PassedHeaderID).To(Equal(fakeHeader.Id))
|
||||||
|
Expect(repository.PassedModel).To(Equal(test_data.PitFileStabilityFeeModel))
|
||||||
|
})
|
||||||
|
|
||||||
|
It("returns error if repository returns error for create", func() {
|
||||||
|
converter := &stability_fee_mocks.MockPitFileStabilityFeeConverter{}
|
||||||
|
fetcher := &mocks.MockLogFetcher{}
|
||||||
|
fetcher.SetFetchedLogs([]types.Log{test_data.EthPitFileStabilityFeeLog})
|
||||||
|
repository := &stability_fee_mocks.MockPitFileStabilityFeeRepository{}
|
||||||
|
repository.SetMissingHeaders([]core.Header{{BlockNumber: 1, Id: 2}})
|
||||||
|
repository.SetCreateError(fakes.FakeError)
|
||||||
|
transformer := stability_fee.PitFileStabilityFeeTransformer{
|
||||||
|
Fetcher: fetcher,
|
||||||
|
Converter: converter,
|
||||||
|
Repository: repository,
|
||||||
|
}
|
||||||
|
|
||||||
|
err := transformer.Execute()
|
||||||
|
|
||||||
|
Expect(err).To(HaveOccurred())
|
||||||
|
Expect(err).To(MatchError(fakes.FakeError))
|
||||||
|
})
|
||||||
|
})
|
@ -15,13 +15,13 @@
|
|||||||
package shared
|
package shared
|
||||||
|
|
||||||
var (
|
var (
|
||||||
biteMethod = "Bite(bytes32,bytes32,uint256,uint256,uint256,uint256,uint256)"
|
biteMethod = "Bite(bytes32,bytes32,uint256,uint256,uint256,uint256,uint256)"
|
||||||
flipKickMethod = "Kick(uint256,uint256,uint256,address,uint48,bytes32,uint256)"
|
flipKickMethod = "Kick(uint256,uint256,uint256,address,uint48,bytes32,uint256)"
|
||||||
frobMethod = "Frob(bytes32,bytes32,uint256,uint256,int256,int256,uint256)"
|
frobMethod = "Frob(bytes32,bytes32,uint256,uint256,int256,int256,uint256)"
|
||||||
pitFileMethodOne = "file(bytes32,bytes32,uint256)"
|
pitFileIlkMethod = "file(bytes32,bytes32,uint256)"
|
||||||
pitFileMethodThree = "file(bytes32,address)"
|
pitFileStabilityFeeMethod = "file(bytes32,address)"
|
||||||
pitFileMethodTwo = "file(bytes32,uint256)"
|
pitFileDebtCeilingMethod = "file(bytes32,uint256)"
|
||||||
tendMethod = "tend(uint256,uint256,uint256)"
|
tendMethod = "tend(uint256,uint256,uint256)"
|
||||||
|
|
||||||
CatABI = "[{\"constant\":true,\"inputs\":[],\"name\":\"vat\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"vow\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"flips\",\"outputs\":[{\"name\":\"ilk\",\"type\":\"bytes32\"},{\"name\":\"lad\",\"type\":\"bytes32\"},{\"name\":\"ink\",\"type\":\"uint256\"},{\"name\":\"tab\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"nflip\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"live\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"address\"}],\"name\":\"wards\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"bytes32\"}],\"name\":\"ilks\",\"outputs\":[{\"name\":\"flip\",\"type\":\"address\"},{\"name\":\"chop\",\"type\":\"uint256\"},{\"name\":\"lump\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"pit\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"name\":\"vat_\",\"type\":\"address\"},{\"name\":\"pit_\",\"type\":\"address\"},{\"name\":\"vow_\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"ilk\",\"type\":\"bytes32\"},{\"indexed\":true,\"name\":\"lad\",\"type\":\"bytes32\"},{\"indexed\":false,\"name\":\"ink\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"art\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"tab\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"flip\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"iArt\",\"type\":\"uint256\"}],\"name\":\"Bite\",\"type\":\"event\"},{\"anonymous\":true,\"inputs\":[{\"indexed\":true,\"name\":\"sig\",\"type\":\"bytes4\"},{\"indexed\":true,\"name\":\"guy\",\"type\":\"address\"},{\"indexed\":true,\"name\":\"foo\",\"type\":\"bytes32\"},{\"indexed\":true,\"name\":\"bar\",\"type\":\"bytes32\"},{\"indexed\":false,\"name\":\"wad\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"fax\",\"type\":\"bytes\"}],\"name\":\"LogNote\",\"type\":\"event\"},{\"constant\":false,\"inputs\":[{\"name\":\"guy\",\"type\":\"address\"}],\"name\":\"rely\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"guy\",\"type\":\"address\"}],\"name\":\"deny\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"ilk\",\"type\":\"bytes32\"},{\"name\":\"what\",\"type\":\"bytes32\"},{\"name\":\"data\",\"type\":\"uint256\"}],\"name\":\"file\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"ilk\",\"type\":\"bytes32\"},{\"name\":\"what\",\"type\":\"bytes32\"},{\"name\":\"flip\",\"type\":\"address\"}],\"name\":\"file\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"ilk\",\"type\":\"bytes32\"},{\"name\":\"lad\",\"type\":\"bytes32\"}],\"name\":\"bite\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"n\",\"type\":\"uint256\"},{\"name\":\"wad\",\"type\":\"uint256\"}],\"name\":\"flip\",\"outputs\":[{\"name\":\"id\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]"
|
CatABI = "[{\"constant\":true,\"inputs\":[],\"name\":\"vat\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"vow\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"flips\",\"outputs\":[{\"name\":\"ilk\",\"type\":\"bytes32\"},{\"name\":\"lad\",\"type\":\"bytes32\"},{\"name\":\"ink\",\"type\":\"uint256\"},{\"name\":\"tab\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"nflip\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"live\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"address\"}],\"name\":\"wards\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"bytes32\"}],\"name\":\"ilks\",\"outputs\":[{\"name\":\"flip\",\"type\":\"address\"},{\"name\":\"chop\",\"type\":\"uint256\"},{\"name\":\"lump\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"pit\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"name\":\"vat_\",\"type\":\"address\"},{\"name\":\"pit_\",\"type\":\"address\"},{\"name\":\"vow_\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"ilk\",\"type\":\"bytes32\"},{\"indexed\":true,\"name\":\"lad\",\"type\":\"bytes32\"},{\"indexed\":false,\"name\":\"ink\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"art\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"tab\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"flip\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"iArt\",\"type\":\"uint256\"}],\"name\":\"Bite\",\"type\":\"event\"},{\"anonymous\":true,\"inputs\":[{\"indexed\":true,\"name\":\"sig\",\"type\":\"bytes4\"},{\"indexed\":true,\"name\":\"guy\",\"type\":\"address\"},{\"indexed\":true,\"name\":\"foo\",\"type\":\"bytes32\"},{\"indexed\":true,\"name\":\"bar\",\"type\":\"bytes32\"},{\"indexed\":false,\"name\":\"wad\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"fax\",\"type\":\"bytes\"}],\"name\":\"LogNote\",\"type\":\"event\"},{\"constant\":false,\"inputs\":[{\"name\":\"guy\",\"type\":\"address\"}],\"name\":\"rely\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"guy\",\"type\":\"address\"}],\"name\":\"deny\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"ilk\",\"type\":\"bytes32\"},{\"name\":\"what\",\"type\":\"bytes32\"},{\"name\":\"data\",\"type\":\"uint256\"}],\"name\":\"file\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"ilk\",\"type\":\"bytes32\"},{\"name\":\"what\",\"type\":\"bytes32\"},{\"name\":\"flip\",\"type\":\"address\"}],\"name\":\"file\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"ilk\",\"type\":\"bytes32\"},{\"name\":\"lad\",\"type\":\"bytes32\"}],\"name\":\"bite\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"n\",\"type\":\"uint256\"},{\"name\":\"wad\",\"type\":\"uint256\"}],\"name\":\"flip\",\"outputs\":[{\"name\":\"id\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]"
|
||||||
FlipperABI = `[{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"bids","outputs":[{"name":"bid","type":"uint256"},{"name":"lot","type":"uint256"},{"name":"guy","type":"address"},{"name":"tic","type":"uint48"},{"name":"end","type":"uint48"},{"name":"urn","type":"bytes32"},{"name":"gal","type":"address"},{"name":"tab","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function","signature":"0x4423c5f1"},{"constant":true,"inputs":[],"name":"ttl","outputs":[{"name":"","type":"uint48"}],"payable":false,"stateMutability":"view","type":"function","signature":"0x4e8b1dd5"},{"constant":true,"inputs":[],"name":"gem","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function","signature":"0x7bd2bea7"},{"constant":true,"inputs":[],"name":"beg","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function","signature":"0x7d780d82"},{"constant":true,"inputs":[],"name":"tau","outputs":[{"name":"","type":"uint48"}],"payable":false,"stateMutability":"view","type":"function","signature":"0xcfc4af55"},{"constant":true,"inputs":[],"name":"kicks","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function","signature":"0xcfdd3302"},{"constant":true,"inputs":[],"name":"dai","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function","signature":"0xf4b9fa75"},{"inputs":[{"name":"dai_","type":"address"},{"name":"gem_","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor","signature":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"id","type":"uint256"},{"indexed":false,"name":"lot","type":"uint256"},{"indexed":false,"name":"bid","type":"uint256"},{"indexed":false,"name":"gal","type":"address"},{"indexed":false,"name":"end","type":"uint48"},{"indexed":true,"name":"urn","type":"bytes32"},{"indexed":false,"name":"tab","type":"uint256"}],"name":"Kick","type":"event","signature":"0xbac86238bdba81d21995024470425ecb370078fa62b7271b90cf28cbd1e3e87e"},{"anonymous":true,"inputs":[{"indexed":true,"name":"sig","type":"bytes4"},{"indexed":true,"name":"guy","type":"address"},{"indexed":true,"name":"foo","type":"bytes32"},{"indexed":true,"name":"bar","type":"bytes32"},{"indexed":false,"name":"wad","type":"uint256"},{"indexed":false,"name":"fax","type":"bytes"}],"name":"LogNote","type":"event","signature":"0x644843f351d3fba4abcd60109eaff9f54bac8fb8ccf0bab941009c21df21cf31"},{"constant":true,"inputs":[],"name":"era","outputs":[{"name":"","type":"uint48"}],"payable":false,"stateMutability":"view","type":"function","signature":"0x143e55e0"},{"constant":false,"inputs":[{"name":"urn","type":"bytes32"},{"name":"gal","type":"address"},{"name":"tab","type":"uint256"},{"name":"lot","type":"uint256"},{"name":"bid","type":"uint256"}],"name":"kick","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function","signature":"0xeae19d9e"},{"constant":false,"inputs":[{"name":"id","type":"uint256"}],"name":"tick","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function","signature":"0xfc7b6aee"},{"constant":false,"inputs":[{"name":"id","type":"uint256"},{"name":"lot","type":"uint256"},{"name":"bid","type":"uint256"}],"name":"tend","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function","signature":"0x4b43ed12"},{"constant":false,"inputs":[{"name":"id","type":"uint256"},{"name":"lot","type":"uint256"},{"name":"bid","type":"uint256"}],"name":"dent","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function","signature":"0x5ff3a382"},{"constant":false,"inputs":[{"name":"id","type":"uint256"}],"name":"deal","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function","signature":"0xc959c42b"}]`
|
FlipperABI = `[{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"bids","outputs":[{"name":"bid","type":"uint256"},{"name":"lot","type":"uint256"},{"name":"guy","type":"address"},{"name":"tic","type":"uint48"},{"name":"end","type":"uint48"},{"name":"urn","type":"bytes32"},{"name":"gal","type":"address"},{"name":"tab","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function","signature":"0x4423c5f1"},{"constant":true,"inputs":[],"name":"ttl","outputs":[{"name":"","type":"uint48"}],"payable":false,"stateMutability":"view","type":"function","signature":"0x4e8b1dd5"},{"constant":true,"inputs":[],"name":"gem","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function","signature":"0x7bd2bea7"},{"constant":true,"inputs":[],"name":"beg","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function","signature":"0x7d780d82"},{"constant":true,"inputs":[],"name":"tau","outputs":[{"name":"","type":"uint48"}],"payable":false,"stateMutability":"view","type":"function","signature":"0xcfc4af55"},{"constant":true,"inputs":[],"name":"kicks","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function","signature":"0xcfdd3302"},{"constant":true,"inputs":[],"name":"dai","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function","signature":"0xf4b9fa75"},{"inputs":[{"name":"dai_","type":"address"},{"name":"gem_","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor","signature":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"id","type":"uint256"},{"indexed":false,"name":"lot","type":"uint256"},{"indexed":false,"name":"bid","type":"uint256"},{"indexed":false,"name":"gal","type":"address"},{"indexed":false,"name":"end","type":"uint48"},{"indexed":true,"name":"urn","type":"bytes32"},{"indexed":false,"name":"tab","type":"uint256"}],"name":"Kick","type":"event","signature":"0xbac86238bdba81d21995024470425ecb370078fa62b7271b90cf28cbd1e3e87e"},{"anonymous":true,"inputs":[{"indexed":true,"name":"sig","type":"bytes4"},{"indexed":true,"name":"guy","type":"address"},{"indexed":true,"name":"foo","type":"bytes32"},{"indexed":true,"name":"bar","type":"bytes32"},{"indexed":false,"name":"wad","type":"uint256"},{"indexed":false,"name":"fax","type":"bytes"}],"name":"LogNote","type":"event","signature":"0x644843f351d3fba4abcd60109eaff9f54bac8fb8ccf0bab941009c21df21cf31"},{"constant":true,"inputs":[],"name":"era","outputs":[{"name":"","type":"uint48"}],"payable":false,"stateMutability":"view","type":"function","signature":"0x143e55e0"},{"constant":false,"inputs":[{"name":"urn","type":"bytes32"},{"name":"gal","type":"address"},{"name":"tab","type":"uint256"},{"name":"lot","type":"uint256"},{"name":"bid","type":"uint256"}],"name":"kick","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function","signature":"0xeae19d9e"},{"constant":false,"inputs":[{"name":"id","type":"uint256"}],"name":"tick","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function","signature":"0xfc7b6aee"},{"constant":false,"inputs":[{"name":"id","type":"uint256"},{"name":"lot","type":"uint256"},{"name":"bid","type":"uint256"}],"name":"tend","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function","signature":"0x4b43ed12"},{"constant":false,"inputs":[{"name":"id","type":"uint256"},{"name":"lot","type":"uint256"},{"name":"bid","type":"uint256"}],"name":"dent","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function","signature":"0x5ff3a382"},{"constant":false,"inputs":[{"name":"id","type":"uint256"}],"name":"deal","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function","signature":"0xc959c42b"}]`
|
||||||
@ -30,12 +30,12 @@ var (
|
|||||||
|
|
||||||
FlipperContractAddress = "0x6b59c42097e2fff7cad96cb08ceefd601081ad9c" //this is a temporary address deployed locally
|
FlipperContractAddress = "0x6b59c42097e2fff7cad96cb08ceefd601081ad9c" //this is a temporary address deployed locally
|
||||||
|
|
||||||
BiteSignature = GetEventSignature(biteMethod)
|
BiteSignature = GetEventSignature(biteMethod)
|
||||||
FlipKickSignature = GetEventSignature(flipKickMethod)
|
FlipKickSignature = GetEventSignature(flipKickMethod)
|
||||||
FrobSignature = GetEventSignature(frobMethod)
|
FrobSignature = GetEventSignature(frobMethod)
|
||||||
LogValueSignature = GetEventSignature("")
|
LogValueSignature = GetEventSignature("")
|
||||||
PitFileSignatureOne = GetLogNoteSignature(pitFileMethodOne)
|
PitFileIlkSignature = GetLogNoteSignature(pitFileIlkMethod)
|
||||||
PitFileSignatureThree = GetLogNoteSignature(pitFileMethodThree)
|
PitFileStabilityFeeSignature = GetLogNoteSignature(pitFileStabilityFeeMethod)
|
||||||
PitFileSignatureTwo = GetLogNoteSignature(pitFileMethodTwo)
|
PitFileDebtCeilingSignature = GetLogNoteSignature(pitFileDebtCeilingMethod)
|
||||||
TendFunctionSignature = GetLogNoteSignature(tendMethod)
|
TendFunctionSignature = GetLogNoteSignature(tendMethod)
|
||||||
)
|
)
|
||||||
|
@ -1,26 +1,26 @@
|
|||||||
package pit_file
|
package ilk
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/ethereum/go-ethereum/core/types"
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
|
|
||||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/pit_file"
|
"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"
|
||||||
)
|
)
|
||||||
|
|
||||||
type MockPitFileConverter struct {
|
type MockPitFileIlkConverter struct {
|
||||||
PassedContractAddress string
|
PassedContractAddress string
|
||||||
PassedContractABI string
|
PassedContractABI string
|
||||||
PassedLog types.Log
|
PassedLog types.Log
|
||||||
converterError error
|
converterError error
|
||||||
}
|
}
|
||||||
|
|
||||||
func (converter *MockPitFileConverter) SetConverterError(err error) {
|
func (converter *MockPitFileIlkConverter) SetConverterError(err error) {
|
||||||
converter.converterError = err
|
converter.converterError = err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (converter *MockPitFileConverter) ToModel(contractAddress string, contractAbi string, ethLog types.Log) (pit_file.PitFileModel, error) {
|
func (converter *MockPitFileIlkConverter) ToModel(contractAddress string, contractAbi string, ethLog types.Log) (ilk.PitFileIlkModel, error) {
|
||||||
converter.PassedContractAddress = contractAddress
|
converter.PassedContractAddress = contractAddress
|
||||||
converter.PassedContractABI = contractAbi
|
converter.PassedContractABI = contractAbi
|
||||||
converter.PassedLog = ethLog
|
converter.PassedLog = ethLog
|
||||||
return test_data.PitFileModel, converter.converterError
|
return test_data.PitFileIlkModel, converter.converterError
|
||||||
}
|
}
|
40
pkg/transformers/test_data/mocks/pit_file/ilk/repository.go
Normal file
40
pkg/transformers/test_data/mocks/pit_file/ilk/repository.go
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
package ilk
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/vulcanize/vulcanizedb/pkg/core"
|
||||||
|
"github.com/vulcanize/vulcanizedb/pkg/transformers/pit_file/ilk"
|
||||||
|
)
|
||||||
|
|
||||||
|
type MockPitFileIlkRepository struct {
|
||||||
|
createError error
|
||||||
|
PassedEndingBlockNumber int64
|
||||||
|
PassedModel ilk.PitFileIlkModel
|
||||||
|
PassedHeaderID int64
|
||||||
|
PassedStartingBlockNumber int64
|
||||||
|
missingHeaders []core.Header
|
||||||
|
missingHeadersErr error
|
||||||
|
}
|
||||||
|
|
||||||
|
func (repository *MockPitFileIlkRepository) SetCreateError(err error) {
|
||||||
|
repository.createError = err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (repository *MockPitFileIlkRepository) SetMissingHeadersErr(err error) {
|
||||||
|
repository.missingHeadersErr = err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (repository *MockPitFileIlkRepository) SetMissingHeaders(headers []core.Header) {
|
||||||
|
repository.missingHeaders = headers
|
||||||
|
}
|
||||||
|
|
||||||
|
func (repository *MockPitFileIlkRepository) Create(headerID int64, model ilk.PitFileIlkModel) error {
|
||||||
|
repository.PassedHeaderID = headerID
|
||||||
|
repository.PassedModel = model
|
||||||
|
return repository.createError
|
||||||
|
}
|
||||||
|
|
||||||
|
func (repository *MockPitFileIlkRepository) MissingHeaders(startingBlockNumber, endingBlockNumber int64) ([]core.Header, error) {
|
||||||
|
repository.PassedStartingBlockNumber = startingBlockNumber
|
||||||
|
repository.PassedEndingBlockNumber = endingBlockNumber
|
||||||
|
return repository.missingHeaders, repository.missingHeadersErr
|
||||||
|
}
|
@ -1,42 +0,0 @@
|
|||||||
package pit_file
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/vulcanize/vulcanizedb/pkg/core"
|
|
||||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/pit_file"
|
|
||||||
)
|
|
||||||
|
|
||||||
type MockPitFileRepository struct {
|
|
||||||
createError error
|
|
||||||
PassedEndingBlockNumber int64
|
|
||||||
PassedModel pit_file.PitFileModel
|
|
||||||
PassedHeaderID int64
|
|
||||||
PassedStartingBlockNumber int64
|
|
||||||
PassedTransactionIndex uint
|
|
||||||
missingHeaders []core.Header
|
|
||||||
missingHeadersErr error
|
|
||||||
}
|
|
||||||
|
|
||||||
func (repository *MockPitFileRepository) SetCreateError(err error) {
|
|
||||||
repository.createError = err
|
|
||||||
}
|
|
||||||
|
|
||||||
func (repository *MockPitFileRepository) SetMissingHeadersErr(err error) {
|
|
||||||
repository.missingHeadersErr = err
|
|
||||||
}
|
|
||||||
|
|
||||||
func (repository *MockPitFileRepository) SetMissingHeaders(headers []core.Header) {
|
|
||||||
repository.missingHeaders = headers
|
|
||||||
}
|
|
||||||
|
|
||||||
func (repository *MockPitFileRepository) Create(headerID int64, transactionIndex uint, model pit_file.PitFileModel) error {
|
|
||||||
repository.PassedHeaderID = headerID
|
|
||||||
repository.PassedTransactionIndex = transactionIndex
|
|
||||||
repository.PassedModel = model
|
|
||||||
return repository.createError
|
|
||||||
}
|
|
||||||
|
|
||||||
func (repository *MockPitFileRepository) MissingHeaders(startingBlockNumber, endingBlockNumber int64) ([]core.Header, error) {
|
|
||||||
repository.PassedStartingBlockNumber = startingBlockNumber
|
|
||||||
repository.PassedEndingBlockNumber = endingBlockNumber
|
|
||||||
return repository.missingHeaders, repository.missingHeadersErr
|
|
||||||
}
|
|
@ -0,0 +1,25 @@
|
|||||||
|
package stability_fee
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
|
|
||||||
|
"github.com/vulcanize/vulcanizedb/pkg/transformers/pit_file/stability_fee"
|
||||||
|
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
|
||||||
|
)
|
||||||
|
|
||||||
|
type MockPitFileStabilityFeeConverter struct {
|
||||||
|
converterErr error
|
||||||
|
PassedContractAddress string
|
||||||
|
PassedContractABI string
|
||||||
|
PassedLog types.Log
|
||||||
|
}
|
||||||
|
|
||||||
|
func (converter *MockPitFileStabilityFeeConverter) ToModel(contractAddress string, contractAbi string, ethLog types.Log) (stability_fee.PitFileStabilityFeeModel, error) {
|
||||||
|
converter.PassedContractAddress = contractAddress
|
||||||
|
converter.PassedContractABI = contractAbi
|
||||||
|
converter.PassedLog = ethLog
|
||||||
|
return test_data.PitFileStabilityFeeModel, converter.converterErr
|
||||||
|
}
|
||||||
|
func (converter *MockPitFileStabilityFeeConverter) SetConverterError(e error) {
|
||||||
|
converter.converterErr = e
|
||||||
|
}
|
@ -0,0 +1,38 @@
|
|||||||
|
package stability_fee
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/vulcanize/vulcanizedb/pkg/core"
|
||||||
|
"github.com/vulcanize/vulcanizedb/pkg/transformers/pit_file/stability_fee"
|
||||||
|
)
|
||||||
|
|
||||||
|
type MockPitFileStabilityFeeRepository struct {
|
||||||
|
createErr error
|
||||||
|
missingHeaders []core.Header
|
||||||
|
missingHeadersErr error
|
||||||
|
PassedStartingBlockNumber int64
|
||||||
|
PassedEndingBlockNumber int64
|
||||||
|
PassedHeaderID int64
|
||||||
|
PassedModel stability_fee.PitFileStabilityFeeModel
|
||||||
|
}
|
||||||
|
|
||||||
|
func (repository *MockPitFileStabilityFeeRepository) Create(headerID int64, model stability_fee.PitFileStabilityFeeModel) error {
|
||||||
|
repository.PassedModel = model
|
||||||
|
repository.PassedHeaderID = headerID
|
||||||
|
return repository.createErr
|
||||||
|
}
|
||||||
|
|
||||||
|
func (repository *MockPitFileStabilityFeeRepository) MissingHeaders(startingBlockNumber, endingBlockNumber int64) ([]core.Header, error) {
|
||||||
|
repository.PassedStartingBlockNumber = startingBlockNumber
|
||||||
|
repository.PassedEndingBlockNumber = endingBlockNumber
|
||||||
|
return repository.missingHeaders, repository.missingHeadersErr
|
||||||
|
}
|
||||||
|
|
||||||
|
func (repository *MockPitFileStabilityFeeRepository) SetMissingHeadersErr(e error) {
|
||||||
|
repository.missingHeadersErr = e
|
||||||
|
}
|
||||||
|
func (repository *MockPitFileStabilityFeeRepository) SetMissingHeaders(headers []core.Header) {
|
||||||
|
repository.missingHeaders = headers
|
||||||
|
}
|
||||||
|
func (repository *MockPitFileStabilityFeeRepository) SetCreateError(e error) {
|
||||||
|
repository.createErr = e
|
||||||
|
}
|
@ -5,7 +5,8 @@ import (
|
|||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||||
"github.com/ethereum/go-ethereum/core/types"
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/pit_file"
|
ilk2 "github.com/vulcanize/vulcanizedb/pkg/transformers/pit_file/ilk"
|
||||||
|
"github.com/vulcanize/vulcanizedb/pkg/transformers/pit_file/stability_fee"
|
||||||
"math/big"
|
"math/big"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -13,7 +14,7 @@ var (
|
|||||||
PitAddress = "0xff3f2400f1600f3f493a9a92704a29b96795af1a"
|
PitAddress = "0xff3f2400f1600f3f493a9a92704a29b96795af1a"
|
||||||
)
|
)
|
||||||
|
|
||||||
var EthPitFileLog = types.Log{
|
var EthPitFileIlkLog = types.Log{
|
||||||
Address: common.HexToAddress(PitAddress),
|
Address: common.HexToAddress(PitAddress),
|
||||||
Topics: []common.Hash{
|
Topics: []common.Hash{
|
||||||
common.HexToHash("0x1a0b287e00000000000000000000000000000000000000000000000000000000"),
|
common.HexToHash("0x1a0b287e00000000000000000000000000000000000000000000000000000000"),
|
||||||
@ -30,11 +31,36 @@ var EthPitFileLog = types.Log{
|
|||||||
Removed: false,
|
Removed: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
var rawPitFileLog, _ = json.Marshal(EthPitFileLog)
|
var rawPitFileIlkLog, _ = json.Marshal(EthPitFileIlkLog)
|
||||||
var PitFileModel = pit_file.PitFileModel{
|
var PitFileIlkModel = ilk2.PitFileIlkModel{
|
||||||
Ilk: "fake ilk",
|
Ilk: "fake ilk",
|
||||||
What: "spot",
|
What: "spot",
|
||||||
Risk: big.NewInt(123).String(),
|
Data: big.NewInt(123).String(),
|
||||||
TransactionIndex: EthPitFileLog.TxIndex,
|
TransactionIndex: EthPitFileIlkLog.TxIndex,
|
||||||
Raw: rawPitFileLog,
|
Raw: rawPitFileIlkLog,
|
||||||
|
}
|
||||||
|
|
||||||
|
var EthPitFileStabilityFeeLog = types.Log{
|
||||||
|
Address: common.HexToAddress("0x6b59c42097e2Fff7cad96cb08cEeFd601081aD9c"),
|
||||||
|
Topics: []common.Hash{
|
||||||
|
common.HexToHash("0xd4e8be8300000000000000000000000000000000000000000000000000000000"),
|
||||||
|
common.HexToHash("0x00000000000000000000000064d922894153be9eef7b7218dc565d1d0ce2a092"),
|
||||||
|
common.HexToHash("0x6472697000000000000000000000000000000000000000000000000000000000"),
|
||||||
|
common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
||||||
|
},
|
||||||
|
Data: hexutil.MustDecode("0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000044d4e8be8364726970000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"),
|
||||||
|
BlockNumber: 12,
|
||||||
|
TxHash: common.HexToHash("0x78cdc62316ccf8e31515d09745cc724f557569f01a557d0d09b1066bf7079fd2"),
|
||||||
|
TxIndex: 0,
|
||||||
|
BlockHash: common.HexToHash("0xe3d8e458421533170871b4033f978a3793ef10b7e33a9328a13c09e2fd90208d"),
|
||||||
|
Index: 0,
|
||||||
|
Removed: false,
|
||||||
|
}
|
||||||
|
|
||||||
|
var rawPitFileStabilityFeeLog, _ = json.Marshal(EthPitFileStabilityFeeLog)
|
||||||
|
var PitFileStabilityFeeModel = stability_fee.PitFileStabilityFeeModel{
|
||||||
|
What: "drip",
|
||||||
|
Data: "0x64d922894153BE9EEf7b7218dc565d1D0Ce2a092",
|
||||||
|
TransactionIndex: 0,
|
||||||
|
Raw: rawPitFileStabilityFeeLog,
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,8 @@ import (
|
|||||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/flip_kick"
|
"github.com/vulcanize/vulcanizedb/pkg/transformers/flip_kick"
|
||||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/frob"
|
"github.com/vulcanize/vulcanizedb/pkg/transformers/frob"
|
||||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/pit_file"
|
"github.com/vulcanize/vulcanizedb/pkg/transformers/pit_file"
|
||||||
|
"github.com/vulcanize/vulcanizedb/pkg/transformers/pit_file/ilk"
|
||||||
|
"github.com/vulcanize/vulcanizedb/pkg/transformers/pit_file/stability_fee"
|
||||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/price_feeds"
|
"github.com/vulcanize/vulcanizedb/pkg/transformers/price_feeds"
|
||||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
|
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
|
||||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/tend"
|
"github.com/vulcanize/vulcanizedb/pkg/transformers/tend"
|
||||||
@ -30,7 +32,8 @@ func TransformerInitializers() []shared.TransformerInitializer {
|
|||||||
frobConfig := frob.FrobConfig
|
frobConfig := frob.FrobConfig
|
||||||
frobTransformerInitializer := frob.FrobTransformerInitializer{Config: frobConfig}
|
frobTransformerInitializer := frob.FrobTransformerInitializer{Config: frobConfig}
|
||||||
pitFileConfig := pit_file.PitFileConfig
|
pitFileConfig := pit_file.PitFileConfig
|
||||||
pitFileTransformerInitializer := pit_file.PitFileTransformerInitializer{Config: pitFileConfig}
|
pitFileIlkTransformerInitializer := ilk.PitFileIlkTransformerInitializer{Config: pitFileConfig}
|
||||||
|
pitFileStabilityFeeTransformerInitializer := stability_fee.PitFileStabilityFeeTransformerInitializer{Config: pitFileConfig}
|
||||||
priceFeedConfig := price_feeds.PriceFeedConfig
|
priceFeedConfig := price_feeds.PriceFeedConfig
|
||||||
priceFeedTransformerInitializer := price_feeds.PriceFeedTransformerInitializer{Config: priceFeedConfig}
|
priceFeedTransformerInitializer := price_feeds.PriceFeedTransformerInitializer{Config: priceFeedConfig}
|
||||||
tendConfig := tend.TendConfig
|
tendConfig := tend.TendConfig
|
||||||
@ -41,7 +44,8 @@ func TransformerInitializers() []shared.TransformerInitializer {
|
|||||||
biteTransformerInitializer.NewBiteTransformer,
|
biteTransformerInitializer.NewBiteTransformer,
|
||||||
flipKickTransformerInitializer.NewFlipKickTransformer,
|
flipKickTransformerInitializer.NewFlipKickTransformer,
|
||||||
frobTransformerInitializer.NewFrobTransformer,
|
frobTransformerInitializer.NewFrobTransformer,
|
||||||
pitFileTransformerInitializer.NewPitFileTransformer,
|
pitFileIlkTransformerInitializer.NewPitFileIlkTransformer,
|
||||||
|
pitFileStabilityFeeTransformerInitializer.NewPitFileStabilityFeeTransformer,
|
||||||
priceFeedTransformerInitializer.NewPriceFeedTransformer,
|
priceFeedTransformerInitializer.NewPriceFeedTransformer,
|
||||||
tendTransformerInitializer.NewTendTransformer,
|
tendTransformerInitializer.NewTendTransformer,
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,8 @@ func CleanTestDB(db *postgres.DB) {
|
|||||||
db.MustExec("DELETE FROM headers")
|
db.MustExec("DELETE FROM headers")
|
||||||
db.MustExec("DELETE FROM log_filters")
|
db.MustExec("DELETE FROM log_filters")
|
||||||
db.MustExec("DELETE FROM logs")
|
db.MustExec("DELETE FROM logs")
|
||||||
db.MustExec("DELETE FROM maker.pit_file")
|
db.MustExec("DELETE FROM maker.pit_file_ilk")
|
||||||
|
db.MustExec("DELETE FROM maker.pit_file_stability_fee")
|
||||||
db.MustExec("DELETE FROM receipts")
|
db.MustExec("DELETE FROM receipts")
|
||||||
db.MustExec("DELETE FROM transactions")
|
db.MustExec("DELETE FROM transactions")
|
||||||
db.MustExec("DELETE FROM watched_contracts")
|
db.MustExec("DELETE FROM watched_contracts")
|
||||||
|
Loading…
Reference in New Issue
Block a user