mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-06 02:08:02 +00:00
This reverts commit d149c2f719.
This commit is contained in:
@@ -153,23 +153,6 @@ impl<B, E, P, RA> AuthorApi<ExHash<P>, BlockHash<P>> for Author<B, E, P, RA> whe
|
||||
}
|
||||
|
||||
fn watch_extrinsic(&self,
|
||||
_metadata: Self::Metadata,
|
||||
subscriber: Subscriber<Status<ExHash<P>, BlockHash<P>>>,
|
||||
hash: ExHash<P>,
|
||||
) {
|
||||
let watcher = self.pool.watch(hash).into_stream().map(|v| Ok::<_, ()>(Ok(v)));
|
||||
let subscriptions = self.subscriptions.clone();
|
||||
|
||||
subscriptions.add(subscriber,
|
||||
move |sink| {
|
||||
sink.sink_map_err(|_| unimplemented!())
|
||||
.send_all(Compat::new(watcher))
|
||||
.map(|_| ())
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
fn submit_and_watch_extrinsic(&self,
|
||||
_metadata: Self::Metadata,
|
||||
subscriber: Subscriber<Status<ExHash<P>, BlockHash<P>>>,
|
||||
xt: Bytes
|
||||
|
||||
@@ -115,7 +115,7 @@ fn should_watch_extrinsic() {
|
||||
let (subscriber, id_rx, data) = jsonrpc_pubsub::typed::Subscriber::new_test("test");
|
||||
|
||||
// when
|
||||
p.submit_and_watch_extrinsic(Default::default(), subscriber, uxt(AccountKeyring::Alice, 0).encode().into());
|
||||
p.watch_extrinsic(Default::default(), subscriber, uxt(AccountKeyring::Alice, 0).encode().into());
|
||||
|
||||
// then
|
||||
assert_eq!(setup.runtime.block_on(id_rx), Ok(Ok(1.into())));
|
||||
@@ -142,53 +142,6 @@ fn should_watch_extrinsic() {
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
#[test]
|
||||
fn should_watch_existing_extrinsic() {
|
||||
// Initial setup is 1 submitted extrinsic
|
||||
let mut runtime = runtime::Runtime::new().unwrap();
|
||||
let client = Arc::new(test_client::new());
|
||||
let pool = Arc::new(Pool::new(Default::default(), FullChainApi::new(client.clone())));
|
||||
let keystore = KeyStore::new();
|
||||
let p = Author {
|
||||
client,
|
||||
pool: pool.clone(),
|
||||
subscriptions: Subscriptions::new(Arc::new(runtime.executor())),
|
||||
keystore: keystore.clone(),
|
||||
};
|
||||
let (subscriber, id_rx, data) = jsonrpc_pubsub::typed::Subscriber::new_test("test");
|
||||
|
||||
let xt = uxt(AccountKeyring::Alice, 0).encode();
|
||||
let xt_hash: H256 = blake2_256(&xt).into();
|
||||
p.submit_extrinsic(xt.into()).wait().expect("Failed to submit extrinsic");
|
||||
|
||||
// Then we track it
|
||||
p.watch_extrinsic(Default::default(), subscriber, xt_hash.into());
|
||||
assert_eq!(runtime.block_on(id_rx), Ok(Ok(1.into())));
|
||||
|
||||
// Add replacement
|
||||
let replacement = {
|
||||
let tx = Transfer {
|
||||
amount: 5,
|
||||
nonce: 0,
|
||||
from: AccountKeyring::Alice.into(),
|
||||
to: Default::default(),
|
||||
};
|
||||
tx.into_signed_tx()
|
||||
}.encode();
|
||||
let replacement_hash = blake2_256(&replacement);
|
||||
AuthorApi::submit_extrinsic(&p, replacement.into()).wait().unwrap();
|
||||
|
||||
// And check if the tracked one received usurped event
|
||||
assert_eq!(
|
||||
runtime.block_on(data.into_future()).unwrap().0,
|
||||
Some(format!(
|
||||
r#"{{"jsonrpc":"2.0","method":"test","params":{{"result":{{"usurped":"0x{}"}},"subscription":1}}}}"#,
|
||||
HexDisplay::from(&replacement_hash))
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn should_return_watch_validation_error() {
|
||||
//given
|
||||
@@ -198,7 +151,7 @@ fn should_return_watch_validation_error() {
|
||||
let (subscriber, id_rx, _data) = jsonrpc_pubsub::typed::Subscriber::new_test("test");
|
||||
|
||||
// when
|
||||
p.submit_and_watch_extrinsic(Default::default(), subscriber, uxt(AccountKeyring::Alice, 179).encode().into());
|
||||
p.watch_extrinsic(Default::default(), subscriber, uxt(AccountKeyring::Alice, 179).encode().into());
|
||||
|
||||
// then
|
||||
let res = setup.runtime.block_on(id_rx).unwrap();
|
||||
|
||||
Reference in New Issue
Block a user