Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // block data BlockNumber = big.NewInt(1) MockHeader = types.Header{ Time: 0, Number: new(big.Int).Set(BlockNumber), Root: common.HexToHash("0x0"), TxHash: common.HexToHash("0x0"), ReceiptHash: common.HexToHash("0x0"), Difficulty: big.NewInt(5000000), Extra: []byte{}, } MockTransactions, MockReceipts, SenderAddr = createTransactionsAndReceipts() ReceiptsRlp, _ = rlp.EncodeToBytes(MockReceipts) MockBlock = types.NewBlock(&MockHeader, MockTransactions, nil, MockReceipts) MockBlockRlp, _ = rlp.EncodeToBytes(MockBlock) MockHeaderRlp, _ = rlp.EncodeToBytes(MockBlock.Header()) Address = common.HexToAddress("0xaE9BEa628c4Ce503DcFD7E305CaB4e29E7476592") AnotherAddress = common.HexToAddress("0xaE9BEa628c4Ce503DcFD7E305CaB4e29E7476593") ContractAddress = crypto.CreateAddress(SenderAddr, MockTransactions[2].Nonce()) ContractHash = crypto.Keccak256Hash(ContractAddress.Bytes()).String() MockContractByteCode = []byte{0, 1, 2, 3, 4, 5} MockLog1 = &types.Log{ Address: Address, Topics: []common.Hash{mockTopic11, mockTopic12}, Data: []byte{}, } MockLog2 = &types.Log{ Address: AnotherAddress, Topics: []common.Hash{mockTopic21, mockTopic22}, Data: []byte{}, } HeaderCID, _ = ipld.RawdataToCid(ipld.MEthHeader, MockHeaderRlp, multihash.KECCAK_256) HeaderMhKey = shared.MultihashKeyFromCID(HeaderCID) Trx1CID, _ = ipld.RawdataToCid(ipld.MEthTx, MockTransactions.GetRlp(0), multihash.KECCAK_256) Trx1MhKey = shared.MultihashKeyFromCID(Trx1CID) Trx2CID, _ = ipld.RawdataToCid(ipld.MEthTx, MockTransactions.GetRlp(1), multihash.KECCAK_256) Trx2MhKey = shared.MultihashKeyFromCID(Trx2CID) Trx3CID, _ = ipld.RawdataToCid(ipld.MEthTx, MockTransactions.GetRlp(2), multihash.KECCAK_256) Trx3MhKey = shared.MultihashKeyFromCID(Trx3CID) Rct1CID, _ = ipld.RawdataToCid(ipld.MEthTxReceipt, MockReceipts.GetRlp(0), multihash.KECCAK_256) Rct1MhKey = shared.MultihashKeyFromCID(Rct1CID) Rct2CID, _ = ipld.RawdataToCid(ipld.MEthTxReceipt, MockReceipts.GetRlp(1), multihash.KECCAK_256) Rct2MhKey = shared.MultihashKeyFromCID(Rct2CID) Rct3CID, _ = ipld.RawdataToCid(ipld.MEthTxReceipt, MockReceipts.GetRlp(2), multihash.KECCAK_256) Rct3MhKey = shared.MultihashKeyFromCID(Rct3CID) State1CID, _ = ipld.RawdataToCid(ipld.MEthStateTrie, ContractLeafNode, multihash.KECCAK_256) State1MhKey = shared.MultihashKeyFromCID(State1CID) State2CID, _ = ipld.RawdataToCid(ipld.MEthStateTrie, AccountLeafNode, multihash.KECCAK_256) State2MhKey = shared.MultihashKeyFromCID(State2CID) StorageCID, _ = ipld.RawdataToCid(ipld.MEthStorageTrie, StorageLeafNode, multihash.KECCAK_256) StorageMhKey = shared.MultihashKeyFromCID(StorageCID) MockTrxMeta = []eth.TxModel{ { CID: "", MhKey: "", Src: SenderAddr.Hex(), Dst: Address.String(), Index: 0, TxHash: MockTransactions[0].Hash().String(), Data: []byte{}, Deployment: false, }, { CID: "", MhKey: "", Src: SenderAddr.Hex(), Dst: AnotherAddress.String(), Index: 1, TxHash: MockTransactions[1].Hash().String(), Data: []byte{}, Deployment: false, }, { CID: "", MhKey: "", Src: SenderAddr.Hex(), Dst: "", Index: 2, TxHash: MockTransactions[2].Hash().String(), Data: MockContractByteCode, Deployment: true, }, } MockTrxMetaPostPublsh = []eth.TxModel{ { CID: Trx1CID.String(), MhKey: Trx1MhKey, Src: SenderAddr.Hex(), Dst: Address.String(), Index: 0, TxHash: MockTransactions[0].Hash().String(), Data: []byte{}, Deployment: false, }, { CID: Trx2CID.String(), MhKey: Trx2MhKey, Src: SenderAddr.Hex(), Dst: AnotherAddress.String(), Index: 1, TxHash: MockTransactions[1].Hash().String(), Data: []byte{}, Deployment: false, }, { CID: Trx3CID.String(), MhKey: Trx3MhKey, Src: SenderAddr.Hex(), Dst: "", Index: 2, TxHash: MockTransactions[2].Hash().String(), Data: MockContractByteCode, Deployment: true, }, } MockRctMeta = []eth.ReceiptModel{ { CID: "", MhKey: "", Topic0s: []string{ mockTopic11.String(), }, Topic1s: []string{ mockTopic12.String(), }, Contract: "", ContractHash: "", LogContracts: []string{ Address.String(), }, }, { CID: "", MhKey: "", Topic0s: []string{ mockTopic21.String(), }, Topic1s: []string{ mockTopic22.String(), }, Contract: "", ContractHash: "", LogContracts: []string{ AnotherAddress.String(), }, }, { CID: "", MhKey: "", Contract: ContractAddress.String(), ContractHash: ContractHash, LogContracts: []string{}, }, } MockRctMetaPostPublish = []eth.ReceiptModel{ { CID: Rct1CID.String(), MhKey: Rct1MhKey, Topic0s: []string{ mockTopic11.String(), }, Topic1s: []string{ mockTopic12.String(), }, Contract: "", ContractHash: "", LogContracts: []string{ Address.String(), }, }, { CID: Rct2CID.String(), MhKey: Rct2MhKey, Topic0s: []string{ mockTopic21.String(), }, Topic1s: []string{ mockTopic22.String(), }, Contract: "", ContractHash: "", LogContracts: []string{ AnotherAddress.String(), }, }, { CID: Rct3CID.String(), MhKey: Rct3MhKey, Contract: ContractAddress.String(), ContractHash: ContractHash, LogContracts: []string{}, }, } StorageLeafKey = crypto.Keccak256Hash(storageLocation[:]).Bytes() StorageValue = common.Hex2Bytes("01") StoragePartialPath = common.Hex2Bytes("20290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e563") StorageLeafNode, _ = rlp.EncodeToBytes([]interface{}{ StoragePartialPath, StorageValue, }) ContractRoot = "0x821e2556a290c86405f8160a2d662042a431ba456b9db265c79bb837c04be5f0" ContractCodeHash = common.HexToHash("0x753f98a8d4328b15636e46f66f2cb4bc860100aa17967cc145fcd17d1d4710ea") ContractLeafKey = testhelpers.AddressToLeafKey(ContractAddress) ContractAccount, _ = rlp.EncodeToBytes(state.Account{ Nonce: nonce1, Balance: big.NewInt(0), CodeHash: ContractCodeHash.Bytes(), Root: common.HexToHash(ContractRoot), }) ContractPartialPath = common.Hex2Bytes("3114658a74d9cc9f7acf2c5cd696c3494d7c344d78bfec3add0d91ec4e8d1c45") ContractLeafNode, _ = rlp.EncodeToBytes([]interface{}{ ContractPartialPath, ContractAccount, }) AccountRoot = "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421" AccountCodeHash = common.HexToHash("0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470") AccountAddresss = common.HexToAddress("0x0D3ab14BBaD3D99F4203bd7a11aCB94882050E7e") AccountLeafKey = testhelpers.Account2LeafKey Account, _ = rlp.EncodeToBytes(state.Account{ Nonce: nonce0, Balance: big.NewInt(1000), CodeHash: AccountCodeHash.Bytes(), Root: common.HexToHash(AccountRoot), }) AccountPartialPath = common.Hex2Bytes("3957f3e2f04a0764c3a0491b175f69926da61efbcc8f61fa1455fd2d2b4cdd45") AccountLeafNode, _ = rlp.EncodeToBytes([]interface{}{ AccountPartialPath, Account, }) StateDiffs = []statediff.StateNode{ { Path: []byte{'\x06'}, NodeType: statediff.Leaf, LeafKey: ContractLeafKey, NodeValue: ContractLeafNode, StorageNodes: []statediff.StorageNode{ { Path: []byte{}, NodeType: statediff.Leaf, LeafKey: StorageLeafKey, NodeValue: StorageLeafNode, }, }, }, { Path: []byte{'\x0c'}, NodeType: statediff.Leaf, LeafKey: AccountLeafKey, NodeValue: AccountLeafNode, StorageNodes: []statediff.StorageNode{}, }, } MockStateDiff = statediff.StateObject{ BlockNumber: new(big.Int).Set(BlockNumber), BlockHash: MockBlock.Hash(), Nodes: StateDiffs, } MockStateDiffBytes, _ = rlp.EncodeToBytes(MockStateDiff) MockStateNodes = []eth.TrieNode{ { LeafKey: common.BytesToHash(ContractLeafKey), Path: []byte{'\x06'}, Value: ContractLeafNode, Type: statediff.Leaf, }, { LeafKey: common.BytesToHash(AccountLeafKey), Path: []byte{'\x0c'}, Value: AccountLeafNode, Type: statediff.Leaf, }, } MockStateMetaPostPublish = []eth.StateNodeModel{ { CID: State1CID.String(), MhKey: State1MhKey, Path: []byte{'\x06'}, NodeType: 2, StateKey: common.BytesToHash(ContractLeafKey).Hex(), }, { CID: State2CID.String(), MhKey: State2MhKey, Path: []byte{'\x0c'}, NodeType: 2, StateKey: common.BytesToHash(AccountLeafKey).Hex(), }, } MockStorageNodes = map[string][]eth.TrieNode{ // contains filtered or unexported fields } // aggregate payloads MockStateDiffPayload = statediff.Payload{ BlockRlp: MockBlockRlp, StateObjectRlp: MockStateDiffBytes, ReceiptsRlp: ReceiptsRlp, TotalDifficulty: MockBlock.Difficulty(), } MockConvertedPayload = eth.ConvertedPayload{ TotalDifficulty: MockBlock.Difficulty(), Block: MockBlock, Receipts: MockReceipts, TxMetaData: MockTrxMeta, ReceiptMetaData: MockRctMeta, StorageNodes: MockStorageNodes, StateNodes: MockStateNodes, } MockCIDPayload = eth.CIDPayload{ HeaderCID: eth.HeaderModel{ BlockHash: MockBlock.Hash().String(), BlockNumber: MockBlock.Number().String(), CID: HeaderCID.String(), MhKey: HeaderMhKey, ParentHash: MockBlock.ParentHash().String(), TotalDifficulty: MockBlock.Difficulty().String(), Reward: "5000000000000000000", StateRoot: MockBlock.Root().String(), RctRoot: MockBlock.ReceiptHash().String(), TxRoot: MockBlock.TxHash().String(), UncleRoot: MockBlock.UncleHash().String(), Bloom: MockBlock.Bloom().Bytes(), Timestamp: MockBlock.Time(), }, UncleCIDs: []eth.UncleModel{}, TransactionCIDs: MockTrxMetaPostPublsh, ReceiptCIDs: map[common.Hash]eth.ReceiptModel{ MockTransactions[0].Hash(): MockRctMetaPostPublish[0], MockTransactions[1].Hash(): MockRctMetaPostPublish[1], MockTransactions[2].Hash(): MockRctMetaPostPublish[2], }, StateNodeCIDs: MockStateMetaPostPublish, StorageNodeCIDs: map[string][]eth.StorageNodeModel{ // contains filtered or unexported fields }, StateAccounts: map[string]eth.StateAccountModel{ // contains filtered or unexported fields }, } HeaderIPLD, _ = blocks.NewBlockWithCid(MockHeaderRlp, HeaderCID) Trx1IPLD, _ = blocks.NewBlockWithCid(MockTransactions.GetRlp(0), Trx1CID) Trx2IPLD, _ = blocks.NewBlockWithCid(MockTransactions.GetRlp(1), Trx2CID) Trx3IPLD, _ = blocks.NewBlockWithCid(MockTransactions.GetRlp(2), Trx3CID) Rct1IPLD, _ = blocks.NewBlockWithCid(MockReceipts.GetRlp(0), Rct1CID) Rct2IPLD, _ = blocks.NewBlockWithCid(MockReceipts.GetRlp(1), Rct2CID) Rct3IPLD, _ = blocks.NewBlockWithCid(MockReceipts.GetRlp(2), Rct3CID) State1IPLD, _ = blocks.NewBlockWithCid(ContractLeafNode, State1CID) State2IPLD, _ = blocks.NewBlockWithCid(AccountLeafNode, State2CID) StorageIPLD, _ = blocks.NewBlockWithCid(StorageLeafNode, StorageCID) )
Test variables
Functions ¶
This section is empty.
Types ¶
type BackFillerClient ¶
BackFillerClient is a mock client for use in backfiller tests
func (*BackFillerClient) BatchCall ¶
func (mc *BackFillerClient) BatchCall(batch []rpc.BatchElem) error
BatchCall mockClient method to simulate batch call to geth
func (*BackFillerClient) BatchCallContext ¶
BatchCallContext mockClient method to simulate batch call to geth
func (*BackFillerClient) SetReturnDiffAt ¶
func (mc *BackFillerClient) SetReturnDiffAt(height uint64, diffPayload statediff.Payload) error
SetReturnDiffAt method to set what statediffs the mock client returns
type CIDIndexer ¶
type CIDIndexer struct { PassedCIDPayload []eth.CIDPayload ReturnErr error }
CIDIndexer is the underlying struct for the Indexer interface
func (*CIDIndexer) Index ¶
func (repo *CIDIndexer) Index(cids eth.CIDPayload) error
Index indexes a cidPayload in Postgres
type IPLDPublisher ¶
type IPLDPublisher struct { PassedIPLDPayload eth.ConvertedPayload ReturnErr error }
IPLDPublisher is the underlying struct for the Publisher interface
func (*IPLDPublisher) Publish ¶
func (pub *IPLDPublisher) Publish(payload eth.ConvertedPayload) error
Publish publishes an IPLDPayload to IPFS and returns the corresponding CIDPayload
type IterativeIPLDPublisher ¶
type IterativeIPLDPublisher struct { PassedIPLDPayload []eth.ConvertedPayload ReturnErr error // contains filtered or unexported fields }
IterativeIPLDPublisher is the underlying struct for the Publisher interface; used in testing
func (*IterativeIPLDPublisher) Publish ¶
func (pub *IterativeIPLDPublisher) Publish(payload eth.ConvertedPayload) error
Publish publishes an IPLDPayload to IPFS and returns the corresponding CIDPayload
type IterativePayloadConverter ¶
type IterativePayloadConverter struct { PassedStatediffPayload []statediff.Payload ReturnIPLDPayload []*eth.ConvertedPayload ReturnErr error // contains filtered or unexported fields }
IterativePayloadConverter is the underlying struct for the Converter interface
func (*IterativePayloadConverter) Convert ¶
func (pc *IterativePayloadConverter) Convert(payload statediff.Payload) (*eth.ConvertedPayload, error)
Convert method is used to convert a geth statediff.Payload to a IPLDPayload
type IterativeTransformer ¶
type IterativeTransformer struct { PassedWorkerIDs []int PassedStateDiffs []statediff.Payload ReturnHeights []uint64 ReturnErr error // contains filtered or unexported fields }
IterativeTransformer for testing
type PayloadConverter ¶
type PayloadConverter struct { PassedStatediffPayload statediff.Payload ReturnIPLDPayload *eth.ConvertedPayload ReturnErr error }
PayloadConverter is the underlying struct for the Converter interface
func (*PayloadConverter) Convert ¶
func (pc *PayloadConverter) Convert(payload statediff.Payload) (*eth.ConvertedPayload, error)
Convert method is used to convert a geth statediff.Payload to a IPLDPayload
type PayloadFetcher ¶
type PayloadFetcher struct { PayloadsToReturn map[uint64]statediff.Payload FetchErrs map[uint64]error CalledAtBlockHeights [][]uint64 CalledTimes int64 }
PayloadFetcher mock for tests
type PayloadStreamer ¶
type PayloadStreamer struct { PassedPayloadChan chan statediff.Payload ReturnSub *rpc.ClientSubscription ReturnErr error StreamPayloads []statediff.Payload }
PayloadStreamer mock struct
func (*PayloadStreamer) Stream ¶
func (sds *PayloadStreamer) Stream(payloadChan chan statediff.Payload) (*rpc.ClientSubscription, error)
Stream mock method
type Retriever ¶
type Retriever struct { GapsToRetrieve []eth.DBGap GapsToRetrieveErr error CalledTimes int FirstBlockNumberToReturn int64 RetrieveFirstBlockNumberErr error }
Retriever is a mock retriever for use in tests
func (*Retriever) RetrieveFirstBlockNumber ¶
RetrieveFirstBlockNumber mock method
func (*Retriever) RetrieveGapsInData ¶
RetrieveGapsInData mock method
func (*Retriever) RetrieveLastBlockNumber ¶
RetrieveLastBlockNumber mock method
func (*Retriever) SetGapsToRetrieve ¶
SetGapsToRetrieve mock method
type StreamClient ¶
type StreamClient struct {
// contains filtered or unexported fields
}
func (*StreamClient) Subscribe ¶
func (client *StreamClient) Subscribe(ctx context.Context, namespace string, payloadChan interface{}, args ...interface{}) (*rpc.ClientSubscription, error)