bd428e752a
* Update vat grab to use transformer factory
49 lines
1.2 KiB
Go
49 lines
1.2 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/factories"
|
|
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
|
|
"github.com/vulcanize/vulcanizedb/pkg/transformers/vat_grab"
|
|
)
|
|
|
|
var _ = Describe("Vat grab converter", func() {
|
|
var converter factories.Converter
|
|
|
|
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))
|
|
})
|
|
})
|