From 44177e07729a1e3bc967bc8f519673d137ffa0fa Mon Sep 17 00:00:00 2001 From: Ian Norden Date: Tue, 18 Sep 2018 22:15:49 -0500 Subject: [PATCH] reorganizing contract-specific modules into event_triggered contract directories --- .../event_triggered/{ => dai}/converter.go | 15 ++++---- .../{ => dai}/converter_test.go | 15 ++++---- .../event_triggered/dai/dai_suite_test.go} | 4 +-- .../event_triggered/{ => dai}/entity.go | 2 +- .../{ => dai}/integration_test.go | 7 ++-- .../{ => dai}/repository_test.go | 11 +++--- .../event_triggered/{ => dai}/transformer.go | 7 ++-- .../{ => dai}/transformer_test.go | 8 ++--- .../event_triggered/{ => tusd}/converter.go | 15 ++++---- .../{ => tusd}/converter_test.go | 15 ++++---- .../event_triggered/{ => tusd}/entity.go | 2 +- .../{ => tusd}/integration_test.go | 7 ++-- .../{ => tusd}/repository_test.go | 11 +++--- .../event_triggered/{ => tusd}/transformer.go | 7 ++-- .../{ => tusd}/transformer_test.go | 8 ++--- .../event_triggered/tusd/tusd_suite_test.go} | 4 +-- examples/mocks/converter.go | 34 ++++++++++--------- 17 files changed, 92 insertions(+), 80 deletions(-) rename examples/erc20_watcher/event_triggered/{ => dai}/converter.go (90%) rename examples/erc20_watcher/event_triggered/{ => dai}/converter_test.go (93%) rename examples/{generic/event_triggered/event_triggered_suite_test.go => erc20_watcher/event_triggered/dai/dai_suite_test.go} (90%) rename examples/erc20_watcher/event_triggered/{ => dai}/entity.go (97%) rename examples/erc20_watcher/event_triggered/{ => dai}/integration_test.go (95%) rename examples/erc20_watcher/event_triggered/{ => dai}/repository_test.go (97%) rename examples/erc20_watcher/event_triggered/{ => dai}/transformer.go (93%) rename examples/erc20_watcher/event_triggered/{ => dai}/transformer_test.go (96%) rename examples/generic/event_triggered/{ => tusd}/converter.go (88%) rename examples/generic/event_triggered/{ => tusd}/converter_test.go (93%) rename examples/generic/event_triggered/{ => tusd}/entity.go (97%) rename examples/generic/event_triggered/{ => tusd}/integration_test.go (94%) rename examples/generic/event_triggered/{ => tusd}/repository_test.go (97%) rename examples/generic/event_triggered/{ => tusd}/transformer.go (93%) rename examples/generic/event_triggered/{ => tusd}/transformer_test.go (97%) rename examples/{erc20_watcher/event_triggered/event_triggered_suite_test.go => generic/event_triggered/tusd/tusd_suite_test.go} (90%) diff --git a/examples/erc20_watcher/event_triggered/converter.go b/examples/erc20_watcher/event_triggered/dai/converter.go similarity index 90% rename from examples/erc20_watcher/event_triggered/converter.go rename to examples/erc20_watcher/event_triggered/dai/converter.go index 563b24f1..06f75145 100644 --- a/examples/erc20_watcher/event_triggered/converter.go +++ b/examples/erc20_watcher/event_triggered/dai/converter.go @@ -12,13 +12,14 @@ // See the License for the specific language governing permissions and // limitations under the License. -package event_triggered +package dai import ( "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" "github.com/vulcanize/vulcanizedb/examples/constants" + "github.com/vulcanize/vulcanizedb/examples/erc20_watcher/event_triggered" "github.com/vulcanize/vulcanizedb/examples/generic" "github.com/vulcanize/vulcanizedb/examples/generic/helpers" "github.com/vulcanize/vulcanizedb/pkg/core" @@ -30,9 +31,9 @@ import ( type ERC20ConverterInterface interface { ToTransferEntity(watchedEvent core.WatchedEvent) (*TransferEntity, error) - ToTransferModel(entity *TransferEntity) *TransferModel + ToTransferModel(entity *TransferEntity) *event_triggered.TransferModel ToApprovalEntity(watchedEvent core.WatchedEvent) (*ApprovalEntity, error) - ToApprovalModel(entity *ApprovalEntity) *ApprovalModel + ToApprovalModel(entity *ApprovalEntity) *event_triggered.ApprovalModel } type ERC20Converter struct { @@ -70,12 +71,12 @@ func (c ERC20Converter) ToTransferEntity(watchedEvent core.WatchedEvent) (*Trans return result, nil } -func (c ERC20Converter) ToTransferModel(entity *TransferEntity) *TransferModel { +func (c ERC20Converter) ToTransferModel(entity *TransferEntity) *event_triggered.TransferModel { to := entity.Dst.String() from := entity.Src.String() tokens := entity.Wad.String() - return &TransferModel{ + return &event_triggered.TransferModel{ TokenName: c.config.Name, TokenAddress: c.config.Address, To: to, @@ -102,12 +103,12 @@ func (c ERC20Converter) ToApprovalEntity(watchedEvent core.WatchedEvent) (*Appro return result, nil } -func (c ERC20Converter) ToApprovalModel(entity *ApprovalEntity) *ApprovalModel { +func (c ERC20Converter) ToApprovalModel(entity *ApprovalEntity) *event_triggered.ApprovalModel { tokenOwner := entity.Src.String() spender := entity.Guy.String() tokens := entity.Wad.String() - return &ApprovalModel{ + return &event_triggered.ApprovalModel{ TokenName: c.config.Name, TokenAddress: c.config.Address, Owner: tokenOwner, diff --git a/examples/erc20_watcher/event_triggered/converter_test.go b/examples/erc20_watcher/event_triggered/dai/converter_test.go similarity index 93% rename from examples/erc20_watcher/event_triggered/converter_test.go rename to examples/erc20_watcher/event_triggered/dai/converter_test.go index 49242077..1a100e15 100644 --- a/examples/erc20_watcher/event_triggered/converter_test.go +++ b/examples/erc20_watcher/event_triggered/dai/converter_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package event_triggered_test +package dai_test import ( "github.com/ethereum/go-ethereum/common" @@ -21,6 +21,7 @@ import ( "github.com/vulcanize/vulcanizedb/examples/constants" "github.com/vulcanize/vulcanizedb/examples/erc20_watcher/event_triggered" + "github.com/vulcanize/vulcanizedb/examples/erc20_watcher/event_triggered/dai" "github.com/vulcanize/vulcanizedb/examples/generic" "github.com/vulcanize/vulcanizedb/examples/generic/helpers" "github.com/vulcanize/vulcanizedb/pkg/core" @@ -36,7 +37,7 @@ var expectedTransferModel = event_triggered.TransferModel{ TxHash: "0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad6546ae", } -var expectedTransferEntity = event_triggered.TransferEntity{ +var expectedTransferEntity = dai.TransferEntity{ TokenName: "Dai", TokenAddress: common.HexToAddress(constants.DaiContractAddress), Src: common.HexToAddress("0x000000000000000000000000000000000000Af21"), @@ -56,7 +57,7 @@ var expectedApprovalModel = event_triggered.ApprovalModel{ TxHash: "0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad6546ae", } -var expectedApprovalEntity = event_triggered.ApprovalEntity{ +var expectedApprovalEntity = dai.ApprovalEntity{ TokenName: "Dai", TokenAddress: common.HexToAddress(constants.DaiContractAddress), Src: common.HexToAddress("0x000000000000000000000000000000000000Af21"), @@ -96,11 +97,11 @@ var approvalEvent = core.WatchedEvent{ var _ = Describe("Transfer Converter", func() { - var daiConverter *event_triggered.ERC20Converter + var daiConverter *dai.ERC20Converter var err error BeforeEach(func() { - daiConverter, err = event_triggered.NewERC20Converter(generic.DaiConfig) + daiConverter, err = dai.NewERC20Converter(generic.DaiConfig) Expect(err).NotTo(HaveOccurred()) }) @@ -124,11 +125,11 @@ var _ = Describe("Transfer Converter", func() { var _ = Describe("Approval Converter", func() { - var daiConverter *event_triggered.ERC20Converter + var daiConverter *dai.ERC20Converter var err error BeforeEach(func() { - daiConverter, err = event_triggered.NewERC20Converter(generic.DaiConfig) + daiConverter, err = dai.NewERC20Converter(generic.DaiConfig) Expect(err).NotTo(HaveOccurred()) }) diff --git a/examples/generic/event_triggered/event_triggered_suite_test.go b/examples/erc20_watcher/event_triggered/dai/dai_suite_test.go similarity index 90% rename from examples/generic/event_triggered/event_triggered_suite_test.go rename to examples/erc20_watcher/event_triggered/dai/dai_suite_test.go index f75089a9..277c192d 100644 --- a/examples/generic/event_triggered/event_triggered_suite_test.go +++ b/examples/erc20_watcher/event_triggered/dai/dai_suite_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package event_triggered_test +package dai_test import ( "testing" @@ -23,5 +23,5 @@ import ( func TestLogKill(t *testing.T) { RegisterFailHandler(Fail) - RunSpecs(t, "ERC20 Event Triggered test Suite") + RunSpecs(t, "Dai ERC20 Event Triggered Test Suite") } diff --git a/examples/erc20_watcher/event_triggered/entity.go b/examples/erc20_watcher/event_triggered/dai/entity.go similarity index 97% rename from examples/erc20_watcher/event_triggered/entity.go rename to examples/erc20_watcher/event_triggered/dai/entity.go index f3cfce2f..8a6c27f3 100644 --- a/examples/erc20_watcher/event_triggered/entity.go +++ b/examples/erc20_watcher/event_triggered/dai/entity.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package event_triggered +package dai import ( "math/big" diff --git a/examples/erc20_watcher/event_triggered/integration_test.go b/examples/erc20_watcher/event_triggered/dai/integration_test.go similarity index 95% rename from examples/erc20_watcher/event_triggered/integration_test.go rename to examples/erc20_watcher/event_triggered/dai/integration_test.go index 856d7d59..b8af844f 100644 --- a/examples/erc20_watcher/event_triggered/integration_test.go +++ b/examples/erc20_watcher/event_triggered/dai/integration_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package event_triggered_test +package dai_test import ( . "github.com/onsi/ginkgo" @@ -20,6 +20,7 @@ import ( "github.com/vulcanize/vulcanizedb/examples/constants" "github.com/vulcanize/vulcanizedb/examples/erc20_watcher/event_triggered" + "github.com/vulcanize/vulcanizedb/examples/erc20_watcher/event_triggered/dai" "github.com/vulcanize/vulcanizedb/examples/generic" "github.com/vulcanize/vulcanizedb/examples/test_helpers" "github.com/vulcanize/vulcanizedb/pkg/core" @@ -80,7 +81,7 @@ var _ = Describe("Integration test with vulcanizedb", func() { }) It("creates token_transfers entry for each Transfer event received", func() { - transformer, err := event_triggered.NewTransformer(db, generic.DaiConfig) + transformer, err := dai.NewTransformer(db, generic.DaiConfig) Expect(err).ToNot(HaveOccurred()) transformer.Execute() @@ -106,7 +107,7 @@ var _ = Describe("Integration test with vulcanizedb", func() { }) It("creates token_approvals entry for each Approval event received", func() { - transformer, err := event_triggered.NewTransformer(db, generic.DaiConfig) + transformer, err := dai.NewTransformer(db, generic.DaiConfig) Expect(err).ToNot(HaveOccurred()) transformer.Execute() diff --git a/examples/erc20_watcher/event_triggered/repository_test.go b/examples/erc20_watcher/event_triggered/dai/repository_test.go similarity index 97% rename from examples/erc20_watcher/event_triggered/repository_test.go rename to examples/erc20_watcher/event_triggered/dai/repository_test.go index 2adb39b2..b809c915 100644 --- a/examples/erc20_watcher/event_triggered/repository_test.go +++ b/examples/erc20_watcher/event_triggered/dai/repository_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package event_triggered_test +package dai_test import ( "math/rand" @@ -23,6 +23,7 @@ import ( . "github.com/onsi/gomega" "github.com/vulcanize/vulcanizedb/examples/erc20_watcher/event_triggered" + "github.com/vulcanize/vulcanizedb/examples/erc20_watcher/event_triggered/dai" "github.com/vulcanize/vulcanizedb/examples/generic/helpers" "github.com/vulcanize/vulcanizedb/examples/test_helpers" "github.com/vulcanize/vulcanizedb/pkg/config" @@ -31,7 +32,7 @@ import ( "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres/repositories" ) -var transferEntity = &event_triggered.TransferEntity{ +var transferEntity = &dai.TransferEntity{ TokenName: "Dai", TokenAddress: common.HexToAddress("0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359"), Src: common.HexToAddress("0x000000000000000000000000000000000000Af21"), @@ -41,7 +42,7 @@ var transferEntity = &event_triggered.TransferEntity{ TxHash: "0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad6546ae", } -var approvalEntity = &event_triggered.ApprovalEntity{ +var approvalEntity = &dai.ApprovalEntity{ TokenName: "Dai", TokenAddress: common.HexToAddress("0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359"), Src: common.HexToAddress("0x000000000000000000000000000000000000Af21"), @@ -53,7 +54,7 @@ var approvalEntity = &event_triggered.ApprovalEntity{ var _ = Describe("Approval and Transfer Repository Tests", func() { var db *postgres.DB - var converter event_triggered.ERC20Converter + var converter dai.ERC20Converter var repository event_triggered.ERC20EventRepository var logRepository repositories.LogRepository var blockRepository repositories.BlockRepository @@ -93,7 +94,7 @@ var _ = Describe("Approval and Transfer Repository Tests", func() { Expect(err).ToNot(HaveOccurred()) repository = event_triggered.ERC20EventRepository{DB: db} - converter = event_triggered.ERC20Converter{} + converter = dai.ERC20Converter{} }) diff --git a/examples/erc20_watcher/event_triggered/transformer.go b/examples/erc20_watcher/event_triggered/dai/transformer.go similarity index 93% rename from examples/erc20_watcher/event_triggered/transformer.go rename to examples/erc20_watcher/event_triggered/dai/transformer.go index 7ae95ae3..3f3c3e1a 100644 --- a/examples/erc20_watcher/event_triggered/transformer.go +++ b/examples/erc20_watcher/event_triggered/dai/transformer.go @@ -12,13 +12,14 @@ // See the License for the specific language governing permissions and // limitations under the License. -package event_triggered +package dai import ( "fmt" "log" "github.com/vulcanize/vulcanizedb/examples/constants" + "github.com/vulcanize/vulcanizedb/examples/erc20_watcher/event_triggered" "github.com/vulcanize/vulcanizedb/examples/generic" "github.com/vulcanize/vulcanizedb/libraries/shared" "github.com/vulcanize/vulcanizedb/pkg/datastore" @@ -30,7 +31,7 @@ type ERC20EventTransformer struct { Converter ERC20ConverterInterface WatchedEventRepository datastore.WatchedEventRepository FilterRepository datastore.FilterRepository - Repository ERC20EventDatastore + Repository event_triggered.ERC20EventDatastore } func NewTransformer(db *postgres.DB, config generic.ContractConfig) (shared.Transformer, error) { @@ -43,7 +44,7 @@ func NewTransformer(db *postgres.DB, config generic.ContractConfig) (shared.Tran wer := repositories.WatchedEventRepository{DB: db} fr := repositories.FilterRepository{DB: db} - lkr := ERC20EventRepository{DB: db} + lkr := event_triggered.ERC20EventRepository{DB: db} transformer = ERC20EventTransformer{ Converter: cnvtr, WatchedEventRepository: wer, diff --git a/examples/erc20_watcher/event_triggered/transformer_test.go b/examples/erc20_watcher/event_triggered/dai/transformer_test.go similarity index 96% rename from examples/erc20_watcher/event_triggered/transformer_test.go rename to examples/erc20_watcher/event_triggered/dai/transformer_test.go index a02583f9..0f35e025 100644 --- a/examples/erc20_watcher/event_triggered/transformer_test.go +++ b/examples/erc20_watcher/event_triggered/dai/transformer_test.go @@ -12,14 +12,14 @@ // See the License for the specific language governing permissions and // limitations under the License. -package event_triggered_test +package dai_test import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" "github.com/vulcanize/vulcanizedb/examples/constants" - "github.com/vulcanize/vulcanizedb/examples/erc20_watcher/event_triggered" + "github.com/vulcanize/vulcanizedb/examples/erc20_watcher/event_triggered/dai" "github.com/vulcanize/vulcanizedb/examples/mocks" "github.com/vulcanize/vulcanizedb/pkg/core" ) @@ -63,7 +63,7 @@ var _ = Describe("Mock ERC20 transformer", func() { var watchedEventsRepo mocks.MockWatchedEventsRepository var mockEventRepo mocks.MockEventRepo var filterRepo mocks.MockFilterRepository - var transformer event_triggered.ERC20EventTransformer + var transformer dai.ERC20EventTransformer BeforeEach(func() { mockERC20Converter = mocks.MockERC20Converter{} @@ -72,7 +72,7 @@ var _ = Describe("Mock ERC20 transformer", func() { mockEventRepo = mocks.MockEventRepo{} filterRepo = mocks.MockFilterRepository{} - transformer = event_triggered.ERC20EventTransformer{ + transformer = dai.ERC20EventTransformer{ Converter: &mockERC20Converter, WatchedEventRepository: &watchedEventsRepo, FilterRepository: filterRepo, diff --git a/examples/generic/event_triggered/converter.go b/examples/generic/event_triggered/tusd/converter.go similarity index 88% rename from examples/generic/event_triggered/converter.go rename to examples/generic/event_triggered/tusd/converter.go index 0a80a1a1..ab6c8aa3 100644 --- a/examples/generic/event_triggered/converter.go +++ b/examples/generic/event_triggered/tusd/converter.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package event_triggered +package tusd import ( "github.com/ethereum/go-ethereum/accounts/abi/bind" @@ -20,6 +20,7 @@ import ( "github.com/vulcanize/vulcanizedb/examples/constants" "github.com/vulcanize/vulcanizedb/examples/generic" + "github.com/vulcanize/vulcanizedb/examples/generic/event_triggered" "github.com/vulcanize/vulcanizedb/examples/generic/helpers" "github.com/vulcanize/vulcanizedb/pkg/core" "github.com/vulcanize/vulcanizedb/pkg/geth" @@ -30,9 +31,9 @@ import ( type GenericConverterInterface interface { ToBurnEntity(watchedEvent core.WatchedEvent) (*BurnEntity, error) - ToBurnModel(entity *BurnEntity) *BurnModel + ToBurnModel(entity *BurnEntity) *event_triggered.BurnModel ToMintEntity(watchedEvent core.WatchedEvent) (*MintEntity, error) - ToMintModel(entity *MintEntity) *MintModel + ToMintModel(entity *MintEntity) *event_triggered.MintModel } type GenericConverter struct { @@ -70,11 +71,11 @@ func (c GenericConverter) ToBurnEntity(watchedEvent core.WatchedEvent) (*BurnEnt return result, nil } -func (c GenericConverter) ToBurnModel(entity *BurnEntity) *BurnModel { +func (c GenericConverter) ToBurnModel(entity *BurnEntity) *event_triggered.BurnModel { burner := entity.Burner.String() tokens := entity.Value.String() - return &BurnModel{ + return &event_triggered.BurnModel{ TokenName: c.config.Name, TokenAddress: c.config.Address, Burner: burner, @@ -100,12 +101,12 @@ func (c GenericConverter) ToMintEntity(watchedEvent core.WatchedEvent) (*MintEnt return result, nil } -func (c GenericConverter) ToMintModel(entity *MintEntity) *MintModel { +func (c GenericConverter) ToMintModel(entity *MintEntity) *event_triggered.MintModel { mintee := entity.To.String() minter := c.config.Owner tokens := entity.Amount.String() - return &MintModel{ + return &event_triggered.MintModel{ TokenName: c.config.Name, TokenAddress: c.config.Address, Mintee: mintee, diff --git a/examples/generic/event_triggered/converter_test.go b/examples/generic/event_triggered/tusd/converter_test.go similarity index 93% rename from examples/generic/event_triggered/converter_test.go rename to examples/generic/event_triggered/tusd/converter_test.go index bd6cd41d..e576ced8 100644 --- a/examples/generic/event_triggered/converter_test.go +++ b/examples/generic/event_triggered/tusd/converter_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package event_triggered_test +package tusd_test import ( "github.com/ethereum/go-ethereum/common" @@ -22,6 +22,7 @@ import ( "github.com/vulcanize/vulcanizedb/examples/constants" "github.com/vulcanize/vulcanizedb/examples/generic" "github.com/vulcanize/vulcanizedb/examples/generic/event_triggered" + "github.com/vulcanize/vulcanizedb/examples/generic/event_triggered/tusd" "github.com/vulcanize/vulcanizedb/examples/generic/helpers" "github.com/vulcanize/vulcanizedb/pkg/core" ) @@ -35,7 +36,7 @@ var expectedBurnModel = event_triggered.BurnModel{ TxHash: "0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad6546ae", } -var expectedBurnEntity = event_triggered.BurnEntity{ +var expectedBurnEntity = tusd.BurnEntity{ TokenName: "Tusd", TokenAddress: common.HexToAddress(constants.TusdContractAddress), Burner: common.HexToAddress("0x09BbBBE21a5975cAc061D82f7b843bCE061BA391"), @@ -54,7 +55,7 @@ var expectedMintModel = event_triggered.MintModel{ TxHash: "0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad6546ae", } -var expectedMintEntity = event_triggered.MintEntity{ +var expectedMintEntity = tusd.MintEntity{ TokenName: "Tusd", TokenAddress: common.HexToAddress(constants.TusdContractAddress), To: common.HexToAddress("0x09BbBBE21a5975cAc061D82f7b843bCE061BA391"), @@ -93,11 +94,11 @@ var mintEvent = core.WatchedEvent{ var _ = Describe("Transfer Converter", func() { - var converter *event_triggered.GenericConverter + var converter *tusd.GenericConverter var err error BeforeEach(func() { - converter, err = event_triggered.NewGenericConverter(generic.TusdConfig) + converter, err = tusd.NewGenericConverter(generic.TusdConfig) Expect(err).NotTo(HaveOccurred()) }) @@ -121,11 +122,11 @@ var _ = Describe("Transfer Converter", func() { var _ = Describe("Approval Converter", func() { - var converter *event_triggered.GenericConverter + var converter *tusd.GenericConverter var err error BeforeEach(func() { - converter, err = event_triggered.NewGenericConverter(generic.TusdConfig) + converter, err = tusd.NewGenericConverter(generic.TusdConfig) Expect(err).NotTo(HaveOccurred()) }) diff --git a/examples/generic/event_triggered/entity.go b/examples/generic/event_triggered/tusd/entity.go similarity index 97% rename from examples/generic/event_triggered/entity.go rename to examples/generic/event_triggered/tusd/entity.go index 9bfbe814..0f46f74a 100644 --- a/examples/generic/event_triggered/entity.go +++ b/examples/generic/event_triggered/tusd/entity.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package event_triggered +package tusd import ( "math/big" diff --git a/examples/generic/event_triggered/integration_test.go b/examples/generic/event_triggered/tusd/integration_test.go similarity index 94% rename from examples/generic/event_triggered/integration_test.go rename to examples/generic/event_triggered/tusd/integration_test.go index 5948c3b3..1d0627ee 100644 --- a/examples/generic/event_triggered/integration_test.go +++ b/examples/generic/event_triggered/tusd/integration_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package event_triggered_test +package tusd_test import ( . "github.com/onsi/ginkgo" @@ -21,6 +21,7 @@ import ( "github.com/vulcanize/vulcanizedb/examples/constants" "github.com/vulcanize/vulcanizedb/examples/generic" "github.com/vulcanize/vulcanizedb/examples/generic/event_triggered" + "github.com/vulcanize/vulcanizedb/examples/generic/event_triggered/tusd" "github.com/vulcanize/vulcanizedb/examples/test_helpers" "github.com/vulcanize/vulcanizedb/pkg/core" "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres" @@ -80,7 +81,7 @@ var _ = Describe("Integration test with vulcanizedb", func() { }) It("creates token_burns entry for each Burn event received", func() { - transformer, err := event_triggered.NewTransformer(db, generic.TusdConfig) + transformer, err := tusd.NewTransformer(db, generic.TusdConfig) Expect(err).ToNot(HaveOccurred()) transformer.Execute() @@ -105,7 +106,7 @@ var _ = Describe("Integration test with vulcanizedb", func() { }) It("creates token_mints entry for each Mint event received", func() { - transformer, err := event_triggered.NewTransformer(db, generic.TusdConfig) + transformer, err := tusd.NewTransformer(db, generic.TusdConfig) Expect(err).ToNot(HaveOccurred()) transformer.Execute() diff --git a/examples/generic/event_triggered/repository_test.go b/examples/generic/event_triggered/tusd/repository_test.go similarity index 97% rename from examples/generic/event_triggered/repository_test.go rename to examples/generic/event_triggered/tusd/repository_test.go index 6b358e2e..3b6b15bc 100644 --- a/examples/generic/event_triggered/repository_test.go +++ b/examples/generic/event_triggered/tusd/repository_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package event_triggered_test +package tusd_test import ( "math/rand" @@ -23,6 +23,7 @@ import ( . "github.com/onsi/gomega" "github.com/vulcanize/vulcanizedb/examples/generic/event_triggered" + "github.com/vulcanize/vulcanizedb/examples/generic/event_triggered/tusd" "github.com/vulcanize/vulcanizedb/examples/generic/helpers" "github.com/vulcanize/vulcanizedb/examples/test_helpers" "github.com/vulcanize/vulcanizedb/pkg/config" @@ -31,7 +32,7 @@ import ( "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres/repositories" ) -var burnEntity = &event_triggered.BurnEntity{ +var burnEntity = &tusd.BurnEntity{ TokenName: "Tusd", TokenAddress: common.HexToAddress("0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359"), Burner: common.HexToAddress("0x09BbBBE21a5975cAc061D82f7b843bCE061BA391"), @@ -40,7 +41,7 @@ var burnEntity = &event_triggered.BurnEntity{ TxHash: "0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad6546ae", } -var mintEntity = &event_triggered.MintEntity{ +var mintEntity = &tusd.MintEntity{ TokenName: "Tusd", TokenAddress: common.HexToAddress("0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359"), To: common.HexToAddress("0x09BbBBE21a5975cAc061D82f7b843bCE061BA391"), @@ -51,7 +52,7 @@ var mintEntity = &event_triggered.MintEntity{ var _ = Describe("Approval and Transfer Repository Tests", func() { var db *postgres.DB - var converter event_triggered.GenericConverter + var converter tusd.GenericConverter var repository event_triggered.GenericEventRepository var logRepository repositories.LogRepository var blockRepository repositories.BlockRepository @@ -91,7 +92,7 @@ var _ = Describe("Approval and Transfer Repository Tests", func() { Expect(err).ToNot(HaveOccurred()) repository = event_triggered.GenericEventRepository{DB: db} - converter = event_triggered.GenericConverter{} + converter = tusd.GenericConverter{} }) AfterEach(func() { diff --git a/examples/generic/event_triggered/transformer.go b/examples/generic/event_triggered/tusd/transformer.go similarity index 93% rename from examples/generic/event_triggered/transformer.go rename to examples/generic/event_triggered/tusd/transformer.go index f6b74bf7..93a9b2fc 100644 --- a/examples/generic/event_triggered/transformer.go +++ b/examples/generic/event_triggered/tusd/transformer.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package event_triggered +package tusd import ( "fmt" @@ -20,6 +20,7 @@ import ( "github.com/vulcanize/vulcanizedb/examples/constants" "github.com/vulcanize/vulcanizedb/examples/generic" + "github.com/vulcanize/vulcanizedb/examples/generic/event_triggered" "github.com/vulcanize/vulcanizedb/libraries/shared" "github.com/vulcanize/vulcanizedb/pkg/datastore" "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres" @@ -30,7 +31,7 @@ type GenericTransformer struct { Converter GenericConverterInterface WatchedEventRepository datastore.WatchedEventRepository FilterRepository datastore.FilterRepository - Repository GenericEventDatastore + Repository event_triggered.GenericEventDatastore } func NewTransformer(db *postgres.DB, config generic.ContractConfig) (shared.Transformer, error) { @@ -43,7 +44,7 @@ func NewTransformer(db *postgres.DB, config generic.ContractConfig) (shared.Tran wer := repositories.WatchedEventRepository{DB: db} fr := repositories.FilterRepository{DB: db} - lkr := GenericEventRepository{DB: db} + lkr := event_triggered.GenericEventRepository{DB: db} transformer = GenericTransformer{ Converter: cnvtr, WatchedEventRepository: wer, diff --git a/examples/generic/event_triggered/transformer_test.go b/examples/generic/event_triggered/tusd/transformer_test.go similarity index 97% rename from examples/generic/event_triggered/transformer_test.go rename to examples/generic/event_triggered/tusd/transformer_test.go index cbe2288c..4591a405 100644 --- a/examples/generic/event_triggered/transformer_test.go +++ b/examples/generic/event_triggered/tusd/transformer_test.go @@ -12,14 +12,14 @@ // See the License for the specific language governing permissions and // limitations under the License. -package event_triggered_test +package tusd_test import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" "github.com/vulcanize/vulcanizedb/examples/constants" - "github.com/vulcanize/vulcanizedb/examples/generic/event_triggered" + "github.com/vulcanize/vulcanizedb/examples/generic/event_triggered/tusd" "github.com/vulcanize/vulcanizedb/examples/mocks" "github.com/vulcanize/vulcanizedb/pkg/core" ) @@ -63,7 +63,7 @@ var _ = Describe("Mock ERC20 transformer", func() { var watchedEventsRepo mocks.MockWatchedEventsRepository var mockEventRepo mocks.MockEventRepo var filterRepo mocks.MockFilterRepository - var transformer event_triggered.GenericTransformer + var transformer tusd.GenericTransformer BeforeEach(func() { mockERC20Converter = mocks.MockERC20Converter{} @@ -72,7 +72,7 @@ var _ = Describe("Mock ERC20 transformer", func() { mockEventRepo = mocks.MockEventRepo{} filterRepo = mocks.MockFilterRepository{} - transformer = event_triggered.GenericTransformer{ + transformer = tusd.GenericTransformer{ Converter: &mockERC20Converter, WatchedEventRepository: &watchedEventsRepo, FilterRepository: filterRepo, diff --git a/examples/erc20_watcher/event_triggered/event_triggered_suite_test.go b/examples/generic/event_triggered/tusd/tusd_suite_test.go similarity index 90% rename from examples/erc20_watcher/event_triggered/event_triggered_suite_test.go rename to examples/generic/event_triggered/tusd/tusd_suite_test.go index f75089a9..81f00eb3 100644 --- a/examples/erc20_watcher/event_triggered/event_triggered_suite_test.go +++ b/examples/generic/event_triggered/tusd/tusd_suite_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package event_triggered_test +package tusd_test import ( "testing" @@ -23,5 +23,5 @@ import ( func TestLogKill(t *testing.T) { RegisterFailHandler(Fail) - RunSpecs(t, "ERC20 Event Triggered test Suite") + RunSpecs(t, "Tusd Generic Event Triggered Test Suite") } diff --git a/examples/mocks/converter.go b/examples/mocks/converter.go index 63ff1a98..a87aab1c 100644 --- a/examples/mocks/converter.go +++ b/examples/mocks/converter.go @@ -16,63 +16,65 @@ package mocks import ( et1 "github.com/vulcanize/vulcanizedb/examples/erc20_watcher/event_triggered" + "github.com/vulcanize/vulcanizedb/examples/erc20_watcher/event_triggered/dai" et2 "github.com/vulcanize/vulcanizedb/examples/generic/event_triggered" + "github.com/vulcanize/vulcanizedb/examples/generic/event_triggered/tusd" "github.com/vulcanize/vulcanizedb/pkg/core" ) type MockERC20Converter struct { WatchedEvents []*core.WatchedEvent - TransfersToConvert []et1.TransferEntity - ApprovalsToConvert []et1.ApprovalEntity - BurnsToConvert []et2.BurnEntity - MintsToConvert []et2.MintEntity + TransfersToConvert []dai.TransferEntity + ApprovalsToConvert []dai.ApprovalEntity + BurnsToConvert []tusd.BurnEntity + MintsToConvert []tusd.MintEntity block int64 } -func (mlkc *MockERC20Converter) ToTransferModel(entity *et1.TransferEntity) *et1.TransferModel { +func (mlkc *MockERC20Converter) ToTransferModel(entity *dai.TransferEntity) *et1.TransferModel { mlkc.TransfersToConvert = append(mlkc.TransfersToConvert, *entity) return &et1.TransferModel{} } -func (mlkc *MockERC20Converter) ToTransferEntity(watchedEvent core.WatchedEvent) (*et1.TransferEntity, error) { +func (mlkc *MockERC20Converter) ToTransferEntity(watchedEvent core.WatchedEvent) (*dai.TransferEntity, error) { mlkc.WatchedEvents = append(mlkc.WatchedEvents, &watchedEvent) - e := &et1.TransferEntity{Block: watchedEvent.BlockNumber} + e := &dai.TransferEntity{Block: watchedEvent.BlockNumber} mlkc.block++ return e, nil } -func (mlkc *MockERC20Converter) ToApprovalModel(entity *et1.ApprovalEntity) *et1.ApprovalModel { +func (mlkc *MockERC20Converter) ToApprovalModel(entity *dai.ApprovalEntity) *et1.ApprovalModel { mlkc.ApprovalsToConvert = append(mlkc.ApprovalsToConvert, *entity) return &et1.ApprovalModel{} } -func (mlkc *MockERC20Converter) ToApprovalEntity(watchedEvent core.WatchedEvent) (*et1.ApprovalEntity, error) { +func (mlkc *MockERC20Converter) ToApprovalEntity(watchedEvent core.WatchedEvent) (*dai.ApprovalEntity, error) { mlkc.WatchedEvents = append(mlkc.WatchedEvents, &watchedEvent) - e := &et1.ApprovalEntity{Block: watchedEvent.BlockNumber} + e := &dai.ApprovalEntity{Block: watchedEvent.BlockNumber} mlkc.block++ return e, nil } -func (mlkc *MockERC20Converter) ToBurnEntity(watchedEvent core.WatchedEvent) (*et2.BurnEntity, error) { +func (mlkc *MockERC20Converter) ToBurnEntity(watchedEvent core.WatchedEvent) (*tusd.BurnEntity, error) { mlkc.WatchedEvents = append(mlkc.WatchedEvents, &watchedEvent) - e := &et2.BurnEntity{Block: watchedEvent.BlockNumber} + e := &tusd.BurnEntity{Block: watchedEvent.BlockNumber} mlkc.block++ return e, nil } -func (mlkc *MockERC20Converter) ToBurnModel(entity *et2.BurnEntity) *et2.BurnModel { +func (mlkc *MockERC20Converter) ToBurnModel(entity *tusd.BurnEntity) *et2.BurnModel { mlkc.BurnsToConvert = append(mlkc.BurnsToConvert, *entity) return &et2.BurnModel{} } -func (mlkc *MockERC20Converter) ToMintEntity(watchedEvent core.WatchedEvent) (*et2.MintEntity, error) { +func (mlkc *MockERC20Converter) ToMintEntity(watchedEvent core.WatchedEvent) (*tusd.MintEntity, error) { mlkc.WatchedEvents = append(mlkc.WatchedEvents, &watchedEvent) - e := &et2.MintEntity{Block: watchedEvent.BlockNumber} + e := &tusd.MintEntity{Block: watchedEvent.BlockNumber} mlkc.block++ return e, nil } -func (mlkc *MockERC20Converter) ToMintModel(entity *et2.MintEntity) *et2.MintModel { +func (mlkc *MockERC20Converter) ToMintModel(entity *tusd.MintEntity) *et2.MintModel { mlkc.MintsToConvert = append(mlkc.MintsToConvert, *entity) return &et2.MintModel{} }