Skip to content

Commit

Permalink
Add test scripts.
Browse files Browse the repository at this point in the history
  • Loading branch information
arijitAD committed Jun 14, 2021
1 parent 491d779 commit e7744cc
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 18 deletions.
18 changes: 2 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 ./...
Expand Down
2 changes: 1 addition & 1 deletion pkg/eth/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ var _ = Describe("API", func() {
backend, err := eth.NewEthBackend(db, &eth.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)
Expand Down
21 changes: 21 additions & 0 deletions scripts/run_intregration_test.sh
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions scripts/run_unit_test.sh
Original file line number Diff line number Diff line change
@@ -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
11 changes: 10 additions & 1 deletion test/README.md
Original file line number Diff line number Diff line change
@@ -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
```

0 comments on commit e7744cc

Please sign in to comment.