Reformatting due to go fmt
This commit is contained in:
parent
8578fc20a3
commit
4d4c229594
@ -20,27 +20,26 @@
|
||||
package builder_test
|
||||
|
||||
import (
|
||||
"github.com/onsi/ginkgo"
|
||||
"github.com/ethereum/go-ethereum/ethdb"
|
||||
"github.com/ethereum/go-ethereum/core"
|
||||
"github.com/ethereum/go-ethereum/params"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/consensus/ethash"
|
||||
"math/big"
|
||||
"github.com/ethereum/go-ethereum/core"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/ethereum/go-ethereum/crypto"
|
||||
"github.com/onsi/gomega"
|
||||
"github.com/ethereum/go-ethereum/ethdb"
|
||||
"github.com/ethereum/go-ethereum/params"
|
||||
b "github.com/ethereum/go-ethereum/statediff/builder"
|
||||
"github.com/onsi/ginkgo"
|
||||
"github.com/onsi/gomega"
|
||||
"math/big"
|
||||
)
|
||||
|
||||
|
||||
var (
|
||||
testdb = ethdb.NewMemDatabase()
|
||||
|
||||
testBankKey, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
|
||||
testBankAddress = crypto.PubkeyToAddress(testBankKey.PublicKey) //0x71562b71999873DB5b286dF957af199Ec94617F7
|
||||
testBankFunds = big.NewInt(100000000)
|
||||
genesis = core.GenesisBlockForTesting(testdb, testBankAddress, testBankFunds)
|
||||
genesis = core.GenesisBlockForTesting(testdb, testBankAddress, testBankFunds)
|
||||
|
||||
account1Key, _ = crypto.HexToECDSA("8a1f9a8f95be41cd7ccb6168179afb4504aefe388d1e14474d32c45c72ce7b7a")
|
||||
account2Key, _ = crypto.HexToECDSA("49a7b37aa6f6645917e7b807e9d1c00d4fa71f18343b0d4122a4d2df64dd6fee")
|
||||
@ -50,9 +49,10 @@ var (
|
||||
contractCode = common.Hex2Bytes("606060405260cc8060106000396000f360606040526000357c01000000000000000000000000000000000000000000000000000000009004806360cd2685146041578063c16431b914606b57603f565b005b6055600480803590602001909190505060a9565b6040518082815260200191505060405180910390f35b60886004808035906020019091908035906020019091905050608a565b005b80600060005083606481101560025790900160005b50819055505b5050565b6000600060005082606481101560025790900160005b5054905060c7565b91905056")
|
||||
contractAddr common.Address
|
||||
|
||||
emptyAccountDiffEventualMap = make(map[common.Address]b.AccountDiffEventual)
|
||||
emptyAccountDiffEventualMap = make(map[common.Address]b.AccountDiffEventual)
|
||||
emptyAccountDiffIncrementalMap = make(map[common.Address]b.AccountDiffIncremental)
|
||||
)
|
||||
|
||||
/*
|
||||
contract test {
|
||||
|
||||
@ -68,7 +68,6 @@ contract test {
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
// makeChain creates a chain of n blocks starting at and including parent.
|
||||
// the returned hash chain is ordered head->parent. In addition, every 3rd block
|
||||
// contains a transaction and every 5th an uncle to allow testing correct block
|
||||
@ -86,7 +85,6 @@ func makeChain(n int, seed byte, parent *types.Block) ([]common.Hash, map[common
|
||||
return hashes, blockm
|
||||
}
|
||||
|
||||
|
||||
func testChainGen(i int, block *core.BlockGen) {
|
||||
signer := types.HomesteadSigner{}
|
||||
switch i {
|
||||
@ -117,15 +115,16 @@ func testChainGen(i int, block *core.BlockGen) {
|
||||
block.AddTx(tx)
|
||||
}
|
||||
}
|
||||
|
||||
var _ = ginkgo.FDescribe("", func() {
|
||||
var (
|
||||
block0Hash, block1Hash, block2Hash, block3Hash common.Hash
|
||||
block0, block1, block2, block3 *types.Block
|
||||
builder b.Builder
|
||||
miningReward = int64(3000000000000000000)
|
||||
burnAddress = common.HexToAddress("0x0")
|
||||
diff *b.StateDiff
|
||||
err error
|
||||
block0, block1, block2, block3 *types.Block
|
||||
builder b.Builder
|
||||
miningReward = int64(3000000000000000000)
|
||||
burnAddress = common.HexToAddress("0x0")
|
||||
diff *b.StateDiff
|
||||
err error
|
||||
)
|
||||
|
||||
ginkgo.BeforeEach(func() {
|
||||
@ -207,8 +206,8 @@ var _ = ginkgo.FDescribe("", func() {
|
||||
//1000 transferred from testBankAddress to account1Addr
|
||||
//1000 transferred from account1Addr to account2Addr
|
||||
var (
|
||||
balanceChange = int64(1000)
|
||||
block1BankBalance = int64(99990000)
|
||||
balanceChange = int64(1000)
|
||||
block1BankBalance = int64(99990000)
|
||||
block1Account1Balance = int64(10000)
|
||||
)
|
||||
|
||||
|
@ -22,15 +22,15 @@ package statediff
|
||||
import "fmt"
|
||||
|
||||
type Config struct {
|
||||
On bool // Whether or not to extract state diffs
|
||||
Mode StateDiffMode // Mode for storing diffs
|
||||
Path string // Path for storing diffs
|
||||
On bool // Whether or not to extract state diffs
|
||||
Mode StateDiffMode // Mode for storing diffs
|
||||
Path string // Path for storing diffs
|
||||
}
|
||||
|
||||
type StateDiffMode int
|
||||
|
||||
const (
|
||||
CSV StateDiffMode = iota
|
||||
CSV StateDiffMode = iota
|
||||
IPLD
|
||||
LDB
|
||||
SQL
|
||||
|
@ -30,7 +30,7 @@ type Extractor interface {
|
||||
}
|
||||
|
||||
type extractor struct {
|
||||
Builder builder.Builder // Interface for building state diff objects from two blocks
|
||||
Builder builder.Builder // Interface for building state diff objects from two blocks
|
||||
Publisher publisher.Publisher // Interface for publishing state diff objects to a datastore (e.g. IPFS)
|
||||
}
|
||||
|
||||
|
@ -20,15 +20,16 @@
|
||||
package extractor_test
|
||||
|
||||
import (
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
b "github.com/ethereum/go-ethereum/statediff/builder"
|
||||
e "github.com/ethereum/go-ethereum/statediff/extractor"
|
||||
"github.com/ethereum/go-ethereum/statediff/testhelpers"
|
||||
"github.com/onsi/ginkgo"
|
||||
"github.com/onsi/gomega"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"math/rand"
|
||||
"github.com/ethereum/go-ethereum/statediff/testhelpers"
|
||||
"math/big"
|
||||
e "github.com/ethereum/go-ethereum/statediff/extractor"
|
||||
b "github.com/ethereum/go-ethereum/statediff/builder"
|
||||
"math/rand"
|
||||
)
|
||||
|
||||
var _ = ginkgo.Describe("Extractor", func() {
|
||||
var publisher testhelpers.MockPublisher
|
||||
var builder testhelpers.MockBuilder
|
||||
|
@ -1,13 +1,13 @@
|
||||
package publisher
|
||||
|
||||
import (
|
||||
"github.com/ethereum/go-ethereum/statediff/builder"
|
||||
"time"
|
||||
"os"
|
||||
"encoding/csv"
|
||||
"github.com/ethereum/go-ethereum/statediff/builder"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
"path/filepath"
|
||||
"time"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -20,7 +20,7 @@ var (
|
||||
"storageDiffPaths",
|
||||
}
|
||||
|
||||
timeStampFormat = "20060102150405.00000"
|
||||
timeStampFormat = "20060102150405.00000"
|
||||
deletedAccountAction = "deleted"
|
||||
createdAccountAction = "created"
|
||||
updatedAccountAction = "updated"
|
||||
@ -59,7 +59,7 @@ func (p *publisher) publishStateDiffToCSV(sd builder.StateDiff) error {
|
||||
data = append(data, row)
|
||||
}
|
||||
|
||||
for _, value := range data{
|
||||
for _, value := range data {
|
||||
err := writer.Write(value)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -149,4 +149,3 @@ func formatAccountDiffIncremental(accountDiff builder.AccountDiffIncremental, sd
|
||||
}
|
||||
return formattedAccountData
|
||||
}
|
||||
|
||||
|
@ -20,8 +20,8 @@
|
||||
package publisher
|
||||
|
||||
import (
|
||||
"github.com/ethereum/go-ethereum/statediff/builder"
|
||||
"github.com/ethereum/go-ethereum/statediff"
|
||||
"github.com/ethereum/go-ethereum/statediff/builder"
|
||||
)
|
||||
|
||||
type Publisher interface {
|
||||
|
@ -1,26 +1,26 @@
|
||||
package publisher_test
|
||||
|
||||
import (
|
||||
"github.com/onsi/ginkgo"
|
||||
"github.com/onsi/gomega"
|
||||
"os"
|
||||
"encoding/csv"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"github.com/ethereum/go-ethereum/statediff"
|
||||
"github.com/ethereum/go-ethereum/statediff/builder"
|
||||
p "github.com/ethereum/go-ethereum/statediff/publisher"
|
||||
"github.com/ethereum/go-ethereum/statediff/testhelpers"
|
||||
"github.com/onsi/ginkgo"
|
||||
"github.com/onsi/gomega"
|
||||
"io/ioutil"
|
||||
"github.com/ethereum/go-ethereum/statediff/builder"
|
||||
"github.com/ethereum/go-ethereum/statediff"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
var _ = ginkgo.Describe("Publisher", func() {
|
||||
var (
|
||||
tempDir = os.TempDir()
|
||||
tempDir = os.TempDir()
|
||||
testFilePrefix = "test-statediff"
|
||||
publisher p.Publisher
|
||||
dir string
|
||||
err error
|
||||
publisher p.Publisher
|
||||
dir string
|
||||
err error
|
||||
)
|
||||
|
||||
var expectedCreatedAccountRow = []string{
|
||||
|
@ -3,14 +3,14 @@ package service
|
||||
import (
|
||||
"github.com/ethereum/go-ethereum/core"
|
||||
"github.com/ethereum/go-ethereum/ethdb"
|
||||
"github.com/ethereum/go-ethereum/event"
|
||||
"github.com/ethereum/go-ethereum/p2p"
|
||||
"github.com/ethereum/go-ethereum/rpc"
|
||||
"github.com/ethereum/go-ethereum/event"
|
||||
"log"
|
||||
e "github.com/ethereum/go-ethereum/statediff/extractor"
|
||||
b "github.com/ethereum/go-ethereum/statediff/builder"
|
||||
"github.com/ethereum/go-ethereum/statediff"
|
||||
b "github.com/ethereum/go-ethereum/statediff/builder"
|
||||
e "github.com/ethereum/go-ethereum/statediff/extractor"
|
||||
p "github.com/ethereum/go-ethereum/statediff/publisher"
|
||||
"log"
|
||||
)
|
||||
|
||||
type StateDiffService struct {
|
||||
@ -43,7 +43,7 @@ func (StateDiffService) APIs() []rpc.API {
|
||||
return []rpc.API{}
|
||||
}
|
||||
|
||||
func (sds *StateDiffService) loop (sub event.Subscription, events chan core.ChainHeadEvent) {
|
||||
func (sds *StateDiffService) loop(sub event.Subscription, events chan core.ChainHeadEvent) {
|
||||
defer sub.Unsubscribe()
|
||||
|
||||
for {
|
||||
@ -53,7 +53,7 @@ func (sds *StateDiffService) loop (sub event.Subscription, events chan core.Chai
|
||||
log.Fatalf("Error getting chain head event from subscription.")
|
||||
}
|
||||
log.Println("doing something with an event", ev)
|
||||
previousBlock := ev.Block
|
||||
previousBlock := ev.Block
|
||||
//TODO: figure out the best way to get the previous block
|
||||
currentBlock := ev.Block
|
||||
sds.extractor.ExtractStateDiff(*previousBlock, *currentBlock)
|
||||
|
@ -1,8 +1,8 @@
|
||||
package testhelpers
|
||||
|
||||
import (
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"errors"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/statediff/builder"
|
||||
)
|
||||
|
||||
@ -11,9 +11,9 @@ var MockError = errors.New("mock error")
|
||||
type MockBuilder struct {
|
||||
OldStateRoot common.Hash
|
||||
NewStateRoot common.Hash
|
||||
BlockNumber int64
|
||||
BlockHash common.Hash
|
||||
stateDiff *builder.StateDiff
|
||||
BlockNumber int64
|
||||
BlockHash common.Hash
|
||||
stateDiff *builder.StateDiff
|
||||
builderError error
|
||||
}
|
||||
|
||||
@ -34,8 +34,8 @@ func (builder *MockBuilder) SetBuilderError(err error) {
|
||||
builder.builderError = err
|
||||
}
|
||||
|
||||
type MockPublisher struct{
|
||||
StateDiff *builder.StateDiff
|
||||
type MockPublisher struct {
|
||||
StateDiff *builder.StateDiff
|
||||
publisherError error
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
package testhelpers
|
||||
|
||||
import (
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/statediff/builder"
|
||||
"math/big"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"math/rand"
|
||||
)
|
||||
|
||||
@ -23,7 +23,7 @@ var (
|
||||
NewValue: &newStorage,
|
||||
OldValue: &oldStorage,
|
||||
}}
|
||||
address = common.HexToAddress("0xaE9BEa628c4Ce503DcFD7E305CaB4e29E7476592")
|
||||
address = common.HexToAddress("0xaE9BEa628c4Ce503DcFD7E305CaB4e29E7476592")
|
||||
CreatedAccountDiffs = map[common.Address]builder.AccountDiffEventual{address: {
|
||||
Nonce: builder.DiffUint64{
|
||||
NewValue: &NewNonceValue,
|
||||
@ -43,15 +43,15 @@ var (
|
||||
}}
|
||||
|
||||
UpdatedAccountDiffs = map[common.Address]builder.AccountDiffIncremental{address: {
|
||||
Nonce: builder.DiffUint64{
|
||||
Nonce: builder.DiffUint64{
|
||||
NewValue: &NewNonceValue,
|
||||
OldValue: &OldNonceValue,
|
||||
},
|
||||
Balance: builder.DiffBigInt{
|
||||
Balance: builder.DiffBigInt{
|
||||
NewValue: big.NewInt(NewBalanceValue),
|
||||
OldValue: big.NewInt(OldBalanceValue),
|
||||
},
|
||||
CodeHash: CodeHash,
|
||||
CodeHash: CodeHash,
|
||||
ContractRoot: builder.DiffString{
|
||||
NewValue: &ContractRoot,
|
||||
OldValue: &ContractRoot,
|
||||
|
Loading…
Reference in New Issue
Block a user