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