Merge pull request #56 from 8thlight/introduce-pkg
Nest packages under pkg
This commit is contained in:
commit
6a1589bafa
2
.gitignore
vendored
2
.gitignore
vendored
@ -2,4 +2,4 @@
|
||||
Gododir/godobin-*
|
||||
test_data_dir/
|
||||
vendor/
|
||||
config/environments/*.toml
|
||||
pkg/config/environments/*.toml
|
||||
|
@ -8,6 +8,6 @@ before_script:
|
||||
- createdb vulcanize_private
|
||||
- psql vulcanize_private < migrations/schema.sql
|
||||
script:
|
||||
- go test -v ./blockchain_listener ./core ./geth ./observers
|
||||
- go test -v ./pkg/...
|
||||
notifications:
|
||||
email: false
|
||||
|
@ -5,7 +5,7 @@ import (
|
||||
|
||||
"fmt"
|
||||
|
||||
"github.com/8thlight/vulcanizedb/config"
|
||||
"github.com/8thlight/vulcanizedb/pkg/config"
|
||||
do "gopkg.in/godo.v2"
|
||||
)
|
||||
|
||||
|
@ -71,7 +71,7 @@ The default location for Ethereum is:
|
||||
You can create configuration files for additional environments.
|
||||
|
||||
* Among other things, it will require the IPC file path
|
||||
* See `config/environments/private.toml` for an example
|
||||
* See `pkg/config/environments/private.toml` for an example
|
||||
* You will need to do this if you want to run a node connecting to the public blockchain
|
||||
|
||||
## Running the Tests
|
||||
@ -81,8 +81,8 @@ You can create configuration files for additional environments.
|
||||
In order to run the integration tests, you will need to run them against a real blockchain.
|
||||
|
||||
1. Run `./scripts/start_private_blockchain` as a separate process.
|
||||
2. `go test ./...`
|
||||
2. `go test ./...` to run all tests.
|
||||
|
||||
### Unit Tests
|
||||
|
||||
1. `go test ./core`
|
||||
1. `go test ./pkg/...`
|
||||
|
@ -6,12 +6,12 @@ import (
|
||||
|
||||
"flag"
|
||||
|
||||
"github.com/8thlight/vulcanizedb/blockchain_listener"
|
||||
"github.com/8thlight/vulcanizedb/config"
|
||||
"github.com/8thlight/vulcanizedb/core"
|
||||
"github.com/8thlight/vulcanizedb/geth"
|
||||
"github.com/8thlight/vulcanizedb/observers"
|
||||
"github.com/8thlight/vulcanizedb/repositories"
|
||||
"github.com/8thlight/vulcanizedb/pkg/blockchain_listener"
|
||||
"github.com/8thlight/vulcanizedb/pkg/config"
|
||||
"github.com/8thlight/vulcanizedb/pkg/core"
|
||||
"github.com/8thlight/vulcanizedb/pkg/geth"
|
||||
"github.com/8thlight/vulcanizedb/pkg/observers"
|
||||
"github.com/8thlight/vulcanizedb/pkg/repositories"
|
||||
"github.com/jmoiron/sqlx"
|
||||
)
|
||||
|
||||
|
@ -1,25 +1,15 @@
|
||||
package integration_test
|
||||
|
||||
import (
|
||||
"path"
|
||||
"runtime"
|
||||
|
||||
"github.com/8thlight/vulcanizedb/blockchain_listener"
|
||||
"github.com/8thlight/vulcanizedb/core"
|
||||
"github.com/8thlight/vulcanizedb/fakes"
|
||||
"github.com/8thlight/vulcanizedb/geth"
|
||||
"github.com/8thlight/vulcanizedb/pkg/blockchain_listener"
|
||||
"github.com/8thlight/vulcanizedb/pkg/config"
|
||||
"github.com/8thlight/vulcanizedb/pkg/core"
|
||||
"github.com/8thlight/vulcanizedb/pkg/fakes"
|
||||
"github.com/8thlight/vulcanizedb/pkg/geth"
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
var (
|
||||
_, filename, _, _ = runtime.Caller(0)
|
||||
)
|
||||
|
||||
func RunTimePath() string {
|
||||
return path.Join(path.Dir(filename), "../")
|
||||
}
|
||||
|
||||
var _ = Describe("Reading from the Geth blockchain", func() {
|
||||
|
||||
var listener blockchain_listener.BlockchainListener
|
||||
@ -27,7 +17,8 @@ var _ = Describe("Reading from the Geth blockchain", func() {
|
||||
|
||||
BeforeEach(func() {
|
||||
observer = fakes.NewFakeBlockchainObserver()
|
||||
blockchain := geth.NewGethBlockchain(RunTimePath() + "/test_data_dir/geth.ipc")
|
||||
cfg := config.NewConfig("private")
|
||||
blockchain := geth.NewGethBlockchain(cfg.Client.IPCPath)
|
||||
observers := []core.BlockchainObserver{observer}
|
||||
listener = blockchain_listener.NewBlockchainListener(blockchain, observers)
|
||||
})
|
||||
|
@ -1,6 +1,6 @@
|
||||
package blockchain_listener
|
||||
|
||||
import "github.com/8thlight/vulcanizedb/core"
|
||||
import "github.com/8thlight/vulcanizedb/pkg/core"
|
||||
|
||||
type BlockchainListener struct {
|
||||
inputBlocks chan core.Block
|
@ -1,9 +1,9 @@
|
||||
package blockchain_listener_test
|
||||
|
||||
import (
|
||||
"github.com/8thlight/vulcanizedb/blockchain_listener"
|
||||
"github.com/8thlight/vulcanizedb/core"
|
||||
"github.com/8thlight/vulcanizedb/fakes"
|
||||
"github.com/8thlight/vulcanizedb/pkg/blockchain_listener"
|
||||
"github.com/8thlight/vulcanizedb/pkg/core"
|
||||
"github.com/8thlight/vulcanizedb/pkg/fakes"
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
@ -21,7 +21,7 @@ type Config struct {
|
||||
|
||||
func NewConfig(environment string) Config {
|
||||
filenameWithExtension := fmt.Sprintf("%s.toml", environment)
|
||||
absolutePath := filepath.Join(ProjectRoot(), "config", "environments", filenameWithExtension)
|
||||
absolutePath := filepath.Join(ProjectRoot(), "pkg", "config", "environments", filenameWithExtension)
|
||||
config := parseConfigFile(absolutePath)
|
||||
config.Client.IPCPath = filepath.Join(ProjectRoot(), config.Client.IPCPath)
|
||||
return config
|
||||
@ -29,7 +29,7 @@ func NewConfig(environment string) Config {
|
||||
|
||||
func ProjectRoot() string {
|
||||
var _, filename, _, _ = runtime.Caller(0)
|
||||
return path.Join(path.Dir(filename), "../")
|
||||
return path.Join(path.Dir(filename), "..", "..")
|
||||
}
|
||||
|
||||
func parseConfigFile(configfile string) Config {
|
@ -3,7 +3,7 @@ package config_test
|
||||
import (
|
||||
"path/filepath"
|
||||
|
||||
"github.com/8thlight/vulcanizedb/config"
|
||||
"github.com/8thlight/vulcanizedb/pkg/config"
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
@ -1,6 +1,6 @@
|
||||
package fakes
|
||||
|
||||
import "github.com/8thlight/vulcanizedb/core"
|
||||
import "github.com/8thlight/vulcanizedb/pkg/core"
|
||||
|
||||
type Blockchain struct {
|
||||
outputBlocks chan core.Block
|
@ -1,6 +1,6 @@
|
||||
package fakes
|
||||
|
||||
import "github.com/8thlight/vulcanizedb/core"
|
||||
import "github.com/8thlight/vulcanizedb/pkg/core"
|
||||
|
||||
type BlockchainObserver struct {
|
||||
CurrentBlocks []core.Block
|
@ -1,7 +1,7 @@
|
||||
package geth
|
||||
|
||||
import (
|
||||
"github.com/8thlight/vulcanizedb/core"
|
||||
"github.com/8thlight/vulcanizedb/pkg/core"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
@ -3,7 +3,7 @@ package geth_test
|
||||
import (
|
||||
"math/big"
|
||||
|
||||
"github.com/8thlight/vulcanizedb/geth"
|
||||
"github.com/8thlight/vulcanizedb/pkg/geth"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
@ -3,7 +3,7 @@ package geth
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/8thlight/vulcanizedb/core"
|
||||
"github.com/8thlight/vulcanizedb/pkg/core"
|
||||
"github.com/ethereum/go-ethereum"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/ethereum/go-ethereum/ethclient"
|
@ -1,8 +1,8 @@
|
||||
package observers
|
||||
|
||||
import (
|
||||
"github.com/8thlight/vulcanizedb/core"
|
||||
"github.com/8thlight/vulcanizedb/repositories"
|
||||
"github.com/8thlight/vulcanizedb/pkg/core"
|
||||
"github.com/8thlight/vulcanizedb/pkg/repositories"
|
||||
)
|
||||
|
||||
type BlockchainDbObserver struct {
|
@ -1,9 +1,9 @@
|
||||
package observers_test
|
||||
|
||||
import (
|
||||
"github.com/8thlight/vulcanizedb/core"
|
||||
"github.com/8thlight/vulcanizedb/observers"
|
||||
"github.com/8thlight/vulcanizedb/repositories"
|
||||
"github.com/8thlight/vulcanizedb/pkg/core"
|
||||
"github.com/8thlight/vulcanizedb/pkg/observers"
|
||||
"github.com/8thlight/vulcanizedb/pkg/repositories"
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
@ -4,7 +4,7 @@ import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/8thlight/vulcanizedb/core"
|
||||
"github.com/8thlight/vulcanizedb/pkg/core"
|
||||
)
|
||||
|
||||
type BlockchainLoggingObserver struct{}
|
@ -1,7 +1,7 @@
|
||||
package repositories
|
||||
|
||||
import (
|
||||
"github.com/8thlight/vulcanizedb/core"
|
||||
"github.com/8thlight/vulcanizedb/pkg/core"
|
||||
)
|
||||
|
||||
type InMemory struct {
|
@ -1,8 +1,8 @@
|
||||
package repositories_test
|
||||
|
||||
import (
|
||||
"github.com/8thlight/vulcanizedb/core"
|
||||
"github.com/8thlight/vulcanizedb/repositories"
|
||||
"github.com/8thlight/vulcanizedb/pkg/core"
|
||||
"github.com/8thlight/vulcanizedb/pkg/repositories"
|
||||
_ "github.com/lib/pq"
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
@ -3,7 +3,7 @@ package repositories
|
||||
import (
|
||||
"database/sql"
|
||||
|
||||
"github.com/8thlight/vulcanizedb/core"
|
||||
"github.com/8thlight/vulcanizedb/pkg/core"
|
||||
"github.com/jmoiron/sqlx"
|
||||
_ "github.com/lib/pq"
|
||||
)
|
@ -1,9 +1,9 @@
|
||||
package repositories_test
|
||||
|
||||
import (
|
||||
"github.com/8thlight/vulcanizedb/config"
|
||||
"github.com/8thlight/vulcanizedb/core"
|
||||
"github.com/8thlight/vulcanizedb/repositories"
|
||||
"github.com/8thlight/vulcanizedb/pkg/config"
|
||||
"github.com/8thlight/vulcanizedb/pkg/core"
|
||||
"github.com/8thlight/vulcanizedb/pkg/repositories"
|
||||
"github.com/jmoiron/sqlx"
|
||||
_ "github.com/lib/pq"
|
||||
. "github.com/onsi/ginkgo"
|
@ -1,6 +1,6 @@
|
||||
package repositories
|
||||
|
||||
import "github.com/8thlight/vulcanizedb/core"
|
||||
import "github.com/8thlight/vulcanizedb/pkg/core"
|
||||
|
||||
type Repository interface {
|
||||
CreateBlock(block core.Block)
|
Loading…
Reference in New Issue
Block a user