Skip to content

Commit

Permalink
Refine endpoints in system-api plugin [ECR-4154] (exonum#1790)
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleksandr Anyshchenko committed Feb 21, 2020
1 parent 5a5f79a commit b743ddd
Show file tree
Hide file tree
Showing 13 changed files with 330 additions and 490 deletions.
11 changes: 4 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ cache:
- $HOME/.kcov

dist: bionic
sudo: required

env:
global:
Expand Down Expand Up @@ -132,6 +131,10 @@ jobs:
- name: unit-test
script:
- cargo test --all --lib --tests --benches

# Doc tests.
- name: doc-test
script:
- cargo test --all --doc

# Run examples and soak tests.
Expand Down Expand Up @@ -178,12 +181,6 @@ jobs:
- deactivate
- rm -rf .venv

# Check compatibility with Rust 1.36.
- name: 1.36-compat
rust: 1.36.0
script:
- cargo check --all --benches --tests --bins --examples --features "long_benchmarks"

notifications:
webhooks:
urls:
Expand Down
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,28 @@ The project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html)

#### exonum

- Testkit now does not include incorrect transactions into blocks or memory pool,
similar to real Exonum nodes. (#1785)

- `Runtime::deploy_artifact` no longer returns `Box<dyn Future<...>>`. Instead a
special communication channel is used to send deployment status from the
runtime to the dispatcher. (#1788)

#### exonum-system-api

- Public api module has been removed. List of endpoints from private api has
been changed. (#1790) Current list of the endpoints:
- `v1/info` - obtains information about the node;
- `v1/stats` - obtains statistics of the node;
- `v1/peers` - adds a peer to the Exonum node;
- `v1/consensus_status` - enables or disables consensus on the node;
- `v1/shutdown` - shuts down the node.

#### exonum-supervisor

- `supervisor/services` endpoint has been added which obtains information
about deployed artifacts and available services. (#1790)

### Bug Fixes

#### exonum-node
Expand Down
6 changes: 3 additions & 3 deletions cli/tests/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use exonum::{
use exonum_derive::*;
use exonum_explorer_service::api::BlocksRange;
use exonum_rust_runtime::{api::ServiceApiBuilder, DefaultInstance, Service, ServiceFactory};
use exonum_system_api::public::DispatcherInfo;
use exonum_supervisor::api::DispatcherInfo;
use futures::Future;
use lazy_static::lazy_static;
use tempfile::TempDir;
Expand Down Expand Up @@ -104,9 +104,9 @@ fn node_basic_workflow() -> Result<(), failure::Error> {
thread::sleep(Duration::from_secs(2));

let client = reqwest::Client::new();
// Check info returned by the system API plugin.
// Check info about deployed artifacts returned via supervisor API.
let info: DispatcherInfo = client
.get(&format!("{}/system/v1/services", public_api_root))
.get(&format!("{}/services/supervisor/services", public_api_root))
.send()?
.error_for_status()?
.json()?;
Expand Down
1 change: 1 addition & 0 deletions components/system-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ exonum-node = { version = "1.0.0-rc.1", path = "../../exonum-node" }

actix-web = { version = "0.7.18", default-features = false }
futures = "0.1.25"
semver = "0.9.0"
serde = "1.0"
serde_derive = "1.0"

Expand Down
13 changes: 5 additions & 8 deletions components/system-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
//!
//! REST API of the service is documented in the corresponding modules:
//!
//! - [public API](public/index.html)
//! - [private API](private/index.html)
//!
//! # Examples
Expand Down Expand Up @@ -51,15 +50,15 @@
//! Use with the testkit:
//!
//! ```
//! use exonum_system_api::{private::NodeInfo, SystemApiPlugin};
//! use exonum_system_api::{private::{ConsensusStatus, NodeInfo}, SystemApiPlugin};
//! use exonum_testkit::{ApiKind, TestKitBuilder};
//!
//! let mut testkit = TestKitBuilder::validator()
//! .with_plugin(SystemApiPlugin)
//! .build();
//! let api = testkit.api();
//! let info: NodeInfo = api.private(ApiKind::System).get("v1/network").unwrap();
//! assert!(info.core_version.is_some());
//! let info: NodeInfo = api.private(ApiKind::System).get("v1/info").unwrap();
//! assert_eq!(info.consensus_status, ConsensusStatus::Enabled);
//! ```
//!
//! Note that the testkit does not emulate the functionality of the node completely; it does
Expand All @@ -73,22 +72,20 @@
)]

pub mod private;
pub mod public;

use exonum::blockchain::{ApiSender, Blockchain};
use exonum_api::ApiBuilder;
use exonum_node::{ExternalMessage, NodePlugin, PluginApiContext, SharedNodeState};

use crate::{private::SystemApi as PrivateSystemApi, public::SystemApi};
use crate::private::SystemApi;

fn system_api(
blockchain: Blockchain,
sender: ApiSender<ExternalMessage>,
shared_api_state: SharedNodeState,
) -> ApiBuilder {
let mut builder = ApiBuilder::new();
PrivateSystemApi::new(sender, shared_api_state.clone()).wire(builder.private_scope());
SystemApi::new(blockchain, shared_api_state).wire(builder.public_scope());
SystemApi::new(blockchain, sender, shared_api_state).wire(builder.private_scope());
builder
}

Expand Down
Loading

0 comments on commit b743ddd

Please sign in to comment.