2019-08-28 18:41:49 +00:00
|
|
|
// VulcanizeDB
|
|
|
|
// Copyright © 2019 Vulcanize
|
|
|
|
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU Affero General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU Affero General Public License for more details.
|
|
|
|
|
|
|
|
// You should have received a copy of the GNU Affero General Public License
|
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2020-01-17 23:16:01 +00:00
|
|
|
package eth_test
|
2019-08-28 18:41:49 +00:00
|
|
|
|
|
|
|
import (
|
2021-02-24 16:50:26 +00:00
|
|
|
"math/big"
|
|
|
|
|
2022-09-14 05:20:16 +00:00
|
|
|
"github.com/cerc-io/ipld-eth-server/v4/pkg/eth"
|
|
|
|
"github.com/cerc-io/ipld-eth-server/v4/pkg/eth/test_helpers"
|
|
|
|
"github.com/cerc-io/ipld-eth-server/v4/pkg/shared"
|
2022-03-11 04:32:22 +00:00
|
|
|
"github.com/ethereum/go-ethereum/common"
|
|
|
|
"github.com/ethereum/go-ethereum/core/types"
|
2021-08-12 06:23:41 +00:00
|
|
|
"github.com/ethereum/go-ethereum/params"
|
2022-03-11 04:32:22 +00:00
|
|
|
"github.com/ethereum/go-ethereum/statediff/indexer/interfaces"
|
2021-08-12 06:23:41 +00:00
|
|
|
"github.com/ethereum/go-ethereum/statediff/indexer/models"
|
2021-02-19 20:23:45 +00:00
|
|
|
"github.com/ethereum/go-ethereum/trie"
|
2022-03-11 04:32:22 +00:00
|
|
|
"github.com/jmoiron/sqlx"
|
2022-09-16 19:07:59 +00:00
|
|
|
. "github.com/onsi/ginkgo"
|
|
|
|
. "github.com/onsi/gomega"
|
2019-08-28 18:41:49 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
2020-08-31 15:47:06 +00:00
|
|
|
openFilter = eth.SubscriptionSettings{
|
2020-01-17 23:16:01 +00:00
|
|
|
Start: big.NewInt(0),
|
2021-09-15 11:43:12 +00:00
|
|
|
End: big.NewInt(1),
|
2020-02-03 18:22:29 +00:00
|
|
|
HeaderFilter: eth.HeaderFilter{},
|
|
|
|
TxFilter: eth.TxFilter{},
|
|
|
|
ReceiptFilter: eth.ReceiptFilter{},
|
|
|
|
StateFilter: eth.StateFilter{},
|
|
|
|
StorageFilter: eth.StorageFilter{},
|
2019-08-28 22:07:36 +00:00
|
|
|
}
|
2020-08-31 15:47:06 +00:00
|
|
|
rctAddressFilter = eth.SubscriptionSettings{
|
2020-01-17 23:16:01 +00:00
|
|
|
Start: big.NewInt(0),
|
2021-09-15 11:43:12 +00:00
|
|
|
End: big.NewInt(1),
|
2020-02-03 18:22:29 +00:00
|
|
|
HeaderFilter: eth.HeaderFilter{
|
2019-08-28 22:07:36 +00:00
|
|
|
Off: true,
|
|
|
|
},
|
2020-02-03 18:22:29 +00:00
|
|
|
TxFilter: eth.TxFilter{
|
2019-08-28 22:07:36 +00:00
|
|
|
Off: true,
|
|
|
|
},
|
2020-02-03 18:22:29 +00:00
|
|
|
ReceiptFilter: eth.ReceiptFilter{
|
2020-10-20 20:33:18 +00:00
|
|
|
LogAddresses: []string{test_helpers.Address.String()},
|
2019-08-28 22:07:36 +00:00
|
|
|
},
|
2020-02-03 18:22:29 +00:00
|
|
|
StateFilter: eth.StateFilter{
|
2019-08-28 22:07:36 +00:00
|
|
|
Off: true,
|
|
|
|
},
|
2020-02-03 18:22:29 +00:00
|
|
|
StorageFilter: eth.StorageFilter{
|
2019-08-28 22:07:36 +00:00
|
|
|
Off: true,
|
|
|
|
},
|
|
|
|
}
|
2020-08-31 15:47:06 +00:00
|
|
|
rctTopicsFilter = eth.SubscriptionSettings{
|
2020-01-17 23:16:01 +00:00
|
|
|
Start: big.NewInt(0),
|
2021-09-15 11:43:12 +00:00
|
|
|
End: big.NewInt(1),
|
2020-02-03 18:22:29 +00:00
|
|
|
HeaderFilter: eth.HeaderFilter{
|
2019-08-28 22:07:36 +00:00
|
|
|
Off: true,
|
|
|
|
},
|
2020-02-03 18:22:29 +00:00
|
|
|
TxFilter: eth.TxFilter{
|
2019-08-28 22:07:36 +00:00
|
|
|
Off: true,
|
|
|
|
},
|
2020-02-03 18:22:29 +00:00
|
|
|
ReceiptFilter: eth.ReceiptFilter{
|
2020-01-21 19:12:35 +00:00
|
|
|
Topics: [][]string{{"0x0000000000000000000000000000000000000000000000000000000000000004"}},
|
2019-08-28 22:07:36 +00:00
|
|
|
},
|
2020-02-03 18:22:29 +00:00
|
|
|
StateFilter: eth.StateFilter{
|
2019-08-28 22:07:36 +00:00
|
|
|
Off: true,
|
|
|
|
},
|
2020-02-03 18:22:29 +00:00
|
|
|
StorageFilter: eth.StorageFilter{
|
2019-08-28 22:07:36 +00:00
|
|
|
Off: true,
|
|
|
|
},
|
|
|
|
}
|
2020-08-31 15:47:06 +00:00
|
|
|
rctTopicsAndAddressFilter = eth.SubscriptionSettings{
|
2020-01-17 23:16:01 +00:00
|
|
|
Start: big.NewInt(0),
|
2021-09-15 11:43:12 +00:00
|
|
|
End: big.NewInt(1),
|
2020-02-03 18:22:29 +00:00
|
|
|
HeaderFilter: eth.HeaderFilter{
|
2019-08-28 22:07:36 +00:00
|
|
|
Off: true,
|
|
|
|
},
|
2020-02-03 18:22:29 +00:00
|
|
|
TxFilter: eth.TxFilter{
|
2019-08-28 22:07:36 +00:00
|
|
|
Off: true,
|
|
|
|
},
|
2020-02-03 18:22:29 +00:00
|
|
|
ReceiptFilter: eth.ReceiptFilter{
|
2020-01-21 19:12:35 +00:00
|
|
|
Topics: [][]string{
|
|
|
|
{"0x0000000000000000000000000000000000000000000000000000000000000004"},
|
|
|
|
{"0x0000000000000000000000000000000000000000000000000000000000000006"},
|
|
|
|
},
|
2020-10-20 20:33:18 +00:00
|
|
|
LogAddresses: []string{test_helpers.Address.String()},
|
2020-01-21 19:12:35 +00:00
|
|
|
},
|
2020-02-03 18:22:29 +00:00
|
|
|
StateFilter: eth.StateFilter{
|
2020-01-21 19:12:35 +00:00
|
|
|
Off: true,
|
|
|
|
},
|
2020-02-03 18:22:29 +00:00
|
|
|
StorageFilter: eth.StorageFilter{
|
2020-01-21 19:12:35 +00:00
|
|
|
Off: true,
|
|
|
|
},
|
|
|
|
}
|
2020-08-31 15:47:06 +00:00
|
|
|
rctTopicsAndAddressFilterFail = eth.SubscriptionSettings{
|
2020-01-21 19:12:35 +00:00
|
|
|
Start: big.NewInt(0),
|
2021-09-15 11:43:12 +00:00
|
|
|
End: big.NewInt(1),
|
2020-02-03 18:22:29 +00:00
|
|
|
HeaderFilter: eth.HeaderFilter{
|
2020-01-21 19:12:35 +00:00
|
|
|
Off: true,
|
|
|
|
},
|
2020-02-03 18:22:29 +00:00
|
|
|
TxFilter: eth.TxFilter{
|
2020-01-21 19:12:35 +00:00
|
|
|
Off: true,
|
|
|
|
},
|
2020-02-03 18:22:29 +00:00
|
|
|
ReceiptFilter: eth.ReceiptFilter{
|
2020-01-21 19:12:35 +00:00
|
|
|
Topics: [][]string{
|
|
|
|
{"0x0000000000000000000000000000000000000000000000000000000000000004"},
|
2020-10-20 20:33:18 +00:00
|
|
|
{"0x0000000000000000000000000000000000000000000000000000000000000007"}, // This topic won't match on the mocks.Address.String() contract receipt
|
2020-01-21 19:12:35 +00:00
|
|
|
},
|
2020-10-20 20:33:18 +00:00
|
|
|
LogAddresses: []string{test_helpers.Address.String()},
|
2019-08-28 22:07:36 +00:00
|
|
|
},
|
2020-02-03 18:22:29 +00:00
|
|
|
StateFilter: eth.StateFilter{
|
2019-08-28 22:07:36 +00:00
|
|
|
Off: true,
|
|
|
|
},
|
2020-02-03 18:22:29 +00:00
|
|
|
StorageFilter: eth.StorageFilter{
|
2019-08-28 22:07:36 +00:00
|
|
|
Off: true,
|
|
|
|
},
|
|
|
|
}
|
2020-08-31 15:47:06 +00:00
|
|
|
rctAddressesAndTopicFilter = eth.SubscriptionSettings{
|
2020-01-17 23:16:01 +00:00
|
|
|
Start: big.NewInt(0),
|
2021-09-15 11:43:12 +00:00
|
|
|
End: big.NewInt(1),
|
2020-02-03 18:22:29 +00:00
|
|
|
HeaderFilter: eth.HeaderFilter{
|
2019-08-28 22:07:36 +00:00
|
|
|
Off: true,
|
|
|
|
},
|
2020-02-03 18:22:29 +00:00
|
|
|
TxFilter: eth.TxFilter{
|
2019-08-28 22:07:36 +00:00
|
|
|
Off: true,
|
|
|
|
},
|
2020-02-03 18:22:29 +00:00
|
|
|
ReceiptFilter: eth.ReceiptFilter{
|
2020-04-02 03:34:06 +00:00
|
|
|
Topics: [][]string{{"0x0000000000000000000000000000000000000000000000000000000000000005"}},
|
2020-10-20 20:33:18 +00:00
|
|
|
LogAddresses: []string{test_helpers.Address.String(), test_helpers.AnotherAddress.String()},
|
2019-08-28 22:07:36 +00:00
|
|
|
},
|
2020-02-03 18:22:29 +00:00
|
|
|
StateFilter: eth.StateFilter{
|
2019-08-28 22:07:36 +00:00
|
|
|
Off: true,
|
|
|
|
},
|
2020-02-03 18:22:29 +00:00
|
|
|
StorageFilter: eth.StorageFilter{
|
2019-08-28 22:07:36 +00:00
|
|
|
Off: true,
|
|
|
|
},
|
|
|
|
}
|
2020-08-31 15:47:06 +00:00
|
|
|
rctsForAllCollectedTrxs = eth.SubscriptionSettings{
|
2020-01-17 23:16:01 +00:00
|
|
|
Start: big.NewInt(0),
|
2021-09-15 11:43:12 +00:00
|
|
|
End: big.NewInt(1),
|
2020-02-03 18:22:29 +00:00
|
|
|
HeaderFilter: eth.HeaderFilter{
|
2019-08-28 22:07:36 +00:00
|
|
|
Off: true,
|
|
|
|
},
|
2020-02-03 18:22:29 +00:00
|
|
|
TxFilter: eth.TxFilter{}, // Trx filter open so we will collect all trxs, therefore we will also collect all corresponding rcts despite rct filter
|
|
|
|
ReceiptFilter: eth.ReceiptFilter{
|
2020-04-02 03:34:06 +00:00
|
|
|
MatchTxs: true,
|
|
|
|
Topics: [][]string{{"0x0000000000000000000000000000000000000000000000000000000000000006"}}, // Topic0 isn't one of the topic0s we have
|
|
|
|
LogAddresses: []string{"0x0000000000000000000000000000000000000002"}, // Contract isn't one of the contracts we have
|
2019-08-28 22:07:36 +00:00
|
|
|
},
|
2020-02-03 18:22:29 +00:00
|
|
|
StateFilter: eth.StateFilter{
|
2019-08-28 22:07:36 +00:00
|
|
|
Off: true,
|
|
|
|
},
|
2020-02-03 18:22:29 +00:00
|
|
|
StorageFilter: eth.StorageFilter{
|
2019-08-28 22:07:36 +00:00
|
|
|
Off: true,
|
|
|
|
},
|
|
|
|
}
|
2020-08-31 15:47:06 +00:00
|
|
|
rctsForSelectCollectedTrxs = eth.SubscriptionSettings{
|
2020-01-17 23:16:01 +00:00
|
|
|
Start: big.NewInt(0),
|
2021-09-15 11:43:12 +00:00
|
|
|
End: big.NewInt(1),
|
2020-02-03 18:22:29 +00:00
|
|
|
HeaderFilter: eth.HeaderFilter{
|
2019-08-28 22:07:36 +00:00
|
|
|
Off: true,
|
|
|
|
},
|
2020-02-03 18:22:29 +00:00
|
|
|
TxFilter: eth.TxFilter{
|
2020-10-20 20:33:18 +00:00
|
|
|
Dst: []string{test_helpers.AnotherAddress.String()}, // We only filter for one of the trxs so we will only get the one corresponding receipt
|
2019-08-28 22:07:36 +00:00
|
|
|
},
|
2020-02-03 18:22:29 +00:00
|
|
|
ReceiptFilter: eth.ReceiptFilter{
|
2020-04-02 03:34:06 +00:00
|
|
|
MatchTxs: true,
|
|
|
|
Topics: [][]string{{"0x0000000000000000000000000000000000000000000000000000000000000006"}}, // Topic0 isn't one of the topic0s we have
|
|
|
|
LogAddresses: []string{"0x0000000000000000000000000000000000000002"}, // Contract isn't one of the contracts we have
|
2019-08-28 22:07:36 +00:00
|
|
|
},
|
2020-02-03 18:22:29 +00:00
|
|
|
StateFilter: eth.StateFilter{
|
2019-08-28 22:07:36 +00:00
|
|
|
Off: true,
|
|
|
|
},
|
2020-02-03 18:22:29 +00:00
|
|
|
StorageFilter: eth.StorageFilter{
|
2019-08-28 22:07:36 +00:00
|
|
|
Off: true,
|
|
|
|
},
|
|
|
|
}
|
2020-08-31 15:47:06 +00:00
|
|
|
stateFilter = eth.SubscriptionSettings{
|
2020-01-17 23:16:01 +00:00
|
|
|
Start: big.NewInt(0),
|
2021-09-15 11:43:12 +00:00
|
|
|
End: big.NewInt(1),
|
2020-02-03 18:22:29 +00:00
|
|
|
HeaderFilter: eth.HeaderFilter{
|
2019-08-28 22:07:36 +00:00
|
|
|
Off: true,
|
|
|
|
},
|
2020-02-03 18:22:29 +00:00
|
|
|
TxFilter: eth.TxFilter{
|
2019-08-28 22:07:36 +00:00
|
|
|
Off: true,
|
|
|
|
},
|
2020-02-03 18:22:29 +00:00
|
|
|
ReceiptFilter: eth.ReceiptFilter{
|
2019-08-28 22:07:36 +00:00
|
|
|
Off: true,
|
|
|
|
},
|
2020-02-03 18:22:29 +00:00
|
|
|
StateFilter: eth.StateFilter{
|
2020-10-20 20:33:18 +00:00
|
|
|
Addresses: []string{test_helpers.AccountAddresss.Hex()},
|
2019-08-28 22:07:36 +00:00
|
|
|
},
|
2020-02-03 18:22:29 +00:00
|
|
|
StorageFilter: eth.StorageFilter{
|
2019-08-28 22:07:36 +00:00
|
|
|
Off: true,
|
|
|
|
},
|
|
|
|
}
|
2019-08-28 18:41:49 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
var _ = Describe("Retriever", func() {
|
2019-11-01 19:03:28 +00:00
|
|
|
var (
|
2022-03-11 04:32:22 +00:00
|
|
|
db *sqlx.DB
|
|
|
|
diffIndexer interfaces.StateDiffIndexer
|
2021-08-12 06:23:41 +00:00
|
|
|
retriever *eth.CIDRetriever
|
2019-11-01 19:03:28 +00:00
|
|
|
)
|
2019-08-28 18:41:49 +00:00
|
|
|
BeforeEach(func() {
|
2022-03-17 10:48:18 +00:00
|
|
|
db = shared.SetupDB()
|
2022-03-21 06:11:34 +00:00
|
|
|
diffIndexer = shared.SetupTestStateDiffIndexer(ctx, params.TestChainConfig, test_helpers.Genesis.Hash())
|
2021-10-07 09:35:11 +00:00
|
|
|
|
2020-08-31 15:47:06 +00:00
|
|
|
retriever = eth.NewCIDRetriever(db)
|
2019-08-28 18:41:49 +00:00
|
|
|
})
|
|
|
|
AfterEach(func() {
|
2022-03-17 10:48:18 +00:00
|
|
|
shared.TearDownDB(db)
|
2019-08-28 18:41:49 +00:00
|
|
|
})
|
2019-08-28 22:07:36 +00:00
|
|
|
|
2020-01-17 23:16:01 +00:00
|
|
|
Describe("Retrieve", func() {
|
2019-11-01 19:03:28 +00:00
|
|
|
BeforeEach(func() {
|
2021-08-12 06:23:41 +00:00
|
|
|
tx, err := diffIndexer.PushBlock(test_helpers.MockBlock, test_helpers.MockReceipts, test_helpers.MockBlock.Difficulty())
|
|
|
|
Expect(err).ToNot(HaveOccurred())
|
|
|
|
for _, node := range test_helpers.MockStateNodes {
|
2022-03-11 04:32:22 +00:00
|
|
|
err = diffIndexer.PushStateNode(tx, node, test_helpers.MockBlock.Hash().String())
|
2021-08-12 06:23:41 +00:00
|
|
|
Expect(err).ToNot(HaveOccurred())
|
|
|
|
}
|
|
|
|
|
2022-03-11 04:32:22 +00:00
|
|
|
err = tx.Submit(err)
|
2020-01-16 20:48:38 +00:00
|
|
|
Expect(err).ToNot(HaveOccurred())
|
2019-11-01 19:03:28 +00:00
|
|
|
})
|
2019-08-28 22:07:36 +00:00
|
|
|
It("Retrieves all CIDs for the given blocknumber when provided an open filter", func() {
|
2021-09-16 12:49:42 +00:00
|
|
|
type rctCIDAndMHKeyResult struct {
|
|
|
|
LeafCID string `db:"leaf_cid"`
|
|
|
|
LeafMhKey string `db:"leaf_mh_key"`
|
|
|
|
}
|
|
|
|
expectedRctCIDsAndLeafNodes := make([]rctCIDAndMHKeyResult, 0)
|
|
|
|
pgStr := `SELECT receipt_cids.leaf_cid, receipt_cids.leaf_mh_key FROM eth.receipt_cids, eth.transaction_cids, eth.header_cids
|
2022-03-11 04:32:22 +00:00
|
|
|
WHERE receipt_cids.tx_id = transaction_cids.tx_hash
|
|
|
|
AND transaction_cids.header_id = header_cids.block_hash
|
2021-09-16 12:49:42 +00:00
|
|
|
AND header_cids.block_number = $1
|
|
|
|
ORDER BY transaction_cids.index`
|
|
|
|
err := db.Select(&expectedRctCIDsAndLeafNodes, pgStr, test_helpers.BlockNumber.Uint64())
|
2022-04-26 14:10:06 +00:00
|
|
|
Expect(err).ToNot(HaveOccurred())
|
2021-09-15 11:43:12 +00:00
|
|
|
cids, empty, err := retriever.Retrieve(openFilter, 1)
|
2019-08-28 18:41:49 +00:00
|
|
|
Expect(err).ToNot(HaveOccurred())
|
2020-01-17 23:16:01 +00:00
|
|
|
Expect(empty).ToNot(BeTrue())
|
2020-02-23 23:14:29 +00:00
|
|
|
Expect(len(cids)).To(Equal(1))
|
2020-10-20 20:33:18 +00:00
|
|
|
Expect(cids[0].BlockNumber).To(Equal(test_helpers.MockCIDWrapper.BlockNumber))
|
2021-06-03 16:49:48 +00:00
|
|
|
|
2020-10-20 20:33:18 +00:00
|
|
|
expectedHeaderCID := test_helpers.MockCIDWrapper.Header
|
2022-03-11 04:32:22 +00:00
|
|
|
expectedHeaderCID.BlockHash = cids[0].Header.BlockHash
|
2020-08-31 15:47:06 +00:00
|
|
|
expectedHeaderCID.NodeID = cids[0].Header.NodeID
|
|
|
|
Expect(cids[0].Header).To(Equal(expectedHeaderCID))
|
2021-09-01 07:02:28 +00:00
|
|
|
Expect(len(cids[0].Transactions)).To(Equal(4))
|
2020-10-20 20:33:18 +00:00
|
|
|
Expect(eth.TxModelsContainsCID(cids[0].Transactions, test_helpers.MockCIDWrapper.Transactions[0].CID)).To(BeTrue())
|
|
|
|
Expect(eth.TxModelsContainsCID(cids[0].Transactions, test_helpers.MockCIDWrapper.Transactions[1].CID)).To(BeTrue())
|
|
|
|
Expect(eth.TxModelsContainsCID(cids[0].Transactions, test_helpers.MockCIDWrapper.Transactions[2].CID)).To(BeTrue())
|
2021-09-16 13:45:56 +00:00
|
|
|
Expect(len(cids[0].Receipts)).To(Equal(4))
|
2021-09-16 12:49:42 +00:00
|
|
|
Expect(eth.ReceiptModelsContainsCID(cids[0].Receipts, expectedRctCIDsAndLeafNodes[0].LeafCID)).To(BeTrue())
|
|
|
|
Expect(eth.ReceiptModelsContainsCID(cids[0].Receipts, expectedRctCIDsAndLeafNodes[1].LeafCID)).To(BeTrue())
|
|
|
|
Expect(eth.ReceiptModelsContainsCID(cids[0].Receipts, expectedRctCIDsAndLeafNodes[2].LeafCID)).To(BeTrue())
|
2020-08-31 15:47:06 +00:00
|
|
|
Expect(len(cids[0].StateNodes)).To(Equal(2))
|
2021-06-03 16:49:48 +00:00
|
|
|
|
2020-08-31 15:47:06 +00:00
|
|
|
for _, stateNode := range cids[0].StateNodes {
|
2020-10-20 20:33:18 +00:00
|
|
|
if stateNode.CID == test_helpers.State1CID.String() {
|
|
|
|
Expect(stateNode.StateKey).To(Equal(common.BytesToHash(test_helpers.ContractLeafKey).Hex()))
|
2020-03-11 18:41:59 +00:00
|
|
|
Expect(stateNode.NodeType).To(Equal(2))
|
|
|
|
Expect(stateNode.Path).To(Equal([]byte{'\x06'}))
|
2019-08-28 18:41:49 +00:00
|
|
|
}
|
2020-10-20 20:33:18 +00:00
|
|
|
if stateNode.CID == test_helpers.State2CID.String() {
|
|
|
|
Expect(stateNode.StateKey).To(Equal(common.BytesToHash(test_helpers.AccountLeafKey).Hex()))
|
2020-03-11 18:41:59 +00:00
|
|
|
Expect(stateNode.NodeType).To(Equal(2))
|
|
|
|
Expect(stateNode.Path).To(Equal([]byte{'\x0c'}))
|
2019-08-28 18:41:49 +00:00
|
|
|
}
|
|
|
|
}
|
2020-08-31 15:47:06 +00:00
|
|
|
Expect(len(cids[0].StorageNodes)).To(Equal(1))
|
2020-10-20 20:33:18 +00:00
|
|
|
expectedStorageNodeCIDs := test_helpers.MockCIDWrapper.StorageNodes
|
2022-03-11 04:32:22 +00:00
|
|
|
expectedStorageNodeCIDs[0].HeaderID = cids[0].StorageNodes[0].HeaderID
|
|
|
|
expectedStorageNodeCIDs[0].StatePath = cids[0].StorageNodes[0].StatePath
|
2020-08-31 15:47:06 +00:00
|
|
|
Expect(cids[0].StorageNodes).To(Equal(expectedStorageNodeCIDs))
|
2019-08-28 18:41:49 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
It("Applies filters from the provided config.Subscription", func() {
|
2021-09-16 12:49:42 +00:00
|
|
|
type rctCIDAndMHKeyResult struct {
|
|
|
|
LeafCID string `db:"leaf_cid"`
|
|
|
|
LeafMhKey string `db:"leaf_mh_key"`
|
|
|
|
}
|
|
|
|
expectedRctCIDsAndLeafNodes := make([]rctCIDAndMHKeyResult, 0)
|
|
|
|
pgStr := `SELECT receipt_cids.leaf_cid, receipt_cids.leaf_mh_key FROM eth.receipt_cids, eth.transaction_cids, eth.header_cids
|
2022-03-11 04:32:22 +00:00
|
|
|
WHERE receipt_cids.tx_id = transaction_cids.tx_hash
|
|
|
|
AND transaction_cids.header_id = header_cids.block_hash
|
2021-09-16 12:49:42 +00:00
|
|
|
AND header_cids.block_number = $1
|
|
|
|
ORDER BY transaction_cids.index`
|
|
|
|
err := db.Select(&expectedRctCIDsAndLeafNodes, pgStr, test_helpers.BlockNumber.Uint64())
|
2021-09-15 11:43:12 +00:00
|
|
|
cids1, empty, err := retriever.Retrieve(rctAddressFilter, 1)
|
2020-01-17 23:16:01 +00:00
|
|
|
Expect(err).ToNot(HaveOccurred())
|
|
|
|
Expect(empty).ToNot(BeTrue())
|
2020-02-23 23:14:29 +00:00
|
|
|
Expect(len(cids1)).To(Equal(1))
|
2020-10-20 20:33:18 +00:00
|
|
|
Expect(cids1[0].BlockNumber).To(Equal(test_helpers.MockCIDWrapper.BlockNumber))
|
2021-08-12 06:23:41 +00:00
|
|
|
Expect(cids1[0].Header).To(Equal(models.HeaderModel{}))
|
2020-08-31 15:47:06 +00:00
|
|
|
Expect(len(cids1[0].Transactions)).To(Equal(0))
|
|
|
|
Expect(len(cids1[0].StateNodes)).To(Equal(0))
|
|
|
|
Expect(len(cids1[0].StorageNodes)).To(Equal(0))
|
|
|
|
Expect(len(cids1[0].Receipts)).To(Equal(1))
|
2020-10-20 20:33:18 +00:00
|
|
|
expectedReceiptCID := test_helpers.MockCIDWrapper.Receipts[0]
|
2020-08-31 15:47:06 +00:00
|
|
|
expectedReceiptCID.TxID = cids1[0].Receipts[0].TxID
|
2021-09-16 12:49:42 +00:00
|
|
|
expectedReceiptCID.LeafCID = expectedRctCIDsAndLeafNodes[0].LeafCID
|
|
|
|
expectedReceiptCID.LeafMhKey = expectedRctCIDsAndLeafNodes[0].LeafMhKey
|
2020-08-31 15:47:06 +00:00
|
|
|
Expect(cids1[0].Receipts[0]).To(Equal(expectedReceiptCID))
|
2019-08-28 18:41:49 +00:00
|
|
|
|
2021-09-15 11:43:12 +00:00
|
|
|
cids2, empty, err := retriever.Retrieve(rctTopicsFilter, 1)
|
2020-01-17 23:16:01 +00:00
|
|
|
Expect(err).ToNot(HaveOccurred())
|
|
|
|
Expect(empty).ToNot(BeTrue())
|
2020-02-23 23:14:29 +00:00
|
|
|
Expect(len(cids2)).To(Equal(1))
|
2020-10-20 20:33:18 +00:00
|
|
|
Expect(cids2[0].BlockNumber).To(Equal(test_helpers.MockCIDWrapper.BlockNumber))
|
2021-08-12 06:23:41 +00:00
|
|
|
Expect(cids2[0].Header).To(Equal(models.HeaderModel{}))
|
2020-08-31 15:47:06 +00:00
|
|
|
Expect(len(cids2[0].Transactions)).To(Equal(0))
|
|
|
|
Expect(len(cids2[0].StateNodes)).To(Equal(0))
|
|
|
|
Expect(len(cids2[0].StorageNodes)).To(Equal(0))
|
|
|
|
Expect(len(cids2[0].Receipts)).To(Equal(1))
|
2020-10-20 20:33:18 +00:00
|
|
|
expectedReceiptCID = test_helpers.MockCIDWrapper.Receipts[0]
|
2020-08-31 15:47:06 +00:00
|
|
|
expectedReceiptCID.TxID = cids2[0].Receipts[0].TxID
|
2021-09-16 12:49:42 +00:00
|
|
|
expectedReceiptCID.LeafCID = expectedRctCIDsAndLeafNodes[0].LeafCID
|
|
|
|
expectedReceiptCID.LeafMhKey = expectedRctCIDsAndLeafNodes[0].LeafMhKey
|
2020-08-31 15:47:06 +00:00
|
|
|
Expect(cids2[0].Receipts[0]).To(Equal(expectedReceiptCID))
|
2019-08-28 18:41:49 +00:00
|
|
|
|
2021-09-15 11:43:12 +00:00
|
|
|
cids3, empty, err := retriever.Retrieve(rctTopicsAndAddressFilter, 1)
|
2020-01-17 23:16:01 +00:00
|
|
|
Expect(err).ToNot(HaveOccurred())
|
|
|
|
Expect(empty).ToNot(BeTrue())
|
2020-02-23 23:14:29 +00:00
|
|
|
Expect(len(cids3)).To(Equal(1))
|
2020-10-20 20:33:18 +00:00
|
|
|
Expect(cids3[0].BlockNumber).To(Equal(test_helpers.MockCIDWrapper.BlockNumber))
|
2021-08-12 06:23:41 +00:00
|
|
|
Expect(cids3[0].Header).To(Equal(models.HeaderModel{}))
|
2020-08-31 15:47:06 +00:00
|
|
|
Expect(len(cids3[0].Transactions)).To(Equal(0))
|
|
|
|
Expect(len(cids3[0].StateNodes)).To(Equal(0))
|
|
|
|
Expect(len(cids3[0].StorageNodes)).To(Equal(0))
|
|
|
|
Expect(len(cids3[0].Receipts)).To(Equal(1))
|
2020-10-20 20:33:18 +00:00
|
|
|
expectedReceiptCID = test_helpers.MockCIDWrapper.Receipts[0]
|
2020-08-31 15:47:06 +00:00
|
|
|
expectedReceiptCID.TxID = cids3[0].Receipts[0].TxID
|
2021-09-16 12:49:42 +00:00
|
|
|
expectedReceiptCID.LeafCID = expectedRctCIDsAndLeafNodes[0].LeafCID
|
|
|
|
expectedReceiptCID.LeafMhKey = expectedRctCIDsAndLeafNodes[0].LeafMhKey
|
2020-08-31 15:47:06 +00:00
|
|
|
Expect(cids3[0].Receipts[0]).To(Equal(expectedReceiptCID))
|
2019-08-28 18:41:49 +00:00
|
|
|
|
2021-09-15 11:43:12 +00:00
|
|
|
cids4, empty, err := retriever.Retrieve(rctAddressesAndTopicFilter, 1)
|
2020-01-17 23:16:01 +00:00
|
|
|
Expect(err).ToNot(HaveOccurred())
|
|
|
|
Expect(empty).ToNot(BeTrue())
|
2020-02-23 23:14:29 +00:00
|
|
|
Expect(len(cids4)).To(Equal(1))
|
2020-10-20 20:33:18 +00:00
|
|
|
Expect(cids4[0].BlockNumber).To(Equal(test_helpers.MockCIDWrapper.BlockNumber))
|
2021-08-12 06:23:41 +00:00
|
|
|
Expect(cids4[0].Header).To(Equal(models.HeaderModel{}))
|
2020-08-31 15:47:06 +00:00
|
|
|
Expect(len(cids4[0].Transactions)).To(Equal(0))
|
|
|
|
Expect(len(cids4[0].StateNodes)).To(Equal(0))
|
|
|
|
Expect(len(cids4[0].StorageNodes)).To(Equal(0))
|
|
|
|
Expect(len(cids4[0].Receipts)).To(Equal(1))
|
2020-10-20 20:33:18 +00:00
|
|
|
expectedReceiptCID = test_helpers.MockCIDWrapper.Receipts[1]
|
2020-08-31 15:47:06 +00:00
|
|
|
expectedReceiptCID.TxID = cids4[0].Receipts[0].TxID
|
2021-09-16 12:49:42 +00:00
|
|
|
expectedReceiptCID.LeafCID = expectedRctCIDsAndLeafNodes[1].LeafCID
|
|
|
|
expectedReceiptCID.LeafMhKey = expectedRctCIDsAndLeafNodes[1].LeafMhKey
|
2020-08-31 15:47:06 +00:00
|
|
|
Expect(cids4[0].Receipts[0]).To(Equal(expectedReceiptCID))
|
2019-08-28 18:41:49 +00:00
|
|
|
|
2021-09-15 11:43:12 +00:00
|
|
|
cids5, empty, err := retriever.Retrieve(rctsForAllCollectedTrxs, 1)
|
2020-01-17 23:16:01 +00:00
|
|
|
Expect(err).ToNot(HaveOccurred())
|
|
|
|
Expect(empty).ToNot(BeTrue())
|
2020-02-23 23:14:29 +00:00
|
|
|
Expect(len(cids5)).To(Equal(1))
|
2020-10-20 20:33:18 +00:00
|
|
|
Expect(cids5[0].BlockNumber).To(Equal(test_helpers.MockCIDWrapper.BlockNumber))
|
2021-08-12 06:23:41 +00:00
|
|
|
Expect(cids5[0].Header).To(Equal(models.HeaderModel{}))
|
2021-09-01 07:02:28 +00:00
|
|
|
Expect(len(cids5[0].Transactions)).To(Equal(4))
|
2020-10-20 20:33:18 +00:00
|
|
|
Expect(eth.TxModelsContainsCID(cids5[0].Transactions, test_helpers.Trx1CID.String())).To(BeTrue())
|
|
|
|
Expect(eth.TxModelsContainsCID(cids5[0].Transactions, test_helpers.Trx2CID.String())).To(BeTrue())
|
|
|
|
Expect(eth.TxModelsContainsCID(cids5[0].Transactions, test_helpers.Trx3CID.String())).To(BeTrue())
|
2020-08-31 15:47:06 +00:00
|
|
|
Expect(len(cids5[0].StateNodes)).To(Equal(0))
|
|
|
|
Expect(len(cids5[0].StorageNodes)).To(Equal(0))
|
2021-09-16 13:45:56 +00:00
|
|
|
Expect(len(cids5[0].Receipts)).To(Equal(4))
|
2021-09-16 12:49:42 +00:00
|
|
|
Expect(eth.ReceiptModelsContainsCID(cids5[0].Receipts, expectedRctCIDsAndLeafNodes[0].LeafCID)).To(BeTrue())
|
|
|
|
Expect(eth.ReceiptModelsContainsCID(cids5[0].Receipts, expectedRctCIDsAndLeafNodes[1].LeafCID)).To(BeTrue())
|
|
|
|
Expect(eth.ReceiptModelsContainsCID(cids5[0].Receipts, expectedRctCIDsAndLeafNodes[2].LeafCID)).To(BeTrue())
|
2019-08-28 18:41:49 +00:00
|
|
|
|
2021-09-15 11:43:12 +00:00
|
|
|
cids6, empty, err := retriever.Retrieve(rctsForSelectCollectedTrxs, 1)
|
2020-01-17 23:16:01 +00:00
|
|
|
Expect(err).ToNot(HaveOccurred())
|
|
|
|
Expect(empty).ToNot(BeTrue())
|
2020-02-23 23:14:29 +00:00
|
|
|
Expect(len(cids6)).To(Equal(1))
|
2020-10-20 20:33:18 +00:00
|
|
|
Expect(cids6[0].BlockNumber).To(Equal(test_helpers.MockCIDWrapper.BlockNumber))
|
2021-08-12 06:23:41 +00:00
|
|
|
Expect(cids6[0].Header).To(Equal(models.HeaderModel{}))
|
2020-08-31 15:47:06 +00:00
|
|
|
Expect(len(cids6[0].Transactions)).To(Equal(1))
|
2020-10-20 20:33:18 +00:00
|
|
|
expectedTxCID := test_helpers.MockCIDWrapper.Transactions[1]
|
2022-03-11 04:32:22 +00:00
|
|
|
expectedTxCID.TxHash = cids6[0].Transactions[0].TxHash
|
2020-08-31 15:47:06 +00:00
|
|
|
expectedTxCID.HeaderID = cids6[0].Transactions[0].HeaderID
|
|
|
|
Expect(cids6[0].Transactions[0]).To(Equal(expectedTxCID))
|
|
|
|
Expect(len(cids6[0].StateNodes)).To(Equal(0))
|
|
|
|
Expect(len(cids6[0].StorageNodes)).To(Equal(0))
|
|
|
|
Expect(len(cids6[0].Receipts)).To(Equal(1))
|
2020-10-20 20:33:18 +00:00
|
|
|
expectedReceiptCID = test_helpers.MockCIDWrapper.Receipts[1]
|
2020-08-31 15:47:06 +00:00
|
|
|
expectedReceiptCID.TxID = cids6[0].Receipts[0].TxID
|
2021-09-16 12:49:42 +00:00
|
|
|
expectedReceiptCID.LeafCID = expectedRctCIDsAndLeafNodes[1].LeafCID
|
|
|
|
expectedReceiptCID.LeafMhKey = expectedRctCIDsAndLeafNodes[1].LeafMhKey
|
2020-08-31 15:47:06 +00:00
|
|
|
Expect(cids6[0].Receipts[0]).To(Equal(expectedReceiptCID))
|
2019-08-28 18:41:49 +00:00
|
|
|
|
2021-09-15 11:43:12 +00:00
|
|
|
cids7, empty, err := retriever.Retrieve(stateFilter, 1)
|
2020-01-17 23:16:01 +00:00
|
|
|
Expect(err).ToNot(HaveOccurred())
|
|
|
|
Expect(empty).ToNot(BeTrue())
|
2020-02-23 23:14:29 +00:00
|
|
|
Expect(len(cids7)).To(Equal(1))
|
2020-10-20 20:33:18 +00:00
|
|
|
Expect(cids7[0].BlockNumber).To(Equal(test_helpers.MockCIDWrapper.BlockNumber))
|
2021-08-12 06:23:41 +00:00
|
|
|
Expect(cids7[0].Header).To(Equal(models.HeaderModel{}))
|
2020-08-31 15:47:06 +00:00
|
|
|
Expect(len(cids7[0].Transactions)).To(Equal(0))
|
|
|
|
Expect(len(cids7[0].Receipts)).To(Equal(0))
|
|
|
|
Expect(len(cids7[0].StorageNodes)).To(Equal(0))
|
|
|
|
Expect(len(cids7[0].StateNodes)).To(Equal(1))
|
2021-08-12 06:23:41 +00:00
|
|
|
Expect(cids7[0].StateNodes[0]).To(Equal(models.StateNodeModel{
|
2022-04-26 14:10:06 +00:00
|
|
|
BlockNumber: "1",
|
|
|
|
HeaderID: cids7[0].StateNodes[0].HeaderID,
|
|
|
|
NodeType: 2,
|
|
|
|
StateKey: common.BytesToHash(test_helpers.AccountLeafKey).Hex(),
|
|
|
|
CID: test_helpers.State2CID.String(),
|
|
|
|
MhKey: test_helpers.State2MhKey,
|
|
|
|
Path: []byte{'\x0c'},
|
2019-08-28 18:41:49 +00:00
|
|
|
}))
|
2020-01-21 19:12:35 +00:00
|
|
|
|
2020-04-02 03:34:06 +00:00
|
|
|
_, empty, err = retriever.Retrieve(rctTopicsAndAddressFilterFail, 1)
|
2020-01-21 19:12:35 +00:00
|
|
|
Expect(err).ToNot(HaveOccurred())
|
|
|
|
Expect(empty).To(BeTrue())
|
2019-08-28 18:41:49 +00:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
Describe("RetrieveFirstBlockNumber", func() {
|
2020-08-05 03:34:49 +00:00
|
|
|
It("Throws an error if there are no blocks in the database", func() {
|
|
|
|
_, err := retriever.RetrieveFirstBlockNumber()
|
|
|
|
Expect(err).To(HaveOccurred())
|
|
|
|
})
|
2019-08-28 18:41:49 +00:00
|
|
|
It("Gets the number of the first block that has data in the database", func() {
|
2021-08-12 06:23:41 +00:00
|
|
|
tx, err := diffIndexer.PushBlock(test_helpers.MockBlock, test_helpers.MockReceipts, test_helpers.MockBlock.Difficulty())
|
|
|
|
Expect(err).ToNot(HaveOccurred())
|
|
|
|
|
2022-03-11 04:32:22 +00:00
|
|
|
err = tx.Submit(err)
|
2020-01-16 20:48:38 +00:00
|
|
|
Expect(err).ToNot(HaveOccurred())
|
2021-08-12 06:23:41 +00:00
|
|
|
|
2020-01-16 20:48:38 +00:00
|
|
|
num, err := retriever.RetrieveFirstBlockNumber()
|
|
|
|
Expect(err).ToNot(HaveOccurred())
|
2021-09-15 11:43:12 +00:00
|
|
|
Expect(num).To(Equal(int64(1)))
|
2019-08-28 18:41:49 +00:00
|
|
|
})
|
2019-11-01 19:03:28 +00:00
|
|
|
|
|
|
|
It("Gets the number of the first block that has data in the database", func() {
|
2020-10-20 20:33:18 +00:00
|
|
|
payload := test_helpers.MockConvertedPayload
|
2020-08-05 03:34:49 +00:00
|
|
|
payload.Block = newMockBlock(1010101)
|
2021-08-12 06:23:41 +00:00
|
|
|
tx, err := diffIndexer.PushBlock(payload.Block, payload.Receipts, payload.Block.Difficulty())
|
|
|
|
Expect(err).ToNot(HaveOccurred())
|
|
|
|
|
2022-03-11 04:32:22 +00:00
|
|
|
err = tx.Submit(err)
|
2020-01-16 20:48:38 +00:00
|
|
|
Expect(err).ToNot(HaveOccurred())
|
2021-08-12 06:23:41 +00:00
|
|
|
|
2020-01-16 20:48:38 +00:00
|
|
|
num, err := retriever.RetrieveFirstBlockNumber()
|
|
|
|
Expect(err).ToNot(HaveOccurred())
|
2019-11-01 19:03:28 +00:00
|
|
|
Expect(num).To(Equal(int64(1010101)))
|
|
|
|
})
|
|
|
|
|
|
|
|
It("Gets the number of the first block that has data in the database", func() {
|
2020-10-20 20:33:18 +00:00
|
|
|
payload1 := test_helpers.MockConvertedPayload
|
2020-08-05 03:34:49 +00:00
|
|
|
payload1.Block = newMockBlock(1010101)
|
2019-11-01 19:03:28 +00:00
|
|
|
payload2 := payload1
|
2020-08-05 03:34:49 +00:00
|
|
|
payload2.Block = newMockBlock(5)
|
2021-08-12 06:23:41 +00:00
|
|
|
tx, err := diffIndexer.PushBlock(payload1.Block, payload1.Receipts, payload1.Block.Difficulty())
|
|
|
|
Expect(err).ToNot(HaveOccurred())
|
2022-03-11 04:32:22 +00:00
|
|
|
err = tx.Submit(err)
|
2020-01-16 20:48:38 +00:00
|
|
|
Expect(err).ToNot(HaveOccurred())
|
2021-08-12 06:23:41 +00:00
|
|
|
|
|
|
|
tx, err = diffIndexer.PushBlock(payload2.Block, payload2.Receipts, payload2.Block.Difficulty())
|
2020-01-16 20:48:38 +00:00
|
|
|
Expect(err).ToNot(HaveOccurred())
|
2022-03-11 04:32:22 +00:00
|
|
|
err = tx.Submit(err)
|
2021-08-12 06:23:41 +00:00
|
|
|
Expect(err).ToNot(HaveOccurred())
|
|
|
|
|
2020-01-16 20:48:38 +00:00
|
|
|
num, err := retriever.RetrieveFirstBlockNumber()
|
|
|
|
Expect(err).ToNot(HaveOccurred())
|
2019-11-01 19:03:28 +00:00
|
|
|
Expect(num).To(Equal(int64(5)))
|
|
|
|
})
|
2019-08-28 18:41:49 +00:00
|
|
|
})
|
2019-08-28 22:07:36 +00:00
|
|
|
|
2019-08-28 18:41:49 +00:00
|
|
|
Describe("RetrieveLastBlockNumber", func() {
|
2020-08-05 03:34:49 +00:00
|
|
|
It("Throws an error if there are no blocks in the database", func() {
|
|
|
|
_, err := retriever.RetrieveLastBlockNumber()
|
|
|
|
Expect(err).To(HaveOccurred())
|
|
|
|
})
|
2019-08-28 18:41:49 +00:00
|
|
|
It("Gets the number of the latest block that has data in the database", func() {
|
2021-08-12 06:23:41 +00:00
|
|
|
tx, err := diffIndexer.PushBlock(test_helpers.MockBlock, test_helpers.MockReceipts, test_helpers.MockBlock.Difficulty())
|
|
|
|
Expect(err).ToNot(HaveOccurred())
|
2022-03-11 04:32:22 +00:00
|
|
|
err = tx.Submit(err)
|
2020-01-16 20:48:38 +00:00
|
|
|
Expect(err).ToNot(HaveOccurred())
|
2021-08-12 06:23:41 +00:00
|
|
|
|
2020-01-16 20:48:38 +00:00
|
|
|
num, err := retriever.RetrieveLastBlockNumber()
|
|
|
|
Expect(err).ToNot(HaveOccurred())
|
2021-09-15 11:43:12 +00:00
|
|
|
Expect(num).To(Equal(int64(1)))
|
2019-08-28 18:41:49 +00:00
|
|
|
})
|
2019-11-01 19:03:28 +00:00
|
|
|
|
|
|
|
It("Gets the number of the latest block that has data in the database", func() {
|
2020-10-20 20:33:18 +00:00
|
|
|
payload := test_helpers.MockConvertedPayload
|
2020-08-05 03:34:49 +00:00
|
|
|
payload.Block = newMockBlock(1010101)
|
2021-08-12 06:23:41 +00:00
|
|
|
tx, err := diffIndexer.PushBlock(payload.Block, payload.Receipts, payload.Block.Difficulty())
|
|
|
|
Expect(err).ToNot(HaveOccurred())
|
|
|
|
|
2022-03-11 04:32:22 +00:00
|
|
|
err = tx.Submit(err)
|
2020-01-16 20:48:38 +00:00
|
|
|
Expect(err).ToNot(HaveOccurred())
|
2021-08-12 06:23:41 +00:00
|
|
|
|
2020-01-16 20:48:38 +00:00
|
|
|
num, err := retriever.RetrieveLastBlockNumber()
|
|
|
|
Expect(err).ToNot(HaveOccurred())
|
2019-11-01 19:03:28 +00:00
|
|
|
Expect(num).To(Equal(int64(1010101)))
|
|
|
|
})
|
|
|
|
|
|
|
|
It("Gets the number of the latest block that has data in the database", func() {
|
2020-10-20 20:33:18 +00:00
|
|
|
payload1 := test_helpers.MockConvertedPayload
|
2020-08-05 03:34:49 +00:00
|
|
|
payload1.Block = newMockBlock(1010101)
|
2019-11-01 19:03:28 +00:00
|
|
|
payload2 := payload1
|
2020-08-05 03:34:49 +00:00
|
|
|
payload2.Block = newMockBlock(5)
|
2021-08-12 06:23:41 +00:00
|
|
|
tx, err := diffIndexer.PushBlock(payload1.Block, payload1.Receipts, payload1.Block.Difficulty())
|
|
|
|
Expect(err).ToNot(HaveOccurred())
|
2022-03-11 04:32:22 +00:00
|
|
|
err = tx.Submit(err)
|
2020-01-16 20:48:38 +00:00
|
|
|
Expect(err).ToNot(HaveOccurred())
|
2021-08-12 06:23:41 +00:00
|
|
|
|
|
|
|
tx, err = diffIndexer.PushBlock(payload2.Block, payload2.Receipts, payload2.Block.Difficulty())
|
2020-01-16 20:48:38 +00:00
|
|
|
Expect(err).ToNot(HaveOccurred())
|
2022-03-11 04:32:22 +00:00
|
|
|
err = tx.Submit(err)
|
2021-08-12 06:23:41 +00:00
|
|
|
Expect(err).ToNot(HaveOccurred())
|
|
|
|
|
2020-01-16 20:48:38 +00:00
|
|
|
num, err := retriever.RetrieveLastBlockNumber()
|
|
|
|
Expect(err).ToNot(HaveOccurred())
|
2019-11-01 19:03:28 +00:00
|
|
|
Expect(num).To(Equal(int64(1010101)))
|
|
|
|
})
|
|
|
|
})
|
2019-08-28 18:41:49 +00:00
|
|
|
})
|
2020-08-05 03:34:49 +00:00
|
|
|
|
|
|
|
func newMockBlock(blockNumber uint64) *types.Block {
|
2020-10-20 20:33:18 +00:00
|
|
|
header := test_helpers.MockHeader
|
2020-08-05 03:34:49 +00:00
|
|
|
header.Number.SetUint64(blockNumber)
|
2021-02-19 20:23:45 +00:00
|
|
|
return types.NewBlock(&test_helpers.MockHeader, test_helpers.MockTransactions, nil, test_helpers.MockReceipts, new(trie.Trie))
|
2020-08-05 03:34:49 +00:00
|
|
|
}
|