Skip to content
Snippets Groups Projects
Unverified Commit b2a62a56 authored by Bruno Galvao's avatar Bruno Galvao Committed by GitHub
Browse files

Use `TEST_WS` in all remote-externalities tests (#3284)


Refactor in accordance with
https://github.com/paritytech/polkadot-sdk/issues/2245#issuecomment-1937025951

Prior to this PR, the `remote_tests` test module would either use
`TEST_WS` or `DEFAULT_HTTP_ENDPOINT`.

With the PR, `TEST_WS` is the default for the `remote_tests` test module
and the fallback is `DEFAULT_HTTP_ENDPOINT`.

The only downside I see to this PR is that for particular tests in the
`remote_tests` module, one would want to use a different http endpoint.
If that is the case, they would have to manually hardcode the http
endpoint for that particular test.

Note: The `TEST_WS` node should fulfill the role for all test cases e.g.
include child tries.

Give it a _try_:
```
TEST_WS=wss://rococo-try-runtime-node.parity-chains.parity.io:443 cargo test --features=remote-test -p frame-remote-externalities -- --nocapture
```

---------

Co-authored-by: default avatarOliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
parent 044d914c
No related merge requests found
Pipeline #444423 canceled with stages
in 7 minutes and 50 seconds
......@@ -1263,7 +1263,11 @@ mod tests {
#[cfg(all(test, feature = "remote-test"))]
mod remote_tests {
use super::test_prelude::*;
use std::os::unix::fs::MetadataExt;
use std::{env, os::unix::fs::MetadataExt};
fn endpoint() -> String {
env::var("TEST_WS").unwrap_or_else(|_| DEFAULT_HTTP_ENDPOINT.to_string())
}
#[tokio::test]
async fn state_version_is_kept_and_can_be_altered() {
......@@ -1273,6 +1277,7 @@ mod remote_tests {
// first, build a snapshot.
let ext = Builder::<Block>::new()
.mode(Mode::Online(OnlineConfig {
transport: endpoint().clone().into(),
pallets: vec!["Proxy".to_owned()],
child_trie: false,
state_snapshot: Some(SnapshotConfig::new(CACHE)),
......@@ -1314,6 +1319,7 @@ mod remote_tests {
// first, build a snapshot.
let ext = Builder::<Block>::new()
.mode(Mode::Online(OnlineConfig {
transport: endpoint().clone().into(),
pallets: vec!["Proxy".to_owned()],
child_trie: false,
state_snapshot: Some(SnapshotConfig::new(CACHE)),
......@@ -1341,6 +1347,7 @@ mod remote_tests {
// create an ext with children keys
let child_ext = Builder::<Block>::new()
.mode(Mode::Online(OnlineConfig {
transport: endpoint().clone().into(),
pallets: vec!["Proxy".to_owned()],
child_trie: true,
state_snapshot: Some(SnapshotConfig::new(CACHE)),
......@@ -1353,6 +1360,7 @@ mod remote_tests {
// create an ext without children keys
let ext = Builder::<Block>::new()
.mode(Mode::Online(OnlineConfig {
transport: endpoint().clone().into(),
pallets: vec!["Proxy".to_owned()],
child_trie: false,
state_snapshot: Some(SnapshotConfig::new(CACHE)),
......@@ -1378,6 +1386,7 @@ mod remote_tests {
.mode(Mode::OfflineOrElseOnline(
OfflineConfig { state_snapshot: SnapshotConfig::new(CACHE) },
OnlineConfig {
transport: endpoint().clone().into(),
pallets: vec!["Proxy".to_owned()],
child_trie: false,
state_snapshot: Some(SnapshotConfig::new(CACHE)),
......@@ -1419,6 +1428,7 @@ mod remote_tests {
init_logger();
Builder::<Block>::new()
.mode(Mode::Online(OnlineConfig {
transport: endpoint().clone().into(),
pallets: vec!["Proxy".to_owned()],
child_trie: false,
..Default::default()
......@@ -1434,6 +1444,7 @@ mod remote_tests {
init_logger();
Builder::<Block>::new()
.mode(Mode::Online(OnlineConfig {
transport: endpoint().clone().into(),
pallets: vec!["Proxy".to_owned(), "Multisig".to_owned()],
child_trie: false,
..Default::default()
......@@ -1451,6 +1462,7 @@ mod remote_tests {
Builder::<Block>::new()
.mode(Mode::Online(OnlineConfig {
transport: endpoint().clone().into(),
state_snapshot: Some(SnapshotConfig::new(CACHE)),
pallets: vec!["Proxy".to_owned()],
child_trie: false,
......@@ -1480,6 +1492,7 @@ mod remote_tests {
init_logger();
Builder::<Block>::new()
.mode(Mode::Online(OnlineConfig {
transport: endpoint().clone().into(),
state_snapshot: Some(SnapshotConfig::new(CACHE)),
pallets: vec!["Crowdloan".to_owned()],
child_trie: true,
......@@ -1511,7 +1524,7 @@ mod remote_tests {
init_logger();
Builder::<Block>::new()
.mode(Mode::Online(OnlineConfig {
transport: std::option_env!("TEST_WS").unwrap().to_owned().into(),
transport: endpoint().clone().into(),
pallets: vec!["Staking".to_owned()],
child_trie: false,
..Default::default()
......@@ -1530,7 +1543,7 @@ mod remote_tests {
init_logger();
Builder::<Block>::new()
.mode(Mode::Online(OnlineConfig {
transport: std::option_env!("TEST_WS").unwrap().to_owned().into(),
transport: endpoint().clone().into(),
..Default::default()
}))
.build()
......@@ -1543,9 +1556,10 @@ mod remote_tests {
async fn can_fetch_in_parallel() {
init_logger();
let uri = String::from("wss://kusama-bridge-hub-rpc.polkadot.io:443");
let mut builder = Builder::<Block>::new()
.mode(Mode::Online(OnlineConfig { transport: uri.into(), ..Default::default() }));
let mut builder = Builder::<Block>::new().mode(Mode::Online(OnlineConfig {
transport: endpoint().clone().into(),
..Default::default()
}));
builder.init_remote_client().await.unwrap();
let at = builder.as_online().at.unwrap();
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment