diff --git a/Makefile b/Makefile index 720a196e..49636c89 100644 --- a/Makefile +++ b/Makefile @@ -67,33 +67,19 @@ test: | $(GINKGO) $(GOOSE) integrationtest: | $(GINKGO) $(GOOSE) go vet ./... go fmt ./... - #export PGPASSWORD=$(DATABASE_PASSWORD) - #dropdb -h $(DATABASE_HOSTNAME) -p $(DATABASE_PORT) -U $(DATABASE_USER) --if-exists $(TEST_DB) - #createdb -h $(DATABASE_HOSTNAME) -p $(DATABASE_PORT) -U $(DATABASE_USER) $(TEST_DB) - #$(GOOSE) -dir db/migrations postgres "$(TEST_CONNECT_STRING)" up $(GINKGO) -r test/ -v .PHONY: test_local test_local: | $(GINKGO) $(GOOSE) go vet ./... go fmt ./... - dropdb -h $(HOST_NAME) -p $(PORT) -U $(USER) --if-exists $(TEST_DB) - createdb -h $(HOST_NAME) -p $(PORT) -U $(USER) $(TEST_DB) - $(GOOSE) -dir db/migrations postgres "$(TEST_CONNECT_STRING_LOCAL)" up - $(GOOSE) -dir db/migrations postgres "$(TEST_CONNECT_STRING_LOCAL)" reset - make migrate NAME=$(TEST_DB) - $(GINKGO) -r --skipPackage=test + ./scripts/run_unit_test.sh .PHONY: integrationtest_local integrationtest_local: | $(GINKGO) $(GOOSE) go vet ./... go fmt ./... - dropdb -h $(HOST_NAME) -p $(PORT) -U $(USER) --if-exists $(TEST_DB) - createdb -h $(HOST_NAME) -p $(PORT) -U $(USER) $(TEST_DB) - $(GOOSE) -dir db/migrations postgres "$(TEST_CONNECT_STRING_LOCAL)" up - $(GOOSE) -dir db/migrations postgres "$(TEST_CONNECT_STRING_LOCAL)" reset - make migrate NAME=$(TEST_DB) - $(GINKGO) -r integration_test/ + ./scripts/run_intregration_test.sh build: go fmt ./... diff --git a/pkg/eth/api_test.go b/pkg/eth/api_test.go index f4e8ad47..75152d11 100644 --- a/pkg/eth/api_test.go +++ b/pkg/eth/api_test.go @@ -194,7 +194,7 @@ var _ = Describe("API", func() { backend, err := eth.NewEthBackend(db, ð.Config{ ChainConfig: chainConfig, VmConfig: vm.Config{}, - RPCGasCap: big.NewInt(10000000000), + RPCGasCap: big.NewInt(10000000000), // Max gas capacity for a rpc call. }) Expect(err).ToNot(HaveOccurred()) api = eth.NewPublicEthAPI(backend, nil, false) diff --git a/scripts/run_intregration_test.sh b/scripts/run_intregration_test.sh new file mode 100755 index 00000000..f9056dc4 --- /dev/null +++ b/scripts/run_intregration_test.sh @@ -0,0 +1,21 @@ +set -e +set -o xtrace + +# Clear up existing docker images and volume. +docker-compose down --remove-orphans --volumes + +# Build and start the containers. +# Note: Build only if `ipld-eth-server` code is modified. Otherwise comment this line. +docker build -t ipld-eth-server_eth-server:latest . +docker-compose -f docker-compose.test.yml -f docker-compose.yml up -d db dapptools contract eth-server + +export PGPASSWORD=password +export DATABASE_USER=vdbm +export DATABASE_PORT=8077 +export DATABASE_PASSWORD=password +export DATABASE_HOSTNAME=127.0.0.1 + +# Wait for containers to be up and execute the integration test. +while [ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:8081)" != "200" ]; do echo "waiting for ipld-eth-server..." && sleep 5; done && \ + while [ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:8545)" != "200" ]; do echo "waiting for geth-statediff..." && sleep 5; done && \ + make integrationtest \ No newline at end of file diff --git a/scripts/run_unit_test.sh b/scripts/run_unit_test.sh new file mode 100755 index 00000000..1e15f03b --- /dev/null +++ b/scripts/run_unit_test.sh @@ -0,0 +1,2 @@ +docker-compose -f docker-compose.test.yml -f docker-compose.yml up -d db +PGPASSWORD=password DATABASE_USER=vdbm DATABASE_PORT=8077 DATABASE_PASSWORD=password DATABASE_HOSTNAME=127.0.0.1 make test \ No newline at end of file diff --git a/test/README.md b/test/README.md index 95e3b5f8..a2d93136 100644 --- a/test/README.md +++ b/test/README.md @@ -1,6 +1,15 @@ Spin up services: ``` -docker-compose -f docker-compose.test.yml -f ../docker-compose.yml up contract +docker-compose -f docker-compose.test.yml -f docker-compose.yml up -d db dapptools contract eth-server +``` +Running unit tests: +```bash +make test_local +``` + +Running intrgration test: +```bash +make integrationtest_local ``` \ No newline at end of file