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 (CatFileChopLumpConverter) ToModels(ethLogs []types.Log) ([]CatFileChopLump
|
||||
What: what,
|
||||
Data: data,
|
||||
TransactionIndex: ethLog.TxIndex,
|
||||
LogIndex: ethLog.Index,
|
||||
Raw: raw,
|
||||
}
|
||||
results = append(results, result)
|
||||
|
||||
@@ -19,5 +19,6 @@ type CatFileChopLumpModel struct {
|
||||
What string
|
||||
Data string
|
||||
TransactionIndex uint `db:"tx_idx"`
|
||||
LogIndex uint `db:"log_idx"`
|
||||
Raw []byte `db:"raw_log"`
|
||||
}
|
||||
|
||||
@@ -40,9 +40,9 @@ func (repository CatFileChopLumpRepository) Create(headerID int64, models []CatF
|
||||
}
|
||||
for _, model := range models {
|
||||
_, err := tx.Exec(
|
||||
`INSERT into maker.cat_file_chop_lump (header_id, ilk, what, data, tx_idx, raw_log)
|
||||
VALUES($1, $2, $3, $4::NUMERIC, $5, $6)`,
|
||||
headerID, model.Ilk, model.What, model.Data, model.TransactionIndex, model.Raw,
|
||||
`INSERT into maker.cat_file_chop_lump (header_id, ilk, what, data, tx_idx, log_idx, raw_log)
|
||||
VALUES($1, $2, $3, $4::NUMERIC, $5, $6, $7)`,
|
||||
headerID, model.Ilk, model.What, model.Data, model.TransactionIndex, model.LogIndex, model.Raw,
|
||||
)
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
|
||||
@@ -81,6 +81,14 @@ var _ = Describe("Cat file chop lump repository", func() {
|
||||
Expect(err.Error()).To(ContainSubstring("pq: duplicate key value violates unique constraint"))
|
||||
})
|
||||
|
||||
It("allows for multiple cat file chop lump events if they have different log indexes", func() {
|
||||
newCatFileChopLump := test_data.CatFileChopLumpModel
|
||||
newCatFileChopLump.LogIndex = newCatFileChopLump.LogIndex + 1
|
||||
err = catFileRepository.Create(headerID, []chop_lump.CatFileChopLumpModel{newCatFileChopLump})
|
||||
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
})
|
||||
|
||||
It("removes cat file chop lump if corresponding header is deleted", func() {
|
||||
_, err = db.Exec(`DELETE FROM headers WHERE id = $1`, headerID)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user