|
78 | 78 | expected_http_requests: VecDeque<(http::Request, http::Response)>, |
79 | 79 | expected_read_data_blob_requests: VecDeque<(DataBlobHash, Vec<u8>)>, |
80 | 80 | expected_assert_data_blob_exists_requests: VecDeque<(DataBlobHash, Option<()>)>, |
| 81 | + expected_has_non_trivial_storage_requests: VecDeque<(ApplicationId, bool)>, |
81 | 82 | expected_open_chain_calls: VecDeque<(ChainOwnership, ApplicationPermissions, Amount, ChainId)>, |
82 | 83 | expected_publish_module_calls: VecDeque<ExpectedPublishModuleCall>, |
83 | 84 | expected_create_application_calls: VecDeque<ExpectedCreateApplicationCall>, |
@@ -127,6 +128,7 @@ where |
127 | 128 | expected_http_requests: VecDeque::new(), |
128 | 129 | expected_read_data_blob_requests: VecDeque::new(), |
129 | 130 | expected_assert_data_blob_exists_requests: VecDeque::new(), |
| 131 | + expected_has_non_trivial_storage_requests: VecDeque::new(), |
130 | 132 | expected_open_chain_calls: VecDeque::new(), |
131 | 133 | expected_publish_module_calls: VecDeque::new(), |
132 | 134 | expected_create_application_calls: VecDeque::new(), |
@@ -936,6 +938,16 @@ where |
936 | 938 | .push_back((hash, response)); |
937 | 939 | } |
938 | 940 |
|
| 941 | + /// Adds an expected `has_non_trivial_storage` call, and the response it should return in the test. |
| 942 | + pub fn add_expected_has_non_trivial_storage_requests( |
| 943 | + &mut self, |
| 944 | + application: ApplicationId, |
| 945 | + response: bool, |
| 946 | + ) { |
| 947 | + self.expected_has_non_trivial_storage_requests |
| 948 | + .push_back((application, response)); |
| 949 | + } |
| 950 | + |
939 | 951 | /// Queries an application service as an oracle and returns the response. |
940 | 952 | /// |
941 | 953 | /// Should only be used with queries where it is very likely that all validators will compute |
@@ -997,6 +1009,15 @@ where |
997 | 1009 | response.expect("Blob does not exist!"); |
998 | 1010 | } |
999 | 1011 |
|
| 1012 | + /// Returns true if the corresponding contract uses a non-zero amount of storage. |
| 1013 | + pub fn has_non_trivial_storage(&mut self, application: ApplicationId) -> bool { |
| 1014 | + let maybe_request = self.expected_has_non_trivial_storage_requests.pop_front(); |
| 1015 | + let (expected_application_id, response) = |
| 1016 | + maybe_request.expect("Unexpected has_non_trivial_storage request"); |
| 1017 | + assert_eq!(application, expected_application_id); |
| 1018 | + response |
| 1019 | + } |
| 1020 | + |
1000 | 1021 | /// Returns the round in which this block was validated. |
1001 | 1022 | pub fn validation_round(&mut self) -> Option<u32> { |
1002 | 1023 | self.round |
|
0 commit comments