Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Prev Previous commit
Next Next commit
Fix author RPC test
This test used to check for a numerial subscription ID,
whereas now it uses a string based ID which is the default
provided by `jsonrpc-pubsub`'s subscription manager.
  • Loading branch information
HCastano committed Jun 2, 2020
commit f7db874a1f1c07186367ce7423161da598ba33b7
12 changes: 6 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 22 additions & 13 deletions client/rpc/src/author/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,13 @@ fn should_watch_extrinsic() {
uxt(AccountKeyring::Alice, 0).encode().into(),
);

// then
assert!(matches!(
executor::block_on(id_rx.compat()),
Ok(Ok(SubscriptionId::String(_)))
));
let id = executor::block_on(id_rx.compat()).unwrap().unwrap();
assert_matches!(id, SubscriptionId::String(_));

let id = match id {
SubscriptionId::String(id) => id,
_ => unreachable!(),
};

// check notifications
let replacement = {
Expand All @@ -151,15 +153,22 @@ fn should_watch_extrinsic() {
};
AuthorApi::submit_extrinsic(&p, replacement.encode().into()).wait().unwrap();
let (res, data) = executor::block_on(data.into_future().compat()).unwrap();
assert_eq!(
res,
Some(r#"{"jsonrpc":"2.0","method":"test","params":{"result":"ready","subscription":1}}"#.into())
);

let expected = Some(format!(
r#"{{"jsonrpc":"2.0","method":"test","params":{{"result":"ready","subscription":"{}"}}}}"#,
id,
));
assert_eq!(res, expected);

let h = blake2_256(&replacement.encode());
assert_eq!(
executor::block_on(data.into_future().compat()).unwrap().0,
Some(format!(r#"{{"jsonrpc":"2.0","method":"test","params":{{"result":{{"usurped":"0x{}"}},"subscription":1}}}}"#, HexDisplay::from(&h)))
);
let expected = Some(format!(
r#"{{"jsonrpc":"2.0","method":"test","params":{{"result":{{"usurped":"0x{}"}},"subscription":"{}"}}}}"#,
HexDisplay::from(&h),
id,
));

let res = executor::block_on(data.into_future().compat()).unwrap().0;
assert_eq!(res, expected);
}

#[test]
Expand Down