Merge pull request #18 from vulcanize/vdb-380-continued
Vdb 380 continued
This commit is contained in:
commit
dc6a4a707e
@ -38,7 +38,7 @@ CREATE TABLE maker.cat_ilk_flip (
|
|||||||
id SERIAL PRIMARY KEY,
|
id SERIAL PRIMARY KEY,
|
||||||
block_number BIGINT,
|
block_number BIGINT,
|
||||||
block_hash TEXT,
|
block_hash TEXT,
|
||||||
ilk TEXT,
|
ilk INTEGER NOT NULL REFERENCES maker.ilks (id),
|
||||||
flip TEXT
|
flip TEXT
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -46,7 +46,7 @@ CREATE TABLE maker.cat_ilk_chop (
|
|||||||
id SERIAL PRIMARY KEY,
|
id SERIAL PRIMARY KEY,
|
||||||
block_number BIGINT,
|
block_number BIGINT,
|
||||||
block_hash TEXT,
|
block_hash TEXT,
|
||||||
ilk TEXT,
|
ilk INTEGER NOT NULL REFERENCES maker.ilks (id),
|
||||||
chop NUMERIC NOT NULL
|
chop NUMERIC NOT NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -54,7 +54,7 @@ CREATE TABLE maker.cat_ilk_lump (
|
|||||||
id SERIAL PRIMARY KEY,
|
id SERIAL PRIMARY KEY,
|
||||||
block_number BIGINT,
|
block_number BIGINT,
|
||||||
block_hash TEXT,
|
block_hash TEXT,
|
||||||
ilk TEXT,
|
ilk INTEGER NOT NULL REFERENCES maker.ilks (id),
|
||||||
lump NUMERIC NOT NULL
|
lump NUMERIC NOT NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -63,7 +63,7 @@ CREATE TABLE maker.cat_flip_ilk (
|
|||||||
block_number BIGINT,
|
block_number BIGINT,
|
||||||
block_hash TEXT,
|
block_hash TEXT,
|
||||||
flip NUMERIC NOT NULL,
|
flip NUMERIC NOT NULL,
|
||||||
ilk TEXT
|
ilk INTEGER NOT NULL REFERENCES maker.ilks (id)
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE maker.cat_flip_urn (
|
CREATE TABLE maker.cat_flip_urn (
|
||||||
|
@ -213,7 +213,7 @@ CREATE TABLE maker.cat_flip_ilk (
|
|||||||
block_number bigint,
|
block_number bigint,
|
||||||
block_hash text,
|
block_hash text,
|
||||||
flip numeric NOT NULL,
|
flip numeric NOT NULL,
|
||||||
ilk text
|
ilk integer NOT NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
@ -344,7 +344,7 @@ CREATE TABLE maker.cat_ilk_chop (
|
|||||||
id integer NOT NULL,
|
id integer NOT NULL,
|
||||||
block_number bigint,
|
block_number bigint,
|
||||||
block_hash text,
|
block_hash text,
|
||||||
ilk text,
|
ilk integer NOT NULL,
|
||||||
chop numeric NOT NULL
|
chop numeric NOT NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -377,7 +377,7 @@ CREATE TABLE maker.cat_ilk_flip (
|
|||||||
id integer NOT NULL,
|
id integer NOT NULL,
|
||||||
block_number bigint,
|
block_number bigint,
|
||||||
block_hash text,
|
block_hash text,
|
||||||
ilk text,
|
ilk integer NOT NULL,
|
||||||
flip text
|
flip text
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -410,7 +410,7 @@ CREATE TABLE maker.cat_ilk_lump (
|
|||||||
id integer NOT NULL,
|
id integer NOT NULL,
|
||||||
block_number bigint,
|
block_number bigint,
|
||||||
block_hash text,
|
block_hash text,
|
||||||
ilk text,
|
ilk integer NOT NULL,
|
||||||
lump numeric NOT NULL
|
lump numeric NOT NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -4413,6 +4413,38 @@ ALTER TABLE ONLY maker.cat_file_pit_vow
|
|||||||
ADD CONSTRAINT cat_file_pit_vow_header_id_fkey FOREIGN KEY (header_id) REFERENCES public.headers(id) ON DELETE CASCADE;
|
ADD CONSTRAINT cat_file_pit_vow_header_id_fkey FOREIGN KEY (header_id) REFERENCES public.headers(id) ON DELETE CASCADE;
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: cat_flip_ilk cat_flip_ilk_ilk_fkey; Type: FK CONSTRAINT; Schema: maker; Owner: -
|
||||||
|
--
|
||||||
|
|
||||||
|
ALTER TABLE ONLY maker.cat_flip_ilk
|
||||||
|
ADD CONSTRAINT cat_flip_ilk_ilk_fkey FOREIGN KEY (ilk) REFERENCES maker.ilks(id);
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: cat_ilk_chop cat_ilk_chop_ilk_fkey; Type: FK CONSTRAINT; Schema: maker; Owner: -
|
||||||
|
--
|
||||||
|
|
||||||
|
ALTER TABLE ONLY maker.cat_ilk_chop
|
||||||
|
ADD CONSTRAINT cat_ilk_chop_ilk_fkey FOREIGN KEY (ilk) REFERENCES maker.ilks(id);
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: cat_ilk_flip cat_ilk_flip_ilk_fkey; Type: FK CONSTRAINT; Schema: maker; Owner: -
|
||||||
|
--
|
||||||
|
|
||||||
|
ALTER TABLE ONLY maker.cat_ilk_flip
|
||||||
|
ADD CONSTRAINT cat_ilk_flip_ilk_fkey FOREIGN KEY (ilk) REFERENCES maker.ilks(id);
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: cat_ilk_lump cat_ilk_lump_ilk_fkey; Type: FK CONSTRAINT; Schema: maker; Owner: -
|
||||||
|
--
|
||||||
|
|
||||||
|
ALTER TABLE ONLY maker.cat_ilk_lump
|
||||||
|
ADD CONSTRAINT cat_ilk_lump_ilk_fkey FOREIGN KEY (ilk) REFERENCES maker.ilks(id);
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Name: deal deal_header_id_fkey; Type: FK CONSTRAINT; Schema: maker; Owner: -
|
-- Name: deal deal_header_id_fkey; Type: FK CONSTRAINT; Schema: maker; Owner: -
|
||||||
--
|
--
|
||||||
|
@ -3,6 +3,7 @@ package cat
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
|
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
|
||||||
|
shared2 "github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
|
||||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/storage_diffs/shared"
|
"github.com/vulcanize/vulcanizedb/pkg/transformers/storage_diffs/shared"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -86,10 +87,29 @@ func (repository *CatStorageRepository) insertIlkFlip(blockNumber int, blockHash
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
_, writeErr := repository.db.Exec(
|
tx, txErr := repository.db.Begin()
|
||||||
|
if txErr != nil {
|
||||||
|
return txErr
|
||||||
|
}
|
||||||
|
ilkID, ilkErr := shared2.GetOrCreateIlkInTransaction(ilk, tx)
|
||||||
|
if ilkErr != nil {
|
||||||
|
rollbackErr := tx.Rollback()
|
||||||
|
if rollbackErr != nil {
|
||||||
|
return fmt.Errorf("failed to rollback transaction after failing to insert ilk: %s", ilkErr.Error())
|
||||||
|
}
|
||||||
|
return ilkErr
|
||||||
|
}
|
||||||
|
_, writeErr := tx.Exec(
|
||||||
`INSERT INTO maker.cat_ilk_flip (block_number, block_hash, ilk, flip) VALUES ($1, $2, $3, $4)`,
|
`INSERT INTO maker.cat_ilk_flip (block_number, block_hash, ilk, flip) VALUES ($1, $2, $3, $4)`,
|
||||||
blockNumber, blockHash, ilk, flip)
|
blockNumber, blockHash, ilkID, flip)
|
||||||
return writeErr
|
if writeErr != nil {
|
||||||
|
rollbackErr := tx.Rollback()
|
||||||
|
if rollbackErr != nil {
|
||||||
|
return fmt.Errorf("failed to rollback transaction after failing to insert ilk flip: %s", writeErr.Error())
|
||||||
|
}
|
||||||
|
return writeErr
|
||||||
|
}
|
||||||
|
return tx.Commit()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (repository *CatStorageRepository) insertIlkChop(blockNumber int, blockHash string, metadata shared.StorageValueMetadata, chop string) error {
|
func (repository *CatStorageRepository) insertIlkChop(blockNumber int, blockHash string, metadata shared.StorageValueMetadata, chop string) error {
|
||||||
@ -97,10 +117,29 @@ func (repository *CatStorageRepository) insertIlkChop(blockNumber int, blockHash
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
_, writeErr := repository.db.Exec(
|
tx, txErr := repository.db.Begin()
|
||||||
|
if txErr != nil {
|
||||||
|
return txErr
|
||||||
|
}
|
||||||
|
ilkID, ilkErr := shared2.GetOrCreateIlkInTransaction(ilk, tx)
|
||||||
|
if ilkErr != nil {
|
||||||
|
rollbackErr := tx.Rollback()
|
||||||
|
if rollbackErr != nil {
|
||||||
|
return fmt.Errorf("failed to rollback transaction after failing to insert ilk: %s", ilkErr.Error())
|
||||||
|
}
|
||||||
|
return ilkErr
|
||||||
|
}
|
||||||
|
_, writeErr := tx.Exec(
|
||||||
`INSERT INTO maker.cat_ilk_chop (block_number, block_hash, ilk, chop) VALUES ($1, $2, $3, $4)`,
|
`INSERT INTO maker.cat_ilk_chop (block_number, block_hash, ilk, chop) VALUES ($1, $2, $3, $4)`,
|
||||||
blockNumber, blockHash, ilk, chop)
|
blockNumber, blockHash, ilkID, chop)
|
||||||
return writeErr
|
if writeErr != nil {
|
||||||
|
rollbackErr := tx.Rollback()
|
||||||
|
if rollbackErr != nil {
|
||||||
|
return fmt.Errorf("failed to rollback transaction after failing to insert ilk chop: %s", writeErr.Error())
|
||||||
|
}
|
||||||
|
return writeErr
|
||||||
|
}
|
||||||
|
return tx.Commit()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (repository *CatStorageRepository) insertIlkLump(blockNumber int, blockHash string, metadata shared.StorageValueMetadata, lump string) error {
|
func (repository *CatStorageRepository) insertIlkLump(blockNumber int, blockHash string, metadata shared.StorageValueMetadata, lump string) error {
|
||||||
@ -108,10 +147,29 @@ func (repository *CatStorageRepository) insertIlkLump(blockNumber int, blockHash
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
_, writeErr := repository.db.Exec(
|
tx, txErr := repository.db.Begin()
|
||||||
|
if txErr != nil {
|
||||||
|
return txErr
|
||||||
|
}
|
||||||
|
ilkID, ilkErr := shared2.GetOrCreateIlkInTransaction(ilk, tx)
|
||||||
|
if ilkErr != nil {
|
||||||
|
rollbackErr := tx.Rollback()
|
||||||
|
if rollbackErr != nil {
|
||||||
|
return fmt.Errorf("failed to rollback transaction after failing to insert ilk: %s", ilkErr.Error())
|
||||||
|
}
|
||||||
|
return ilkErr
|
||||||
|
}
|
||||||
|
_, writeErr := tx.Exec(
|
||||||
`INSERT INTO maker.cat_ilk_lump (block_number, block_hash, ilk, lump) VALUES ($1, $2, $3, $4)`,
|
`INSERT INTO maker.cat_ilk_lump (block_number, block_hash, ilk, lump) VALUES ($1, $2, $3, $4)`,
|
||||||
blockNumber, blockHash, ilk, lump)
|
blockNumber, blockHash, ilkID, lump)
|
||||||
return writeErr
|
if writeErr != nil {
|
||||||
|
rollbackErr := tx.Rollback()
|
||||||
|
if rollbackErr != nil {
|
||||||
|
return fmt.Errorf("failed to rollback transaction after failing to insert ilk lump: %s", writeErr.Error())
|
||||||
|
}
|
||||||
|
return writeErr
|
||||||
|
}
|
||||||
|
return tx.Commit()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Flips mapping: uint256 => ilk, urn bytes32; ink, tab uint256 (both wad)
|
// Flips mapping: uint256 => ilk, urn bytes32; ink, tab uint256 (both wad)
|
||||||
@ -120,10 +178,29 @@ func (repository *CatStorageRepository) insertFlipIlk(blockNumber int, blockHash
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
_, writeErr := repository.db.Exec(
|
tx, txErr := repository.db.Begin()
|
||||||
|
if txErr != nil {
|
||||||
|
return txErr
|
||||||
|
}
|
||||||
|
ilkID, ilkErr := shared2.GetOrCreateIlkInTransaction(ilk, tx)
|
||||||
|
if ilkErr != nil {
|
||||||
|
rollbackErr := tx.Rollback()
|
||||||
|
if rollbackErr != nil {
|
||||||
|
return fmt.Errorf("failed to rollback transaction after failing to insert ilk: %s", ilkErr.Error())
|
||||||
|
}
|
||||||
|
return ilkErr
|
||||||
|
}
|
||||||
|
_, writeErr := tx.Exec(
|
||||||
`INSERT INTO maker.cat_flip_ilk (block_number, block_hash, flip, ilk) VALUES ($1, $2, $3, $4)`,
|
`INSERT INTO maker.cat_flip_ilk (block_number, block_hash, flip, ilk) VALUES ($1, $2, $3, $4)`,
|
||||||
blockNumber, blockHash, flip, ilk)
|
blockNumber, blockHash, flip, ilkID)
|
||||||
return writeErr
|
if writeErr != nil {
|
||||||
|
rollbackErr := tx.Rollback()
|
||||||
|
if rollbackErr != nil {
|
||||||
|
return fmt.Errorf("failed to rollback transaction after failing to insert flip ilk: %s", writeErr.Error())
|
||||||
|
}
|
||||||
|
return writeErr
|
||||||
|
}
|
||||||
|
return tx.Commit()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (repository *CatStorageRepository) insertFlipUrn(blockNumber int, blockHash string, metadata shared.StorageValueMetadata, urn string) error {
|
func (repository *CatStorageRepository) insertFlipUrn(blockNumber int, blockHash string, metadata shared.StorageValueMetadata, urn string) error {
|
||||||
|
@ -4,10 +4,12 @@ import (
|
|||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
|
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
|
||||||
|
shared2 "github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
|
||||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/storage_diffs/maker/cat"
|
"github.com/vulcanize/vulcanizedb/pkg/transformers/storage_diffs/maker/cat"
|
||||||
. "github.com/vulcanize/vulcanizedb/pkg/transformers/storage_diffs/maker/test_helpers"
|
. "github.com/vulcanize/vulcanizedb/pkg/transformers/storage_diffs/maker/test_helpers"
|
||||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/storage_diffs/shared"
|
"github.com/vulcanize/vulcanizedb/pkg/transformers/storage_diffs/shared"
|
||||||
"github.com/vulcanize/vulcanizedb/test_config"
|
"github.com/vulcanize/vulcanizedb/test_config"
|
||||||
|
"strconv"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ = Describe("Cat storage repository", func() {
|
var _ = Describe("Cat storage repository", func() {
|
||||||
@ -110,7 +112,9 @@ var _ = Describe("Cat storage repository", func() {
|
|||||||
|
|
||||||
err = db.Get(&result, `SELECT block_number, block_hash, ilk AS key, flip AS value FROM maker.cat_ilk_flip`)
|
err = db.Get(&result, `SELECT block_number, block_hash, ilk AS key, flip AS value FROM maker.cat_ilk_flip`)
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
AssertMapping(result, fakeBlockNumber, fakeBlockHash, fakeIlk, fakeAddress)
|
ilkID, err := shared2.GetOrCreateIlk(fakeIlk, db)
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
AssertMapping(result, fakeBlockNumber, fakeBlockHash, strconv.Itoa(ilkID), fakeAddress)
|
||||||
})
|
})
|
||||||
|
|
||||||
It("returns an error if metadata missing ilk", func() {
|
It("returns an error if metadata missing ilk", func() {
|
||||||
@ -130,7 +134,9 @@ var _ = Describe("Cat storage repository", func() {
|
|||||||
|
|
||||||
err = db.Get(&result, `SELECT block_number, block_hash, ilk AS key, chop AS value FROM maker.cat_ilk_chop`)
|
err = db.Get(&result, `SELECT block_number, block_hash, ilk AS key, chop AS value FROM maker.cat_ilk_chop`)
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
AssertMapping(result, fakeBlockNumber, fakeBlockHash, fakeIlk, fakeUint256)
|
ilkID, err := shared2.GetOrCreateIlk(fakeIlk, db)
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
AssertMapping(result, fakeBlockNumber, fakeBlockHash, strconv.Itoa(ilkID), fakeUint256)
|
||||||
})
|
})
|
||||||
|
|
||||||
It("returns an error if metadata missing ilk", func() {
|
It("returns an error if metadata missing ilk", func() {
|
||||||
@ -150,7 +156,9 @@ var _ = Describe("Cat storage repository", func() {
|
|||||||
|
|
||||||
err = db.Get(&result, `SELECT block_number, block_hash, ilk AS key, lump AS value FROM maker.cat_ilk_lump`)
|
err = db.Get(&result, `SELECT block_number, block_hash, ilk AS key, lump AS value FROM maker.cat_ilk_lump`)
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
AssertMapping(result, fakeBlockNumber, fakeBlockHash, fakeIlk, fakeUint256)
|
ilkID, err := shared2.GetOrCreateIlk(fakeIlk, db)
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
AssertMapping(result, fakeBlockNumber, fakeBlockHash, strconv.Itoa(ilkID), fakeUint256)
|
||||||
})
|
})
|
||||||
|
|
||||||
It("returns an error if metadata missing ilk", func() {
|
It("returns an error if metadata missing ilk", func() {
|
||||||
@ -174,7 +182,9 @@ var _ = Describe("Cat storage repository", func() {
|
|||||||
|
|
||||||
err = db.Get(&result, `SELECT block_number, block_hash, flip AS key, ilk AS value FROM maker.cat_flip_ilk`)
|
err = db.Get(&result, `SELECT block_number, block_hash, flip AS key, ilk AS value FROM maker.cat_flip_ilk`)
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
AssertMapping(result, fakeBlockNumber, fakeBlockHash, fakeUint256, fakeBytes32)
|
ilkID, err := shared2.GetOrCreateIlk(fakeBytes32, db)
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
AssertMapping(result, fakeBlockNumber, fakeBlockHash, fakeUint256, strconv.Itoa(ilkID))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("returns an error if metadata missing flip", func() {
|
It("returns an error if metadata missing flip", func() {
|
||||||
|
@ -34,9 +34,9 @@ func (repository *PitStorageRepository) SetDB(db *postgres.DB) {
|
|||||||
func (repository PitStorageRepository) Create(blockNumber int, blockHash string, metadata shared.StorageValueMetadata, value interface{}) error {
|
func (repository PitStorageRepository) Create(blockNumber int, blockHash string, metadata shared.StorageValueMetadata, value interface{}) error {
|
||||||
switch metadata.Name {
|
switch metadata.Name {
|
||||||
case IlkLine:
|
case IlkLine:
|
||||||
return repository.insertIlkLine(blockNumber, blockHash, metadata.Keys[shared.Ilk], value.(string))
|
return repository.insertIlkLine(blockNumber, blockHash, metadata, value.(string))
|
||||||
case IlkSpot:
|
case IlkSpot:
|
||||||
return repository.insertIlkSpot(blockNumber, blockHash, metadata.Keys[shared.Ilk], value.(string))
|
return repository.insertIlkSpot(blockNumber, blockHash, metadata, value.(string))
|
||||||
case PitDrip:
|
case PitDrip:
|
||||||
return repository.insertPitDrip(blockNumber, blockHash, value.(string))
|
return repository.insertPitDrip(blockNumber, blockHash, value.(string))
|
||||||
case PitLine:
|
case PitLine:
|
||||||
@ -50,7 +50,11 @@ func (repository PitStorageRepository) Create(blockNumber int, blockHash string,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (repository PitStorageRepository) insertIlkLine(blockNumber int, blockHash string, ilk string, line string) error {
|
func (repository PitStorageRepository) insertIlkLine(blockNumber int, blockHash string, metadata shared.StorageValueMetadata, line string) error {
|
||||||
|
ilk, err := getIlk(metadata.Keys)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
tx, err := repository.db.Begin()
|
tx, err := repository.db.Begin()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -74,7 +78,11 @@ func (repository PitStorageRepository) insertIlkLine(blockNumber int, blockHash
|
|||||||
return tx.Commit()
|
return tx.Commit()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (repository PitStorageRepository) insertIlkSpot(blockNumber int, blockHash string, ilk string, spot string) error {
|
func (repository PitStorageRepository) insertIlkSpot(blockNumber int, blockHash string, metadata shared.StorageValueMetadata, spot string) error {
|
||||||
|
ilk, err := getIlk(metadata.Keys)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
tx, err := repository.db.Begin()
|
tx, err := repository.db.Begin()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -117,3 +125,11 @@ func (repository PitStorageRepository) insertPitVat(blockNumber int, blockHash s
|
|||||||
_, err := repository.db.Exec(`INSERT INTO maker.pit_vat (block_number, block_hash, vat) VALUES ($1, $2, $3)`, blockNumber, blockHash, vat)
|
_, err := repository.db.Exec(`INSERT INTO maker.pit_vat (block_number, block_hash, vat) VALUES ($1, $2, $3)`, blockNumber, blockHash, vat)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getIlk(keys map[shared.Key]string) (string, error) {
|
||||||
|
ilk, ok := keys[shared.Ilk]
|
||||||
|
if !ok {
|
||||||
|
return "", shared.ErrMetadataMalformed{MissingData: shared.Ilk}
|
||||||
|
}
|
||||||
|
return ilk, nil
|
||||||
|
}
|
||||||
|
@ -30,111 +30,108 @@ import (
|
|||||||
|
|
||||||
var _ = Describe("Pit storage repository", func() {
|
var _ = Describe("Pit storage repository", func() {
|
||||||
var (
|
var (
|
||||||
blockNumber int
|
db *postgres.DB
|
||||||
blockHash string
|
err error
|
||||||
db *postgres.DB
|
repo pit.PitStorageRepository
|
||||||
err error
|
fakeAddress = "0x12345"
|
||||||
repo pit.PitStorageRepository
|
fakeBlockHash = "expected_block_hash"
|
||||||
|
fakeBlockNumber = 123
|
||||||
|
fakeIlk = "fake_ilk"
|
||||||
|
fakeUint256 = "12345"
|
||||||
)
|
)
|
||||||
|
|
||||||
BeforeEach(func() {
|
BeforeEach(func() {
|
||||||
blockNumber = 123
|
|
||||||
blockHash = "expected_block_hash"
|
|
||||||
db = test_config.NewTestDB(test_config.NewTestNode())
|
db = test_config.NewTestDB(test_config.NewTestNode())
|
||||||
test_config.CleanTestDB(db)
|
test_config.CleanTestDB(db)
|
||||||
repo = pit.PitStorageRepository{}
|
repo = pit.PitStorageRepository{}
|
||||||
repo.SetDB(db)
|
repo.SetDB(db)
|
||||||
})
|
})
|
||||||
|
|
||||||
It("persists an ilk line", func() {
|
Describe("Ilk", func() {
|
||||||
expectedIlk := "fake_ilk"
|
Describe("Line", func() {
|
||||||
expectedLine := "12345"
|
It("writes a row", func() {
|
||||||
ilkLineMetadata := shared.StorageValueMetadata{
|
ilkLineMetadata := shared.GetStorageValueMetadata(pit.IlkLine, map[shared.Key]string{shared.Ilk: fakeIlk}, shared.Uint256)
|
||||||
Name: pit.IlkLine,
|
|
||||||
Keys: map[shared.Key]string{shared.Ilk: expectedIlk},
|
|
||||||
Type: shared.Uint256,
|
|
||||||
}
|
|
||||||
err = repo.Create(blockNumber, blockHash, ilkLineMetadata, expectedLine)
|
|
||||||
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
err = repo.Create(fakeBlockNumber, fakeBlockHash, ilkLineMetadata, fakeUint256)
|
||||||
|
|
||||||
var result MappingRes
|
Expect(err).NotTo(HaveOccurred())
|
||||||
err = db.Get(&result, `SELECT block_number, block_hash, ilk AS key, line AS value FROM maker.pit_ilk_line`)
|
var result MappingRes
|
||||||
Expect(err).NotTo(HaveOccurred())
|
err = db.Get(&result, `SELECT block_number, block_hash, ilk AS key, line AS value FROM maker.pit_ilk_line`)
|
||||||
ilkID, err := shared2.GetOrCreateIlk(expectedIlk, db)
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(err).NotTo(HaveOccurred())
|
ilkID, err := shared2.GetOrCreateIlk(fakeIlk, db)
|
||||||
AssertMapping(result, blockNumber, blockHash, strconv.Itoa(ilkID), expectedLine)
|
Expect(err).NotTo(HaveOccurred())
|
||||||
})
|
AssertMapping(result, fakeBlockNumber, fakeBlockHash, strconv.Itoa(ilkID), fakeUint256)
|
||||||
|
})
|
||||||
|
|
||||||
It("persists an ilk spot", func() {
|
It("returns an error if metadata missing ilk", func() {
|
||||||
expectedIlk := "fake_ilk"
|
malformedIlkLineMetadata := shared.GetStorageValueMetadata(pit.IlkLine, nil, shared.Uint256)
|
||||||
expectedSpot := "12345"
|
|
||||||
ilkSpotMetadata := shared.StorageValueMetadata{
|
|
||||||
Name: pit.IlkSpot,
|
|
||||||
Keys: map[shared.Key]string{shared.Ilk: expectedIlk},
|
|
||||||
Type: shared.Uint256,
|
|
||||||
}
|
|
||||||
err = repo.Create(blockNumber, blockHash, ilkSpotMetadata, expectedSpot)
|
|
||||||
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
err := repo.Create(fakeBlockNumber, fakeBlockHash, malformedIlkLineMetadata, fakeUint256)
|
||||||
|
Expect(err).To(MatchError(shared.ErrMetadataMalformed{MissingData: shared.Ilk}))
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
var result MappingRes
|
Describe("Spot", func() {
|
||||||
err = db.Get(&result, `SELECT block_number, block_hash, ilk AS key, spot AS value FROM maker.pit_ilk_spot`)
|
It("writes a row", func() {
|
||||||
Expect(err).NotTo(HaveOccurred())
|
ilkSpotMetadata := shared.GetStorageValueMetadata(pit.IlkSpot, map[shared.Key]string{shared.Ilk: fakeIlk}, shared.Uint256)
|
||||||
ilkID, err := shared2.GetOrCreateIlk(expectedIlk, db)
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
err = repo.Create(fakeBlockNumber, fakeBlockHash, ilkSpotMetadata, fakeUint256)
|
||||||
AssertMapping(result, blockNumber, blockHash, strconv.Itoa(ilkID), expectedSpot)
|
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
var result MappingRes
|
||||||
|
err = db.Get(&result, `SELECT block_number, block_hash, ilk AS key, spot AS value FROM maker.pit_ilk_spot`)
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
ilkID, err := shared2.GetOrCreateIlk(fakeIlk, db)
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
AssertMapping(result, fakeBlockNumber, fakeBlockHash, strconv.Itoa(ilkID), fakeUint256)
|
||||||
|
})
|
||||||
|
|
||||||
|
It("returns an error if metadata missing ilk", func() {
|
||||||
|
malformedIlkSpotMetadata := shared.GetStorageValueMetadata(pit.IlkSpot, nil, shared.Uint256)
|
||||||
|
|
||||||
|
err := repo.Create(fakeBlockNumber, fakeBlockHash, malformedIlkSpotMetadata, fakeUint256)
|
||||||
|
Expect(err).To(MatchError(shared.ErrMetadataMalformed{MissingData: shared.Ilk}))
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
It("persists a pit drip", func() {
|
It("persists a pit drip", func() {
|
||||||
expectedDrip := "0x0123456789abcdef0123"
|
err = repo.Create(fakeBlockNumber, fakeBlockHash, pit.DripMetadata, fakeAddress)
|
||||||
|
|
||||||
err = repo.Create(blockNumber, blockHash, pit.DripMetadata, expectedDrip)
|
|
||||||
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
|
||||||
var result VariableRes
|
var result VariableRes
|
||||||
err = db.Get(&result, `SELECT block_number, block_hash, drip AS value FROM maker.pit_drip`)
|
err = db.Get(&result, `SELECT block_number, block_hash, drip AS value FROM maker.pit_drip`)
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
AssertVariable(result, blockNumber, blockHash, expectedDrip)
|
AssertVariable(result, fakeBlockNumber, fakeBlockHash, fakeAddress)
|
||||||
})
|
})
|
||||||
|
|
||||||
It("persists a pit line", func() {
|
It("persists a pit line", func() {
|
||||||
expectedLine := "12345"
|
err = repo.Create(fakeBlockNumber, fakeBlockHash, pit.LineMetadata, fakeUint256)
|
||||||
|
|
||||||
err = repo.Create(blockNumber, blockHash, pit.LineMetadata, expectedLine)
|
|
||||||
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
|
||||||
var result VariableRes
|
var result VariableRes
|
||||||
err = db.Get(&result, `SELECT block_number, block_hash, line AS value FROM maker.pit_line`)
|
err = db.Get(&result, `SELECT block_number, block_hash, line AS value FROM maker.pit_line`)
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
AssertVariable(result, blockNumber, blockHash, expectedLine)
|
AssertVariable(result, fakeBlockNumber, fakeBlockHash, fakeUint256)
|
||||||
})
|
})
|
||||||
|
|
||||||
It("persists a pit live", func() {
|
It("persists a pit live", func() {
|
||||||
expectedLive := "12345"
|
err = repo.Create(fakeBlockNumber, fakeBlockHash, pit.LiveMetadata, fakeUint256)
|
||||||
|
|
||||||
err = repo.Create(blockNumber, blockHash, pit.LiveMetadata, expectedLive)
|
|
||||||
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
|
||||||
var result VariableRes
|
var result VariableRes
|
||||||
err = db.Get(&result, `SELECT block_number, block_hash, live AS value FROM maker.pit_live`)
|
err = db.Get(&result, `SELECT block_number, block_hash, live AS value FROM maker.pit_live`)
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
AssertVariable(result, blockNumber, blockHash, expectedLive)
|
AssertVariable(result, fakeBlockNumber, fakeBlockHash, fakeUint256)
|
||||||
})
|
})
|
||||||
|
|
||||||
It("persists a pit vat", func() {
|
It("persists a pit vat", func() {
|
||||||
expectedVat := "0x0123456789abcdef0123"
|
err = repo.Create(fakeBlockNumber, fakeBlockHash, pit.VatMetadata, fakeAddress)
|
||||||
|
|
||||||
err = repo.Create(blockNumber, blockHash, pit.VatMetadata, expectedVat)
|
|
||||||
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
|
||||||
var result VariableRes
|
var result VariableRes
|
||||||
err = db.Get(&result, `SELECT block_number, block_hash, vat AS value FROM maker.pit_vat`)
|
err = db.Get(&result, `SELECT block_number, block_hash, vat AS value FROM maker.pit_vat`)
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
AssertVariable(result, blockNumber, blockHash, expectedVat)
|
AssertVariable(result, fakeBlockNumber, fakeBlockHash, fakeAddress)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -32,11 +32,7 @@ var _ = Describe("Vat storage repository", func() {
|
|||||||
|
|
||||||
Describe("dai", func() {
|
Describe("dai", func() {
|
||||||
It("writes a row", func() {
|
It("writes a row", func() {
|
||||||
daiMetadata := shared.StorageValueMetadata{
|
daiMetadata := shared.GetStorageValueMetadata(vat.Dai, map[shared.Key]string{shared.Guy: fakeGuy}, shared.Uint256)
|
||||||
Name: vat.Dai,
|
|
||||||
Keys: map[shared.Key]string{shared.Guy: fakeGuy},
|
|
||||||
Type: shared.Uint256,
|
|
||||||
}
|
|
||||||
|
|
||||||
err := repo.Create(fakeBlockNumber, fakeBlockHash, daiMetadata, fakeUint256)
|
err := repo.Create(fakeBlockNumber, fakeBlockHash, daiMetadata, fakeUint256)
|
||||||
|
|
||||||
@ -49,11 +45,7 @@ var _ = Describe("Vat storage repository", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
It("returns error if metadata missing guy", func() {
|
It("returns error if metadata missing guy", func() {
|
||||||
malformedDaiMetadata := shared.StorageValueMetadata{
|
malformedDaiMetadata := shared.GetStorageValueMetadata(vat.Dai, nil, shared.Uint256)
|
||||||
Name: vat.Dai,
|
|
||||||
Keys: nil,
|
|
||||||
Type: shared.Uint256,
|
|
||||||
}
|
|
||||||
|
|
||||||
err := repo.Create(fakeBlockNumber, fakeBlockHash, malformedDaiMetadata, fakeUint256)
|
err := repo.Create(fakeBlockNumber, fakeBlockHash, malformedDaiMetadata, fakeUint256)
|
||||||
|
|
||||||
@ -64,11 +56,7 @@ var _ = Describe("Vat storage repository", func() {
|
|||||||
|
|
||||||
Describe("gem", func() {
|
Describe("gem", func() {
|
||||||
It("writes row", func() {
|
It("writes row", func() {
|
||||||
gemMetadata := shared.StorageValueMetadata{
|
gemMetadata := shared.GetStorageValueMetadata(vat.Gem, map[shared.Key]string{shared.Ilk: fakeIlk, shared.Guy: fakeGuy}, shared.Uint256)
|
||||||
Name: vat.Gem,
|
|
||||||
Keys: map[shared.Key]string{shared.Ilk: fakeIlk, shared.Guy: fakeGuy},
|
|
||||||
Type: shared.Uint256,
|
|
||||||
}
|
|
||||||
|
|
||||||
err := repo.Create(fakeBlockNumber, fakeBlockHash, gemMetadata, fakeUint256)
|
err := repo.Create(fakeBlockNumber, fakeBlockHash, gemMetadata, fakeUint256)
|
||||||
|
|
||||||
@ -83,11 +71,7 @@ var _ = Describe("Vat storage repository", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
It("returns error if metadata missing ilk", func() {
|
It("returns error if metadata missing ilk", func() {
|
||||||
malformedGemMetadata := shared.StorageValueMetadata{
|
malformedGemMetadata := shared.GetStorageValueMetadata(vat.Gem, map[shared.Key]string{shared.Guy: fakeGuy}, shared.Uint256)
|
||||||
Name: vat.Gem,
|
|
||||||
Keys: map[shared.Key]string{shared.Guy: fakeGuy},
|
|
||||||
Type: shared.Uint256,
|
|
||||||
}
|
|
||||||
|
|
||||||
err := repo.Create(fakeBlockNumber, fakeBlockHash, malformedGemMetadata, fakeUint256)
|
err := repo.Create(fakeBlockNumber, fakeBlockHash, malformedGemMetadata, fakeUint256)
|
||||||
|
|
||||||
@ -96,11 +80,7 @@ var _ = Describe("Vat storage repository", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
It("returns error if metadata missing guy", func() {
|
It("returns error if metadata missing guy", func() {
|
||||||
malformedGemMetadata := shared.StorageValueMetadata{
|
malformedGemMetadata := shared.GetStorageValueMetadata(vat.Gem, map[shared.Key]string{shared.Ilk: fakeIlk}, shared.Uint256)
|
||||||
Name: vat.Gem,
|
|
||||||
Keys: map[shared.Key]string{shared.Ilk: fakeIlk},
|
|
||||||
Type: shared.Uint256,
|
|
||||||
}
|
|
||||||
|
|
||||||
err := repo.Create(fakeBlockNumber, fakeBlockHash, malformedGemMetadata, fakeUint256)
|
err := repo.Create(fakeBlockNumber, fakeBlockHash, malformedGemMetadata, fakeUint256)
|
||||||
|
|
||||||
@ -111,11 +91,7 @@ var _ = Describe("Vat storage repository", func() {
|
|||||||
|
|
||||||
Describe("ilk Art", func() {
|
Describe("ilk Art", func() {
|
||||||
It("writes row", func() {
|
It("writes row", func() {
|
||||||
ilkArtMetadata := shared.StorageValueMetadata{
|
ilkArtMetadata := shared.GetStorageValueMetadata(vat.IlkArt, map[shared.Key]string{shared.Ilk: fakeIlk}, shared.Uint256)
|
||||||
Name: vat.IlkArt,
|
|
||||||
Keys: map[shared.Key]string{shared.Ilk: fakeIlk},
|
|
||||||
Type: shared.Uint256,
|
|
||||||
}
|
|
||||||
|
|
||||||
err := repo.Create(fakeBlockNumber, fakeBlockHash, ilkArtMetadata, fakeUint256)
|
err := repo.Create(fakeBlockNumber, fakeBlockHash, ilkArtMetadata, fakeUint256)
|
||||||
|
|
||||||
@ -130,11 +106,7 @@ var _ = Describe("Vat storage repository", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
It("returns error if metadata missing ilk", func() {
|
It("returns error if metadata missing ilk", func() {
|
||||||
malformedIlkArtMetadata := shared.StorageValueMetadata{
|
malformedIlkArtMetadata := shared.GetStorageValueMetadata(vat.IlkArt, nil, shared.Uint256)
|
||||||
Name: vat.IlkArt,
|
|
||||||
Keys: nil,
|
|
||||||
Type: shared.Uint256,
|
|
||||||
}
|
|
||||||
|
|
||||||
err := repo.Create(fakeBlockNumber, fakeBlockHash, malformedIlkArtMetadata, fakeUint256)
|
err := repo.Create(fakeBlockNumber, fakeBlockHash, malformedIlkArtMetadata, fakeUint256)
|
||||||
|
|
||||||
@ -145,11 +117,7 @@ var _ = Describe("Vat storage repository", func() {
|
|||||||
|
|
||||||
Describe("ilk Ink", func() {
|
Describe("ilk Ink", func() {
|
||||||
It("writes row", func() {
|
It("writes row", func() {
|
||||||
ilkInkMetadata := shared.StorageValueMetadata{
|
ilkInkMetadata := shared.GetStorageValueMetadata(vat.IlkInk, map[shared.Key]string{shared.Ilk: fakeIlk}, shared.Uint256)
|
||||||
Name: vat.IlkInk,
|
|
||||||
Keys: map[shared.Key]string{shared.Ilk: fakeIlk},
|
|
||||||
Type: shared.Uint256,
|
|
||||||
}
|
|
||||||
|
|
||||||
err := repo.Create(fakeBlockNumber, fakeBlockHash, ilkInkMetadata, fakeUint256)
|
err := repo.Create(fakeBlockNumber, fakeBlockHash, ilkInkMetadata, fakeUint256)
|
||||||
|
|
||||||
@ -164,11 +132,7 @@ var _ = Describe("Vat storage repository", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
It("returns error if metadata missing ilk", func() {
|
It("returns error if metadata missing ilk", func() {
|
||||||
malformedIlkInkMetadata := shared.StorageValueMetadata{
|
malformedIlkInkMetadata := shared.GetStorageValueMetadata(vat.IlkInk, nil, shared.Uint256)
|
||||||
Name: vat.IlkInk,
|
|
||||||
Keys: nil,
|
|
||||||
Type: shared.Uint256,
|
|
||||||
}
|
|
||||||
|
|
||||||
err := repo.Create(fakeBlockNumber, fakeBlockHash, malformedIlkInkMetadata, fakeUint256)
|
err := repo.Create(fakeBlockNumber, fakeBlockHash, malformedIlkInkMetadata, fakeUint256)
|
||||||
|
|
||||||
@ -179,11 +143,7 @@ var _ = Describe("Vat storage repository", func() {
|
|||||||
|
|
||||||
Describe("ilk rate", func() {
|
Describe("ilk rate", func() {
|
||||||
It("writes row", func() {
|
It("writes row", func() {
|
||||||
ilkRateMetadata := shared.StorageValueMetadata{
|
ilkRateMetadata := shared.GetStorageValueMetadata(vat.IlkRate, map[shared.Key]string{shared.Ilk: fakeIlk}, shared.Uint256)
|
||||||
Name: vat.IlkRate,
|
|
||||||
Keys: map[shared.Key]string{shared.Ilk: fakeIlk},
|
|
||||||
Type: shared.Uint256,
|
|
||||||
}
|
|
||||||
|
|
||||||
err := repo.Create(fakeBlockNumber, fakeBlockHash, ilkRateMetadata, fakeUint256)
|
err := repo.Create(fakeBlockNumber, fakeBlockHash, ilkRateMetadata, fakeUint256)
|
||||||
|
|
||||||
@ -198,11 +158,7 @@ var _ = Describe("Vat storage repository", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
It("returns error if metadata missing ilk", func() {
|
It("returns error if metadata missing ilk", func() {
|
||||||
malformedIlkRateMetadata := shared.StorageValueMetadata{
|
malformedIlkRateMetadata := shared.GetStorageValueMetadata(vat.IlkRate, nil, shared.Uint256)
|
||||||
Name: vat.IlkRate,
|
|
||||||
Keys: nil,
|
|
||||||
Type: shared.Uint256,
|
|
||||||
}
|
|
||||||
|
|
||||||
err := repo.Create(fakeBlockNumber, fakeBlockHash, malformedIlkRateMetadata, fakeUint256)
|
err := repo.Create(fakeBlockNumber, fakeBlockHash, malformedIlkRateMetadata, fakeUint256)
|
||||||
|
|
||||||
@ -213,11 +169,7 @@ var _ = Describe("Vat storage repository", func() {
|
|||||||
|
|
||||||
Describe("ilk take", func() {
|
Describe("ilk take", func() {
|
||||||
It("writes row", func() {
|
It("writes row", func() {
|
||||||
ilkTakeMetadata := shared.StorageValueMetadata{
|
ilkTakeMetadata := shared.GetStorageValueMetadata(vat.IlkTake, map[shared.Key]string{shared.Ilk: fakeIlk}, shared.Uint256)
|
||||||
Name: vat.IlkTake,
|
|
||||||
Keys: map[shared.Key]string{shared.Ilk: fakeIlk},
|
|
||||||
Type: shared.Uint256,
|
|
||||||
}
|
|
||||||
|
|
||||||
err := repo.Create(fakeBlockNumber, fakeBlockHash, ilkTakeMetadata, fakeUint256)
|
err := repo.Create(fakeBlockNumber, fakeBlockHash, ilkTakeMetadata, fakeUint256)
|
||||||
|
|
||||||
@ -232,11 +184,7 @@ var _ = Describe("Vat storage repository", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
It("returns error if metadata missing ilk", func() {
|
It("returns error if metadata missing ilk", func() {
|
||||||
malformedIlkTakeMetadata := shared.StorageValueMetadata{
|
malformedIlkTakeMetadata := shared.GetStorageValueMetadata(vat.IlkTake, nil, shared.Uint256)
|
||||||
Name: vat.IlkTake,
|
|
||||||
Keys: nil,
|
|
||||||
Type: shared.Uint256,
|
|
||||||
}
|
|
||||||
|
|
||||||
err := repo.Create(fakeBlockNumber, fakeBlockHash, malformedIlkTakeMetadata, fakeUint256)
|
err := repo.Create(fakeBlockNumber, fakeBlockHash, malformedIlkTakeMetadata, fakeUint256)
|
||||||
|
|
||||||
@ -247,11 +195,7 @@ var _ = Describe("Vat storage repository", func() {
|
|||||||
|
|
||||||
Describe("sin", func() {
|
Describe("sin", func() {
|
||||||
It("writes a row", func() {
|
It("writes a row", func() {
|
||||||
sinMetadata := shared.StorageValueMetadata{
|
sinMetadata := shared.GetStorageValueMetadata(vat.Sin, map[shared.Key]string{shared.Guy: fakeGuy}, shared.Uint256)
|
||||||
Name: vat.Sin,
|
|
||||||
Keys: map[shared.Key]string{shared.Guy: fakeGuy},
|
|
||||||
Type: shared.Uint256,
|
|
||||||
}
|
|
||||||
|
|
||||||
err := repo.Create(fakeBlockNumber, fakeBlockHash, sinMetadata, fakeUint256)
|
err := repo.Create(fakeBlockNumber, fakeBlockHash, sinMetadata, fakeUint256)
|
||||||
|
|
||||||
@ -264,11 +208,7 @@ var _ = Describe("Vat storage repository", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
It("returns error if metadata missing guy", func() {
|
It("returns error if metadata missing guy", func() {
|
||||||
malformedSinMetadata := shared.StorageValueMetadata{
|
malformedSinMetadata := shared.GetStorageValueMetadata(vat.Sin, nil, shared.Uint256)
|
||||||
Name: vat.Sin,
|
|
||||||
Keys: nil,
|
|
||||||
Type: shared.Uint256,
|
|
||||||
}
|
|
||||||
|
|
||||||
err := repo.Create(fakeBlockNumber, fakeBlockHash, malformedSinMetadata, fakeUint256)
|
err := repo.Create(fakeBlockNumber, fakeBlockHash, malformedSinMetadata, fakeUint256)
|
||||||
|
|
||||||
@ -279,11 +219,7 @@ var _ = Describe("Vat storage repository", func() {
|
|||||||
|
|
||||||
Describe("urn art", func() {
|
Describe("urn art", func() {
|
||||||
It("writes row", func() {
|
It("writes row", func() {
|
||||||
urnArtMetadata := shared.StorageValueMetadata{
|
urnArtMetadata := shared.GetStorageValueMetadata(vat.UrnArt, map[shared.Key]string{shared.Ilk: fakeIlk, shared.Guy: fakeGuy}, shared.Uint256)
|
||||||
Name: vat.UrnArt,
|
|
||||||
Keys: map[shared.Key]string{shared.Ilk: fakeIlk, shared.Guy: fakeGuy},
|
|
||||||
Type: shared.Uint256,
|
|
||||||
}
|
|
||||||
|
|
||||||
err := repo.Create(fakeBlockNumber, fakeBlockHash, urnArtMetadata, fakeUint256)
|
err := repo.Create(fakeBlockNumber, fakeBlockHash, urnArtMetadata, fakeUint256)
|
||||||
|
|
||||||
@ -298,11 +234,7 @@ var _ = Describe("Vat storage repository", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
It("returns error if metadata missing ilk", func() {
|
It("returns error if metadata missing ilk", func() {
|
||||||
malformedUrnArtMetadata := shared.StorageValueMetadata{
|
malformedUrnArtMetadata := shared.GetStorageValueMetadata(vat.UrnArt, map[shared.Key]string{shared.Guy: fakeGuy}, shared.Uint256)
|
||||||
Name: vat.UrnArt,
|
|
||||||
Keys: map[shared.Key]string{shared.Guy: fakeGuy},
|
|
||||||
Type: shared.Uint256,
|
|
||||||
}
|
|
||||||
|
|
||||||
err := repo.Create(fakeBlockNumber, fakeBlockHash, malformedUrnArtMetadata, fakeUint256)
|
err := repo.Create(fakeBlockNumber, fakeBlockHash, malformedUrnArtMetadata, fakeUint256)
|
||||||
|
|
||||||
@ -311,11 +243,7 @@ var _ = Describe("Vat storage repository", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
It("returns error if metadata missing guy", func() {
|
It("returns error if metadata missing guy", func() {
|
||||||
malformedUrnArtMetadata := shared.StorageValueMetadata{
|
malformedUrnArtMetadata := shared.GetStorageValueMetadata(vat.UrnArt, map[shared.Key]string{shared.Ilk: fakeIlk}, shared.Uint256)
|
||||||
Name: vat.UrnArt,
|
|
||||||
Keys: map[shared.Key]string{shared.Ilk: fakeIlk},
|
|
||||||
Type: shared.Uint256,
|
|
||||||
}
|
|
||||||
|
|
||||||
err := repo.Create(fakeBlockNumber, fakeBlockHash, malformedUrnArtMetadata, fakeUint256)
|
err := repo.Create(fakeBlockNumber, fakeBlockHash, malformedUrnArtMetadata, fakeUint256)
|
||||||
|
|
||||||
@ -326,11 +254,7 @@ var _ = Describe("Vat storage repository", func() {
|
|||||||
|
|
||||||
Describe("urn ink", func() {
|
Describe("urn ink", func() {
|
||||||
It("writes row", func() {
|
It("writes row", func() {
|
||||||
urnInkMetadata := shared.StorageValueMetadata{
|
urnInkMetadata := shared.GetStorageValueMetadata(vat.UrnInk, map[shared.Key]string{shared.Ilk: fakeIlk, shared.Guy: fakeGuy}, shared.Uint256)
|
||||||
Name: vat.UrnInk,
|
|
||||||
Keys: map[shared.Key]string{shared.Ilk: fakeIlk, shared.Guy: fakeGuy},
|
|
||||||
Type: shared.Uint256,
|
|
||||||
}
|
|
||||||
|
|
||||||
err := repo.Create(fakeBlockNumber, fakeBlockHash, urnInkMetadata, fakeUint256)
|
err := repo.Create(fakeBlockNumber, fakeBlockHash, urnInkMetadata, fakeUint256)
|
||||||
|
|
||||||
@ -345,11 +269,7 @@ var _ = Describe("Vat storage repository", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
It("returns error if metadata missing ilk", func() {
|
It("returns error if metadata missing ilk", func() {
|
||||||
malformedUrnInkMetadata := shared.StorageValueMetadata{
|
malformedUrnInkMetadata := shared.GetStorageValueMetadata(vat.UrnInk, map[shared.Key]string{shared.Guy: fakeGuy}, shared.Uint256)
|
||||||
Name: vat.UrnInk,
|
|
||||||
Keys: map[shared.Key]string{shared.Guy: fakeGuy},
|
|
||||||
Type: shared.Uint256,
|
|
||||||
}
|
|
||||||
|
|
||||||
err := repo.Create(fakeBlockNumber, fakeBlockHash, malformedUrnInkMetadata, fakeUint256)
|
err := repo.Create(fakeBlockNumber, fakeBlockHash, malformedUrnInkMetadata, fakeUint256)
|
||||||
|
|
||||||
@ -358,11 +278,7 @@ var _ = Describe("Vat storage repository", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
It("returns error if metadata missing guy", func() {
|
It("returns error if metadata missing guy", func() {
|
||||||
malformedUrnInkMetadata := shared.StorageValueMetadata{
|
malformedUrnInkMetadata := shared.GetStorageValueMetadata(vat.UrnInk, map[shared.Key]string{shared.Ilk: fakeIlk}, shared.Uint256)
|
||||||
Name: vat.UrnInk,
|
|
||||||
Keys: map[shared.Key]string{shared.Ilk: fakeIlk},
|
|
||||||
Type: shared.Uint256,
|
|
||||||
}
|
|
||||||
|
|
||||||
err := repo.Create(fakeBlockNumber, fakeBlockHash, malformedUrnInkMetadata, fakeUint256)
|
err := repo.Create(fakeBlockNumber, fakeBlockHash, malformedUrnInkMetadata, fakeUint256)
|
||||||
|
|
||||||
@ -372,13 +288,7 @@ var _ = Describe("Vat storage repository", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
It("persists vat debt", func() {
|
It("persists vat debt", func() {
|
||||||
debtMetadata := shared.StorageValueMetadata{
|
err := repo.Create(fakeBlockNumber, fakeBlockHash, vat.DebtMetadata, fakeUint256)
|
||||||
Name: vat.VatDebt,
|
|
||||||
Keys: nil,
|
|
||||||
Type: shared.Uint256,
|
|
||||||
}
|
|
||||||
|
|
||||||
err := repo.Create(fakeBlockNumber, fakeBlockHash, debtMetadata, fakeUint256)
|
|
||||||
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
|
||||||
@ -389,13 +299,7 @@ var _ = Describe("Vat storage repository", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
It("persists vat vice", func() {
|
It("persists vat vice", func() {
|
||||||
viceMetadata := shared.StorageValueMetadata{
|
err := repo.Create(fakeBlockNumber, fakeBlockHash, vat.ViceMetadata, fakeUint256)
|
||||||
Name: vat.VatVice,
|
|
||||||
Keys: nil,
|
|
||||||
Type: shared.Uint256,
|
|
||||||
}
|
|
||||||
|
|
||||||
err := repo.Create(fakeBlockNumber, fakeBlockHash, viceMetadata, fakeUint256)
|
|
||||||
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user