From 6c206b88d8bea41704720e84881c04a9a88ee08d Mon Sep 17 00:00:00 2001 From: Victor Baranov Date: Thu, 15 Aug 2019 16:40:05 +0300 Subject: [PATCH 01/12] Need recompile column in the env vars table --- CHANGELOG.md | 1 + docs/env-variables.md | 98 ++++++++++++++++++++++--------------------- 2 files changed, 51 insertions(+), 48 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f006769dbf..c9614afa96 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ - [#2538](https://github.com/poanetwork/blockscout/pull/2538) - fetch the last not empty coin balance records ### Chore +- [#2577](https://github.com/poanetwork/blockscout/pull/2577) - Need recompile column in the env vars table - [#2566](https://github.com/poanetwork/blockscout/pull/2566) - upgrade absinthe phoenix diff --git a/docs/env-variables.md b/docs/env-variables.md index 60c9eee442..a0fae07bc3 100644 --- a/docs/env-variables.md +++ b/docs/env-variables.md @@ -14,52 +14,54 @@ $ export NETWORK=POA ``` -| Variable | Required | Description | Default | Version | -| --- | --- | --- | ---| --- | -| `NETWORK`| :white_check_mark: | Environment variable for the main EVM network such as Ethereum Network or POA Network | POA Network | all | -| `SUBNETWORK` | :white_check_mark: | Environment variable for the subnetwork such as Core or Sokol Network | Sokol Testnet | all | -| `NETWORK_ICON` | :white_check_mark: | Environment variable for the main network icon or testnet icon. Two options are `_test_network_icon.html` and `_network_icon.html` | `_test_network_icon.html` | all | -| `LOGO` | :white_check_mark: | Environment variable for the logo image location. The logo files names for different chains can be found [here](https://github.com/poanetwork/blockscout/tree/master/apps/block_scout_web/assets/static/images) | /images/blockscout_logo.svg | all | -| `ETHEREUM_JSONRPC_VARIANT` | :white_check_mark: | This environment variable is used to tell the application which RPC Client the node is using (i.e. Geth, Parity, or Ganache) | parity | all | -| `ETHEREUM_JSONRPC_HTTP_URL` | :white_check_mark: | The RPC endpoint used to fetch blocks, transactions, receipts, tokens. | localhost:8545 | all | -| `ETHEREUM_JSONRPC_TRACE_URL` | | The RPC endpoint specifically for the Geth/Parity client used by trace_block and trace_replayTransaction. This can be used to designate a tracing node. | localhost:8545 | all | -| `ETHEREUM_JSONRPC_WS_URL` | :white_check_mark: | The WebSockets RPC endpoint used to subscribe to the `newHeads` subscription alerting the indexer to fetch new blocks. | ws://localhost:8546 | all | -| `NETWORK_PATH` | | Used to set a network path other than what is displayed in the root directory. An example would be to add /eth/mainnet/ to the root directory. | (empty) | all | -| `SECRET_KEY_BASE` | :white_check_mark: | Use mix phx.gen.secret to generate a new Secret Key Base string to protect production assets. | (empty) | all | -| `CHECK_ORIGIN` | | Used to check the origin of requests when the origin header is present. It defaults to false. In case of true, it will check against the host value. | false | all | -| `PORT` | :white_check_mark: | Default port the application runs on is 4000 | 4000 | all | -| `COIN` | :white_check_mark: | The coin here is checked via the Coinmarketcap API to obtain USD prices on graphs and other areas of the UI | POA | all | -| `METADATA_CONTRACT` | | This environment variable is specifically used by POA Network to obtain Validators information to display in the UI. | (empty) | all | -| `VALIDATORS_CONTRACT` | | This environment variable is specifically used by POA Network to obtain the Emission Fund contract. | (empty) | all | -| `SUPPLY_MODULE` | | This environment variable is used by the xDai Chain in order to tell the application how to calculate the total supply of the chain. | false | all | -| `SOURCE_MODULE` | | This environment variable is used to calculate the exchange rate and is specifically used by the xDai Chain. | false | all | -| `DATABASE_URL` | | Production environment variable to define the Database endpoint. | (empty) | all | -| `POOL_SIZE` | | Production environment variable to define the number of database connections allowed. | 20 | all | -| `ECTO_USE_SSL` | | Production environment variable to use SSL on Ecto queries. | true | all | -| `DATADOG_HOST` | | Host configuration setting for [Datadog integration](https://docs.datadoghq.com/integrations/) | (empty) | all | -| `DATADOG_PORT` | | Port configuration setting for [Datadog integration](https://docs.datadoghq.com/integrations/). | (empty} | all | +| Variable | Required | Description | Default | Version | Need recompile | +| --- | --- | --- | ---| --- | --- | +| `NETWORK`| :white_check_mark: | Environment variable for the main EVM network such as Ethereum Network or POA Network | POA Network | all | | +| `SUBNETWORK` | :white_check_mark: | Environment variable for the subnetwork such as Core or Sokol Network | Sokol Testnet | all | | +| `NETWORK_ICON` | :white_check_mark: | Environment variable for the main network icon or testnet icon. Two options are `_test_network_icon.html` and `_network_icon.html` | `_test_network_icon.html` | all | | +| `LOGO` | :white_check_mark: | Environment variable for the logo image location. The logo files names for different chains can be found [here](https://github.com/poanetwork/blockscout/tree/master/apps/block_scout_web/assets/static/images) | /images/blockscout_logo.svg | all | | +| `ETHEREUM_JSONRPC_VARIANT` | :white_check_mark: | This environment variable is used to tell the application which RPC Client the node is using (i.e. Geth, Parity, or Ganache) | parity | all | | +| `ETHEREUM_JSONRPC_HTTP_URL` | :white_check_mark: | The RPC endpoint used to fetch blocks, transactions, receipts, tokens. | localhost:8545 | all | | +| `ETHEREUM_JSONRPC_TRACE_URL` | | The RPC endpoint specifically for the Geth/Parity client used by trace_block and trace_replayTransaction. This can be used to designate a tracing node. | localhost:8545 | all | | +| `ETHEREUM_JSONRPC_WS_URL` | :white_check_mark: | The WebSockets RPC endpoint used to subscribe to the `newHeads` subscription alerting the indexer to fetch new blocks. | ws://localhost:8546 | all | | +| `NETWORK_PATH` | | Used to set a network path other than what is displayed in the root directory. An example would be to add /eth/mainnet/ to the root directory. | (empty) | all | | +| `SECRET_KEY_BASE` | :white_check_mark: | Use mix phx.gen.secret to generate a new Secret Key Base string to protect production assets. | (empty) | all | | +| `CHECK_ORIGIN` | | Used to check the origin of requests when the origin header is present. It defaults to false. In case of true, it will check against the host value. | false | all | | +| `PORT` | :white_check_mark: | Default port the application runs on is 4000 | 4000 | all | | +| `COIN` | :white_check_mark: | The coin here is checked via the Coinmarketcap API to obtain USD prices on graphs and other areas of the UI | POA | all | | +| `METADATA_CONTRACT` | | This environment variable is specifically used by POA Network to obtain Validators information to display in the UI. | (empty) | all | | +| `VALIDATORS_CONTRACT` | | This environment variable is specifically used by POA Network to obtain the Emission Fund contract. | (empty) | all | | +| `SUPPLY_MODULE` | | This environment variable is used by the xDai Chain in order to tell the application how to calculate the total supply of the chain. | false | all | | +| `SOURCE_MODULE` | | This environment variable is used to calculate the exchange rate and is specifically used by the xDai Chain. | false | all | | +| `DATABASE_URL` | | Production environment variable to define the Database endpoint. | (empty) | all | | +| `POOL_SIZE` | | Production environment variable to define the number of database connections allowed. | 20 | all | | +| `ECTO_USE_SSL` | | Production environment variable to use SSL on Ecto queries. | true | all | | +| `DATADOG_HOST` | | Host configuration setting for [Datadog integration](https://docs.datadoghq.com/integrations/) | (empty) | all | | +| `DATADOG_PORT` | | Port configuration setting for [Datadog integration](https://docs.datadoghq.com/integrations/). | (empty} | all | | | `SPANDEX_BATCH_SIZE` | | [Spandex](https://github.com/spandex-project/spandex) and Datadog configuration setting. | (empty) | all | -| `SPANDEX_SYNC_THRESHOLD` | | [Spandex](https://github.com/spandex-project/spandex) and Datadog configuration setting. | (empty) | all | -| `HEART_BEAT_TIMEOUT` | | Production environment variable to restart the application in the event of a crash. | 30 | all | -| `HEART_COMMAND` | | Production environment variable to restart the application in the event of a crash. | systemctl restart explorer.service | all | -| `BLOCKSCOUT_VERSION` | | Added to the footer to signify the current BlockScout version. | (empty) | v1.3.4+ | -| `RELEASE_LINK` | | The link to Blockscout release notes in the footer. | https: //github.com/poanetwork/
blockscout/releases/
tag/${BLOCKSCOUT_VERSION} | v1.3.5+ | -| `ELIXIR_VERSION` | | Elixir version to install on the node before Blockscout deploy. | (empty) | all | -| `BLOCK_TRANSFORMER` | | Transformer for blocks: base or clique. | base | v1.3.4+ | -| `GRAPHIQL _TRANSACTION` | | Default transaction in query to GraphiQL. | (empty) | v1.3.4+ | -| `FIRST_BLOCK` | | The block number, where indexing begins from. | 0 | v1.3.8+ | -| `LAST_BLOCK` | | The block number, where indexing stops. | (empty) | v2.0.3+ | -| `TXS_COUNT_CACHE_PERIOD` | | Interval in seconds to restart the task, which calculates the total txs count. | 60 * 60 * 2 | v1.3.9+ | -| `ADDRESS_WITH_BALANCES`
`_UPDATE_INTERVAL`| | Interval in seconds to restart the task, which calculates addresses with balances. | 30 * 60 | v1.3.9+ | -| `LINK_TO_OTHER_EXPLORERS` | | true/false. If true, links to other explorers are added in the footer | (empty) | v1.3.0+ | -| `COINMARKETCAP_PAGES` | | the number of pages on coinmarketcap to list in order to find token's price | 10 | v1.3.10+ | -| `CHAIN_SPEC_PATH` | | Chain specification path (absolute file system path or url) to import block emission reward ranges and genesis account balances from | (empty) | master | -| `SUPPORTED_CHAINS` | | Array of supported chains that displays in the footer and in the chains dropdown. This var was introduced in this PR [#1900](https://github.com/poanetwork/blockscout/pull/1900) and looks like an array of JSON objects. | (empty) | v2.0.0+ | -| `BLOCK_COUNT_CACHE_PERIOD ` | | time to live of cache in seconds. This var was introduced in [#1876](https://github.com/poanetwork/blockscout/pull/1876) | 600 | v2.0.0+ | -| `ALLOWED_EVM_VERSIONS ` | | the comma-separated list of allowed EVM versions for contracts verification. This var was introduced in [#1964](https://github.com/poanetwork/blockscout/pull/1964) | "homestead, tangerineWhistle, spuriousDragon, byzantium, constantinople, petersburg" | v2.0.0+ | -| `DISABLE_WEBAPP` | | If `true`, endpoints to webapp are hidden (compile-time) | `false` | v2.0.3+ | -| `DISABLE_READ_API` | | If `true`, read-only endpoints to API are hidden (compile-time) | `false` | v2.0.3+ | -| `DISABLE_WRITE_API` | | If `true`, write endpoints to API are hidden (compile-time) | `false` | v2.0.3+ | -| `DISABLE_INDEXER` | | If `true`, indexer application doesn't run | `false` | v2.0.3+ | -| `WEBAPP_URL` | | Link to web application instance, e.g. `http://host/path` | (empty) | v2.0.3+ | -| `API_URL` | | Link to API instance, e.g. `http://host/path` | (empty) | v2.0.3+ | +| `SPANDEX_SYNC_THRESHOLD` | | [Spandex](https://github.com/spandex-project/spandex) and Datadog configuration setting. | (empty) | all | | +| `HEART_BEAT_TIMEOUT` | | Production environment variable to restart the application in the event of a crash. | 30 | all | | +| `HEART_COMMAND` | | Production environment variable to restart the application in the event of a crash. | systemctl restart explorer.service | all | | +| `BLOCKSCOUT_VERSION` | | Added to the footer to signify the current BlockScout version. | (empty) | v1.3.4+ | | +| `RELEASE_LINK` | | The link to Blockscout release notes in the footer. | https: //github.com/poanetwork/
blockscout/releases/
tag/${BLOCKSCOUT_VERSION} | v1.3.5+ | | +| `ELIXIR_VERSION` | | Elixir version to install on the node before Blockscout deploy. | (empty) | all | | +| `BLOCK_TRANSFORMER` | | Transformer for blocks: base or clique. | base | v1.3.4+ | | +| `GRAPHIQL_TRANSACTION` | | Default transaction in query to GraphiQL. | (empty) | v1.2.0+ | :white_check_mark: | +| `FIRST_BLOCK` | | The block number, where indexing begins from. | 0 | v1.3.8+ | | +| `LAST_BLOCK` | | The block number, where indexing stops. | (empty) | v2.0.3+ | | +| `TXS_COUNT_CACHE_PERIOD` | | Interval in seconds to restart the task, which calculates the total txs count. | 60 * 60 * 2 | v1.3.9+ | | +| `ADDRESS_WITH_BALANCES`
`_UPDATE_INTERVAL`| | Interval in seconds to restart the task, which calculates addresses with balances. | 30 * 60 | v1.3.9+ | | +| `LINK_TO_OTHER_EXPLORERS` | | true/false. If true, links to other explorers are added in the footer | (empty) | v1.3.0+ | | +| `COINMARKETCAP_PAGES` | | the number of pages on coinmarketcap to list in order to find token's price | 10 | v1.3.10+ | | +| `SUPPORTED_CHAINS` | | Array of supported chains that displays in the footer and in the chains dropdown. This var was introduced in this PR [#1900](https://github.com/poanetwork/blockscout/pull/1900) and looks like an array of JSON objects. | (empty) | v2.0.0+ | | +| `BLOCK_COUNT_CACHE_PERIOD ` | | time to live of cache in seconds. This var was introduced in [#1876](https://github.com/poanetwork/blockscout/pull/1876) | 600 | v2.0.0+ | | +| `ALLOWED_EVM_VERSIONS ` | | the comma-separated list of allowed EVM versions for contracts verification. This var was introduced in [#1964](https://github.com/poanetwork/blockscout/pull/1964) | "homestead, tangerineWhistle, spuriousDragon, byzantium, constantinople, petersburg" | v2.0.0+ | | +| `AVERAGE_BLOCK_CACHE_PERIOD` | | Update of average block cache, in seconds | 30 minutes | v2.0.2+ | +| `MARKET_HISTORY_CACHE_PERIOD` | | Update of market history cache, in seconds | 6 hours | v2.0.2+ | +| `DISABLE_WEBAPP` | | If `true`, endpoints to webapp are hidden (compile-time) | `false` | v2.0.3+ | :white_check_mark: | +| `DISABLE_READ_API` | | If `true`, read-only endpoints to API are hidden (compile-time) | `false` | v2.0.3+ | :white_check_mark: | +| `DISABLE_WRITE_API` | | If `true`, write endpoints to API are hidden (compile-time) | `false` | v2.0.3+ | :white_check_mark: | +| `DISABLE_INDEXER` | | If `true`, indexer application doesn't run | `false` | v2.0.3+ | :white_check_mark: | +| `WEBAPP_URL` | | Link to web application instance, e.g. `http://host/path` | (empty) | v2.0.3+ | | +| `API_URL` | | Link to API instance, e.g. `http://host/path` | (empty) | v2.0.3+ | | +| `CHAIN_SPEC_PATH` | | Chain specification path (absolute file system path or url) to import block emission reward ranges and genesis account balances from | (empty) | master | | From c5e4485d3d658b5fc53c2e254e93338ae4348c13 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Fri, 23 Aug 2019 12:54:27 +0300 Subject: [PATCH 02/12] deduplicate coin history records by delta On coin history page we show records that are found in the db. Since we may fetch a lot of duplicated balances for the same address if its balance is not changes for multiple blocks. This PR adds deduplication by delta value to remove duplication. --- apps/explorer/lib/explorer/chain.ex | 3 +++ apps/explorer/test/explorer/chain_test.exs | 26 ++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/apps/explorer/lib/explorer/chain.ex b/apps/explorer/lib/explorer/chain.ex index 58253c0f27..a6200a81f9 100644 --- a/apps/explorer/lib/explorer/chain.ex +++ b/apps/explorer/lib/explorer/chain.ex @@ -2967,6 +2967,9 @@ defmodule Explorer.Chain do |> CoinBalance.fetch_coin_balances(paging_options) |> page_coin_balances(paging_options) |> Repo.all() + |> Enum.dedup_by(fn record -> + record.delta == Decimal.new(0) + end) end def get_coin_balance(address_hash, block_number) do diff --git a/apps/explorer/test/explorer/chain_test.exs b/apps/explorer/test/explorer/chain_test.exs index f49be6da4e..10788b60ba 100644 --- a/apps/explorer/test/explorer/chain_test.exs +++ b/apps/explorer/test/explorer/chain_test.exs @@ -4159,4 +4159,30 @@ defmodule Explorer.ChainTest do assert Chain.staking_pools_count(:inactive) == 1 end end + + describe "address_to_coin_balances/2" do + test "deduplicates records by zero delta" do + address = insert(:address) + + 1..5 + |> Enum.each(fn block_number -> + insert(:block, number: block_number) + insert(:fetched_balance, value: 1, block_number: block_number, address_hash: address.hash) + end) + + insert(:block, number: 6) + insert(:fetched_balance, value: 2, block_number: 6, address_hash: address.hash) + + assert [first, second, third] = Chain.address_to_coin_balances(address.hash, []) + + assert first.block_number == 6 + assert first.delta == Decimal.new(1) + + assert second.block_number == 5 + assert second.delta == Decimal.new(0) + + assert third.block_number == 1 + assert third.delta == Decimal.new(1) + end + end end From e8ba3b22785931c890ebc856096b99482c99a399 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Fri, 23 Aug 2019 12:59:07 +0300 Subject: [PATCH 03/12] add CHANGELOG entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0c26c016be..d6cfce7118 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ - [#2497](https://github.com/poanetwork/blockscout/pull/2497) - Add generic Ordered Cache behaviour and implementation ### Fixes +- [#2616](https://github.com/poanetwork/blockscout/pull/2616) - deduplicate coin history records by delta - [#2592](https://github.com/poanetwork/blockscout/pull/2592) - process new metadata format for whisper - [#2572](https://github.com/poanetwork/blockscout/pull/2572) - Ease non-critical css - [#2570](https://github.com/poanetwork/blockscout/pull/2570) - Network icons preload From 045652a505a93120d28a1db92fc20241a6a8dd40 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Fri, 23 Aug 2019 14:00:16 +0300 Subject: [PATCH 04/12] fix tests --- apps/explorer/lib/explorer/chain.ex | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/explorer/lib/explorer/chain.ex b/apps/explorer/lib/explorer/chain.ex index a6200a81f9..c781a3463e 100644 --- a/apps/explorer/lib/explorer/chain.ex +++ b/apps/explorer/lib/explorer/chain.ex @@ -2968,7 +2968,11 @@ defmodule Explorer.Chain do |> page_coin_balances(paging_options) |> Repo.all() |> Enum.dedup_by(fn record -> - record.delta == Decimal.new(0) + if record.delta == Decimal.new(0) do + :dup + else + System.unique_integer + end end) end From cd979c02c2f257fa06eb79d05684cd14333e6406 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Fri, 23 Aug 2019 14:02:46 +0300 Subject: [PATCH 05/12] mix format --- apps/explorer/lib/explorer/chain.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/explorer/lib/explorer/chain.ex b/apps/explorer/lib/explorer/chain.ex index c781a3463e..b2c18e8a50 100644 --- a/apps/explorer/lib/explorer/chain.ex +++ b/apps/explorer/lib/explorer/chain.ex @@ -2971,7 +2971,7 @@ defmodule Explorer.Chain do if record.delta == Decimal.new(0) do :dup else - System.unique_integer + System.unique_integer() end end) end From b007451f0671567f5eda9326550b1725380fbe15 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Mon, 26 Aug 2019 12:10:04 +0300 Subject: [PATCH 06/12] fix a blinking test The test was failing because `RollingWindow` process is already initialized in `setup` hook --- .../test/ethereum_jsonrpc/rolling_window_test.exs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/ethereum_jsonrpc/test/ethereum_jsonrpc/rolling_window_test.exs b/apps/ethereum_jsonrpc/test/ethereum_jsonrpc/rolling_window_test.exs index 43f400434a..d053a66493 100644 --- a/apps/ethereum_jsonrpc/test/ethereum_jsonrpc/rolling_window_test.exs +++ b/apps/ethereum_jsonrpc/test/ethereum_jsonrpc/rolling_window_test.exs @@ -29,7 +29,7 @@ defmodule EthereumJSONRPC.RollingWindowTest do describe "init/1" do test "raises when duration isn't evenly divisble by window_count" do assert_raise ArgumentError, ~r"evenly divisible", fn -> - RollingWindow.init(table: @table, duration: :timer.seconds(2), window_count: 3) + RollingWindow.init(table: :init_test_table, duration: :timer.seconds(2), window_count: 3) end end From dfbc6fa7fe2c19c06c2c241bcb2293e22dd0a214 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Mon, 26 Aug 2019 12:21:01 +0300 Subject: [PATCH 07/12] add CHANGELOG entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0c26c016be..2ee0459051 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ - [#2497](https://github.com/poanetwork/blockscout/pull/2497) - Add generic Ordered Cache behaviour and implementation ### Fixes +- [#2623](https://github.com/poanetwork/blockscout/pull/2623) - fix a blinking test - [#2592](https://github.com/poanetwork/blockscout/pull/2592) - process new metadata format for whisper - [#2572](https://github.com/poanetwork/blockscout/pull/2572) - Ease non-critical css - [#2570](https://github.com/poanetwork/blockscout/pull/2570) - Network icons preload From e6a65b82a3b221738a3b0e2885355b19685d2dbb Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Mon, 26 Aug 2019 13:46:58 +0300 Subject: [PATCH 08/12] fix tests --- .../ethereum_jsonrpc/rolling_window_test.exs | 114 ++++++++++-------- 1 file changed, 64 insertions(+), 50 deletions(-) diff --git a/apps/ethereum_jsonrpc/test/ethereum_jsonrpc/rolling_window_test.exs b/apps/ethereum_jsonrpc/test/ethereum_jsonrpc/rolling_window_test.exs index d053a66493..5f8db2a821 100644 --- a/apps/ethereum_jsonrpc/test/ethereum_jsonrpc/rolling_window_test.exs +++ b/apps/ethereum_jsonrpc/test/ethereum_jsonrpc/rolling_window_test.exs @@ -1,27 +1,8 @@ defmodule EthereumJSONRPC.RollingWindowTest do - use ExUnit.Case, - # The same named process is used for all tests and they use the same key in the table, so they would interfere - async: false + use ExUnit.Case, async: true alias EthereumJSONRPC.RollingWindow - @table :table - - setup do - # We set `window_length` to a large time frame so that we can sweep manually to simulate - # time passing - {:ok, pid} = - RollingWindow.start_link([table: @table, duration: :timer.minutes(120), window_count: 3], name: RollingWindow) - - on_exit(fn -> Process.exit(pid, :normal) end) - - :ok - end - - defp sweep do - GenServer.call(RollingWindow, :sweep) - end - test "start_link/2" do assert {:ok, _} = RollingWindow.start_link(table: :test_table, duration: 5, window_count: 1) end @@ -40,61 +21,85 @@ defmodule EthereumJSONRPC.RollingWindowTest do end test "when no increments have happened, inspect returns an empty list" do - assert RollingWindow.inspect(@table, :foobar) == [] + table = :no_increments_have_happened + start_rolling_window(table) + + assert RollingWindow.inspect(table, :foobar) == [] end test "when no increments have happened, count returns 0" do - assert RollingWindow.count(@table, :foobar) == 0 + table = :no_increments_have_happened_empty_list + start_rolling_window(table) + + assert RollingWindow.count(table, :foobar) == 0 end test "when an increment has happened, inspect returns the count for that window" do - RollingWindow.inc(@table, :foobar) + table = :no_increments_have_happened_count + start_rolling_window(table) - assert RollingWindow.inspect(@table, :foobar) == [1] + RollingWindow.inc(table, :foobar) + + assert RollingWindow.inspect(table, :foobar) == [1] end test "when an increment has happened, count returns the count for that window" do - RollingWindow.inc(@table, :foobar) + table = :no_increments_have_happened_count1 + start_rolling_window(table) + + RollingWindow.inc(table, :foobar) - assert RollingWindow.count(@table, :foobar) == 1 + assert RollingWindow.count(table, :foobar) == 1 end test "when an increment has happened in multiple windows, inspect returns the count for both windows" do - RollingWindow.inc(@table, :foobar) - sweep() - RollingWindow.inc(@table, :foobar) + table = :no_increments_have_happened_multiple_windows + start_rolling_window(table) - assert RollingWindow.inspect(@table, :foobar) == [1, 1] + RollingWindow.inc(table, :foobar) + sweep(table) + RollingWindow.inc(table, :foobar) + + assert RollingWindow.inspect(table, :foobar) == [1, 1] end test "when an increment has happened in multiple windows, count returns the sum of both windows" do - RollingWindow.inc(@table, :foobar) - sweep() - RollingWindow.inc(@table, :foobar) + table = :no_increments_have_happened_multiple_windows1 + start_rolling_window(table) + + RollingWindow.inc(table, :foobar) + sweep(table) + RollingWindow.inc(table, :foobar) - assert RollingWindow.count(@table, :foobar) == 2 + assert RollingWindow.count(table, :foobar) == 2 end test "when an increment has happened, but has been swept times, it no longer appears in inspect" do - RollingWindow.inc(@table, :foobar) - sweep() - sweep() - RollingWindow.inc(@table, :foobar) - sweep() - RollingWindow.inc(@table, :foobar) - - assert RollingWindow.inspect(@table, :foobar) == [1, 1, 0] + table = :no_increments_have_happened_multiple_windows3 + start_rolling_window(table) + + RollingWindow.inc(table, :foobar) + sweep(table) + sweep(table) + RollingWindow.inc(table, :foobar) + sweep(table) + RollingWindow.inc(table, :foobar) + + assert RollingWindow.inspect(table, :foobar) == [1, 1, 0] end test "when an increment has happened, but has been swept times, it no longer is included in count" do - RollingWindow.inc(@table, :foobar) - sweep() - sweep() - RollingWindow.inc(@table, :foobar) - sweep() - RollingWindow.inc(@table, :foobar) - - assert RollingWindow.count(@table, :foobar) == 2 + table = :no_increments_have_happened_multiple_windows4 + start_rolling_window(table) + + RollingWindow.inc(table, :foobar) + sweep(table) + sweep(table) + RollingWindow.inc(table, :foobar) + sweep(table) + RollingWindow.inc(table, :foobar) + + assert RollingWindow.count(table, :foobar) == 2 end test "sweeping schedules another sweep" do @@ -102,4 +107,13 @@ defmodule EthereumJSONRPC.RollingWindowTest do RollingWindow.handle_info(:sweep, state) assert_receive(:sweep) end + + defp start_rolling_window(table_name) do + {:ok, _pid} = + RollingWindow.start_link([table: table_name, duration: :timer.minutes(120), window_count: 3], name: table_name) + end + + defp sweep(name) do + GenServer.call(name, :sweep) + end end From b9f9bbfac7979efdff1f34f475f2bce78adecc04 Mon Sep 17 00:00:00 2001 From: Ethan van Ballegooyen Date: Mon, 26 Aug 2019 20:39:29 +0200 Subject: [PATCH 09/12] Removed "nav-item-networks" Having "nav-item-networks" causes the networks menu button on mobile to be pushed to the right, by removing it, it corrects this and moves the menu inline with the rest. --- .../lib/block_scout_web/templates/layout/_topnav.html.eex | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/block_scout_web/lib/block_scout_web/templates/layout/_topnav.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/layout/_topnav.html.eex index 970206636c..a990e73000 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/layout/_topnav.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/layout/_topnav.html.eex @@ -99,7 +99,7 @@ <% end %> -