mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-10 02:57:58 +00:00
Add alternative RPC methods to system_networkState (#5643)
* Add alternatives to system_networkState * Fix tests * Apply suggestions from code review Co-Authored-By: Tomasz Drwięga <tomusdrw@users.noreply.github.com> Co-authored-by: Tomasz Drwięga <tomusdrw@users.noreply.github.com>
This commit is contained in:
@@ -55,6 +55,15 @@ fn api<T: Into<Option<Status>>>(sync: T) -> System<Block> {
|
||||
should_have_peers,
|
||||
});
|
||||
},
|
||||
Request::LocalPeerId(sender) => {
|
||||
let _ = sender.send("QmSk5HQbn6LhUwDiNMseVUjuRYhEtYj4aUZ6WfWoGURpdV".to_string());
|
||||
},
|
||||
Request::LocalListenAddresses(sender) => {
|
||||
let _ = sender.send(vec![
|
||||
"/ip4/198.51.100.19/tcp/30333/p2p/QmSk5HQbn6LhUwDiNMseVUjuRYhEtYj4aUZ6WfWoGURpdV".to_string(),
|
||||
"/ip4/127.0.0.1/tcp/30334/ws/p2p/QmSk5HQbn6LhUwDiNMseVUjuRYhEtYj4aUZ6WfWoGURpdV".to_string(),
|
||||
]);
|
||||
},
|
||||
Request::Peers(sender) => {
|
||||
let mut peers = vec![];
|
||||
for _peer in 0..status.peers {
|
||||
@@ -208,6 +217,25 @@ fn system_health() {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn system_local_peer_id_works() {
|
||||
assert_eq!(
|
||||
wait_receiver(api(None).system_local_peer_id()),
|
||||
"QmSk5HQbn6LhUwDiNMseVUjuRYhEtYj4aUZ6WfWoGURpdV".to_owned(),
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn system_local_listen_addresses_works() {
|
||||
assert_eq!(
|
||||
wait_receiver(api(None).system_local_listen_addresses()),
|
||||
vec![
|
||||
"/ip4/198.51.100.19/tcp/30333/p2p/QmSk5HQbn6LhUwDiNMseVUjuRYhEtYj4aUZ6WfWoGURpdV".to_string(),
|
||||
"/ip4/127.0.0.1/tcp/30334/ws/p2p/QmSk5HQbn6LhUwDiNMseVUjuRYhEtYj4aUZ6WfWoGURpdV".to_string(),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn system_peers() {
|
||||
let peer_id = PeerId::random();
|
||||
|
||||
Reference in New Issue
Block a user