Browse Source

Merge pull request #220 from hermeznetwork/test/fake-server

Add the ability to run the API forever when testing
feature/sql-semaphore1
Eduard S 3 years ago
committed by GitHub
parent
commit
721e5e8bf0
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 1 deletions
  1. +2
    -0
      README.md
  2. +7
    -0
      api/api_test.go
  3. +0
    -1
      api/swagger.yml

+ 2
- 0
README.md

@ -20,6 +20,8 @@ NOTE: `-p 1` forces execution of package test in serial. Otherwise they may be
executed in paralel and the test may find unexpected entries in the SQL executed in paralel and the test may find unexpected entries in the SQL
databse because it's shared among all tests. databse because it's shared among all tests.
- There is an extra temporal option that allows to run the API server through the Go tests. This should be removed once the API can be properly initialized, with data from the synchronizer and so on. To use this, run `FAKE_SERVER=yes POSTGRES_PASS=yourpasswordhere ETHCLIENT_DIAL_URL=yourethereumurlhere go test -timeout 0 ./api -p 1 -count 1 -v`
## Lint ## Lint
- Install [golangci-lint](https://golangci-lint.run) - Install [golangci-lint](https://golangci-lint.run)

+ 7
- 0
api/api_test.go

@ -654,6 +654,13 @@ func TestMain(m *testing.M) {
poolTxsToReceive: poolTxsToReceive, poolTxsToReceive: poolTxsToReceive,
router: router, router: router,
} }
// Fake server
if os.Getenv("FAKE_SERVER") == "yes" {
for {
log.Info("Running fake server until ^C is received")
time.Sleep(10 * time.Second)
}
}
// Run tests // Run tests
result := m.Run() result := m.Run()
// Stop server // Stop server

+ 0
- 1
api/swagger.yml

@ -1997,7 +1997,6 @@ components:
- Value - Value
- Fnc - Fnc
additionalProperties: false additionalProperties: false
example: {"Root":[0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"Siblings":[0,1,2],"OldKey":[0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"OldValue":[0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"IsOld0":true,"Key":[0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"Value":[0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"Fnc":0}
balance: balance:
$ref: '#/components/schemas/BigInt' $ref: '#/components/schemas/BigInt'
instantWithdrawn: instantWithdrawn:

Loading…
Cancel
Save