Skip to content

Commit a8857e7

Browse files
authored
Merge pull request #164 from vulcanize/rct_size_bug
Rct size bug
2 parents a784cfd + 62d51fd commit a8857e7

22 files changed

+73
-58
lines changed
4.35 KB
Binary file not shown.
5.75 KB
Binary file not shown.
3.95 KB
Binary file not shown.
15.7 KB
Binary file not shown.
3.95 KB
Binary file not shown.

statediff/indexer/database/file/mainnet_tests/indexer_test.go

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -20,32 +20,25 @@ import (
2020
"context"
2121
"errors"
2222
"fmt"
23+
"math/big"
2324
"os"
2425
"testing"
2526

26-
"github.com/ipfs/go-cid"
2727
"github.com/jmoiron/sqlx"
28-
"github.com/multiformats/go-multihash"
2928
"github.com/stretchr/testify/require"
3029

3130
"github.com/ethereum/go-ethereum/core/types"
3231
"github.com/ethereum/go-ethereum/params"
33-
"github.com/ethereum/go-ethereum/rlp"
3432
"github.com/ethereum/go-ethereum/statediff/indexer/database/file"
3533
"github.com/ethereum/go-ethereum/statediff/indexer/database/sql/postgres"
3634
"github.com/ethereum/go-ethereum/statediff/indexer/interfaces"
37-
"github.com/ethereum/go-ethereum/statediff/indexer/ipld"
3835
"github.com/ethereum/go-ethereum/statediff/indexer/mocks"
3936
"github.com/ethereum/go-ethereum/statediff/indexer/test_helpers"
4037
)
4138

4239
var (
43-
testBlock *types.Block
44-
testReceipts types.Receipts
45-
testHeaderCID cid.Cid
46-
sqlxdb *sqlx.DB
47-
err error
48-
chainConf = params.MainnetChainConfig
40+
sqlxdb *sqlx.DB
41+
chainConf = params.MainnetChainConfig
4942
)
5043

5144
func init() {
@@ -55,13 +48,35 @@ func init() {
5548
}
5649
}
5750

58-
func setup(t *testing.T) {
59-
testBlock, testReceipts, err = TestBlocksAndReceiptsFromEnv()
60-
require.NoError(t, err)
61-
headerRLP, err := rlp.EncodeToBytes(testBlock.Header())
51+
func TestPushBlockAndState(t *testing.T) {
52+
conf := DefaultTestConfig
53+
rawURL := os.Getenv(TEST_RAW_URL)
54+
if rawURL == "" {
55+
fmt.Printf("Warning: no raw url configured for statediffing mainnet tests, will look for local file and"+
56+
"then try default endpoint (%s)\r\n", DefaultTestConfig.RawURL)
57+
} else {
58+
conf.RawURL = rawURL
59+
}
60+
for _, blockNumber := range problemBlocks {
61+
conf.BlockNumber = big.NewInt(blockNumber)
62+
tb, trs, err := TestBlockAndReceipts(conf)
63+
require.NoError(t, err)
64+
testPushBlockAndState(t, tb, trs)
65+
}
66+
testBlock, testReceipts, err := TestBlockAndReceiptsFromEnv(conf)
6267
require.NoError(t, err)
68+
testPushBlockAndState(t, testBlock, testReceipts)
69+
}
6370

64-
testHeaderCID, _ = ipld.RawdataToCid(ipld.MEthHeader, headerRLP, multihash.KECCAK_256)
71+
func testPushBlockAndState(t *testing.T, block *types.Block, receipts types.Receipts) {
72+
t.Run("Test PushBlock and PushStateNode", func(t *testing.T) {
73+
setup(t, block, receipts)
74+
dumpData(t)
75+
tearDown(t)
76+
})
77+
}
78+
79+
func setup(t *testing.T, testBlock *types.Block, testReceipts types.Receipts) {
6580
if _, err := os.Stat(file.TestConfig.FilePath); !errors.Is(err, os.ErrNotExist) {
6681
err := os.Remove(file.TestConfig.FilePath)
6782
require.NoError(t, err)
@@ -113,11 +128,3 @@ func tearDown(t *testing.T) {
113128
err = sqlxdb.Close()
114129
require.NoError(t, err)
115130
}
116-
117-
func TestPushBlockAndState(t *testing.T) {
118-
t.Run("Test PushBlock and PushStateNode", func(t *testing.T) {
119-
setup(t)
120-
dumpData(t)
121-
tearDown(t)
122-
})
123-
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)