Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,36 @@ SUMSUB_APP_TOKEN=
SUMSUB_SECRET_KEY=
SUMSUB_JWT_SECRET_KEY=

VERIFICATION_PROVIDER=sumsub
LEGACY_SUMSUB_WEBHOOKS_ENABLED=true

DIDIT_API_URL=
DIDIT_API_KEY=
DIDIT_ENVIRONMENT=sandbox
DIDIT_APPLICATION_ID=
DIDIT_CALLBACK_URL=
DIDIT_KYC_WORKFLOW_ID=
DIDIT_KYC_WORKFLOW_VERSION=
DIDIT_KYB_WORKFLOW_ID=
DIDIT_KYB_WORKFLOW_VERSION=
DIDIT_WEBHOOK_SECRET=
DIDIT_PREVIOUS_WEBHOOK_SECRET=

DIDIT_KYC_QUESTIONNAIRE_ID=
DIDIT_KYC_QUESTIONNAIRE_VERSION=
DIDIT_KYC_FIRST_NAME_QUESTION_ID=
DIDIT_KYC_LAST_NAME_QUESTION_ID=
DIDIT_KYC_TAX_ID_QUESTION_ID=
DIDIT_KYC_ADDRESS_QUESTION_ID=
DIDIT_KYC_CITY_QUESTION_ID=
DIDIT_KYC_POSTAL_CODE_QUESTION_ID=
DIDIT_KYC_STATE_QUESTION_ID=
DIDIT_KYC_COUNTRY_QUESTION_ID=
DIDIT_KYC_ADDITIONAL_REQUIRED_QUESTION_IDS=

DIDIT_KYB_QUESTIONNAIRE_ID=
DIDIT_KYB_QUESTIONNAIRE_VERSION=
DIDIT_KYB_ADDITIONAL_REQUIRED_QUESTION_IDS=

EMAIL_TEMPLATES_PATH="./templates/html/"
EE_CHAINSTORE_API_URL=
63 changes: 63 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Test

on:
pull_request:

jobs:
test:
runs-on: ubuntu-latest

services:
postgres:
image: postgres:15-alpine
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: ratio1_test
ports:
- 5432:5432
options: >-
--health-cmd "pg_isready -U postgres -d ratio1_test"
--health-interval 5s
--health-timeout 5s
--health-retries 10

env:
RATIO1_STORAGE_TEST_DATABASE: "1"
RATIO1_SERVICE_TEST_DATABASE: "1"
RATIO1_TEST_DATABASE_HOST: 127.0.0.1
RATIO1_TEST_DATABASE_PORT: "5432"
RATIO1_TEST_DATABASE_USER: postgres
RATIO1_TEST_DATABASE_PASSWORD: postgres
RATIO1_TEST_DATABASE_NAME: ratio1_test

steps:
- uses: actions/checkout@v4

- uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true

- name: Download dependencies
run: go mod download

- name: Run model and storage tests
run: go test ./model ./storage -count=1

- name: Run verification policy and HTTP contract tests
run: |
go test ./config -count=1
go test ./service -run 'Test(Didit|NewDidit|MapDidit|Verification|GrandfatheredSumsub|SumsubMonitoring|ProjectDidit)' -count=1
go test ./proxy/handlers -run 'Test(DiditWebhook|SumsubWebhook)' -count=1

- name: Run verification workflow database tests
run: go test ./service -run 'Test(RetryableTerminalDiditSessionCreatesOneReplacementConcurrently|StoredSumsubMonitoringEventIsRestartRecoverable)' -count=1

- name: Compile runtime packages
run: go test ./model ./config ./storage ./service ./proxy/handlers ./proxy -run '^$'

- name: Run persistence contention tests
run: |
go test -race ./storage -run 'Test(UpdateAccountAndCreateKyc|CreateOrUpdateKycConcurrentCreateKeepsOneRow|CreateVerificationWebhookEventConcurrentDuplicateHasOneWinner|WithVerificationCreationLockSerializesSameVerification)' -count=3
go test -race ./service -run '^TestRetryableTerminalDiditSessionCreatesOneReplacementConcurrently$' -count=3
10 changes: 5 additions & 5 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"net/http"
"os"
"os/signal"
"syscall"

"github.com/NaeuralEdgeProtocol/ratio1-backend/config"
"github.com/NaeuralEdgeProtocol/ratio1-backend/proxy"
Expand Down Expand Up @@ -116,20 +117,19 @@ func startApi(ctx *cli.Context) error {
}
server := api.Run()

waitForGracefulShutdown(server)
waitForGracefulShutdown(api, server)

return nil
}

func waitForGracefulShutdown(server *http.Server) {
func waitForGracefulShutdown(api *proxy.WebServer, server *http.Server) {
quit := make(chan os.Signal)
signal.Notify(quit, os.Interrupt, os.Kill)
signal.Notify(quit, os.Interrupt, syscall.SIGTERM)
<-quit

ctx, cancel := context.WithTimeout(context.Background(), backgroundContextTimeout)
defer cancel()
if err := server.Shutdown(ctx); err != nil {
if err := api.Shutdown(ctx, server); err != nil {
panic(err)
}
_ = server.Close()
}
Loading
Loading