forked from cerc-io/ipld-eth-server
integration tests (#75)
* Deal integration test * Add LogIndex to CatFileChopLump to update unique constraint * Add LogIndex to cat_file_pit_vow records * Add integration tests for Cat.file transformers * Add log index to Cat.file flip
This commit is contained in:
@@ -50,6 +50,7 @@ func (CatFileFlipConverter) ToModels(ethLogs []types.Log) ([]CatFileFlipModel, e
|
||||
What: what,
|
||||
Flip: flip,
|
||||
TransactionIndex: ethLog.TxIndex,
|
||||
LogIndex: ethLog.Index,
|
||||
Raw: raw,
|
||||
}
|
||||
results = append(results, result)
|
||||
|
||||
@@ -19,5 +19,6 @@ type CatFileFlipModel struct {
|
||||
What string
|
||||
Flip string
|
||||
TransactionIndex uint `db:"tx_idx"`
|
||||
LogIndex uint `db:"log_idx"`
|
||||
Raw []byte `db:"raw_log"`
|
||||
}
|
||||
|
||||
@@ -40,9 +40,9 @@ func (repository CatFileFlipRepository) Create(headerID int64, models []CatFileF
|
||||
}
|
||||
for _, model := range models {
|
||||
_, err = repository.db.Exec(
|
||||
`INSERT into maker.cat_file_flip (header_id, ilk, what, flip, tx_idx, raw_log)
|
||||
VALUES($1, $2, $3, $4, $5, $6)`,
|
||||
headerID, model.Ilk, model.What, model.Flip, model.TransactionIndex, model.Raw,
|
||||
`INSERT into maker.cat_file_flip (header_id, ilk, what, flip, tx_idx, log_idx, raw_log)
|
||||
VALUES($1, $2, $3, $4, $5, $6, $7)`,
|
||||
headerID, model.Ilk, model.What, model.Flip, model.TransactionIndex, model.LogIndex, model.Raw,
|
||||
)
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
|
||||
@@ -58,12 +58,13 @@ var _ = Describe("Cat file flip repository", func() {
|
||||
|
||||
It("adds a cat file flip event", func() {
|
||||
var dbResult flip.CatFileFlipModel
|
||||
err = db.Get(&dbResult, `SELECT ilk, what, flip, tx_idx, raw_log FROM maker.cat_file_flip WHERE header_id = $1`, headerID)
|
||||
err = db.Get(&dbResult, `SELECT ilk, what, flip, tx_idx, log_idx, raw_log FROM maker.cat_file_flip WHERE header_id = $1`, headerID)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(dbResult.Ilk).To(Equal(test_data.CatFileFlipModel.Ilk))
|
||||
Expect(dbResult.What).To(Equal(test_data.CatFileFlipModel.What))
|
||||
Expect(dbResult.Flip).To(Equal(test_data.CatFileFlipModel.Flip))
|
||||
Expect(dbResult.TransactionIndex).To(Equal(test_data.CatFileFlipModel.TransactionIndex))
|
||||
Expect(dbResult.LogIndex).To(Equal(test_data.CatFileFlipModel.LogIndex))
|
||||
Expect(dbResult.Raw).To(MatchJSON(test_data.CatFileFlipModel.Raw))
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user