add woe to storage diff vow contract
This commit is contained in:
@@ -29,6 +29,7 @@ const (
|
||||
VowCow = "cow"
|
||||
VowRow = "row"
|
||||
VowSin = "Sin"
|
||||
VowWoe = "woe"
|
||||
VowAsh = "ash"
|
||||
VowWait = "wait"
|
||||
VowSump = "sump"
|
||||
@@ -48,14 +49,14 @@ var (
|
||||
CowMetadata = shared.StorageValueMetadata{
|
||||
Name: VowCow,
|
||||
Keys: nil,
|
||||
Type: shared.Uint256,
|
||||
Type: shared.Address,
|
||||
}
|
||||
|
||||
RowKey = common.HexToHash(storage_diffs.IndexThree)
|
||||
RowMetadata = shared.StorageValueMetadata{
|
||||
Name: VowRow,
|
||||
Keys: nil,
|
||||
Type: shared.Uint256,
|
||||
Type: shared.Address,
|
||||
}
|
||||
|
||||
SinKey = common.HexToHash(storage_diffs.IndexFive)
|
||||
@@ -65,6 +66,13 @@ var (
|
||||
Type: shared.Uint256,
|
||||
}
|
||||
|
||||
WoeKey = common.HexToHash(storage_diffs.IndexSix)
|
||||
WoeMetadata = shared.StorageValueMetadata{
|
||||
Name: VowWoe,
|
||||
Keys: nil,
|
||||
Type: shared.Uint256,
|
||||
}
|
||||
|
||||
AshKey = common.HexToHash(storage_diffs.IndexSeven)
|
||||
AshMetadata = shared.StorageValueMetadata{
|
||||
Name: VowAsh,
|
||||
@@ -127,6 +135,7 @@ func (mappings *VowMappings) loadMappings() error {
|
||||
staticMappings[CowKey] = CowMetadata
|
||||
staticMappings[RowKey] = RowMetadata
|
||||
staticMappings[SinKey] = SinMetadata
|
||||
staticMappings[WoeKey] = WoeMetadata
|
||||
staticMappings[AshKey] = AshMetadata
|
||||
staticMappings[WaitKey] = WaitMetadata
|
||||
staticMappings[SumpKey] = SumpMetadata
|
||||
|
||||
@@ -21,6 +21,7 @@ var _ = Describe("Vow storage mappings", func() {
|
||||
Expect(mappings.Lookup(vow.CowKey)).To(Equal(vow.CowMetadata))
|
||||
Expect(mappings.Lookup(vow.RowKey)).To(Equal(vow.RowMetadata))
|
||||
Expect(mappings.Lookup(vow.SinKey)).To(Equal(vow.SinMetadata))
|
||||
Expect(mappings.Lookup(vow.WoeKey)).To(Equal(vow.WoeMetadata))
|
||||
Expect(mappings.Lookup(vow.AshKey)).To(Equal(vow.AshMetadata))
|
||||
Expect(mappings.Lookup(vow.WaitKey)).To(Equal(vow.WaitMetadata))
|
||||
Expect(mappings.Lookup(vow.SumpKey)).To(Equal(vow.SumpMetadata))
|
||||
|
||||
@@ -39,6 +39,8 @@ func (repository VowStorageRepository) Create(blockNumber int, blockHash string,
|
||||
return repository.insertVowRow(blockNumber, blockHash, value.(string))
|
||||
case VowSin:
|
||||
return repository.insertVowSin(blockNumber, blockHash, value.(string))
|
||||
case VowWoe:
|
||||
return repository.insertVowWoe(blockNumber, blockHash, value.(string))
|
||||
case VowAsh:
|
||||
return repository.insertVowAsh(blockNumber, blockHash, value.(string))
|
||||
case VowWait:
|
||||
@@ -78,6 +80,12 @@ func (repository VowStorageRepository) insertVowSin(blockNumber int, blockHash s
|
||||
return err
|
||||
}
|
||||
|
||||
func (repository VowStorageRepository) insertVowWoe(blockNumber int, blockHash string, woe string) error {
|
||||
_, err := repository.db.Exec(`INSERT INTO maker.vow_woe (block_number, block_hash, woe) VALUES ($1, $2, $3)`, blockNumber, blockHash, woe)
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
func (repository VowStorageRepository) insertVowAsh(blockNumber int, blockHash string, ash string) error {
|
||||
_, err := repository.db.Exec(`INSERT INTO maker.vow_ash (block_number, block_hash, ash) VALUES ($1, $2, $3)`, blockNumber, blockHash, ash)
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ var _ = Describe("Vow storage repository test", func() {
|
||||
})
|
||||
|
||||
It("persists a vow vat", func() {
|
||||
expectedVat := "vat"
|
||||
expectedVat := "123"
|
||||
|
||||
err = repo.Create(blockNumber, blockHash, vow.VatMetadata, expectedVat)
|
||||
|
||||
@@ -62,7 +62,7 @@ var _ = Describe("Vow storage repository test", func() {
|
||||
})
|
||||
|
||||
It("persists a vow cow", func() {
|
||||
expectedCow := "cow"
|
||||
expectedCow := "123"
|
||||
|
||||
err = repo.Create(blockNumber, blockHash, vow.CowMetadata, expectedCow)
|
||||
|
||||
@@ -80,7 +80,7 @@ var _ = Describe("Vow storage repository test", func() {
|
||||
})
|
||||
|
||||
It("persists a vow row", func() {
|
||||
expectedRow := "row"
|
||||
expectedRow := "123"
|
||||
|
||||
err = repo.Create(blockNumber, blockHash, vow.RowMetadata, expectedRow)
|
||||
|
||||
@@ -98,7 +98,7 @@ var _ = Describe("Vow storage repository test", func() {
|
||||
})
|
||||
|
||||
It("persists a vow Sin", func() {
|
||||
expectedSow := "sow"
|
||||
expectedSow := "123"
|
||||
|
||||
err = repo.Create(blockNumber, blockHash, vow.SinMetadata, expectedSow)
|
||||
|
||||
@@ -115,8 +115,26 @@ var _ = Describe("Vow storage repository test", func() {
|
||||
Expect(result.Sin).To(Equal(expectedSow))
|
||||
})
|
||||
|
||||
It("persists a vow woe", func() {
|
||||
expectedWoe := "123"
|
||||
|
||||
err = repo.Create(blockNumber, blockHash, vow.WoeMetadata, expectedWoe)
|
||||
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
type VowWoe struct {
|
||||
BlockMetadata
|
||||
Woe string
|
||||
}
|
||||
var result VowWoe
|
||||
err = db.Get(&result, `SELECT block_number, block_hash, woe from maker.vow_woe`)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(result.BlockNumber).To(Equal(blockNumber))
|
||||
Expect(result.BlockHash).To(Equal(blockHash))
|
||||
Expect(result.Woe).To(Equal(expectedWoe))
|
||||
})
|
||||
|
||||
It("persists a vow Ash", func() {
|
||||
expectedAsh := "ash"
|
||||
expectedAsh := "123"
|
||||
|
||||
err = repo.Create(blockNumber, blockHash, vow.AshMetadata, expectedAsh)
|
||||
|
||||
@@ -134,7 +152,7 @@ var _ = Describe("Vow storage repository test", func() {
|
||||
})
|
||||
|
||||
It("persists a vow Wait", func() {
|
||||
expectedWait := "wait"
|
||||
expectedWait := "123"
|
||||
|
||||
err = repo.Create(blockNumber, blockHash, vow.WaitMetadata, expectedWait)
|
||||
|
||||
@@ -152,7 +170,7 @@ var _ = Describe("Vow storage repository test", func() {
|
||||
})
|
||||
|
||||
It("persists a vow Bump", func() {
|
||||
expectedBump := "bump"
|
||||
expectedBump := "123"
|
||||
|
||||
err = repo.Create(blockNumber, blockHash, vow.BumpMetadata, expectedBump)
|
||||
|
||||
@@ -170,7 +188,7 @@ var _ = Describe("Vow storage repository test", func() {
|
||||
})
|
||||
|
||||
It("persists a vow Sump", func() {
|
||||
expectedSump := "sump"
|
||||
expectedSump := "123"
|
||||
|
||||
err = repo.Create(blockNumber, blockHash, vow.SumpMetadata, expectedSump)
|
||||
|
||||
@@ -188,7 +206,7 @@ var _ = Describe("Vow storage repository test", func() {
|
||||
})
|
||||
|
||||
It("persists a vow Hump", func() {
|
||||
expectedHump := "hump"
|
||||
expectedHump := "123"
|
||||
|
||||
err = repo.Create(blockNumber, blockHash, vow.HumpMetadata, expectedHump)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user