Backfill Frob log events

This commit is contained in:
Rob Mulholand
2018-08-14 10:47:43 -05:00
parent 55229cd2eb
commit ac63e43543
40 changed files with 1251 additions and 149 deletions
+8 -8
View File
@@ -24,13 +24,13 @@ import (
"time"
)
var TemporaryFlipAddress = "0x08cb6176addcca2e1d1ffe21bee464b72ee4cd8d"
var TemporaryFlipKickTransaction = "0x6b155a55fd77b751195deeebf7abfd8691ca01ee588817a920f19d5b27f65191"
var Topic0Hex = "0xc2d733c352a325d6ecf23d1cf0a189dbcc236b0636388b8c5e6953c061d7f0b3"
var TemporaryFlipKickData = "0x000000000000000000000000000000000000000000000000000000000000000100000000000000000000000008cb6176addcca2e1d1ffe21bee464b72ee4cd8d00000000000000000000000038219779a699d67d7e7740b8c8f43d3e2dae218266616b6520696c6b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000064000000000000000000000000000000000000000000000000000000000000000000000000000000000000000064d922894153be9eef7b7218dc565d1d0ce2a09200000000000000000000000007fa9ef6609ca7921112231f8f195138ebba2977000000000000000000000000000000000000000000000000000000005b69b8e7000000000000000000000000000000000000000000000000000000005b607e670000000000000000000000007340e006f4135ba6970d43bf43d88dcad4e7a8ca0000000000000000000000000000000000000000000000000000000000000032"
var TempBlockNumber = int64(10)
var TemporaryFlipKickBlockNumber = int64(TempBlockNumber)
var TemporaryFlipKickBlockHash = "0x32f8b12023b3a1b4c73f9a46da976931b0355714ada8b8044ebcb2cd295751a9"
var (
TemporaryFlipBlockNumber = int64(10)
TemporaryFlipAddress = "0x08cb6176addcca2e1d1ffe21bee464b72ee4cd8d"
TemporaryFlipKickBlockHash = "0x32f8b12023b3a1b4c73f9a46da976931b0355714ada8b8044ebcb2cd295751a9"
TemporaryFlipKickData = "0x000000000000000000000000000000000000000000000000000000000000000100000000000000000000000008cb6176addcca2e1d1ffe21bee464b72ee4cd8d00000000000000000000000038219779a699d67d7e7740b8c8f43d3e2dae218266616b6520696c6b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000064000000000000000000000000000000000000000000000000000000000000000000000000000000000000000064d922894153be9eef7b7218dc565d1d0ce2a09200000000000000000000000007fa9ef6609ca7921112231f8f195138ebba2977000000000000000000000000000000000000000000000000000000005b69b8e7000000000000000000000000000000000000000000000000000000005b607e670000000000000000000000007340e006f4135ba6970d43bf43d88dcad4e7a8ca0000000000000000000000000000000000000000000000000000000000000032"
TemporaryFlipKickTransaction = "0x6b155a55fd77b751195deeebf7abfd8691ca01ee588817a920f19d5b27f65191"
)
var idString = "1"
var id, _ = new(big.Int).SetString(idString, 10)
@@ -53,7 +53,7 @@ var EthFlipKickLog = types.Log{
Address: common.HexToAddress(TemporaryFlipAddress),
Topics: []common.Hash{common.HexToHash(flip_kick.FlipKickSignature)},
Data: hexutil.MustDecode(TemporaryFlipKickData),
BlockNumber: uint64(TempBlockNumber),
BlockNumber: uint64(TemporaryFlipBlockNumber),
TxHash: common.HexToHash(TemporaryFlipKickTransaction),
TxIndex: 0,
BlockHash: common.HexToHash(TemporaryFlipKickBlockHash),
+70
View File
@@ -0,0 +1,70 @@
// 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 test_data
import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/core/types"
"github.com/vulcanize/vulcanizedb/pkg/transformers/frob"
"math/big"
)
var (
TemporaryFrobAddress = "0xff3f2400f1600f3f493a9a92704a29b96795af1a"
TemporaryFrobBlockHash = common.HexToHash("0xe1c4264e245ac31d4aed678df007199cffcfcaea7a75aeecc45122957abf4298")
TemporaryFrobBlockNumber = int64(12)
TemporaryFrobData = "0x66616b6520696c6b00000000000000000000000000000000000000000000000000000000000000000000000064d922894153be9eef7b7218dc565d1d0ce2a092fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005b6b39e4"
TemporaryFrobTransaction = "0xbcff98316acb5732891d1a7e02f23ec12fbf8c231ca4b5530fa7a21c1e9b6aa9"
)
var (
// need to set bytes as 0 or else the big Int 0 evaluates differently from the one unpacked by the abi
art = big.NewInt(0).SetBytes([]byte{0})
frobEra = big.NewInt(1533753828)
frobLad = common.HexToAddress("0x64d922894153BE9EEf7b7218dc565d1D0Ce2a092")
gem, _ = big.NewInt(0).SetString("115792089237316195423570985008687907853269984665640564039457584007913129639926", 10)
ink = big.NewInt(10)
)
var EthFrobLog = types.Log{
Address: common.HexToAddress(TemporaryFrobAddress),
Topics: []common.Hash{common.HexToHash(frob.FrobEventSignature)},
Data: hexutil.MustDecode(TemporaryFrobData),
BlockNumber: uint64(TemporaryFrobBlockNumber),
TxHash: common.HexToHash(TemporaryFrobTransaction),
TxIndex: 123,
BlockHash: TemporaryFrobBlockHash,
Index: 1,
Removed: false,
}
var FrobEntity = frob.FrobEntity{
Ilk: ilk,
Lad: frobLad,
Gem: gem,
Ink: ink,
Art: art,
Era: frobEra,
}
var FrobModel = frob.FrobModel{
Ilk: ilk[:],
Lad: frobLad[:],
Gem: gem.String(),
Ink: ink.String(),
Art: art.String(),
Era: frobEra.String(),
}
@@ -0,0 +1,44 @@
// 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 flip_kick
import (
"github.com/ethereum/go-ethereum/core/types"
"github.com/vulcanize/vulcanizedb/pkg/transformers/flip_kick"
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
)
type MockFlipKickConverter struct {
ConverterContract string
ConverterAbi string
LogsToConvert []types.Log
EntitiesToConvert []flip_kick.FlipKickEntity
ConverterError error
}
func (mfkc *MockFlipKickConverter) ToEntity(contractAddress string, contractAbi string, ethLog types.Log) (*flip_kick.FlipKickEntity, error) {
mfkc.ConverterContract = contractAddress
mfkc.ConverterAbi = contractAbi
mfkc.LogsToConvert = append(mfkc.LogsToConvert, ethLog)
return &test_data.FlipKickEntity, mfkc.ConverterError
}
func (mfkc *MockFlipKickConverter) ToModel(flipKickEntity flip_kick.FlipKickEntity) (flip_kick.FlipKickModel, error) {
mfkc.EntitiesToConvert = append(mfkc.EntitiesToConvert, flipKickEntity)
return test_data.FlipKickModel, nil
}
func (mfkc *MockFlipKickConverter) SetConverterError(err error) {
mfkc.ConverterError = err
}
@@ -12,63 +12,13 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package test_data
package flip_kick
import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/vulcanize/vulcanizedb/pkg/core"
"github.com/vulcanize/vulcanizedb/pkg/transformers/flip_kick"
)
type MockLogFetcher struct {
FetchedContractAddress string
FetchedTopics [][]common.Hash
FetchedBlocks []int64
FetcherError error
FetchedLogs []types.Log
}
func (mlf *MockLogFetcher) FetchLogs(contractAddress string, topics [][]common.Hash, blockNumber int64) ([]types.Log, error) {
mlf.FetchedContractAddress = contractAddress
mlf.FetchedTopics = topics
mlf.FetchedBlocks = append(mlf.FetchedBlocks, blockNumber)
return mlf.FetchedLogs, mlf.FetcherError
}
func (mlf *MockLogFetcher) SetFetcherError(err error) {
mlf.FetcherError = err
}
func (mlf *MockLogFetcher) SetFetchedLogs(logs []types.Log) {
mlf.FetchedLogs = logs
}
type MockFlipKickConverter struct {
ConverterContract string
ConverterAbi string
LogsToConvert []types.Log
EntitiesToConvert []flip_kick.FlipKickEntity
ConverterError error
}
func (mfkc *MockFlipKickConverter) ToEntity(contractAddress string, contractAbi string, ethLog types.Log) (*flip_kick.FlipKickEntity, error) {
mfkc.ConverterContract = contractAddress
mfkc.ConverterAbi = contractAbi
mfkc.LogsToConvert = append(mfkc.LogsToConvert, ethLog)
return &FlipKickEntity, mfkc.ConverterError
}
func (mfkc *MockFlipKickConverter) ToModel(flipKick flip_kick.FlipKickEntity) (flip_kick.FlipKickModel, error) {
mfkc.EntitiesToConvert = append(mfkc.EntitiesToConvert, flipKick)
return FlipKickModel, nil
}
func (mfkc *MockFlipKickConverter) SetConverterError(err error) {
mfkc.ConverterError = err
}
type MockFlipKickRepository struct {
HeaderIds []int64
HeadersToReturn []core.Header
@@ -0,0 +1,45 @@
// 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 frob
import (
"github.com/ethereum/go-ethereum/core/types"
"github.com/vulcanize/vulcanizedb/pkg/transformers/frob"
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
)
type MockFrobConverter struct {
PassedContractAddress string
PassedContractABI string
PassedLog types.Log
PassedEntity frob.FrobEntity
converterError error
}
func (converter *MockFrobConverter) SetConverterError(err error) {
converter.converterError = err
}
func (converter *MockFrobConverter) ToEntity(contractAddress string, contractAbi string, ethLog types.Log) (frob.FrobEntity, error) {
converter.PassedContractAddress = contractAddress
converter.PassedContractABI = contractAbi
converter.PassedLog = ethLog
return test_data.FrobEntity, converter.converterError
}
func (converter *MockFrobConverter) ToModel(frobEntity frob.FrobEntity) frob.FrobModel {
converter.PassedEntity = frobEntity
return test_data.FrobModel
}
@@ -0,0 +1,56 @@
// 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 frob
import (
"github.com/vulcanize/vulcanizedb/pkg/core"
"github.com/vulcanize/vulcanizedb/pkg/transformers/frob"
)
type MockFrobRepository struct {
createError error
PassedEndingBlockNumber int64
PassedFrobModel frob.FrobModel
PassedHeaderID int64
PassedStartingBlockNumber int64
PassedTransactionIndex uint
missingHeaders []core.Header
missingHeadersErr error
}
func (repository *MockFrobRepository) SetCreateError(err error) {
repository.createError = err
}
func (repository *MockFrobRepository) SetMissingHeadersErr(err error) {
repository.missingHeadersErr = err
}
func (repository *MockFrobRepository) SetMissingHeaders(headers []core.Header) {
repository.missingHeaders = headers
}
func (repository *MockFrobRepository) Create(headerID int64, transactionIndex uint, model frob.FrobModel) error {
repository.PassedHeaderID = headerID
repository.PassedTransactionIndex = transactionIndex
repository.PassedFrobModel = model
return repository.createError
}
func (repository *MockFrobRepository) MissingHeaders(startingBlockNumber, endingBlockNumber int64) ([]core.Header, error) {
repository.PassedStartingBlockNumber = startingBlockNumber
repository.PassedEndingBlockNumber = endingBlockNumber
return repository.missingHeaders, repository.missingHeadersErr
}
@@ -0,0 +1,44 @@
// 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 mocks
import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
)
type MockLogFetcher struct {
FetchedContractAddress string
FetchedTopics [][]common.Hash
FetchedBlocks []int64
fetcherError error
FetchedLogs []types.Log
}
func (mlf *MockLogFetcher) FetchLogs(contractAddress string, topics [][]common.Hash, blockNumber int64) ([]types.Log, error) {
mlf.FetchedContractAddress = contractAddress
mlf.FetchedTopics = topics
mlf.FetchedBlocks = append(mlf.FetchedBlocks, blockNumber)
return mlf.FetchedLogs, mlf.fetcherError
}
func (mlf *MockLogFetcher) SetFetcherError(err error) {
mlf.fetcherError = err
}
func (mlf *MockLogFetcher) SetFetchedLogs(logs []types.Log) {
mlf.FetchedLogs = logs
}