Merge branch 'master' of github.com:ethcore/parity

This commit is contained in:
Gav Wood 2016-05-21 15:30:44 +02:00
commit 33e7f5e390
6 changed files with 111 additions and 22 deletions

View File

@ -33,7 +33,7 @@ env:
global:
# GH_TOKEN
- secure: bumJASbZSU8bxJ0EyPUJmu16AiV9EXOpyOj86Jlq/Ty9CfwGqsSXt96uDyE+OUJf34RUFQMsw0nk37/zC4lcn6kqk2wpuH3N/o85Zo/cVZY/NusBWLQqtT5VbYWsV+u2Ua4Tmmsw8yVYQhYwU2ZOejNpflL+Cs9XGgORp1L+/gMRMC2y5Se6ZhwnKPQlRJ8LGsG1dzjQULxzADIt3/zuspNBS8a2urJwlHfGMkvHDoUWCviP/GXoSqw3TZR7FmKyxE19I8n9+iSvm9+oZZquvcgfUxMHn8Gq/b44UbPvjtFOg2yam4xdWXF/RyWCHdc/R9EHorSABeCbefIsm+zcUF3/YQxwpSxM4IZEeH2rTiC7dcrsKw3XsO16xFQz5YI5Bay+CT/wTdMmJd7DdYz7Dyf+pOvcM9WOf/zorxYWSBOMYy0uzbusU2iyIghQ82s7E/Ahg+WARtPgkuTLSB5aL1oCTBKHqQscMr7lo5Ti6RpWLxEdTQMBznc+bMr+6dEtkEcG9zqc6cE9XX+ox3wTU6+HVMfQ1ltCntJ4UKcw3A6INEbw9wgocQa812CIASQ2fE+SCAbz6JxBjIAlFUnD1lUB7S8PdMPwn9plfQgKQ2A5YZqg6FnBdf0rQXIJYxQWKHXj/rBHSUCT0tHACDlzTA+EwWggvkP5AGIxRxm8jhw=
- TARGETS="-p ethash -p ethcore-util -p ethcore -p ethsync -p ethcore-rpc -p parity -p ethminer -p ethjson"
- TARGETS="-p ethash -p ethcore-util -p ethcore -p ethsync -p ethcore-rpc -p parity -p ethminer -p ethjson -p ethcore-webapp"
- ARCHIVE_SUFFIX="-${TRAVIS_OS_NAME}-${TRAVIS_TAG}"
- KCOV_FEATURES=""
- KCOV_CMD="./kcov-master/tmp/usr/local/bin/kcov --exclude-pattern /usr/,/.cargo,/root/.multirust,src/tests,util/json-tests,util/src/network/tests,sync/src/tests,ethcore/src/tests,ethcore/src/evm/tests target/kcov"
@ -70,6 +70,7 @@ after_success: |
$KCOV_CMD target/debug/deps/ethcore-* &&
$KCOV_CMD target/debug/deps/ethsync-* &&
$KCOV_CMD target/debug/deps/ethcore_rpc-* &&
$KCOV_CMD target/debug/deps/ethcore_webapp-* &&
$KCOV_CMD target/debug/deps/ethminer-* &&
$KCOV_CMD target/debug/deps/ethjson-* &&
$KCOV_CMD target/debug/parity-* &&
@ -102,4 +103,4 @@ notifications:
notifications:
slack:
rooms:
- ethcore:4EGxt9WP6AS7uX4JKXSfR9vi#chatops
- ethcore:4EGxt9WP6AS7uX4JKXSfR9vi#chatops

26
Cargo.lock generated
View File

@ -356,9 +356,11 @@ dependencies = [
"jsonrpc-core 2.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"jsonrpc-http-server 5.1.0 (git+https://github.com/ethcore/jsonrpc-http-server.git)",
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-daodapp 0.2.1 (git+https://github.com/ethcore/parity-daodapp-rs.git)",
"parity-idmanager 0.2.2 (git+https://github.com/ethcore/parity-idmanager-rs.git)",
"parity-makerotc 0.1.3 (git+https://github.com/ethcore/parity-makerotc-rs.git)",
"parity-status 0.4.3 (git+https://github.com/ethcore/parity-status.git)",
"parity-wallet 0.4.0 (git+https://github.com/ethcore/parity-wallet.git)",
"parity-wallet 0.4.1 (git+https://github.com/ethcore/parity-wallet.git)",
"parity-webapp 0.2.0 (git+https://github.com/ethcore/parity-webapp.git)",
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -834,10 +836,26 @@ name = "odds"
version = "0.2.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "parity-daodapp"
version = "0.2.1"
source = "git+https://github.com/ethcore/parity-daodapp-rs.git#333478fac5b0dfa3c17a740316eda51e5305fc42"
dependencies = [
"parity-webapp 0.2.0 (git+https://github.com/ethcore/parity-webapp.git)",
]
[[package]]
name = "parity-idmanager"
version = "0.2.2"
source = "git+https://github.com/ethcore/parity-idmanager-rs.git#e93ef48a78722561d52ab88c3dfcc5c1465558ac"
source = "git+https://github.com/ethcore/parity-idmanager-rs.git#19dd79ca7b7afb8824ad072b43ca63babe2ba9bc"
dependencies = [
"parity-webapp 0.2.0 (git+https://github.com/ethcore/parity-webapp.git)",
]
[[package]]
name = "parity-makerotc"
version = "0.1.3"
source = "git+https://github.com/ethcore/parity-makerotc-rs.git#5fec743658e82b365e1db739a966a69e557b5873"
dependencies = [
"parity-webapp 0.2.0 (git+https://github.com/ethcore/parity-webapp.git)",
]
@ -852,8 +870,8 @@ dependencies = [
[[package]]
name = "parity-wallet"
version = "0.4.0"
source = "git+https://github.com/ethcore/parity-wallet.git#5391a89dc5dbf162d1beeba555f03c24bfd619bd"
version = "0.4.1"
source = "git+https://github.com/ethcore/parity-wallet.git#6e714a31cdc26cc86f0edb14fd1ae1dc7d496d1e"
dependencies = [
"parity-webapp 0.2.0 (git+https://github.com/ethcore/parity-webapp.git)",
]

View File

@ -24,7 +24,9 @@ parity-webapp = { git = "https://github.com/ethcore/parity-webapp.git", version
# List of apps
parity-status = { git = "https://github.com/ethcore/parity-status.git", version = "0.4.3" }
parity-idmanager = { git = "https://github.com/ethcore/parity-idmanager-rs.git", version = "0.2.2" }
parity-wallet = { git = "https://github.com/ethcore/parity-wallet.git", version = "0.4.0", optional = true }
parity-wallet = { git = "https://github.com/ethcore/parity-wallet.git", version = "0.4.1", optional = true }
parity-daodapp = { git = "https://github.com/ethcore/parity-daodapp-rs.git", version = "0.2.1", optional = true }
parity-makerotc = { git = "https://github.com/ethcore/parity-makerotc-rs.git", version = "0.1.3", optional = true }
clippy = { version = "0.0.67", optional = true}
[build-dependencies]
@ -32,6 +34,6 @@ serde_codegen = { version = "0.7.0", optional = true }
syntex = "0.32.0"
[features]
default = ["parity-wallet", "serde_codegen"]
default = ["parity-wallet", "serde_codegen", "parity-daodapp", "parity-makerotc"]
nightly = ["serde_macros"]
dev = ["clippy", "ethcore-rpc/dev", "ethcore-util/dev"]

View File

@ -21,8 +21,7 @@ use parity_webapp::WebApp;
extern crate parity_status;
extern crate parity_idmanager;
#[cfg(feature = "parity-wallet")]
extern crate parity_wallet;
pub const DAPPS_DOMAIN : &'static str = ".parity";
pub const RPC_PATH : &'static str = "rpc";
@ -46,17 +45,35 @@ pub fn all_endpoints() -> Endpoints {
insert::<parity_idmanager::App>(&mut pages, "home");
wallet_page(&mut pages);
daodapp_page(&mut pages);
makerotc_page(&mut pages);
pages
}
#[cfg(feature = "parity-wallet")]
fn wallet_page(pages: &mut Endpoints) {
extern crate parity_wallet;
insert::<parity_wallet::App>(pages, "wallet");
}
#[cfg(not(feature = "parity-wallet"))]
fn wallet_page(_pages: &mut Endpoints) {}
#[cfg(feature = "parity-daodapp")]
fn daodapp_page(pages: &mut Endpoints) {
extern crate parity_daodapp;
insert::<parity_daodapp::App>(pages, "dao");
}
#[cfg(not(feature = "parity-daodapp"))]
fn daodapp_page(_pages: &mut Endpoints) {}
#[cfg(feature = "parity-makerotc")]
fn makerotc_page(pages: &mut Endpoints) {
extern crate parity_makerotc;
insert::<parity_makerotc::App>(pages, "makerotc");
}
#[cfg(not(feature = "parity-makerotc"))]
fn makerotc_page(_pages: &mut Endpoints) {}
fn insert<T : WebApp + Default + 'static>(pages: &mut Endpoints, id: &str) {
pages.insert(id.to_owned(), Box::new(PageEndpoint::new(T::default())));
}

View File

@ -90,16 +90,17 @@ impl<T: WebApp + 'static> PageHandler<T> {
let app_id = &self.path.app_id;
let prefix = "/".to_owned() + self.prefix.as_ref().unwrap_or(app_id);
let prefix_with_slash = prefix.clone() + "/";
let query_pos = path.find('?').unwrap_or_else(|| path.len());
// Index file support
match path == "/" || path == &prefix || path == &prefix_with_slash {
true => "index.html".to_owned(),
false => if path.starts_with(&prefix_with_slash) {
path[prefix_with_slash.len()..].to_owned()
path[prefix_with_slash.len()..query_pos].to_owned()
} else if path.starts_with("/") {
path[1..].to_owned()
path[1..query_pos].to_owned()
} else {
path.to_owned()
path[0..query_pos].to_owned()
}
}
}
@ -155,3 +156,53 @@ impl<T: WebApp + 'static> server::Handler<HttpStream> for PageHandler<T> {
res
}
}
#[cfg(test)]
use parity_webapp::File;
#[cfg(test)]
#[derive(Default)]
struct TestWebapp;
#[cfg(test)]
impl WebApp for TestWebapp {
fn file(&self, _path: &str) -> Option<&File> {
None
}
fn info(&self) -> Info {
unimplemented!()
}
}
#[test]
fn should_extract_path_with_appid() {
// given
let path1 = "/";
let path2= "/test.css";
let path3 = "/app/myfile.txt";
let path4 = "/app/myfile.txt?query=123";
let page_handler = PageHandler {
app: Arc::new(TestWebapp),
prefix: None,
path: EndpointPath {
app_id: "app".to_owned(),
host: "".to_owned(),
port: 8080
},
file: None,
write_pos: 0,
};
// when
let res1 = page_handler.extract_path(path1);
let res2 = page_handler.extract_path(path2);
let res3 = page_handler.extract_path(path3);
let res4 = page_handler.extract_path(path4);
// then
assert_eq!(&res1, "index.html");
assert_eq!(&res2, "test.css");
assert_eq!(&res3, "myfile.txt");
assert_eq!(&res4, "myfile.txt");
}

View File

@ -215,40 +215,40 @@ fn should_extract_endpoint() {
);
assert_eq!(
extract_endpoint(&Url::parse("http://my.status.dapp/parity-utils/inject.js").ok()),
extract_endpoint(&Url::parse("http://my.status.parity/parity-utils/inject.js").ok()),
(Some(EndpointPath {
app_id: "my.status".to_owned(),
host: "my.status.dapp".to_owned(),
host: "my.status.parity".to_owned(),
port: 80,
}), SpecialEndpoint::Utils)
);
// By Subdomain
assert_eq!(
extract_endpoint(&Url::parse("http://my.status.dapp/test.html").ok()),
extract_endpoint(&Url::parse("http://my.status.parity/test.html").ok()),
(Some(EndpointPath {
app_id: "my.status".to_owned(),
host: "my.status.dapp".to_owned(),
host: "my.status.parity".to_owned(),
port: 80,
}), SpecialEndpoint::None)
);
// RPC by subdomain
assert_eq!(
extract_endpoint(&Url::parse("http://my.status.dapp/rpc/").ok()),
extract_endpoint(&Url::parse("http://my.status.parity/rpc/").ok()),
(Some(EndpointPath {
app_id: "my.status".to_owned(),
host: "my.status.dapp".to_owned(),
host: "my.status.parity".to_owned(),
port: 80,
}), SpecialEndpoint::Rpc)
);
// API by subdomain
assert_eq!(
extract_endpoint(&Url::parse("http://my.status.dapp/api/").ok()),
extract_endpoint(&Url::parse("http://my.status.parity/api/").ok()),
(Some(EndpointPath {
app_id: "my.status".to_owned(),
host: "my.status.dapp".to_owned(),
host: "my.status.parity".to_owned(),
port: 80,
}), SpecialEndpoint::Api)
);