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 (TendConverter) ToModels(ethLogs []types.Log) (results []interface{}, err e
|
||||
lastItem := ethLog.Data[lastDataItemStartIndex:]
|
||||
last := big.NewInt(0).SetBytes(lastItem)
|
||||
bidValue := last.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
|
||||
transactionIndex := ethLog.TxIndex
|
||||
logIndex := ethLog.Index
|
||||
|
||||
@@ -56,7 +53,6 @@ func (TendConverter) ToModels(ethLogs []types.Log) (results []interface{}, err e
|
||||
Lot: lot,
|
||||
Bid: bidValue,
|
||||
Guy: guy,
|
||||
Tic: tic,
|
||||
LogIndex: logIndex,
|
||||
TransactionIndex: transactionIndex,
|
||||
Raw: rawLog,
|
||||
|
||||
@@ -19,7 +19,6 @@ type TendModel 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 TendRepository) Create(headerID int64, models []interface{}) er
|
||||
return err
|
||||
}
|
||||
|
||||
tic, err := shared.GetTicInTx(headerID, tx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, model := range models {
|
||||
tend, ok := model.(TendModel)
|
||||
if !ok {
|
||||
@@ -47,8 +52,8 @@ func (repository TendRepository) Create(headerID int64, models []interface{}) er
|
||||
|
||||
_, err = tx.Exec(
|
||||
`INSERT into maker.tend (header_id, bid_id, lot, bid, guy, tic, log_idx, tx_idx, raw_log)
|
||||
VALUES($1, $2, $3::NUMERIC, $4::NUMERIC, $5, $6::NUMERIC, $7, $8, $9)`,
|
||||
headerID, tend.BidId, tend.Lot, tend.Bid, tend.Guy, tend.Tic, tend.LogIndex, tend.TransactionIndex, tend.Raw,
|
||||
VALUES($1, $2, $3::NUMERIC, $4::NUMERIC, $5, $6, $7, $8, $9)`,
|
||||
headerID, tend.BidId, tend.Lot, tend.Bid, tend.Guy, tic, tend.LogIndex, tend.TransactionIndex, tend.Raw,
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
|
||||
@@ -68,19 +68,22 @@ var _ = Describe("TendRepository", func() {
|
||||
Expect(count).To(Equal(1))
|
||||
|
||||
dbResult := tend.TendModel{}
|
||||
err = db.Get(&dbResult, `SELECT bid_id, lot, bid, guy, tic, log_idx, tx_idx, raw_log FROM maker.tend WHERE header_id = $1`, headerID)
|
||||
err = db.Get(&dbResult, `SELECT bid_id, lot, bid, guy, log_idx, tx_idx, raw_log FROM maker.tend WHERE header_id = $1`, headerID)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
Expect(dbResult.BidId).To(Equal(test_data.TendModel.BidId))
|
||||
Expect(dbResult.Lot).To(Equal(test_data.TendModel.Lot))
|
||||
Expect(dbResult.Bid).To(Equal(test_data.TendModel.Bid))
|
||||
Expect(dbResult.Guy).To(Equal(test_data.TendModel.Guy))
|
||||
Expect(dbResult.Tic).To(Equal(test_data.TendModel.Tic))
|
||||
Expect(dbResult.LogIndex).To(Equal(test_data.TendModel.LogIndex))
|
||||
Expect(dbResult.TransactionIndex).To(Equal(test_data.TendModel.TransactionIndex))
|
||||
Expect(dbResult.Raw).To(MatchJSON(test_data.TendModel.Raw))
|
||||
})
|
||||
|
||||
var dbTic int64
|
||||
err = db.Get(&dbTic, `SELECT tic FROM maker.tend WHERE header_id = $1`, headerID)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(dbTic).To(Equal(fakes.FakeHeaderTic))
|
||||
})
|
||||
})
|
||||
|
||||
Describe("MarkHeaderChecked", func() {
|
||||
|
||||
Reference in New Issue
Block a user