Skip to content

Commit

Permalink
Merge branch 'main' into gas-price
Browse files Browse the repository at this point in the history
  • Loading branch information
distractedm1nd committed Jan 23, 2024
2 parents a208063 + af417b0 commit 92211be
Show file tree
Hide file tree
Showing 33 changed files with 700 additions and 246 deletions.
29 changes: 8 additions & 21 deletions .github/workflows/go-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ concurrency:

jobs:
setup:
name: Setup
runs-on: ubuntu-latest
outputs:
debug: ${{ steps.debug.outputs.debug }}
Expand Down Expand Up @@ -104,11 +105,10 @@ jobs:
file: ./coverage.txt
name: coverage-${{ matrix.os }}

unit_race_test:
unit_test_race:
needs: [lint, go_mod_tidy_check]
name: Run Unit Tests with Race Detector
name: Unit Tests with Race Detector (ubuntu-latest)
runs-on: ubuntu-latest
continue-on-error: true

steps:
- uses: actions/checkout@v4
Expand All @@ -119,24 +119,11 @@ jobs:
go-version: ${{ inputs.go-version }}

- name: execute test run
run: make test-unit-race
run: make test-unit-race ENABLE_VERBOSE=${{ needs.setup.outputs.debug }}

integration_test:
name: Integration Tests
needs: [lint, go_mod_tidy_check]
name: Run Integration Tests
runs-on: ubuntu-latest
continue-on-error: true

steps:
- uses: actions/checkout@v4

- name: set up go
uses: actions/setup-go@v5
with:
go-version: ${{ inputs.go-version }}

- name: Integration Tests
run: make test-integration

- name: Integration Tests with Race Detector
run: make test-integration-race
uses: ./.github/workflows/integration-tests.yml
with:
go-version: ${{ inputs.go-version }}
115 changes: 115 additions & 0 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
name: Integration Tests

on:
workflow_call:
inputs:
go-version:
description: 'Go version'
required: true
type: string

jobs:
api_tests:
name: Integration Tests API
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: set up go
uses: actions/setup-go@v5
with:
go-version: ${{ inputs.go-version }}

- name: run API tests
run: make test-integration TAGS=api

blob_tests:
name: Integration Tests Blob
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: set up go
uses: actions/setup-go@v5
with:
go-version: ${{ inputs.go-version }}

- name: run blob tests
run: make test-integration TAGS=blob

fraud_tests:
name: Integration Tests Fraud
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: set up go
uses: actions/setup-go@v5
with:
go-version: ${{ inputs.go-version }}

- name: run fraud tests
run: make test-integration TAGS=fraud

nd_tests:
name: Integration Tests ND
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: set up go
uses: actions/setup-go@v5
with:
go-version: ${{ inputs.go-version }}

- name: run nd tests
run: make test-integration TAGS=nd

p2p_tests:
name: Integration Tests p2p
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: set up go
uses: actions/setup-go@v5
with:
go-version: ${{ inputs.go-version }}

- name: run p2p tests
run: make test-integration TAGS=p2p

reconstruction_tests:
name: Integration Tests Reconstruction
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: set up go
uses: actions/setup-go@v5
with:
go-version: ${{ inputs.go-version }}

- name: run reconstruction tests
run: make test-integration SHORT=true TAGS=reconstruction

sync_tests:
name: Integration Tests Sync
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: set up go
uses: actions/setup-go@v5
with:
go-version: ${{ inputs.go-version }}

- name: run sync tests
run: make test-integration SHORT=true TAGS=sync
27 changes: 12 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ PROJECTNAME=$(shell basename "$(PWD)")
DIR_FULLPATH=$(shell pwd)
versioningPath := "github.com/celestiaorg/celestia-node/nodebuilder/node"
LDFLAGS=-ldflags="-X '$(versioningPath).buildTime=$(shell date)' -X '$(versioningPath).lastCommit=$(shell git rev-parse HEAD)' -X '$(versioningPath).semanticVersion=$(shell git describe --tags --dirty=-dev 2>/dev/null || git rev-parse --abbrev-ref HEAD)'"
TAGS=integration
SHORT=
ifeq (${PREFIX},)
PREFIX := /usr/local
endif
Expand All @@ -13,6 +15,11 @@ else
VERBOSE =
LOG_AND_FILTER =
endif
ifeq ($(SHORT),true)
INTEGRATION_RUN_LENGTH = -short
else
INTEGRATION_RUN_LENGTH =
endif
## help: Get more info on make commands.
help: Makefile
@echo " Choose a command run in "$(PROJECTNAME)":"
Expand Down Expand Up @@ -118,29 +125,21 @@ test-unit:
## test-unit-race: Running unit tests with data race detector
test-unit-race:
@echo "--> Running unit tests with data race detector"
@go test -race `go list ./... | grep -v nodebuilder/tests`
@go test $(VERBOSE) -race -covermode=atomic -coverprofile=coverage.txt `go list ./... | grep -v nodebuilder/tests` $(LOG_AND_FILTER)
.PHONY: test-unit-race

## test-integration: Running /integration tests located in nodebuilder/tests
test-integration:
@echo "--> Running integrations tests"
@go test ./nodebuilder/tests
@echo "--> Running integrations tests $(VERBOSE) -tags=$(TAGS) $(INTEGRATION_RUN_LENGTH)"
@go test $(VERBOSE) -tags=$(TAGS) $(INTEGRATION_RUN_LENGTH) ./nodebuilder/tests
.PHONY: test-integration

## test-integration-race: Running integration tests with data race detector located in node/tests
test-integration-race:
@echo "--> Running integration tests with data race detector"
@go test -race ./nodebuilder/tests
@echo "--> Running integration tests with data race detector -tags=$(TAGS)"
@go test -race -tags=$(TAGS) ./nodebuilder/tests
.PHONY: test-integration-race

## test: Running both unit and integrations tests
test:
@echo "--> Running all tests without data race detector"
@go test ./...
@echo "--> Running all tests with data race detector"
@go test -race ./...
.PHONY: test

## benchmark: Running all benchmarks
benchmark:
@echo "--> Running benchmarks"
Expand All @@ -164,7 +163,6 @@ pb-gen:
done;
.PHONY: pb-gen


## openrpc-gen: Generate OpenRPC spec for Celestia-Node's RPC api
openrpc-gen:
@echo "--> Generating OpenRPC spec"
Expand Down Expand Up @@ -221,7 +219,6 @@ goreleaser-release:
.PHONY: goreleaser-release

# Copied from https://github.com/dgraph-io/badger/blob/main/Makefile

USER_ID = $(shell id -u)
HAS_JEMALLOC = $(shell test -f /usr/local/lib/libjemalloc.a && echo "jemalloc")
JEMALLOC_URL = "https://github.com/jemalloc/jemalloc/releases/download/5.2.1/jemalloc-5.2.1.tar.bz2"
Expand Down
73 changes: 73 additions & 0 deletions api/gateway/bindings.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
package gateway

import (
"fmt"
"net/http"
)

func (h *Handler) RegisterEndpoints(rpc *Server) {
// state endpoints
rpc.RegisterHandlerFunc(
fmt.Sprintf("%s/{%s}", balanceEndpoint, addrKey),
h.handleBalanceRequest,
http.MethodGet,
)

rpc.RegisterHandlerFunc(
submitTxEndpoint,
h.handleSubmitTx,
http.MethodPost,
)

rpc.RegisterHandlerFunc(
healthEndpoint,
h.handleHealthRequest,
http.MethodGet,
)

// share endpoints
rpc.RegisterHandlerFunc(
fmt.Sprintf(
"%s/{%s}/height/{%s}",
namespacedSharesEndpoint,
namespaceKey,
heightKey,
),
h.handleSharesByNamespaceRequest,
http.MethodGet,
)

rpc.RegisterHandlerFunc(
fmt.Sprintf("%s/{%s}", namespacedSharesEndpoint, namespaceKey),
h.handleSharesByNamespaceRequest,
http.MethodGet,
)

rpc.RegisterHandlerFunc(
fmt.Sprintf("%s/{%s}/height/{%s}", namespacedDataEndpoint, namespaceKey, heightKey),
h.handleDataByNamespaceRequest,
http.MethodGet,
)

rpc.RegisterHandlerFunc(
fmt.Sprintf("%s/{%s}", namespacedDataEndpoint, namespaceKey),
h.handleDataByNamespaceRequest,
http.MethodGet,
)

// DAS endpoints
rpc.RegisterHandlerFunc(
fmt.Sprintf("%s/{%s}", heightAvailabilityEndpoint, heightKey),
h.handleHeightAvailabilityRequest,
http.MethodGet,
)

// header endpoints
rpc.RegisterHandlerFunc(
fmt.Sprintf("%s/{%s}", headerByHeightEndpoint, heightKey),
h.handleHeaderRequest,
http.MethodGet,
)

rpc.RegisterHandlerFunc(headEndpoint, h.handleHeadRequest, http.MethodGet)
}
Loading

0 comments on commit 92211be

Please sign in to comment.