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:
parent
7870451b5c
commit
954fcf2378
@ -5,8 +5,9 @@ CREATE TABLE maker.cat_file_chop_lump (
|
||||
what TEXT,
|
||||
data NUMERIC,
|
||||
tx_idx INTEGER NOT NUll,
|
||||
log_idx INTEGER NOT NULL,
|
||||
raw_log JSONB,
|
||||
UNIQUE (header_id, tx_idx)
|
||||
UNIQUE (header_id, tx_idx, log_idx)
|
||||
);
|
||||
|
||||
CREATE TABLE maker.cat_file_flip (
|
||||
@ -16,8 +17,9 @@ CREATE TABLE maker.cat_file_flip (
|
||||
what TEXT,
|
||||
flip TEXT,
|
||||
tx_idx INTEGER NOT NUll,
|
||||
log_idx INTEGER NOT NULL,
|
||||
raw_log JSONB,
|
||||
UNIQUE (header_id, tx_idx)
|
||||
UNIQUE (header_id, tx_idx, log_idx)
|
||||
);
|
||||
|
||||
CREATE TABLE maker.cat_file_pit_vow (
|
||||
@ -26,6 +28,7 @@ CREATE TABLE maker.cat_file_pit_vow (
|
||||
what TEXT,
|
||||
data TEXT,
|
||||
tx_idx INTEGER NOT NUll,
|
||||
log_idx INTEGER NOT NULL,
|
||||
raw_log JSONB,
|
||||
UNIQUE (header_id, tx_idx)
|
||||
UNIQUE (header_id, tx_idx, log_idx)
|
||||
);
|
@ -108,6 +108,7 @@ CREATE TABLE maker.cat_file_chop_lump (
|
||||
what text,
|
||||
data numeric,
|
||||
tx_idx integer NOT NULL,
|
||||
log_idx integer NOT NULL,
|
||||
raw_log jsonb
|
||||
);
|
||||
|
||||
@ -143,6 +144,7 @@ CREATE TABLE maker.cat_file_flip (
|
||||
what text,
|
||||
flip text,
|
||||
tx_idx integer NOT NULL,
|
||||
log_idx integer NOT NULL,
|
||||
raw_log jsonb
|
||||
);
|
||||
|
||||
@ -177,6 +179,7 @@ CREATE TABLE maker.cat_file_pit_vow (
|
||||
what text,
|
||||
data text,
|
||||
tx_idx integer NOT NULL,
|
||||
log_idx integer NOT NULL,
|
||||
raw_log jsonb
|
||||
);
|
||||
|
||||
@ -1730,11 +1733,11 @@ ALTER TABLE ONLY maker.bite
|
||||
|
||||
|
||||
--
|
||||
-- Name: cat_file_chop_lump cat_file_chop_lump_header_id_tx_idx_key; Type: CONSTRAINT; Schema: maker; Owner: -
|
||||
-- Name: cat_file_chop_lump cat_file_chop_lump_header_id_tx_idx_log_idx_key; Type: CONSTRAINT; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY maker.cat_file_chop_lump
|
||||
ADD CONSTRAINT cat_file_chop_lump_header_id_tx_idx_key UNIQUE (header_id, tx_idx);
|
||||
ADD CONSTRAINT cat_file_chop_lump_header_id_tx_idx_log_idx_key UNIQUE (header_id, tx_idx, log_idx);
|
||||
|
||||
|
||||
--
|
||||
@ -1746,11 +1749,11 @@ ALTER TABLE ONLY maker.cat_file_chop_lump
|
||||
|
||||
|
||||
--
|
||||
-- Name: cat_file_flip cat_file_flip_header_id_tx_idx_key; Type: CONSTRAINT; Schema: maker; Owner: -
|
||||
-- Name: cat_file_flip cat_file_flip_header_id_tx_idx_log_idx_key; Type: CONSTRAINT; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY maker.cat_file_flip
|
||||
ADD CONSTRAINT cat_file_flip_header_id_tx_idx_key UNIQUE (header_id, tx_idx);
|
||||
ADD CONSTRAINT cat_file_flip_header_id_tx_idx_log_idx_key UNIQUE (header_id, tx_idx, log_idx);
|
||||
|
||||
|
||||
--
|
||||
@ -1762,11 +1765,11 @@ ALTER TABLE ONLY maker.cat_file_flip
|
||||
|
||||
|
||||
--
|
||||
-- Name: cat_file_pit_vow cat_file_pit_vow_header_id_tx_idx_key; Type: CONSTRAINT; Schema: maker; Owner: -
|
||||
-- Name: cat_file_pit_vow cat_file_pit_vow_header_id_tx_idx_log_idx_key; Type: CONSTRAINT; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY maker.cat_file_pit_vow
|
||||
ADD CONSTRAINT cat_file_pit_vow_header_id_tx_idx_key UNIQUE (header_id, tx_idx);
|
||||
ADD CONSTRAINT cat_file_pit_vow_header_id_tx_idx_log_idx_key UNIQUE (header_id, tx_idx, log_idx);
|
||||
|
||||
|
||||
--
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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))
|
||||
})
|
||||
|
||||
|
@ -47,6 +47,7 @@ func (CatFilePitVowConverter) ToModels(ethLogs []types.Log) ([]CatFilePitVowMode
|
||||
What: what,
|
||||
Data: data,
|
||||
TransactionIndex: ethLog.TxIndex,
|
||||
LogIndex: ethLog.Index,
|
||||
Raw: raw,
|
||||
}
|
||||
results = append(results, result)
|
||||
|
@ -18,5 +18,6 @@ type CatFilePitVowModel 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 CatFilePitVowRepository) Create(headerID int64, models []CatFil
|
||||
}
|
||||
for _, model := range models {
|
||||
_, err = repository.db.Exec(
|
||||
`INSERT into maker.cat_file_pit_vow (header_id, what, data, tx_idx, raw_log)
|
||||
VALUES($1, $2, $3, $4, $5)`,
|
||||
headerID, model.What, model.Data, model.TransactionIndex, model.Raw,
|
||||
`INSERT into maker.cat_file_pit_vow (header_id, what, data, tx_idx, log_idx, raw_log)
|
||||
VALUES($1, $2, $3, $4, $5, $6)`,
|
||||
headerID, model.What, model.Data, model.TransactionIndex, model.LogIndex, model.Raw,
|
||||
)
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
|
@ -58,11 +58,12 @@ var _ = Describe("Cat file pit vow repository", func() {
|
||||
|
||||
It("adds a cat file pit vow event", func() {
|
||||
var dbResult pit_vow.CatFilePitVowModel
|
||||
err = db.Get(&dbResult, `SELECT what, data, tx_idx, raw_log FROM maker.cat_file_pit_vow WHERE header_id = $1`, headerID)
|
||||
err = db.Get(&dbResult, `SELECT what, data, tx_idx, log_idx, raw_log FROM maker.cat_file_pit_vow WHERE header_id = $1`, headerID)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(dbResult.What).To(Equal(test_data.CatFilePitVowModel.What))
|
||||
Expect(dbResult.Data).To(Equal(test_data.CatFilePitVowModel.Data))
|
||||
Expect(dbResult.TransactionIndex).To(Equal(test_data.CatFilePitVowModel.TransactionIndex))
|
||||
Expect(dbResult.LogIndex).To(Equal(test_data.CatFilePitVowModel.LogIndex))
|
||||
Expect(dbResult.Raw).To(MatchJSON(test_data.CatFilePitVowModel.Raw))
|
||||
})
|
||||
|
||||
|
152
pkg/transformers/integration_tests/cat_file.go
Normal file
152
pkg/transformers/integration_tests/cat_file.go
Normal file
@ -0,0 +1,152 @@
|
||||
// Copyright 2018 Vulcanize
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package integration_tests
|
||||
|
||||
import (
|
||||
"sort"
|
||||
|
||||
"github.com/ethereum/go-ethereum/ethclient"
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
"github.com/vulcanize/vulcanizedb/pkg/core"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/geth/client"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/cat_file"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/cat_file/chop_lump"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/cat_file/flip"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/cat_file/pit_vow"
|
||||
"github.com/vulcanize/vulcanizedb/test_config"
|
||||
)
|
||||
|
||||
var _ = Describe("Cat File transformer", func() {
|
||||
var (
|
||||
db *postgres.DB
|
||||
blockchain core.BlockChain
|
||||
rpcClient client.RpcClient
|
||||
err error
|
||||
ethClient *ethclient.Client
|
||||
)
|
||||
|
||||
BeforeEach(func() {
|
||||
rpcClient, ethClient, err = getClients(ipc)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
blockchain, err = getBlockChain(rpcClient, ethClient)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
db = test_config.NewTestDB(blockchain.Node())
|
||||
test_config.CleanTestDB(db)
|
||||
})
|
||||
|
||||
// Cat contract Kovan address: 0x2f34f22a00ee4b7a8f8bbc4eaee1658774c624e0
|
||||
It("persists a chop lump event", func() {
|
||||
// transaction: 0x98574bfba4d05c3875be10d2376e678d005dbebe9a4520363407508fd21f4014
|
||||
chopLumpBlockNumber := int64(8762253)
|
||||
err = persistHeader(rpcClient, db, chopLumpBlockNumber)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
config := cat_file.CatFileConfig
|
||||
config.StartingBlockNumber = chopLumpBlockNumber
|
||||
config.EndingBlockNumber = chopLumpBlockNumber
|
||||
|
||||
initializer := chop_lump.CatFileChopLumpTransformerInitializer{Config: config}
|
||||
transformer := initializer.NewCatFileChopLumpTransformer(db, blockchain)
|
||||
err := transformer.Execute()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
var dbResult []chop_lump.CatFileChopLumpModel
|
||||
err = db.Select(&dbResult, `SELECT ilk, what, data, log_idx FROM maker.cat_file_chop_lump`)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
Expect(len(dbResult)).To(Equal(2))
|
||||
sort.Sort(byLogIndexChopLump(dbResult))
|
||||
|
||||
Expect(dbResult[0].Ilk).To(Equal("REP"))
|
||||
Expect(dbResult[0].What).To(Equal("lump"))
|
||||
Expect(dbResult[0].Data).To(Equal("10000000000000000000000"))
|
||||
Expect(dbResult[0].LogIndex).To(Equal(uint(3)))
|
||||
|
||||
Expect(dbResult[1].Ilk).To(Equal("REP"))
|
||||
Expect(dbResult[1].What).To(Equal("chop"))
|
||||
Expect(dbResult[1].Data).To(Equal("1000000000000000000000000000"))
|
||||
Expect(dbResult[1].LogIndex).To(Equal(uint(4)))
|
||||
})
|
||||
|
||||
It("persists a flip event", func() {
|
||||
// transaction: 0x44bc18fdb1a5a263db114e7879653304db3e19ceb4e4496f21bc0a76c5faccbe
|
||||
flipBlockNumber := int64(8751794)
|
||||
err = persistHeader(rpcClient, db, flipBlockNumber)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
config := cat_file.CatFileConfig
|
||||
config.StartingBlockNumber = flipBlockNumber
|
||||
config.EndingBlockNumber = flipBlockNumber
|
||||
|
||||
initializer := flip.CatFileFlipTransformerInitializer{Config: config}
|
||||
transformer := initializer.NewCatFileFlipTransformer(db, blockchain)
|
||||
err := transformer.Execute()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
var dbResult []flip.CatFileFlipModel
|
||||
err = db.Select(&dbResult, `SELECT ilk, what, flip FROM maker.cat_file_flip`)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
Expect(len(dbResult)).To(Equal(1))
|
||||
Expect(dbResult[0].Ilk).To(Equal("ETH"))
|
||||
Expect(dbResult[0].What).To(Equal("flip"))
|
||||
Expect(dbResult[0].Flip).To(Equal("0x32D496Ad866D110060866B7125981C73642cc509"))
|
||||
})
|
||||
|
||||
It("persists a pit vow event", func() {
|
||||
// transaction: 0x44bc18fdb1a5a263db114e7879653304db3e19ceb4e4496f21bc0a76c5faccbe
|
||||
pitVowBlockNumber := int64(8751794)
|
||||
err = persistHeader(rpcClient, db, pitVowBlockNumber)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
config := cat_file.CatFileConfig
|
||||
config.StartingBlockNumber = pitVowBlockNumber
|
||||
config.EndingBlockNumber = pitVowBlockNumber
|
||||
|
||||
initializer := pit_vow.CatFilePitVowTransformerInitializer{Config: config}
|
||||
transformer := initializer.NewCatFilePitVowTransformer(db, blockchain)
|
||||
err := transformer.Execute()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
var dbResult []pit_vow.CatFilePitVowModel
|
||||
err = db.Select(&dbResult, `SELECT what, data, log_idx FROM maker.cat_file_pit_vow`)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
Expect(len(dbResult)).To(Equal(2))
|
||||
sort.Sort(byLogIndexPitVow(dbResult))
|
||||
Expect(dbResult[0].What).To(Equal("vow"))
|
||||
Expect(dbResult[0].Data).To(Equal("0x3728e9777B2a0a611ee0F89e00E01044ce4736d1"))
|
||||
Expect(dbResult[0].LogIndex).To(Equal(uint(1)))
|
||||
|
||||
Expect(dbResult[1].What).To(Equal("pit"))
|
||||
Expect(dbResult[1].Data).To(Equal("0xE7CF3198787C9A4daAc73371A38f29aAeECED87e"))
|
||||
Expect(dbResult[1].LogIndex).To(Equal(uint(2)))
|
||||
})
|
||||
})
|
||||
|
||||
type byLogIndexChopLump []chop_lump.CatFileChopLumpModel
|
||||
|
||||
func (c byLogIndexChopLump) Len() int { return len(c) }
|
||||
func (c byLogIndexChopLump) Less(i, j int) bool { return c[i].LogIndex < c[j].LogIndex }
|
||||
func (c byLogIndexChopLump) Swap(i, j int) { c[i], c[j] = c[j], c[i] }
|
||||
|
||||
type byLogIndexPitVow []pit_vow.CatFilePitVowModel
|
||||
|
||||
func (c byLogIndexPitVow) Len() int { return len(c) }
|
||||
func (c byLogIndexPitVow) Less(i, j int) bool { return c[i].LogIndex < c[j].LogIndex }
|
||||
func (c byLogIndexPitVow) Swap(i, j int) { c[i], c[j] = c[j], c[i] }
|
79
pkg/transformers/integration_tests/deal.go
Normal file
79
pkg/transformers/integration_tests/deal.go
Normal file
@ -0,0 +1,79 @@
|
||||
// Copyright 2018 Vulcanize
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package integration_tests
|
||||
|
||||
import (
|
||||
"github.com/ethereum/go-ethereum/ethclient"
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
"github.com/vulcanize/vulcanizedb/pkg/core"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/geth/client"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/deal"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
|
||||
"github.com/vulcanize/vulcanizedb/test_config"
|
||||
)
|
||||
|
||||
var _ = Describe("Deal transformer", func() {
|
||||
var (
|
||||
db *postgres.DB
|
||||
blockchain core.BlockChain
|
||||
rpcClient client.RpcClient
|
||||
err error
|
||||
ethClient *ethclient.Client
|
||||
)
|
||||
|
||||
BeforeEach(func() {
|
||||
rpcClient, ethClient, err = getClients(ipc)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
blockchain, err = getBlockChain(rpcClient, ethClient)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
db = test_config.NewTestDB(blockchain.Node())
|
||||
test_config.CleanTestDB(db)
|
||||
})
|
||||
|
||||
It("persists a flip deal log event", func() {
|
||||
// transaction: 0x05b5eabac2ace136f0f7e0efc61d7d42abe8e8938cc0f04fbf1a6ba545d59e58
|
||||
flipBlockNumber := int64(8958007)
|
||||
err = persistHeader(rpcClient, db, flipBlockNumber)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
config := deal.Config
|
||||
config.StartingBlockNumber = flipBlockNumber
|
||||
config.EndingBlockNumber = flipBlockNumber
|
||||
|
||||
initializer := deal.DealTransformerInitializer{Config: config}
|
||||
transformer := initializer.NewDealTransformer(db, blockchain)
|
||||
err := transformer.Execute()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
var dbResult []deal.DealModel
|
||||
err = db.Select(&dbResult, `SELECT bid_id, contract_address FROM maker.deal`)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
Expect(len(dbResult)).To(Equal(1))
|
||||
Expect(dbResult[0].BidId).To(Equal("6"))
|
||||
Expect(dbResult[0].ContractAddress).To(Equal(shared.FlipperContractAddress))
|
||||
})
|
||||
|
||||
It("persists a flop deal log event", func() {
|
||||
//TODO: There are currently no Flop.deal events on Kovan
|
||||
})
|
||||
|
||||
It("persists a flap deal log event", func() {
|
||||
//TODO: The flap.deal transformer has not yet been implemented
|
||||
})
|
||||
})
|
@ -39,7 +39,7 @@ var EthCatFileChopLumpLog = types.Log{
|
||||
TxHash: common.HexToHash("0xe32dfe6afd7ea28475569756fc30f0eea6ad4cfd32f67436ff1d1c805e4382df"),
|
||||
TxIndex: 13,
|
||||
BlockHash: common.HexToHash("0x2764998a4e048d4c4ba45ea40fd5efaa8e2d4f1dd2b15425a6c6a3dea7f1064a"),
|
||||
Index: 0,
|
||||
Index: 1,
|
||||
Removed: false,
|
||||
}
|
||||
|
||||
@ -49,6 +49,7 @@ var CatFileChopLumpModel = chop_lump.CatFileChopLumpModel{
|
||||
What: "chop",
|
||||
Data: big.NewInt(123456789).String(),
|
||||
TransactionIndex: EthCatFileChopLumpLog.TxIndex,
|
||||
LogIndex: EthCatFileChopLumpLog.Index,
|
||||
Raw: rawCatFileChopLumpLog,
|
||||
}
|
||||
|
||||
@ -65,7 +66,7 @@ var EthCatFileFlipLog = types.Log{
|
||||
TxHash: common.HexToHash("0xc71ef3e9999595913d31e89446cab35319bd4289520e55611a1b42fc2a8463b6"),
|
||||
TxIndex: 12,
|
||||
BlockHash: common.HexToHash("0xe5fcc1b65dd901e003e3768c1d4ce58d72f5f3a31e6a5d27d9cbdc7dca4bb405"),
|
||||
Index: 0,
|
||||
Index: 1,
|
||||
Removed: false,
|
||||
}
|
||||
|
||||
@ -75,6 +76,7 @@ var CatFileFlipModel = flip.CatFileFlipModel{
|
||||
What: "flip",
|
||||
Flip: "0x07Fa9eF6609cA7921112231F8f195138ebbA2977",
|
||||
TransactionIndex: EthCatFileFlipLog.TxIndex,
|
||||
LogIndex: EthCatFileFlipLog.Index,
|
||||
Raw: rawCatFileFlipLog,
|
||||
}
|
||||
|
||||
@ -91,7 +93,7 @@ var EthCatFilePitVowLog = types.Log{
|
||||
TxHash: common.HexToHash("0x6515c7dfe53f0ad83ce1173fa99032c24a07cfd8b5d5a1c1f80486c99dd52800"),
|
||||
TxIndex: 11,
|
||||
BlockHash: common.HexToHash("0xae75936bc6b6a3383e8c991686747ef2221984b0ec8a5d4a6350989ec0ddbd67"),
|
||||
Index: 0,
|
||||
Index: 2,
|
||||
Removed: false,
|
||||
}
|
||||
|
||||
@ -100,5 +102,6 @@ var CatFilePitVowModel = pit_vow.CatFilePitVowModel{
|
||||
What: "pit",
|
||||
Data: "0x8E84a1e068d77059Cbe263C43AD0cDc130863313",
|
||||
TransactionIndex: EthCatFilePitVowLog.TxIndex,
|
||||
LogIndex: EthCatFilePitVowLog.Index,
|
||||
Raw: rawCatFilePitVowLog,
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user