-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
common crate, expose more tests in wasm #1366
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
c33b5ba
to
cf10919
Compare
cf10919
to
f8d41b5
Compare
3df89c2
to
919f767
Compare
718950b
to
9b9da95
Compare
storage::consent_record::{ConsentState, ConsentType}, | ||
utils::test::wait_for_min_intents, | ||
}; | ||
use xmtp_cryptography::utils::generate_local_wallet; | ||
use xmtp_id::InboxOwner; | ||
|
||
#[tokio::test(flavor = "multi_thread", worker_threads = 1)] | ||
#[wasm_bindgen_test(unsupported = tokio::test(flavor = "multi_thread", worker_threads = 1))] | ||
#[cfg_attr(target_family = "wasm", ignore)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these tests (and all of device sync on web) is blocked on xmtp/xmtp-message-history-server#6, then the ignore
can be removed
9b9da95
to
0b8d1fe
Compare
0b8d1fe
to
fd98665
Compare
use super::*; | ||
use diesel::{connection::LoadConnection, deserialize::FromSqlRow, sql_query, RunQueryDsl}; | ||
impl DbConnection { | ||
/// Create a new table and register triggers for tracking column updates |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a cool idea, nice 😎
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
awesome problem solving on the browser executor for streaming. and clean up in this pr is fantastic thanks! 🥇
pub fn rand_array<const N: usize>() -> [u8; N] { | ||
let mut buffer = [0u8; N]; | ||
crypto_utils::rng().fill_bytes(&mut buffer); | ||
buffer | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's cool. I hadn't thought about using a generic like that before.
common/src/test.rs
Outdated
Fut: Future<Output = T>, | ||
T: std::fmt::Debug + PartialEq, | ||
{ | ||
let result = crate::time::timeout(crate::time::Duration::from_secs(60), async { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we reduce the default timeout to something like 2-3 seconds? Otherwise tests will take a long time to fail.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can reduce it a bit, but reducing too much causes tests in webassembly to flake out. I figure the common case of test success it will still finish quickly, but we need to give liberal time for wasm. I'll lower it to ~20sec?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for making this. Huge QoL improvement.
This PR adds a common crate & some utilities for testing WebAssembly. It mostly moves things around and should not effect functionality other than a few minor bug fixes for tests which previously did not run in web assembly
the bug fixes:
is_ready
in register_identity to toggle once the identity signature has been verified with backend, fixingSequenceId
errorssleep
implementation, replaced withyield
Notify
/Delivery
test utilities panicking streams in webassembly environment because ofstd::time
, replaced withxmtp_common::time
Common Crate:
rand_xx
fns that were duplicated across a few cratestime::
shims, that are now accessible viaxmtp_common::time
. It should be a drop-in replacement forstd::time
, and preferable to use instead ofstd::time
xmtp_common::yield_
which delegates to tokio or the browsers executor depending on environment. Should be preferred overtokio::task::yield
, since a WebAssembly future may not necessarily be running in a tokio executorretry
moved fromxmtp_mls
tocommon
. Retry is general enough that this makes sense, and allows it to be used without including all ofxmtp_mls
.traced_test
moved fromxmtp_mls
to common. Also general enough to be used w/o mls, and useful elsewherexmtp_common
includes a commonlogger
initializer toggling on arch,xmtp_common::logger
assert_x
andoptify
macros moved tocommon
store/mod.rs
create triggers to track intent metadata (created/published/deleted) and exposed for tests onDbConnection
cfg_attr/cfg_attr
pair, with the more succinctwasm_bindgen_test(unsupported = tokio::test)
macro