-
Notifications
You must be signed in to change notification settings - Fork 11.3k
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
Remove balance from client test and added object ownership checks in test #48
Changes from all commits
c0c0c08
7c47f29
b85667b
20e28f7
8f272ed
81bcc6f
d01c7ad
a26b218
82c1855
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,7 +28,7 @@ pub trait AuthorityClient { | |
|
||
/// Handle information requests for this account. | ||
fn handle_account_info_request( | ||
&mut self, | ||
&self, | ||
request: AccountInfoRequest, | ||
) -> AsyncResult<'_, AccountInfoResponse, FastPayError>; | ||
} | ||
|
@@ -90,7 +90,6 @@ pub trait Client { | |
/// Do not confirm the transaction. | ||
fn transfer_to_fastpay_unsafe_unconfirmed( | ||
&mut self, | ||
amount: Amount, | ||
recipient: FastPayAddress, | ||
object_id: ObjectID, | ||
user_data: UserData, | ||
|
@@ -253,14 +252,14 @@ where | |
/// Find the highest sequence number that is known to a quorum of authorities. | ||
/// NOTE: This is only reliable in the synchronous model, with a sufficient timeout value. | ||
#[cfg(test)] | ||
async fn get_strong_majority_sequence_number(&mut self, object_id: ObjectID) -> SequenceNumber { | ||
async fn get_strong_majority_sequence_number(&self, object_id: ObjectID) -> SequenceNumber { | ||
let request = AccountInfoRequest { | ||
object_id, | ||
request_sequence_number: None, | ||
request_received_transfers_excluding_first_nth: None, | ||
}; | ||
let numbers: futures::stream::FuturesUnordered<_> = self | ||
.authority_clients | ||
let mut authority_clients = self.authority_clients.clone(); | ||
let numbers: futures::stream::FuturesUnordered<_> = authority_clients | ||
.iter_mut() | ||
.map(|(name, client)| { | ||
let fut = client.handle_account_info_request(request.clone()); | ||
|
@@ -277,23 +276,26 @@ where | |
) | ||
} | ||
|
||
/// Find the highest balance that is backed by a quorum of authorities. | ||
/// Return owner address and sequence number of an object backed by a quorum of authorities. | ||
/// NOTE: This is only reliable in the synchronous model, with a sufficient timeout value. | ||
#[cfg(test)] | ||
async fn get_strong_majority_balance(&mut self, object_id: ObjectID) -> Balance { | ||
async fn get_strong_majority_owner( | ||
&self, | ||
object_id: ObjectID, | ||
) -> Option<(FastPayAddress, SequenceNumber)> { | ||
let request = AccountInfoRequest { | ||
object_id, | ||
request_sequence_number: None, | ||
request_received_transfers_excluding_first_nth: None, | ||
}; | ||
let numbers: futures::stream::FuturesUnordered<_> = self | ||
.authority_clients | ||
.iter_mut() | ||
let authority_clients = self.authority_clients.clone(); | ||
let numbers: futures::stream::FuturesUnordered<_> = authority_clients | ||
.iter() | ||
.map(|(name, client)| { | ||
let fut = client.handle_account_info_request(request.clone()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's fishy that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is originated from |
||
async move { | ||
match fut.await { | ||
Ok(_info) => Some((*name, Balance::from(0))), | ||
Ok(info) => Some((*name, Some((info.owner, info.next_sequence_number)))), | ||
_ => None, | ||
} | ||
} | ||
|
@@ -686,7 +688,6 @@ where | |
|
||
fn transfer_to_fastpay_unsafe_unconfirmed( | ||
&mut self, | ||
_amount: Amount, | ||
recipient: FastPayAddress, | ||
object_id: ObjectID, | ||
user_data: UserData, | ||
|
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.
Nit: doc comment needs updating to reflect new return value