mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-28 03:58:04 +00:00
Make sure frame examples compile for wasm (#5332)
* Make sure frame examples compile for wasm This makes sure that `frame-example` and `frame-example-offchain-worker` compile for wasm. This also fixes compilation for these crates. The offchain worker example doesn't use serde-json anymore as that is too heavy and breaks `no_std` compilation. * Apply suggestions from code review Co-Authored-By: Nikolay Volf <nikvolf@gmail.com> Co-authored-by: Nikolay Volf <nikvolf@gmail.com>
This commit is contained in:
@@ -132,7 +132,7 @@ fn should_make_http_call_and_parse_result() {
|
||||
// when
|
||||
let price = Example::fetch_price().unwrap();
|
||||
// then
|
||||
assert_eq!(price, 15522);
|
||||
assert_eq!(price, 15523);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -164,7 +164,7 @@ fn should_submit_signed_transaction_on_chain() {
|
||||
assert!(pool_state.read().transactions.is_empty());
|
||||
let tx = Extrinsic::decode(&mut &*tx).unwrap();
|
||||
assert_eq!(tx.signature.unwrap().0, 0);
|
||||
assert_eq!(tx.call, Call::submit_price(15522));
|
||||
assert_eq!(tx.call, Call::submit_price(15523));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -186,7 +186,7 @@ fn should_submit_unsigned_transaction_on_chain() {
|
||||
assert!(pool_state.read().transactions.is_empty());
|
||||
let tx = Extrinsic::decode(&mut &*tx).unwrap();
|
||||
assert_eq!(tx.signature, None);
|
||||
assert_eq!(tx.call, Call::submit_price_unsigned(1, 15522));
|
||||
assert_eq!(tx.call, Call::submit_price_unsigned(1, 15523));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -208,3 +208,19 @@ fn price_oracle_response(state: &mut testing::OffchainState) {
|
||||
..Default::default()
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_price_works() {
|
||||
let test_data = vec![
|
||||
("{\"USD\":6536.92}", Some(653692)),
|
||||
("{\"USD\":65.92}", Some(6592)),
|
||||
("{\"USD\":6536.924565}", Some(653692)),
|
||||
("{\"USD\":6536}", Some(653600)),
|
||||
("{\"USD2\":6536}", None),
|
||||
("{\"USD\":\"6432\"}", None),
|
||||
];
|
||||
|
||||
for (json, expected) in test_data {
|
||||
assert_eq!(expected, Example::parse_price(json));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user