diff --git a/examples/publish-read-data-blob/README.md b/examples/publish-read-data-blob/README.md index e26f43158c28..3fce22e089b6 100644 --- a/examples/publish-read-data-blob/README.md +++ b/examples/publish-read-data-blob/README.md @@ -1,8 +1,8 @@ # Publish and read a data blob This example shows how to create a blob and how to read it. -This example should be read in conjunction with the end-to-end -test `test_wasm_end_to_end_publish_read_data_blob`. +This example should be read in conjunction with the client +test `run_test_publish_read_data_blob`. It shows 3 scenarios: * Publishing and reading blobs with the publishing and reading in different diff --git a/linera-core/src/unit_tests/wasm_client_tests.rs b/linera-core/src/unit_tests/wasm_client_tests.rs index b9757c1c53a6..13cd8d453bf0 100644 --- a/linera-core/src/unit_tests/wasm_client_tests.rs +++ b/linera-core/src/unit_tests/wasm_client_tests.rs @@ -1066,7 +1066,7 @@ where // publishing the data. let publish_op = publish_read_data_blob::Operation::CreateDataBlob(test_data.clone()); - client + let certificate = client .execute_operation(Operation::user(application_id, &publish_op)?) .await .unwrap_ok_committed(); @@ -1081,14 +1081,18 @@ where .execute_operation(Operation::user(application_id, &read_op)?) .await .unwrap_ok_committed(); + // None of the following blocks should have oracle responses: all read blobs were created + // on the same chain, so no oracle is needed. + assert_eq!(certificate.block().body.oracle_responses[0].len(), 0); // Method 2: Publishing and reading in the same transaction let test_data = b"This is test data for method 2.".to_vec(); let combined_op = publish_read_data_blob::Operation::CreateAndReadDataBlob(test_data); - client + let certificate = client .execute_operation(Operation::user(application_id, &combined_op)?) .await .unwrap_ok_committed(); + assert_eq!(certificate.block().body.oracle_responses[0].len(), 0); // Method 3: Publishing and reading in the same block but different transactions let test_data = b"This is test data for method 3.".to_vec(); @@ -1098,10 +1102,12 @@ where let read_op = publish_read_data_blob::Operation::ReadDataBlob(hash, test_data); let op1 = Operation::user(application_id, &publish_op)?; let op2 = Operation::user(application_id, &read_op)?; - client + let certificate = client .execute_operations(vec![op1, op2], vec![]) .await .unwrap_ok_committed(); + assert_eq!(certificate.block().body.oracle_responses[0].len(), 0); + assert_eq!(certificate.block().body.oracle_responses[1].len(), 0); Ok(()) } diff --git a/linera-execution/src/execution_state_actor.rs b/linera-execution/src/execution_state_actor.rs index 193ba4f1c012..49ab8bdac8ff 100644 --- a/linera-execution/src/execution_state_actor.rs +++ b/linera-execution/src/execution_state_actor.rs @@ -452,17 +452,12 @@ where .await? .track_blob_read(content.bytes().len() as u64)?; } + self.state + .system + .blob_used(self.txn_tracker, blob_id) + .await?; content }; - let is_new = self - .state - .system - .blob_used(self.txn_tracker, blob_id) - .await?; - if is_new { - self.txn_tracker - .replay_oracle_response(OracleResponse::Blob(blob_id))?; - } callback.respond(content) }