Skip to content
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

Use updated DB fn for is_empty #385

Merged
merged 2 commits into from
Feb 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion fastpay_core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ move-package = { git = "https://github.com/diem/move", rev="62b5a5075378ae6a7102
move-vm-runtime = { git = "https://github.com/diem/move", rev="62b5a5075378ae6a7102bbfc1fb33b57ba6125d2" }


typed-store = { git = "https://github.com/MystenLabs/mysten-infra", rev = "e62e090a0864ed35ecd4a2766fdfc6f5ef18f58a"}
typed-store = { git = "https://github.com/MystenLabs/mysten-infra", rev = "d04c29e686aba380e6f9fc0c60a2dfdb974c5f8a"}

[dev-dependencies]
fdlimit = "0.2.1"
Expand Down
2 changes: 1 addition & 1 deletion fastpay_core/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,7 @@ where
}

async fn sync_client_state(&mut self) -> Result<AuthorityName, anyhow::Error> {
if !self.store.pending_orders.is_empty()? {
if !self.store.pending_orders.is_empty() {
// Finish executing the previous orders
self.try_complete_pending_orders().await?;
}
Expand Down
22 changes: 11 additions & 11 deletions fastpay_core/src/unit_tests/client_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ fn test_initiating_valid_transfer() {
object_id: object_id_1
})
);
assert!(sender.store().pending_orders.is_empty().unwrap());
assert!(sender.store().pending_orders.is_empty());
assert_eq!(
rt.block_on(sender.authorities().get_strong_majority_owner(object_id_1)),
Some((Authenticator::Address(recipient), SequenceNumber::from(1)))
Expand Down Expand Up @@ -417,7 +417,7 @@ fn test_initiating_valid_transfer_despite_bad_authority() {
sender.next_sequence_number(&object_id),
Err(ObjectNotFound { object_id })
);
assert!(sender.store().pending_orders.is_empty().unwrap());
assert!(sender.store().pending_orders.is_empty());
assert_eq!(
rt.block_on(sender.authorities().get_strong_majority_owner(object_id)),
Some((Authenticator::Address(recipient), SequenceNumber::from(1)))
Expand Down Expand Up @@ -521,7 +521,7 @@ async fn test_bidirectional_transfer() {
.await
.unwrap();

assert!(client1.store().pending_orders.is_empty().unwrap());
assert!(client1.store().pending_orders.is_empty());
// Confirm client1 lose ownership of the object.
assert_eq!(
client1
Expand Down Expand Up @@ -577,7 +577,7 @@ async fn test_bidirectional_transfer() {
.await
.unwrap();

assert!((client2.store().pending_orders.is_empty().unwrap()));
assert!((client2.store().pending_orders.is_empty()));

// Confirm client2 lose ownership of the object.
assert_eq!(
Expand Down Expand Up @@ -692,8 +692,8 @@ async fn test_client_state_sync_with_transferred_object() {

// Client 2's local object_id and cert should be empty before sync
assert!(client2.get_owned_objects().await.is_empty());
assert!(client2.store().object_sequence_numbers.is_empty().unwrap());
assert!(&client2.store().certificates.is_empty().unwrap());
assert!(client2.store().object_sequence_numbers.is_empty());
assert!(&client2.store().certificates.is_empty());

// Sync client state
client2.sync_client_state().await.unwrap();
Expand Down Expand Up @@ -2474,7 +2474,7 @@ fn test_client_store() {
.multi_remove(keys_vals.into_iter().map(|(k, _)| k))
.unwrap();

assert!(store.object_sequence_numbers.is_empty().unwrap());
assert!(store.object_sequence_numbers.is_empty());
}

#[tokio::test]
Expand All @@ -2499,7 +2499,7 @@ async fn test_object_store() {
.clone();
let gas_object_ref = gas_object.clone().to_object_reference();
// Ensure that object store is empty
assert!(client1.store().objects.is_empty().unwrap());
assert!(client1.store().objects.is_empty());

// Run a few syncs to retrieve objects ids
for _ in 0..4 {
Expand Down Expand Up @@ -2653,7 +2653,7 @@ async fn test_transfer_pending_orders() {
.await
.unwrap();
// Pending order should be cleared
assert!(sender_state.store().pending_orders.is_empty().unwrap());
assert!(sender_state.store().pending_orders.is_empty());

// Test 2: Object not known to authorities. This has no side effect
let obj = Object::with_id_owner_for_testing(ObjectID::random(), sender_state.address());
Expand All @@ -2674,7 +2674,7 @@ async fn test_transfer_pending_orders() {
assert!(matches!(result.unwrap_err().downcast_ref(),
Some(FastPayError::QuorumNotReached {errors, ..}) if matches!(errors.as_slice(), [FastPayError::ObjectNotFound{..}, ..])));
// Pending order should be cleared
assert!(sender_state.store().pending_orders.is_empty().unwrap());
assert!(sender_state.store().pending_orders.is_empty());

// Test 3: invalid object digest. This also has no side effect
let object_id = *objects.next().unwrap();
Expand All @@ -2697,7 +2697,7 @@ async fn test_transfer_pending_orders() {
Some(FastPayError::QuorumNotReached {errors, ..}) if matches!(errors.as_slice(), [FastPayError::LockErrors{..}, ..])));

// Pending order should be cleared
assert!(sender_state.store().pending_orders.is_empty().unwrap());
assert!(sender_state.store().pending_orders.is_empty());

// Test 4: Conflicting orders touching same objects
let object_id = *objects.next().unwrap();
Expand Down
2 changes: 1 addition & 1 deletion fastx_types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ serde_bytes = "0.11.5"
serde_with = "1.11.0"
static_assertions = "1.1.0"

typed-store = { git = "https://github.com/MystenLabs/mysten-infra", rev ="e62e090a0864ed35ecd4a2766fdfc6f5ef18f58a"}
typed-store = { git = "https://github.com/MystenLabs/mysten-infra", rev ="d04c29e686aba380e6f9fc0c60a2dfdb974c5f8a"}

move-binary-format = { git = "https://github.com/diem/move", rev="62b5a5075378ae6a7102bbfc1fb33b57ba6125d2" }
move-core-types = { git = "https://github.com/diem/move", rev="62b5a5075378ae6a7102bbfc1fb33b57ba6125d2", features=["address20"] }