forked from cerc-io/ipld-eth-server
DRY up storage diff repo tests
This commit is contained in:
parent
5746de7c97
commit
56ca45509f
@ -5,6 +5,7 @@ import (
|
|||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
|
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
|
||||||
"github.com/vulcanize/vulcanizedb/pkg/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/shared"
|
"github.com/vulcanize/vulcanizedb/pkg/transformers/storage_diffs/shared"
|
||||||
"github.com/vulcanize/vulcanizedb/test_config"
|
"github.com/vulcanize/vulcanizedb/test_config"
|
||||||
)
|
)
|
||||||
@ -40,9 +41,7 @@ var _ = Describe("Cat storage repository", func() {
|
|||||||
|
|
||||||
err = db.Get(&result, `SELECT block_number, block_hash, nflip AS value FROM maker.cat_nflip`)
|
err = db.Get(&result, `SELECT block_number, block_hash, nflip AS value FROM maker.cat_nflip`)
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(result.BlockNumber).To(Equal(fakeBlockNumber))
|
AssertVariable(result, fakeBlockNumber, fakeBlockHash, fakeUint256)
|
||||||
Expect(result.BlockHash).To(Equal(fakeBlockHash))
|
|
||||||
Expect(result.Value).To(Equal(fakeUint256))
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -55,9 +54,7 @@ var _ = Describe("Cat storage repository", func() {
|
|||||||
|
|
||||||
err = db.Get(&result, `SELECT block_number, block_hash, live AS value FROM maker.cat_live`)
|
err = db.Get(&result, `SELECT block_number, block_hash, live AS value FROM maker.cat_live`)
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(result.BlockNumber).To(Equal(fakeBlockNumber))
|
AssertVariable(result, fakeBlockNumber, fakeBlockHash, fakeUint256)
|
||||||
Expect(result.BlockHash).To(Equal(fakeBlockHash))
|
|
||||||
Expect(result.Value).To(Equal(fakeUint256))
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -70,9 +67,7 @@ var _ = Describe("Cat storage repository", func() {
|
|||||||
|
|
||||||
err = db.Get(&result, `SELECT block_number, block_hash, vat AS value FROM maker.cat_vat`)
|
err = db.Get(&result, `SELECT block_number, block_hash, vat AS value FROM maker.cat_vat`)
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(result.BlockNumber).To(Equal(fakeBlockNumber))
|
AssertVariable(result, fakeBlockNumber, fakeBlockHash, fakeAddress)
|
||||||
Expect(result.BlockHash).To(Equal(fakeBlockHash))
|
|
||||||
Expect(result.Value).To(Equal(fakeAddress))
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -85,9 +80,7 @@ var _ = Describe("Cat storage repository", func() {
|
|||||||
|
|
||||||
err = db.Get(&result, `SELECT block_number, block_hash, pit AS value FROM maker.cat_pit`)
|
err = db.Get(&result, `SELECT block_number, block_hash, pit AS value FROM maker.cat_pit`)
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(result.BlockNumber).To(Equal(fakeBlockNumber))
|
AssertVariable(result, fakeBlockNumber, fakeBlockHash, fakeAddress)
|
||||||
Expect(result.BlockHash).To(Equal(fakeBlockHash))
|
|
||||||
Expect(result.Value).To(Equal(fakeAddress))
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -100,9 +93,7 @@ var _ = Describe("Cat storage repository", func() {
|
|||||||
|
|
||||||
err = db.Get(&result, `SELECT block_number, block_hash, vow AS value FROM maker.cat_vow`)
|
err = db.Get(&result, `SELECT block_number, block_hash, vow AS value FROM maker.cat_vow`)
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(result.BlockNumber).To(Equal(fakeBlockNumber))
|
AssertVariable(result, fakeBlockNumber, fakeBlockHash, fakeAddress)
|
||||||
Expect(result.BlockHash).To(Equal(fakeBlockHash))
|
|
||||||
Expect(result.Value).To(Equal(fakeAddress))
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -119,10 +110,7 @@ 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())
|
||||||
Expect(result.BlockNumber).To(Equal(fakeBlockNumber))
|
AssertMapping(result, fakeBlockNumber, fakeBlockHash, fakeIlk, fakeAddress)
|
||||||
Expect(result.BlockHash).To(Equal(fakeBlockHash))
|
|
||||||
Expect(result.Key).To(Equal(fakeIlk))
|
|
||||||
Expect(result.Value).To(Equal(fakeAddress))
|
|
||||||
})
|
})
|
||||||
|
|
||||||
It("returns an error if metadata missing ilk", func() {
|
It("returns an error if metadata missing ilk", func() {
|
||||||
@ -142,10 +130,7 @@ 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())
|
||||||
Expect(result.BlockNumber).To(Equal(fakeBlockNumber))
|
AssertMapping(result, fakeBlockNumber, fakeBlockHash, fakeIlk, fakeUint256)
|
||||||
Expect(result.BlockHash).To(Equal(fakeBlockHash))
|
|
||||||
Expect(result.Key).To(Equal(fakeIlk))
|
|
||||||
Expect(result.Value).To(Equal(fakeUint256))
|
|
||||||
})
|
})
|
||||||
|
|
||||||
It("returns an error if metadata missing ilk", func() {
|
It("returns an error if metadata missing ilk", func() {
|
||||||
@ -165,10 +150,7 @@ 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())
|
||||||
Expect(result.BlockNumber).To(Equal(fakeBlockNumber))
|
AssertMapping(result, fakeBlockNumber, fakeBlockHash, fakeIlk, fakeUint256)
|
||||||
Expect(result.BlockHash).To(Equal(fakeBlockHash))
|
|
||||||
Expect(result.Key).To(Equal(fakeIlk))
|
|
||||||
Expect(result.Value).To(Equal(fakeUint256))
|
|
||||||
})
|
})
|
||||||
|
|
||||||
It("returns an error if metadata missing ilk", func() {
|
It("returns an error if metadata missing ilk", func() {
|
||||||
@ -192,10 +174,7 @@ var _ = Describe("Cat storage repository", func() {
|
|||||||
|
|
||||||
err = db.Get(&result, `SELECT block_number, block_hash, nflip AS key, ilk AS value FROM maker.cat_flip_ilk`)
|
err = db.Get(&result, `SELECT block_number, block_hash, nflip AS key, ilk AS value FROM maker.cat_flip_ilk`)
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(result.BlockNumber).To(Equal(fakeBlockNumber))
|
AssertMapping(result, fakeBlockNumber, fakeBlockHash, fakeUint256, fakeBytes32)
|
||||||
Expect(result.BlockHash).To(Equal(fakeBlockHash))
|
|
||||||
Expect(result.Key).To(Equal(fakeUint256))
|
|
||||||
Expect(result.Value).To(Equal(fakeBytes32))
|
|
||||||
})
|
})
|
||||||
|
|
||||||
It("returns an error if metadata missing flip", func() {
|
It("returns an error if metadata missing flip", func() {
|
||||||
@ -215,10 +194,7 @@ var _ = Describe("Cat storage repository", func() {
|
|||||||
|
|
||||||
err = db.Get(&result, `SELECT block_number, block_hash, nflip AS key, urn AS value FROM maker.cat_flip_urn`)
|
err = db.Get(&result, `SELECT block_number, block_hash, nflip AS key, urn AS value FROM maker.cat_flip_urn`)
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(result.BlockNumber).To(Equal(fakeBlockNumber))
|
AssertMapping(result, fakeBlockNumber, fakeBlockHash, fakeUint256, fakeBytes32)
|
||||||
Expect(result.BlockHash).To(Equal(fakeBlockHash))
|
|
||||||
Expect(result.Key).To(Equal(fakeUint256))
|
|
||||||
Expect(result.Value).To(Equal(fakeBytes32))
|
|
||||||
})
|
})
|
||||||
|
|
||||||
It("returns an error if metadata missing flip", func() {
|
It("returns an error if metadata missing flip", func() {
|
||||||
@ -238,10 +214,7 @@ var _ = Describe("Cat storage repository", func() {
|
|||||||
|
|
||||||
err = db.Get(&result, `SELECT block_number, block_hash, nflip AS key, ink AS value FROM maker.cat_flip_ink`)
|
err = db.Get(&result, `SELECT block_number, block_hash, nflip AS key, ink AS value FROM maker.cat_flip_ink`)
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(result.BlockNumber).To(Equal(fakeBlockNumber))
|
AssertMapping(result, fakeBlockNumber, fakeBlockHash, fakeUint256, fakeUint256)
|
||||||
Expect(result.BlockHash).To(Equal(fakeBlockHash))
|
|
||||||
Expect(result.Key).To(Equal(fakeUint256))
|
|
||||||
Expect(result.Value).To(Equal(fakeUint256))
|
|
||||||
})
|
})
|
||||||
|
|
||||||
It("returns an error if metadata missing flip", func() {
|
It("returns an error if metadata missing flip", func() {
|
||||||
@ -261,10 +234,7 @@ var _ = Describe("Cat storage repository", func() {
|
|||||||
|
|
||||||
err = db.Get(&result, `SELECT block_number, block_hash, nflip AS key, tab AS value FROM maker.cat_flip_tab`)
|
err = db.Get(&result, `SELECT block_number, block_hash, nflip AS key, tab AS value FROM maker.cat_flip_tab`)
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(result.BlockNumber).To(Equal(fakeBlockNumber))
|
AssertMapping(result, fakeBlockNumber, fakeBlockHash, fakeUint256, fakeUint256)
|
||||||
Expect(result.BlockHash).To(Equal(fakeBlockHash))
|
|
||||||
Expect(result.Key).To(Equal(fakeUint256))
|
|
||||||
Expect(result.Value).To(Equal(fakeUint256))
|
|
||||||
})
|
})
|
||||||
|
|
||||||
It("returns an error if metadata missing flip", func() {
|
It("returns an error if metadata missing flip", func() {
|
||||||
@ -276,19 +246,3 @@ var _ = Describe("Cat storage repository", func() {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
type BlockMetadata struct {
|
|
||||||
BlockNumber int `db:"block_number"`
|
|
||||||
BlockHash string `db:"block_hash"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type MappingRes struct {
|
|
||||||
BlockMetadata
|
|
||||||
Key string
|
|
||||||
Value string
|
|
||||||
}
|
|
||||||
|
|
||||||
type VariableRes struct {
|
|
||||||
BlockMetadata
|
|
||||||
Value string
|
|
||||||
}
|
|
||||||
|
@ -21,6 +21,7 @@ import (
|
|||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
|
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
|
||||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/storage_diffs/maker/pit"
|
"github.com/vulcanize/vulcanizedb/pkg/transformers/storage_diffs/maker/pit"
|
||||||
|
. "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"
|
||||||
)
|
)
|
||||||
@ -54,18 +55,11 @@ var _ = Describe("Pit storage repository", func() {
|
|||||||
err = repo.Create(blockNumber, blockHash, ilkLineMetadata, expectedLine)
|
err = repo.Create(blockNumber, blockHash, ilkLineMetadata, expectedLine)
|
||||||
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
type IlkLine struct {
|
|
||||||
BlockMetadata
|
var result MappingRes
|
||||||
Ilk string
|
err = db.Get(&result, `SELECT block_number, block_hash, ilk AS key, line AS value FROM maker.pit_ilk_line`)
|
||||||
Line string
|
|
||||||
}
|
|
||||||
var result IlkLine
|
|
||||||
err = db.Get(&result, `SELECT block_number, block_hash, ilk, line FROM maker.pit_ilk_line`)
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(result.BlockNumber).To(Equal(blockNumber))
|
AssertMapping(result, blockNumber, blockHash, expectedIlk, expectedLine)
|
||||||
Expect(result.BlockHash).To(Equal(blockHash))
|
|
||||||
Expect(result.Ilk).To(Equal(expectedIlk))
|
|
||||||
Expect(result.Line).To(Equal(expectedLine))
|
|
||||||
})
|
})
|
||||||
|
|
||||||
It("persists an ilk spot", func() {
|
It("persists an ilk spot", func() {
|
||||||
@ -79,18 +73,11 @@ var _ = Describe("Pit storage repository", func() {
|
|||||||
err = repo.Create(blockNumber, blockHash, ilkSpotMetadata, expectedSpot)
|
err = repo.Create(blockNumber, blockHash, ilkSpotMetadata, expectedSpot)
|
||||||
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
type IlkSpot struct {
|
|
||||||
BlockMetadata
|
var result MappingRes
|
||||||
Ilk string
|
err = db.Get(&result, `SELECT block_number, block_hash, ilk AS key, spot AS value FROM maker.pit_ilk_spot`)
|
||||||
Spot string
|
|
||||||
}
|
|
||||||
var result IlkSpot
|
|
||||||
err = db.Get(&result, `SELECT block_number, block_hash, ilk, spot FROM maker.pit_ilk_spot`)
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(result.BlockNumber).To(Equal(blockNumber))
|
AssertMapping(result, blockNumber, blockHash, expectedIlk, expectedSpot)
|
||||||
Expect(result.BlockHash).To(Equal(blockHash))
|
|
||||||
Expect(result.Ilk).To(Equal(expectedIlk))
|
|
||||||
Expect(result.Spot).To(Equal(expectedSpot))
|
|
||||||
})
|
})
|
||||||
|
|
||||||
It("persists a pit drip", func() {
|
It("persists a pit drip", func() {
|
||||||
@ -99,16 +86,11 @@ var _ = Describe("Pit storage repository", func() {
|
|||||||
err = repo.Create(blockNumber, blockHash, pit.DripMetadata, expectedDrip)
|
err = repo.Create(blockNumber, blockHash, pit.DripMetadata, expectedDrip)
|
||||||
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
type PitDrip struct {
|
|
||||||
BlockMetadata
|
var result VariableRes
|
||||||
Drip string
|
err = db.Get(&result, `SELECT block_number, block_hash, drip AS value FROM maker.pit_drip`)
|
||||||
}
|
|
||||||
var result PitDrip
|
|
||||||
err = db.Get(&result, `SELECT block_number, block_hash, drip FROM maker.pit_drip`)
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(result.BlockNumber).To(Equal(blockNumber))
|
AssertVariable(result, blockNumber, blockHash, expectedDrip)
|
||||||
Expect(result.BlockHash).To(Equal(blockHash))
|
|
||||||
Expect(result.Drip).To(Equal(expectedDrip))
|
|
||||||
})
|
})
|
||||||
|
|
||||||
It("persists a pit line", func() {
|
It("persists a pit line", func() {
|
||||||
@ -117,16 +99,11 @@ var _ = Describe("Pit storage repository", func() {
|
|||||||
err = repo.Create(blockNumber, blockHash, pit.LineMetadata, expectedLine)
|
err = repo.Create(blockNumber, blockHash, pit.LineMetadata, expectedLine)
|
||||||
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
type PitLine struct {
|
|
||||||
BlockMetadata
|
var result VariableRes
|
||||||
Line string
|
err = db.Get(&result, `SELECT block_number, block_hash, line AS value FROM maker.pit_line`)
|
||||||
}
|
|
||||||
var result PitLine
|
|
||||||
err = db.Get(&result, `SELECT block_number, block_hash, line FROM maker.pit_line`)
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(result.BlockNumber).To(Equal(blockNumber))
|
AssertVariable(result, blockNumber, blockHash, expectedLine)
|
||||||
Expect(result.BlockHash).To(Equal(blockHash))
|
|
||||||
Expect(result.Line).To(Equal(expectedLine))
|
|
||||||
})
|
})
|
||||||
|
|
||||||
It("persists a pit live", func() {
|
It("persists a pit live", func() {
|
||||||
@ -135,16 +112,11 @@ var _ = Describe("Pit storage repository", func() {
|
|||||||
err = repo.Create(blockNumber, blockHash, pit.LiveMetadata, expectedLive)
|
err = repo.Create(blockNumber, blockHash, pit.LiveMetadata, expectedLive)
|
||||||
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
type PitLive struct {
|
|
||||||
BlockMetadata
|
var result VariableRes
|
||||||
Live string
|
err = db.Get(&result, `SELECT block_number, block_hash, live AS value FROM maker.pit_live`)
|
||||||
}
|
|
||||||
var result PitLive
|
|
||||||
err = db.Get(&result, `SELECT block_number, block_hash, live FROM maker.pit_live`)
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(result.BlockNumber).To(Equal(blockNumber))
|
AssertVariable(result, blockNumber, blockHash, expectedLive)
|
||||||
Expect(result.BlockHash).To(Equal(blockHash))
|
|
||||||
Expect(result.Live).To(Equal(expectedLive))
|
|
||||||
})
|
})
|
||||||
|
|
||||||
It("persists a pit vat", func() {
|
It("persists a pit vat", func() {
|
||||||
@ -153,20 +125,10 @@ var _ = Describe("Pit storage repository", func() {
|
|||||||
err = repo.Create(blockNumber, blockHash, pit.VatMetadata, expectedVat)
|
err = repo.Create(blockNumber, blockHash, pit.VatMetadata, expectedVat)
|
||||||
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
type PitVat struct {
|
|
||||||
BlockMetadata
|
var result VariableRes
|
||||||
Vat string
|
err = db.Get(&result, `SELECT block_number, block_hash, vat AS value FROM maker.pit_vat`)
|
||||||
}
|
|
||||||
var result PitVat
|
|
||||||
err = db.Get(&result, `SELECT block_number, block_hash, vat FROM maker.pit_vat`)
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(result.BlockNumber).To(Equal(blockNumber))
|
AssertVariable(result, blockNumber, blockHash, expectedVat)
|
||||||
Expect(result.BlockHash).To(Equal(blockHash))
|
|
||||||
Expect(result.Vat).To(Equal(expectedVat))
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
type BlockMetadata struct {
|
|
||||||
BlockNumber int `db:"block_number"`
|
|
||||||
BlockHash string `db:"block_hash"`
|
|
||||||
}
|
|
||||||
|
@ -0,0 +1,49 @@
|
|||||||
|
package test_helpers
|
||||||
|
|
||||||
|
import (
|
||||||
|
. "github.com/onsi/gomega"
|
||||||
|
)
|
||||||
|
|
||||||
|
type BlockMetadata struct {
|
||||||
|
BlockNumber int `db:"block_number"`
|
||||||
|
BlockHash string `db:"block_hash"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type VariableRes struct {
|
||||||
|
BlockMetadata
|
||||||
|
Value string
|
||||||
|
}
|
||||||
|
|
||||||
|
type MappingRes struct {
|
||||||
|
BlockMetadata
|
||||||
|
Key string
|
||||||
|
Value string
|
||||||
|
}
|
||||||
|
|
||||||
|
type DoubleMappingRes struct {
|
||||||
|
BlockMetadata
|
||||||
|
KeyOne string `db:"key_one"`
|
||||||
|
KeyTwo string `db:"key_two"`
|
||||||
|
Value string
|
||||||
|
}
|
||||||
|
|
||||||
|
func AssertVariable(res VariableRes, blockNumber int, blockHash, value string) {
|
||||||
|
Expect(res.BlockNumber).To(Equal(blockNumber))
|
||||||
|
Expect(res.BlockHash).To(Equal(blockHash))
|
||||||
|
Expect(res.Value).To(Equal(value))
|
||||||
|
}
|
||||||
|
|
||||||
|
func AssertMapping(res MappingRes, blockNumber int, blockHash, key, value string) {
|
||||||
|
Expect(res.BlockNumber).To(Equal(blockNumber))
|
||||||
|
Expect(res.BlockHash).To(Equal(blockHash))
|
||||||
|
Expect(res.Key).To(Equal(key))
|
||||||
|
Expect(res.Value).To(Equal(value))
|
||||||
|
}
|
||||||
|
|
||||||
|
func AssertDoubleMapping(res DoubleMappingRes, blockNumber int, blockHash, keyOne, keyTwo, value string) {
|
||||||
|
Expect(res.BlockNumber).To(Equal(blockNumber))
|
||||||
|
Expect(res.BlockHash).To(Equal(blockHash))
|
||||||
|
Expect(res.KeyOne).To(Equal(keyOne))
|
||||||
|
Expect(res.KeyTwo).To(Equal(keyTwo))
|
||||||
|
Expect(res.Value).To(Equal(value))
|
||||||
|
}
|
@ -4,6 +4,7 @@ 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"
|
||||||
|
. "github.com/vulcanize/vulcanizedb/pkg/transformers/storage_diffs/maker/test_helpers"
|
||||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/storage_diffs/maker/vat"
|
"github.com/vulcanize/vulcanizedb/pkg/transformers/storage_diffs/maker/vat"
|
||||||
"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"
|
||||||
@ -38,18 +39,11 @@ var _ = Describe("Vat storage repository", func() {
|
|||||||
err := repo.Create(fakeBlockNumber, fakeBlockHash, daiMetadata, fakeUint256)
|
err := repo.Create(fakeBlockNumber, fakeBlockHash, daiMetadata, fakeUint256)
|
||||||
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
type Dai struct {
|
|
||||||
BlockMetadata
|
var result MappingRes
|
||||||
Guy string
|
err = db.Get(&result, `SELECT block_number, block_hash, guy AS key, dai AS value FROM maker.vat_dai`)
|
||||||
Dai string
|
|
||||||
}
|
|
||||||
var result Dai
|
|
||||||
err = db.Get(&result, `SELECT block_number, block_hash, guy, dai FROM maker.vat_dai`)
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(result.BlockNumber).To(Equal(fakeBlockNumber))
|
AssertMapping(result, fakeBlockNumber, fakeBlockHash, fakeGuy, fakeUint256)
|
||||||
Expect(result.BlockHash).To(Equal(fakeBlockHash))
|
|
||||||
Expect(result.Guy).To(Equal(fakeGuy))
|
|
||||||
Expect(result.Dai).To(Equal(fakeUint256))
|
|
||||||
})
|
})
|
||||||
|
|
||||||
It("returns error if metadata missing guy", func() {
|
It("returns error if metadata missing guy", func() {
|
||||||
@ -77,20 +71,11 @@ var _ = Describe("Vat storage repository", func() {
|
|||||||
err := repo.Create(fakeBlockNumber, fakeBlockHash, gemMetadata, fakeUint256)
|
err := repo.Create(fakeBlockNumber, fakeBlockHash, gemMetadata, fakeUint256)
|
||||||
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
type Gem struct {
|
|
||||||
BlockMetadata
|
var result DoubleMappingRes
|
||||||
Ilk string
|
err = db.Get(&result, `SELECT block_number, block_hash, ilk AS key_one, guy AS key_two, gem AS value FROM maker.vat_gem`)
|
||||||
Guy string
|
|
||||||
Gem string
|
|
||||||
}
|
|
||||||
var result Gem
|
|
||||||
err = db.Get(&result, `SELECT block_number, block_hash, ilk, guy, gem FROM maker.vat_gem`)
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(result.BlockNumber).To(Equal(fakeBlockNumber))
|
AssertDoubleMapping(result, fakeBlockNumber, fakeBlockHash, fakeIlk, fakeGuy, fakeUint256)
|
||||||
Expect(result.BlockHash).To(Equal(fakeBlockHash))
|
|
||||||
Expect(result.Ilk).To(Equal(fakeIlk))
|
|
||||||
Expect(result.Guy).To(Equal(fakeGuy))
|
|
||||||
Expect(result.Gem).To(Equal(fakeUint256))
|
|
||||||
})
|
})
|
||||||
|
|
||||||
It("returns error if metadata missing ilk", func() {
|
It("returns error if metadata missing ilk", func() {
|
||||||
@ -131,18 +116,11 @@ var _ = Describe("Vat storage repository", func() {
|
|||||||
err := repo.Create(fakeBlockNumber, fakeBlockHash, ilkArtMetadata, fakeUint256)
|
err := repo.Create(fakeBlockNumber, fakeBlockHash, ilkArtMetadata, fakeUint256)
|
||||||
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
type IlkArt struct {
|
|
||||||
BlockMetadata
|
var result MappingRes
|
||||||
Ilk string
|
err = db.Get(&result, `SELECT block_number, block_hash, ilk AS key, art AS value FROM maker.vat_ilk_art`)
|
||||||
Art string
|
|
||||||
}
|
|
||||||
var result IlkArt
|
|
||||||
err = db.Get(&result, `SELECT block_number, block_hash, ilk, art FROM maker.vat_ilk_art`)
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(result.BlockNumber).To(Equal(fakeBlockNumber))
|
AssertMapping(result, fakeBlockNumber, fakeBlockHash, fakeIlk, fakeUint256)
|
||||||
Expect(result.BlockHash).To(Equal(fakeBlockHash))
|
|
||||||
Expect(result.Ilk).To(Equal(fakeIlk))
|
|
||||||
Expect(result.Art).To(Equal(fakeUint256))
|
|
||||||
})
|
})
|
||||||
|
|
||||||
It("returns error if metadata missing ilk", func() {
|
It("returns error if metadata missing ilk", func() {
|
||||||
@ -170,18 +148,11 @@ var _ = Describe("Vat storage repository", func() {
|
|||||||
err := repo.Create(fakeBlockNumber, fakeBlockHash, ilkInkMetadata, fakeUint256)
|
err := repo.Create(fakeBlockNumber, fakeBlockHash, ilkInkMetadata, fakeUint256)
|
||||||
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
type IlkInk struct {
|
|
||||||
BlockMetadata
|
var result MappingRes
|
||||||
Ilk string
|
err = db.Get(&result, `SELECT block_number, block_hash, ilk AS key, ink AS value FROM maker.vat_ilk_ink`)
|
||||||
Ink string
|
|
||||||
}
|
|
||||||
var result IlkInk
|
|
||||||
err = db.Get(&result, `SELECT block_number, block_hash, ilk, ink FROM maker.vat_ilk_ink`)
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(result.BlockNumber).To(Equal(fakeBlockNumber))
|
AssertMapping(result, fakeBlockNumber, fakeBlockHash, fakeIlk, fakeUint256)
|
||||||
Expect(result.BlockHash).To(Equal(fakeBlockHash))
|
|
||||||
Expect(result.Ilk).To(Equal(fakeIlk))
|
|
||||||
Expect(result.Ink).To(Equal(fakeUint256))
|
|
||||||
})
|
})
|
||||||
|
|
||||||
It("returns error if metadata missing ilk", func() {
|
It("returns error if metadata missing ilk", func() {
|
||||||
@ -209,18 +180,11 @@ var _ = Describe("Vat storage repository", func() {
|
|||||||
err := repo.Create(fakeBlockNumber, fakeBlockHash, ilkRateMetadata, fakeUint256)
|
err := repo.Create(fakeBlockNumber, fakeBlockHash, ilkRateMetadata, fakeUint256)
|
||||||
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
type IlkRate struct {
|
|
||||||
BlockMetadata
|
var result MappingRes
|
||||||
Ilk string
|
err = db.Get(&result, `SELECT block_number, block_hash, ilk AS key, rate AS value FROM maker.vat_ilk_rate`)
|
||||||
Rate string
|
|
||||||
}
|
|
||||||
var result IlkRate
|
|
||||||
err = db.Get(&result, `SELECT block_number, block_hash, ilk, rate FROM maker.vat_ilk_rate`)
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(result.BlockNumber).To(Equal(fakeBlockNumber))
|
AssertMapping(result, fakeBlockNumber, fakeBlockHash, fakeIlk, fakeUint256)
|
||||||
Expect(result.BlockHash).To(Equal(fakeBlockHash))
|
|
||||||
Expect(result.Ilk).To(Equal(fakeIlk))
|
|
||||||
Expect(result.Rate).To(Equal(fakeUint256))
|
|
||||||
})
|
})
|
||||||
|
|
||||||
It("returns error if metadata missing ilk", func() {
|
It("returns error if metadata missing ilk", func() {
|
||||||
@ -248,18 +212,11 @@ var _ = Describe("Vat storage repository", func() {
|
|||||||
err := repo.Create(fakeBlockNumber, fakeBlockHash, ilkTakeMetadata, fakeUint256)
|
err := repo.Create(fakeBlockNumber, fakeBlockHash, ilkTakeMetadata, fakeUint256)
|
||||||
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
type IlkTake struct {
|
|
||||||
BlockMetadata
|
var result MappingRes
|
||||||
Ilk string
|
err = db.Get(&result, `SELECT block_number, block_hash, ilk AS key, take AS value FROM maker.vat_ilk_take`)
|
||||||
Take string
|
|
||||||
}
|
|
||||||
var result IlkTake
|
|
||||||
err = db.Get(&result, `SELECT block_number, block_hash, ilk, take FROM maker.vat_ilk_take`)
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(result.BlockNumber).To(Equal(fakeBlockNumber))
|
AssertMapping(result, fakeBlockNumber, fakeBlockHash, fakeIlk, fakeUint256)
|
||||||
Expect(result.BlockHash).To(Equal(fakeBlockHash))
|
|
||||||
Expect(result.Ilk).To(Equal(fakeIlk))
|
|
||||||
Expect(result.Take).To(Equal(fakeUint256))
|
|
||||||
})
|
})
|
||||||
|
|
||||||
It("returns error if metadata missing ilk", func() {
|
It("returns error if metadata missing ilk", func() {
|
||||||
@ -287,18 +244,11 @@ var _ = Describe("Vat storage repository", func() {
|
|||||||
err := repo.Create(fakeBlockNumber, fakeBlockHash, sinMetadata, fakeUint256)
|
err := repo.Create(fakeBlockNumber, fakeBlockHash, sinMetadata, fakeUint256)
|
||||||
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
type Sin struct {
|
|
||||||
BlockMetadata
|
var result MappingRes
|
||||||
Guy string
|
err = db.Get(&result, `SELECT block_number, block_hash, guy AS key, sin AS value FROM maker.vat_sin`)
|
||||||
Sin string
|
|
||||||
}
|
|
||||||
var result Sin
|
|
||||||
err = db.Get(&result, `SELECT block_number, block_hash, guy, sin FROM maker.vat_sin`)
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(result.BlockNumber).To(Equal(fakeBlockNumber))
|
AssertMapping(result, fakeBlockNumber, fakeBlockHash, fakeGuy, fakeUint256)
|
||||||
Expect(result.BlockHash).To(Equal(fakeBlockHash))
|
|
||||||
Expect(result.Guy).To(Equal(fakeGuy))
|
|
||||||
Expect(result.Sin).To(Equal(fakeUint256))
|
|
||||||
})
|
})
|
||||||
|
|
||||||
It("returns error if metadata missing guy", func() {
|
It("returns error if metadata missing guy", func() {
|
||||||
@ -326,20 +276,11 @@ var _ = Describe("Vat storage repository", func() {
|
|||||||
err := repo.Create(fakeBlockNumber, fakeBlockHash, urnArtMetadata, fakeUint256)
|
err := repo.Create(fakeBlockNumber, fakeBlockHash, urnArtMetadata, fakeUint256)
|
||||||
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
type UrnArt struct {
|
|
||||||
BlockMetadata
|
var result DoubleMappingRes
|
||||||
Ilk string
|
err = db.Get(&result, `SELECT block_number, block_hash, ilk AS key_one, urn AS key_two, art AS value FROM maker.vat_urn_art`)
|
||||||
Urn string
|
|
||||||
Art string
|
|
||||||
}
|
|
||||||
var result UrnArt
|
|
||||||
err = db.Get(&result, `SELECT block_number, block_hash, ilk, urn, art FROM maker.vat_urn_art`)
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(result.BlockNumber).To(Equal(fakeBlockNumber))
|
AssertDoubleMapping(result, fakeBlockNumber, fakeBlockHash, fakeIlk, fakeGuy, fakeUint256)
|
||||||
Expect(result.BlockHash).To(Equal(fakeBlockHash))
|
|
||||||
Expect(result.Ilk).To(Equal(fakeIlk))
|
|
||||||
Expect(result.Urn).To(Equal(fakeGuy))
|
|
||||||
Expect(result.Art).To(Equal(fakeUint256))
|
|
||||||
})
|
})
|
||||||
|
|
||||||
It("returns error if metadata missing ilk", func() {
|
It("returns error if metadata missing ilk", func() {
|
||||||
@ -380,20 +321,11 @@ var _ = Describe("Vat storage repository", func() {
|
|||||||
err := repo.Create(fakeBlockNumber, fakeBlockHash, urnInkMetadata, fakeUint256)
|
err := repo.Create(fakeBlockNumber, fakeBlockHash, urnInkMetadata, fakeUint256)
|
||||||
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
type UrnInk struct {
|
|
||||||
BlockMetadata
|
var result DoubleMappingRes
|
||||||
Ilk string
|
err = db.Get(&result, `SELECT block_number, block_hash, ilk AS key_one, urn AS key_two, ink AS value FROM maker.vat_urn_ink`)
|
||||||
Urn string
|
|
||||||
Ink string
|
|
||||||
}
|
|
||||||
var result UrnInk
|
|
||||||
err = db.Get(&result, `SELECT block_number, block_hash, ilk, urn, ink FROM maker.vat_urn_ink`)
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(result.BlockNumber).To(Equal(fakeBlockNumber))
|
AssertDoubleMapping(result, fakeBlockNumber, fakeBlockHash, fakeIlk, fakeGuy, fakeUint256)
|
||||||
Expect(result.BlockHash).To(Equal(fakeBlockHash))
|
|
||||||
Expect(result.Ilk).To(Equal(fakeIlk))
|
|
||||||
Expect(result.Urn).To(Equal(fakeGuy))
|
|
||||||
Expect(result.Ink).To(Equal(fakeUint256))
|
|
||||||
})
|
})
|
||||||
|
|
||||||
It("returns error if metadata missing ilk", func() {
|
It("returns error if metadata missing ilk", func() {
|
||||||
@ -433,16 +365,11 @@ var _ = Describe("Vat storage repository", func() {
|
|||||||
err := repo.Create(fakeBlockNumber, fakeBlockHash, debtMetadata, fakeUint256)
|
err := repo.Create(fakeBlockNumber, fakeBlockHash, debtMetadata, fakeUint256)
|
||||||
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
type Debt struct {
|
|
||||||
BlockMetadata
|
var result VariableRes
|
||||||
Debt string
|
err = db.Get(&result, `SELECT block_number, block_hash, debt AS value FROM maker.vat_debt`)
|
||||||
}
|
|
||||||
var result Debt
|
|
||||||
err = db.Get(&result, `SELECT block_number, block_hash, debt FROM maker.vat_debt`)
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(result.BlockNumber).To(Equal(fakeBlockNumber))
|
AssertVariable(result, fakeBlockNumber, fakeBlockHash, fakeUint256)
|
||||||
Expect(result.BlockHash).To(Equal(fakeBlockHash))
|
|
||||||
Expect(result.Debt).To(Equal(fakeUint256))
|
|
||||||
})
|
})
|
||||||
|
|
||||||
It("persists vat vice", func() {
|
It("persists vat vice", func() {
|
||||||
@ -455,20 +382,10 @@ var _ = Describe("Vat storage repository", func() {
|
|||||||
err := repo.Create(fakeBlockNumber, fakeBlockHash, viceMetadata, fakeUint256)
|
err := repo.Create(fakeBlockNumber, fakeBlockHash, viceMetadata, fakeUint256)
|
||||||
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
type Vice struct {
|
|
||||||
BlockMetadata
|
var result VariableRes
|
||||||
Vice string
|
err = db.Get(&result, `SELECT block_number, block_hash, vice AS value FROM maker.vat_vice`)
|
||||||
}
|
|
||||||
var result Vice
|
|
||||||
err = db.Get(&result, `SELECT block_number, block_hash, vice FROM maker.vat_vice`)
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(result.BlockNumber).To(Equal(fakeBlockNumber))
|
AssertVariable(result, fakeBlockNumber, fakeBlockHash, fakeUint256)
|
||||||
Expect(result.BlockHash).To(Equal(fakeBlockHash))
|
|
||||||
Expect(result.Vice).To(Equal(fakeUint256))
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
type BlockMetadata struct {
|
|
||||||
BlockNumber int `db:"block_number"`
|
|
||||||
BlockHash string `db:"block_hash"`
|
|
||||||
}
|
|
||||||
|
@ -19,6 +19,7 @@ package vow_test
|
|||||||
import (
|
import (
|
||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
|
. "github.com/vulcanize/vulcanizedb/pkg/transformers/storage_diffs/maker/test_helpers"
|
||||||
|
|
||||||
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
|
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
|
||||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/storage_diffs/maker/vow"
|
"github.com/vulcanize/vulcanizedb/pkg/transformers/storage_diffs/maker/vow"
|
||||||
@ -49,16 +50,11 @@ var _ = Describe("Vow storage repository test", func() {
|
|||||||
err = repo.Create(blockNumber, blockHash, vow.VatMetadata, expectedVat)
|
err = repo.Create(blockNumber, blockHash, vow.VatMetadata, expectedVat)
|
||||||
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
type VowVat struct {
|
|
||||||
BlockMetadata
|
var result VariableRes
|
||||||
Vat string
|
err = db.Get(&result, `SELECT block_number, block_hash, vat AS value from maker.vow_vat`)
|
||||||
}
|
|
||||||
var result VowVat
|
|
||||||
err = db.Get(&result, `SELECT block_number, block_hash, vat from maker.vow_vat`)
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(result.BlockNumber).To(Equal(blockNumber))
|
AssertVariable(result, blockNumber, blockHash, expectedVat)
|
||||||
Expect(result.BlockHash).To(Equal(blockHash))
|
|
||||||
Expect(result.Vat).To(Equal(expectedVat))
|
|
||||||
})
|
})
|
||||||
|
|
||||||
It("persists a vow cow", func() {
|
It("persists a vow cow", func() {
|
||||||
@ -67,16 +63,11 @@ var _ = Describe("Vow storage repository test", func() {
|
|||||||
err = repo.Create(blockNumber, blockHash, vow.CowMetadata, expectedCow)
|
err = repo.Create(blockNumber, blockHash, vow.CowMetadata, expectedCow)
|
||||||
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
type VowCow struct {
|
|
||||||
BlockMetadata
|
var result VariableRes
|
||||||
Cow string
|
err = db.Get(&result, `SELECT block_number, block_hash, cow AS value from maker.vow_cow`)
|
||||||
}
|
|
||||||
var result VowCow
|
|
||||||
err = db.Get(&result, `SELECT block_number, block_hash, cow from maker.vow_cow`)
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(result.BlockNumber).To(Equal(blockNumber))
|
AssertVariable(result, blockNumber, blockHash, expectedCow)
|
||||||
Expect(result.BlockHash).To(Equal(blockHash))
|
|
||||||
Expect(result.Cow).To(Equal(expectedCow))
|
|
||||||
})
|
})
|
||||||
|
|
||||||
It("persists a vow row", func() {
|
It("persists a vow row", func() {
|
||||||
@ -85,16 +76,11 @@ var _ = Describe("Vow storage repository test", func() {
|
|||||||
err = repo.Create(blockNumber, blockHash, vow.RowMetadata, expectedRow)
|
err = repo.Create(blockNumber, blockHash, vow.RowMetadata, expectedRow)
|
||||||
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
type VowRow struct {
|
|
||||||
BlockMetadata
|
var result VariableRes
|
||||||
Row string
|
err = db.Get(&result, `SELECT block_number, block_hash, row AS value from maker.vow_row`)
|
||||||
}
|
|
||||||
var result VowRow
|
|
||||||
err = db.Get(&result, `SELECT block_number, block_hash, row from maker.vow_row`)
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(result.BlockNumber).To(Equal(blockNumber))
|
AssertVariable(result, blockNumber, blockHash, expectedRow)
|
||||||
Expect(result.BlockHash).To(Equal(blockHash))
|
|
||||||
Expect(result.Row).To(Equal(expectedRow))
|
|
||||||
})
|
})
|
||||||
|
|
||||||
It("persists a vow Sin", func() {
|
It("persists a vow Sin", func() {
|
||||||
@ -103,16 +89,11 @@ var _ = Describe("Vow storage repository test", func() {
|
|||||||
err = repo.Create(blockNumber, blockHash, vow.SinMetadata, expectedSow)
|
err = repo.Create(blockNumber, blockHash, vow.SinMetadata, expectedSow)
|
||||||
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
type VowSin struct {
|
|
||||||
BlockMetadata
|
var result VariableRes
|
||||||
Sin string
|
err = db.Get(&result, `SELECT block_number, block_hash, sin AS value from maker.vow_sin`)
|
||||||
}
|
|
||||||
var result VowSin
|
|
||||||
err = db.Get(&result, `SELECT block_number, block_hash, sin from maker.vow_sin`)
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(result.BlockNumber).To(Equal(blockNumber))
|
AssertVariable(result, blockNumber, blockHash, expectedSow)
|
||||||
Expect(result.BlockHash).To(Equal(blockHash))
|
|
||||||
Expect(result.Sin).To(Equal(expectedSow))
|
|
||||||
})
|
})
|
||||||
|
|
||||||
It("persists a vow woe", func() {
|
It("persists a vow woe", func() {
|
||||||
@ -121,16 +102,11 @@ var _ = Describe("Vow storage repository test", func() {
|
|||||||
err = repo.Create(blockNumber, blockHash, vow.WoeMetadata, expectedWoe)
|
err = repo.Create(blockNumber, blockHash, vow.WoeMetadata, expectedWoe)
|
||||||
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
type VowWoe struct {
|
|
||||||
BlockMetadata
|
var result VariableRes
|
||||||
Woe string
|
err = db.Get(&result, `SELECT block_number, block_hash, woe AS value from maker.vow_woe`)
|
||||||
}
|
|
||||||
var result VowWoe
|
|
||||||
err = db.Get(&result, `SELECT block_number, block_hash, woe from maker.vow_woe`)
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(result.BlockNumber).To(Equal(blockNumber))
|
AssertVariable(result, blockNumber, blockHash, expectedWoe)
|
||||||
Expect(result.BlockHash).To(Equal(blockHash))
|
|
||||||
Expect(result.Woe).To(Equal(expectedWoe))
|
|
||||||
})
|
})
|
||||||
|
|
||||||
It("persists a vow Ash", func() {
|
It("persists a vow Ash", func() {
|
||||||
@ -139,16 +115,11 @@ var _ = Describe("Vow storage repository test", func() {
|
|||||||
err = repo.Create(blockNumber, blockHash, vow.AshMetadata, expectedAsh)
|
err = repo.Create(blockNumber, blockHash, vow.AshMetadata, expectedAsh)
|
||||||
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
type VowAsh struct {
|
|
||||||
BlockMetadata
|
var result VariableRes
|
||||||
Ash string
|
err = db.Get(&result, `SELECT block_number, block_hash, ash AS value from maker.vow_ash`)
|
||||||
}
|
|
||||||
var result VowAsh
|
|
||||||
err = db.Get(&result, `SELECT block_number, block_hash, ash from maker.vow_ash`)
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(result.BlockNumber).To(Equal(blockNumber))
|
AssertVariable(result, blockNumber, blockHash, expectedAsh)
|
||||||
Expect(result.BlockHash).To(Equal(blockHash))
|
|
||||||
Expect(result.Ash).To(Equal(expectedAsh))
|
|
||||||
})
|
})
|
||||||
|
|
||||||
It("persists a vow Wait", func() {
|
It("persists a vow Wait", func() {
|
||||||
@ -157,16 +128,11 @@ var _ = Describe("Vow storage repository test", func() {
|
|||||||
err = repo.Create(blockNumber, blockHash, vow.WaitMetadata, expectedWait)
|
err = repo.Create(blockNumber, blockHash, vow.WaitMetadata, expectedWait)
|
||||||
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
type VowWait struct {
|
|
||||||
BlockMetadata
|
var result VariableRes
|
||||||
Wait string
|
err = db.Get(&result, `SELECT block_number, block_hash, wait AS value from maker.vow_wait`)
|
||||||
}
|
|
||||||
var result VowWait
|
|
||||||
err = db.Get(&result, `SELECT block_number, block_hash, wait from maker.vow_wait`)
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(result.BlockNumber).To(Equal(blockNumber))
|
AssertVariable(result, blockNumber, blockHash, expectedWait)
|
||||||
Expect(result.BlockHash).To(Equal(blockHash))
|
|
||||||
Expect(result.Wait).To(Equal(expectedWait))
|
|
||||||
})
|
})
|
||||||
|
|
||||||
It("persists a vow Bump", func() {
|
It("persists a vow Bump", func() {
|
||||||
@ -175,16 +141,11 @@ var _ = Describe("Vow storage repository test", func() {
|
|||||||
err = repo.Create(blockNumber, blockHash, vow.BumpMetadata, expectedBump)
|
err = repo.Create(blockNumber, blockHash, vow.BumpMetadata, expectedBump)
|
||||||
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
type VowBump struct {
|
|
||||||
BlockMetadata
|
var result VariableRes
|
||||||
Bump string
|
err = db.Get(&result, `SELECT block_number, block_hash, bump AS value from maker.vow_bump`)
|
||||||
}
|
|
||||||
var result VowBump
|
|
||||||
err = db.Get(&result, `SELECT block_number, block_hash, bump from maker.vow_bump`)
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(result.BlockNumber).To(Equal(blockNumber))
|
AssertVariable(result, blockNumber, blockHash, expectedBump)
|
||||||
Expect(result.BlockHash).To(Equal(blockHash))
|
|
||||||
Expect(result.Bump).To(Equal(expectedBump))
|
|
||||||
})
|
})
|
||||||
|
|
||||||
It("persists a vow Sump", func() {
|
It("persists a vow Sump", func() {
|
||||||
@ -193,16 +154,11 @@ var _ = Describe("Vow storage repository test", func() {
|
|||||||
err = repo.Create(blockNumber, blockHash, vow.SumpMetadata, expectedSump)
|
err = repo.Create(blockNumber, blockHash, vow.SumpMetadata, expectedSump)
|
||||||
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
type VowSump struct {
|
|
||||||
BlockMetadata
|
var result VariableRes
|
||||||
Sump string
|
err = db.Get(&result, `SELECT block_number, block_hash, sump AS value from maker.vow_sump`)
|
||||||
}
|
|
||||||
var result VowSump
|
|
||||||
err = db.Get(&result, `SELECT block_number, block_hash, sump from maker.vow_sump`)
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(result.BlockNumber).To(Equal(blockNumber))
|
AssertVariable(result, blockNumber, blockHash, expectedSump)
|
||||||
Expect(result.BlockHash).To(Equal(blockHash))
|
|
||||||
Expect(result.Sump).To(Equal(expectedSump))
|
|
||||||
})
|
})
|
||||||
|
|
||||||
It("persists a vow Hump", func() {
|
It("persists a vow Hump", func() {
|
||||||
@ -211,20 +167,10 @@ var _ = Describe("Vow storage repository test", func() {
|
|||||||
err = repo.Create(blockNumber, blockHash, vow.HumpMetadata, expectedHump)
|
err = repo.Create(blockNumber, blockHash, vow.HumpMetadata, expectedHump)
|
||||||
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
type VowHump struct {
|
|
||||||
BlockMetadata
|
var result VariableRes
|
||||||
Hump string
|
err = db.Get(&result, `SELECT block_number, block_hash, hump AS value from maker.vow_hump`)
|
||||||
}
|
|
||||||
var result VowHump
|
|
||||||
err = db.Get(&result, `SELECT block_number, block_hash, hump from maker.vow_hump`)
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(result.BlockNumber).To(Equal(blockNumber))
|
AssertVariable(result, blockNumber, blockHash, expectedHump)
|
||||||
Expect(result.BlockHash).To(Equal(blockHash))
|
|
||||||
Expect(result.Hump).To(Equal(expectedHump))
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
type BlockMetadata struct {
|
|
||||||
BlockNumber int `db:"block_number"`
|
|
||||||
BlockHash string `db:"block_hash"`
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user