Skip to content

refactor(platform)!: document creation/update/deletion does not refetch contract #1840

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

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ use drive::drive::batch::{
DataContractOperationType, DocumentOperationType, DriveOperation, IdentityOperationType,
};

use drive::drive::object_size_info::{DocumentAndContractInfo, DocumentInfo, OwnedDocumentInfo};
use drive::drive::object_size_info::{
DataContractInfo, DocumentInfo, DocumentTypeInfo, OwnedDocumentInfo,
};
use drive::query::TransactionArg;
use std::borrow::Cow;
use std::collections::BTreeMap;
Expand Down Expand Up @@ -267,18 +269,15 @@ impl<C> Platform<C> {

let document_type = contract.document_type_for_name("domain")?;

let operation =
DriveOperation::DocumentOperation(DocumentOperationType::AddDocumentForContract {
document_and_contract_info: DocumentAndContractInfo {
owned_document_info: OwnedDocumentInfo {
document_info: DocumentInfo::DocumentOwnedInfo((document, None)),
owner_id: None,
},
contract,
document_type,
},
override_document: false,
});
let operation = DriveOperation::DocumentOperation(DocumentOperationType::AddDocument {
owned_document_info: OwnedDocumentInfo {
document_info: DocumentInfo::DocumentOwnedInfo((document, None)),
owner_id: None,
},
contract_info: DataContractInfo::BorrowedDataContract(contract),
document_type_info: DocumentTypeInfo::DocumentTypeRef(document_type),
override_document: false,
});

operations.push(operation);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,7 @@ mod tests {

assert_eq!(processing_result.valid_count(), 1);

assert_eq!(processing_result.aggregated_fees().processing_fee, 5081030);
assert_eq!(processing_result.aggregated_fees().processing_fee, 3810570);
}

#[test]
Expand Down Expand Up @@ -2014,7 +2014,7 @@ mod tests {

assert_eq!(processing_result.aggregated_fees().storage_fee, 0); // There is no storage fee, as there are no indexes that will change

assert_eq!(processing_result.aggregated_fees().processing_fee, 5609930);
assert_eq!(processing_result.aggregated_fees().processing_fee, 4926670);
}

#[test]
Expand Down Expand Up @@ -2205,7 +2205,7 @@ mod tests {
Some(14992395)
);

assert_eq!(processing_result.aggregated_fees().processing_fee, 9357180);
assert_eq!(processing_result.aggregated_fees().processing_fee, 8622720);

let query_sender_results = platform
.drive
Expand Down Expand Up @@ -2742,7 +2742,7 @@ mod tests {

assert_eq!(processing_result.valid_count(), 1);

assert_eq!(processing_result.aggregated_fees().processing_fee, 10283900);
assert_eq!(processing_result.aggregated_fees().processing_fee, 9549440);

let query_sender_results = platform
.drive
Expand Down Expand Up @@ -3145,7 +3145,7 @@ mod tests {

assert_eq!(processing_result.valid_count(), 1);

assert_eq!(processing_result.aggregated_fees().processing_fee, 6814950);
assert_eq!(processing_result.aggregated_fees().processing_fee, 6075290);

let query_sender_results = platform
.drive
Expand Down Expand Up @@ -3266,11 +3266,11 @@ mod tests {
.change(),
&BalanceChange::RemoveFromBalance {
required_removed_balance: 123579000,
desired_removed_balance: 128673220,
desired_removed_balance: 127933560,
}
);

let original_creation_cost = 128673220;
let original_creation_cost = 127933560;

platform
.drive
Expand Down Expand Up @@ -3397,7 +3397,7 @@ mod tests {
None
);

assert_eq!(processing_result.aggregated_fees().processing_fee, 6814950);
assert_eq!(processing_result.aggregated_fees().processing_fee, 6075290);

let seller_balance = platform
.drive
Expand All @@ -3408,7 +3408,7 @@ mod tests {
// the seller should have received 0.1 and already had 0.1 minus the processing fee and storage fee
assert_eq!(
seller_balance,
dash_to_credits!(0.1) - 6814950 - 216000 - original_creation_cost
dash_to_credits!(0.1) - 6075290 - 216000 - original_creation_cost
);

let query_sender_results = platform
Expand Down Expand Up @@ -3503,7 +3503,7 @@ mod tests {

assert_eq!(processing_result.aggregated_fees().storage_fee, 64611000);

assert_eq!(processing_result.aggregated_fees().processing_fee, 10873700);
assert_eq!(processing_result.aggregated_fees().processing_fee, 10134040);

assert_eq!(
processing_result
Expand Down Expand Up @@ -3537,7 +3537,7 @@ mod tests {
// the seller should have received 0.1 and already had 0.1 minus the processing fee and storage fee
assert_eq!(
seller_balance,
dash_to_credits!(0.2) - 6814950 - 216000 - original_creation_cost + 22704503
dash_to_credits!(0.2) - 6075290 - 216000 - original_creation_cost + 22704503
);

let buyers_balance = platform
Expand All @@ -3547,7 +3547,7 @@ mod tests {
.expect("expected that purchaser exists");

// the buyer payed 0.1, but also storage and processing fees
assert_eq!(buyers_balance, dash_to_credits!(0.9) - 10873700 - 64611000);
assert_eq!(buyers_balance, dash_to_credits!(0.9) - 10134040 - 64611000);
}

#[test]
Expand Down Expand Up @@ -4413,7 +4413,7 @@ mod tests {

assert_eq!(processing_result.valid_count(), 1);

assert_eq!(processing_result.aggregated_fees().processing_fee, 6814950);
assert_eq!(processing_result.aggregated_fees().processing_fee, 6075290);

let query_sender_results = platform
.drive
Expand Down
4 changes: 2 additions & 2 deletions packages/rs-drive-abci/tests/strategy_tests/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1778,7 +1778,7 @@ mod tests {
.unwrap()
.unwrap()
),
"c0c1f59b535f358448a33c20b419b93bcfa12b05b221f77a7347892f48ca2f16".to_string()
"10fbe38850d752b491305b2587468788acbd6dd130272c5a8844d0da05e3a9cf".to_string()
)
}

Expand Down Expand Up @@ -1903,7 +1903,7 @@ mod tests {
.unwrap()
.unwrap()
),
"a7be306dcdf58930dc14befa2b78c839d66699cf9d454942ac9c595161ffe99e".to_string()
"9ed86b1ed5d0f7a981cb0ff2f3943603a095a031c463b3389bce8a6f60e2b21e".to_string()
)
}

Expand Down
2 changes: 1 addition & 1 deletion packages/rs-drive-abci/tests/strategy_tests/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use drive_abci::rpc::core::MockCoreRPCLike;
use rand::prelude::SliceRandom;
use rand::rngs::StdRng;
use rand::{Rng, SeedableRng};
use std::collections::{HashMap, HashSet};
use std::collections::HashMap;
use strategy_tests::frequency::Frequency;
use tenderdash_abci::proto::google::protobuf::Timestamp;
use tenderdash_abci::proto::serializers::timestamp::ToMilis;
Expand Down
Loading