VDB-120 include tic in dent and tend (#118)
* Add constants for TTL and tic for fakeHeader * Add tic to tend transformer * Update tests for tend * Fix string conversion bug in fakes * Fix tend integration tests after staging rebase * Add tic to dent transformer * Update dent tests * Change integration tests to use hardcoded block timestamp
This commit is contained in:
@@ -40,9 +40,6 @@ func (c DentConverter) ToModels(ethLogs []types.Log) (result []interface{}, err
|
||||
lot := log.Topics[3].Big().String()
|
||||
bidValue := getBidValue(log)
|
||||
guy := common.HexToAddress(log.Topics[1].Hex()).String()
|
||||
tic := "0"
|
||||
//TODO: it is likely that the tic value will need to be added to an emitted event,
|
||||
//so this will need to be updated at that point
|
||||
|
||||
logIndex := log.Index
|
||||
transactionIndex := log.TxIndex
|
||||
@@ -57,7 +54,6 @@ func (c DentConverter) ToModels(ethLogs []types.Log) (result []interface{}, err
|
||||
Lot: lot,
|
||||
Bid: bidValue,
|
||||
Guy: guy,
|
||||
Tic: tic,
|
||||
LogIndex: logIndex,
|
||||
TransactionIndex: transactionIndex,
|
||||
Raw: raw,
|
||||
|
||||
@@ -19,7 +19,6 @@ type DentModel struct {
|
||||
Lot string
|
||||
Bid string
|
||||
Guy string
|
||||
Tic string
|
||||
LogIndex uint `db:"log_idx"`
|
||||
TransactionIndex uint `db:"tx_idx"`
|
||||
Raw []byte `db:"raw_log"`
|
||||
|
||||
@@ -32,6 +32,11 @@ func (repository DentRepository) Create(headerID int64, models []interface{}) er
|
||||
return err
|
||||
}
|
||||
|
||||
tic, err := shared.GetTicInTx(headerID, tx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, model := range models {
|
||||
dent, ok := model.(DentModel)
|
||||
if !ok {
|
||||
@@ -48,7 +53,7 @@ func (repository DentRepository) Create(headerID int64, models []interface{}) er
|
||||
_, err = tx.Exec(
|
||||
`INSERT into maker.dent (header_id, bid_id, lot, bid, guy, tic, log_idx, tx_idx, raw_log)
|
||||
VALUES($1, $2, $3, $4, $5, $6, $7, $8, $9)`,
|
||||
headerID, dent.BidId, dent.Lot, dent.Bid, dent.Guy, dent.Tic, dent.LogIndex, dent.TransactionIndex, dent.Raw,
|
||||
headerID, dent.BidId, dent.Lot, dent.Bid, dent.Guy, tic, dent.LogIndex, dent.TransactionIndex, dent.Raw,
|
||||
)
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
|
||||
@@ -57,9 +57,9 @@ var _ = Describe("Dent Repository", func() {
|
||||
shared_behaviors.SharedRepositoryCreateBehaviors(&inputs)
|
||||
|
||||
It("persists a dent record", func() {
|
||||
headerId, err := headerRepository.CreateOrUpdateHeader(fakes.FakeHeader)
|
||||
headerID, err := headerRepository.CreateOrUpdateHeader(fakes.FakeHeader)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
err = dentRepository.Create(headerId, []interface{}{test_data.DentModel})
|
||||
err = dentRepository.Create(headerID, []interface{}{test_data.DentModel})
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
var count int
|
||||
@@ -67,16 +67,20 @@ var _ = Describe("Dent Repository", func() {
|
||||
Expect(count).To(Equal(1))
|
||||
|
||||
var dbResult dent.DentModel
|
||||
err = db.Get(&dbResult, `SELECT bid_id, lot, bid, guy, tic, log_idx, tx_idx, raw_log FROM maker.dent WHERE header_id = $1`, headerId)
|
||||
err = db.Get(&dbResult, `SELECT bid_id, lot, bid, guy, log_idx, tx_idx, raw_log FROM maker.dent WHERE header_id = $1`, headerID)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(dbResult.BidId).To(Equal(test_data.DentModel.BidId))
|
||||
Expect(dbResult.Lot).To(Equal(test_data.DentModel.Lot))
|
||||
Expect(dbResult.Bid).To(Equal(test_data.DentModel.Bid))
|
||||
Expect(dbResult.Guy).To(Equal(test_data.DentModel.Guy))
|
||||
Expect(dbResult.Tic).To(Equal(test_data.DentModel.Tic))
|
||||
Expect(dbResult.LogIndex).To(Equal(test_data.DentModel.LogIndex))
|
||||
Expect(dbResult.TransactionIndex).To(Equal(test_data.DentModel.TransactionIndex))
|
||||
Expect(dbResult.Raw).To(MatchJSON(test_data.DentModel.Raw))
|
||||
|
||||
var dbTic int64
|
||||
err = db.Get(&dbTic, `SELECT tic FROM maker.dent WHERE header_id = $1`, headerID)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(dbTic).To(Equal(fakes.FakeHeaderTic))
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user