Skip to content

Commit

Permalink
Fix: linter and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aopoltorzhicky committed Nov 17, 2021
1 parent e8d7a89 commit 897b8ca
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 291 deletions.
204 changes: 16 additions & 188 deletions cmd/mempool/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,177 +25,32 @@ func TestLoad(t *testing.T) {
DataSources: map[string]config.DataSource{
"tzkt_mainnet": {
Kind: "tzkt",
URL: "https://staging.api.tzkt.io",
URL: "https://api.tzkt.io",
},
"node_mainnet": {
Kind: "tezos-node",
URL: "https://rpc.tzkt.io/mainnet",
URL: "https://mainnet-tezos.giganode.io",
},
},
Database: config.Database{
Kind: "sqlite",
Path: "mempool.db",
},
},
Mempool: Mempool{
Settings: Settings{
KeepOperations: 172800,
ExpiredAfter: 60,
KeepInChainBlocks: 10,
MempoolRequestInterval: 10,
RPCTimeout: 10,
},
Indexers: map[string]*Indexer{
"mainnet": {
Filters: Filters{
Kinds: []string{"transaction"},
Accounts: []string{"KT1Hkg5qeNhfwpKW4fXvq7HGZB9z2EnmCCA9"},
},
DataSource: MempoolDataSource{
Tzkt: "https://staging.api.tzkt.io",
RPC: []string{"https://rpc.tzkt.io/mainnet"},
},
},
},
},
},
}, {
name: "config 2",
filename: "./test/config2.yaml",
want: &Config{
Config: config.Config{
Version: "0.0.1",
Contracts: map[string]config.Contract{
"test": {
Address: "KT1Hkg5qeNhfwpKW4fXvq7HGZB9z2EnmCCA9",
},
},
Database: config.Database{
Kind: "sqlite",
Path: "mempool.db",
},
},
Mempool: Mempool{
Settings: Settings{
KeepOperations: 172800,
ExpiredAfter: 60,
KeepInChainBlocks: 10,
MempoolRequestInterval: 10,
RPCTimeout: 10,
},
Indexers: map[string]*Indexer{
"mainnet": {
Filters: Filters{
Kinds: []string{"transaction"},
Accounts: []string{"KT1Hkg5qeNhfwpKW4fXvq7HGZB9z2EnmCCA9"},
},
DataSource: MempoolDataSource{
Tzkt: "https://staging.api.tzkt.io",
RPC: []string{"https://rpc.tzkt.io/mainnet"},
},
},
},
},
},
}, {
name: "config 3",
filename: "./test/config3.yaml",
want: &Config{
Config: config.Config{
Version: "0.0.1",
Database: config.Database{
Kind: "sqlite",
Path: "mempool.db",
},
},
Mempool: Mempool{
Settings: Settings{
KeepOperations: 172800,
ExpiredAfter: 60,
KeepInChainBlocks: 10,
MempoolRequestInterval: 10,
RPCTimeout: 10,
},
Indexers: map[string]*Indexer{
"mainnet": {
Filters: Filters{
Kinds: []string{"transaction"},
Accounts: []string{"KT1Hkg5qeNhfwpKW4fXvq7HGZB9z2EnmCCA9"},
},
DataSource: MempoolDataSource{
Tzkt: "https://staging.api.tzkt.io",
RPC: []string{"https://rpc.tzkt.io/mainnet"},
},
},
},
},
},
}, {
name: "config 4",
filename: "./test/config4.yaml",
want: &Config{
Config: config.Config{
Version: "0.0.1",
Database: config.Database{
Kind: "sqlite",
Path: "mempool.db",
},
Contracts: map[string]config.Contract{
"test": {
Address: "KT1Hkg5qeNhfwpKW4fXvq7HGZB9z2EnmCCA9",
},
},
DataSources: map[string]config.DataSource{
"tzkt_mainnet": {
Kind: "tzkt",
URL: "https://staging.api.tzkt.io",
},
"node_mainnet": {
Kind: "tezos-node",
URL: "https://rpc.tzkt.io/mainnet",
},
},
},
Mempool: Mempool{
Settings: Settings{
KeepOperations: 172800,
ExpiredAfter: 60,
KeepInChainBlocks: 10,
MempoolRequestInterval: 10,
RPCTimeout: 10,
},
Indexers: map[string]*Indexer{
"mainnet": {
Filters: Filters{
Kinds: []string{"transaction"},
Accounts: []string{"KT1Hkg5qeNhfwpKW4fXvq7HGZB9z2EnmCCA9"},
},
DataSource: MempoolDataSource{
Tzkt: "https://staging.api.tzkt.io",
RPC: []string{"https://rpc.tzkt.io/mainnet"},
},
},
},
},
},
}, {
name: "config 5 without envs",
filename: "./test/config5.yaml",
want: &Config{
Config: config.Config{
Version: "0.0.1",
Database: config.Database{
Kind: "sqlite",
Path: "mempool.db",
Hasura: config.Hasura{
URL: "http://hasura:8080",
Secret: "admin_secret",
RowsLimit: 100,
EnableAggregations: true,
},
},
Mempool: Mempool{
Settings: Settings{
KeepOperations: 172800,
ExpiredAfter: 60,
ExpiredAfter: 120,
KeepInChainBlocks: 10,
MempoolRequestInterval: 10,
MempoolRequestInterval: 2,
RPCTimeout: 10,
GasStatsLifetime: 3600,
},
Indexers: map[string]*Indexer{
"mainnet": {
Expand All @@ -204,44 +59,17 @@ func TestLoad(t *testing.T) {
Accounts: []string{"KT1Hkg5qeNhfwpKW4fXvq7HGZB9z2EnmCCA9"},
},
DataSource: MempoolDataSource{
Tzkt: "https://staging.api.tzkt.io",
RPC: []string{"https://rpc.tzkt.io/mainnet"},
Tzkt: "https://api.tzkt.io",
RPC: []string{"https://mainnet-tezos.giganode.io"},
},
},
},
},
},
}, {
name: "config 5 with envs",
filename: "./test/config5.yaml",
envs: map[string]string{
"ACCOUNT": "test",
},
want: &Config{
Config: config.Config{
Version: "0.0.1",
Database: config.Database{
Kind: "sqlite",
Path: "mempool.db",
},
},
Mempool: Mempool{
Settings: Settings{
KeepOperations: 172800,
ExpiredAfter: 60,
KeepInChainBlocks: 10,
MempoolRequestInterval: 10,
RPCTimeout: 10,
},
Indexers: map[string]*Indexer{
"mainnet": {
"granadanet": {
Filters: Filters{
Kinds: []string{"transaction"},
Accounts: []string{"test"},
Kinds: []string{"endorsement"},
},
DataSource: MempoolDataSource{
Tzkt: "https://staging.api.tzkt.io",
RPC: []string{"https://rpc.tzkt.io/mainnet"},
Tzkt: "https://api.granadanet.tzkt.io",
RPC: []string{"https://testnet-tezos.giganode.io"},
},
},
},
Expand Down
4 changes: 0 additions & 4 deletions cmd/mempool/config/consts.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
package config

const (
tzktMaxSubscriptions = 50
)

// Data source kinds
const (
DataSourceKindTzKT = "tzkt"
Expand Down
37 changes: 29 additions & 8 deletions cmd/mempool/config/test/config1.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
version: 0.0.1

datasources:
tzkt_mainnet:
kind: tzkt
url: https://staging.api.tzkt.io
node_mainnet:
kind: tezos-node
url: https://rpc.tzkt.io/mainnet

mempool:
settings:
keep_operations_seconds: 172800
keep_in_chain_blocks: 10
mempool_request_interval_seconds: 2
rpc_timeout_seconds: 10
gas_stats_lifetime: 3600
expired_after_blocks: 120
indexers:
granadanet:
filters:
kinds:
- endorsement
datasources:
tzkt: https://api.granadanet.tzkt.io
rpc:
- https://testnet-tezos.giganode.io
mainnet:
filters:
kinds:
Expand All @@ -21,6 +28,20 @@ mempool:
rpc:
- node_mainnet

datasources:
tzkt_mainnet:
kind: tzkt
url: https://api.tzkt.io
node_mainnet:
kind: tezos-node
url: https://mainnet-tezos.giganode.io

database:
kind: sqlite
path: mempool.db

hasura:
url: http://hasura:8080
admin_secret: admin_secret
select_limit: 100
allow_aggregation: true
22 changes: 0 additions & 22 deletions cmd/mempool/config/test/config2.yaml

This file was deleted.

18 changes: 0 additions & 18 deletions cmd/mempool/config/test/config3.yaml

This file was deleted.

30 changes: 0 additions & 30 deletions cmd/mempool/config/test/config4.yaml

This file was deleted.

18 changes: 0 additions & 18 deletions cmd/mempool/config/test/config5.yaml

This file was deleted.

Loading

0 comments on commit 897b8ca

Please sign in to comment.