ipld-eth-server/pkg/transformers/vat_grab/converter_test.go
Rob Mulholand d1ee501f12 Use transformer factory for Bite (#89)
* Use transformer factory for Bite

- introduces separate transformer factory for non-LogNote events
- converter includes `ToEntities` for events defined via ABI

* Updates after rebasing with staging
2018-10-26 13:26:10 -05:00

48 lines
1.1 KiB
Go

package vat_grab_test
import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
"github.com/vulcanize/vulcanizedb/pkg/transformers/vat_grab"
)
var _ = Describe("Vat grab converter", func() {
var converter vat_grab.VatGrabConverter
BeforeEach(func() {
converter = vat_grab.VatGrabConverter{}
})
It("returns err if log is missing topics", func() {
badLog := types.Log{
Data: []byte{1, 1, 1, 1, 1},
}
_, err := converter.ToModels([]types.Log{badLog})
Expect(err).To(HaveOccurred())
})
It("returns err if log is missing data", func() {
badLog := types.Log{
Topics: []common.Hash{{}, {}, {}, {}},
}
_, err := converter.ToModels([]types.Log{badLog})
Expect(err).To(HaveOccurred())
})
It("converts a log to an model", func() {
models, err := converter.ToModels([]types.Log{test_data.EthVatGrabLog})
Expect(err).NotTo(HaveOccurred())
Expect(len(models)).To(Equal(1))
Expect(models[0]).To(Equal(test_data.VatGrabModel))
})
})