Skip to content

Commit f2ac478

Browse files
Eliminate another end-to-end test. (#4397)
## Motivation The `test_publish_read_data_blob` was an end-to-end test. ## Proposal The test is now moved to the `linera-core`. ## Test Plan The CI. It has been tested that the functionalities being tested in those end-to-end tests are also tested in those tests. ## Release Plan - Nothing to do / These changes follow the usual release cycle. ## Links None
1 parent 34d93fe commit f2ac478

File tree

5 files changed

+119
-80
lines changed

5 files changed

+119
-80
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

linera-core/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ hex-game.workspace = true
9797
linera-core = { path = ".", default-features = false, features = ["test"] }
9898
linera-views.workspace = true
9999
meta-counter.workspace = true
100+
publish-read-data-blob.workspace = true
100101
serde_json.workspace = true
101102
sha3.workspace = true
102103
social.workspace = true

linera-core/src/unit_tests/wasm_client_tests.rs

Lines changed: 117 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@ use counter::CounterAbi;
2121
use fungible::{FungibleOperation, InitialState, Parameters};
2222
use hex_game::{HexAbi, Operation as HexOperation, Timeouts};
2323
use linera_base::{
24-
crypto::InMemorySigner,
25-
data_types::{Amount, BlockHeight, Bytecode, ChainDescription, Event, OracleResponse},
26-
identifiers::{ApplicationId, BlobId, BlobType, ModuleId, StreamId, StreamName},
24+
crypto::{CryptoHash, InMemorySigner},
25+
data_types::{
26+
Amount, BlobContent, BlockHeight, Bytecode, ChainDescription, Event, OracleResponse,
27+
},
28+
identifiers::{ApplicationId, BlobId, BlobType, DataBlobHash, ModuleId, StreamId, StreamName},
2729
ownership::{ChainOwnership, TimeoutConfig},
2830
vm::VmRuntime,
2931
};
@@ -989,3 +991,115 @@ where
989991
.await?;
990992
Ok(())
991993
}
994+
995+
#[cfg_attr(feature = "wasmer", test_case(WasmRuntime::Wasmer ; "wasmer"))]
996+
#[cfg_attr(feature = "wasmtime", test_case(WasmRuntime::Wasmtime ; "wasmtime"))]
997+
#[test_log::test(tokio::test(flavor = "multi_thread"))]
998+
async fn test_memory_publish_read_data_blob(wasm_runtime: WasmRuntime) -> anyhow::Result<()> {
999+
run_test_publish_read_data_blob(MemoryStorageBuilder::with_wasm_runtime(wasm_runtime)).await
1000+
}
1001+
1002+
#[ignore]
1003+
#[cfg(feature = "storage-service")]
1004+
#[cfg_attr(feature = "wasmer", test_case(WasmRuntime::Wasmer ; "wasmer"))]
1005+
#[cfg_attr(feature = "wasmtime", test_case(WasmRuntime::Wasmtime ; "wasmtime"))]
1006+
#[test_log::test(tokio::test(flavor = "multi_thread"))]
1007+
async fn test_service_publish_read_data_blob(wasm_runtime: WasmRuntime) -> anyhow::Result<()> {
1008+
run_test_publish_read_data_blob(ServiceStorageBuilder::with_wasm_runtime(wasm_runtime).await)
1009+
.await
1010+
}
1011+
1012+
#[ignore]
1013+
#[cfg(feature = "rocksdb")]
1014+
#[cfg_attr(feature = "wasmer", test_case(WasmRuntime::Wasmer ; "wasmer"))]
1015+
#[cfg_attr(feature = "wasmtime", test_case(WasmRuntime::Wasmtime ; "wasmtime"))]
1016+
#[test_log::test(tokio::test(flavor = "multi_thread"))]
1017+
async fn test_rocks_db_publish_read_data_blob(wasm_runtime: WasmRuntime) -> anyhow::Result<()> {
1018+
run_test_publish_read_data_blob(RocksDbStorageBuilder::with_wasm_runtime(wasm_runtime).await)
1019+
.await
1020+
}
1021+
1022+
#[ignore]
1023+
#[cfg(feature = "dynamodb")]
1024+
#[cfg_attr(feature = "wasmer", test_case(WasmRuntime::Wasmer ; "wasmer"))]
1025+
#[cfg_attr(feature = "wasmtime", test_case(WasmRuntime::Wasmtime ; "wasmtime"))]
1026+
#[test_log::test(tokio::test(flavor = "multi_thread"))]
1027+
async fn test_dynamo_db_publish_read_data_blob(wasm_runtime: WasmRuntime) -> anyhow::Result<()> {
1028+
run_test_publish_read_data_blob(DynamoDbStorageBuilder::with_wasm_runtime(wasm_runtime)).await
1029+
}
1030+
1031+
#[ignore]
1032+
#[cfg(feature = "scylladb")]
1033+
#[cfg_attr(feature = "wasmer", test_case(WasmRuntime::Wasmer ; "wasmer"))]
1034+
#[cfg_attr(feature = "wasmtime", test_case(WasmRuntime::Wasmtime ; "wasmtime"))]
1035+
#[test_log::test(tokio::test(flavor = "multi_thread"))]
1036+
async fn test_scylla_db_publish_read_data_blob(wasm_runtime: WasmRuntime) -> anyhow::Result<()> {
1037+
run_test_publish_read_data_blob(ScyllaDbStorageBuilder::with_wasm_runtime(wasm_runtime)).await
1038+
}
1039+
1040+
async fn run_test_publish_read_data_blob<B>(storage_builder: B) -> anyhow::Result<()>
1041+
where
1042+
B: StorageBuilder,
1043+
{
1044+
use publish_read_data_blob::PublishReadDataBlobAbi;
1045+
1046+
let keys = InMemorySigner::new(None);
1047+
let mut builder = TestBuilder::new(storage_builder, 4, 1, keys)
1048+
.await?
1049+
.with_policy(ResourceControlPolicy::all_categories());
1050+
let client = builder.add_root_chain(0, Amount::from_tokens(3)).await?;
1051+
1052+
let module_id = client
1053+
.publish_wasm_example("publish-read-data-blob")
1054+
.await?;
1055+
let module_id = module_id.with_abi::<PublishReadDataBlobAbi, (), ()>();
1056+
1057+
let (application_id, _) = client
1058+
.create_application(module_id, &(), &(), vec![])
1059+
.await
1060+
.unwrap_ok_committed();
1061+
1062+
// Method 1: Publishing and reading in different blocks.
1063+
let test_data = b"This is test data for method 1.".to_vec();
1064+
1065+
// publishing the data.
1066+
let publish_op = publish_read_data_blob::Operation::CreateDataBlob(test_data.clone());
1067+
client
1068+
.execute_operation(Operation::user(application_id, &publish_op)?)
1069+
.await
1070+
.unwrap_ok_committed();
1071+
1072+
// getting the hash
1073+
let content = BlobContent::new_data(test_data.clone());
1074+
let hash = DataBlobHash(CryptoHash::new(&content));
1075+
1076+
// reading and checking
1077+
let read_op = publish_read_data_blob::Operation::ReadDataBlob(hash, test_data);
1078+
client
1079+
.execute_operation(Operation::user(application_id, &read_op)?)
1080+
.await
1081+
.unwrap_ok_committed();
1082+
1083+
// Method 2: Publishing and reading in the same transaction
1084+
let test_data = b"This is test data for method 2.".to_vec();
1085+
let combined_op = publish_read_data_blob::Operation::CreateAndReadDataBlob(test_data);
1086+
client
1087+
.execute_operation(Operation::user(application_id, &combined_op)?)
1088+
.await
1089+
.unwrap_ok_committed();
1090+
1091+
// Method 3: Publishing and reading in the same block but different transactions
1092+
let test_data = b"This is test data for method 3.".to_vec();
1093+
let publish_op = publish_read_data_blob::Operation::CreateDataBlob(test_data.clone());
1094+
let content = BlobContent::new_data(test_data.clone());
1095+
let hash = DataBlobHash(CryptoHash::new(&content));
1096+
let read_op = publish_read_data_blob::Operation::ReadDataBlob(hash, test_data);
1097+
let op1 = Operation::user(application_id, &publish_op)?;
1098+
let op2 = Operation::user(application_id, &read_op)?;
1099+
client
1100+
.execute_operations(vec![op1, op2], vec![])
1101+
.await
1102+
.unwrap_ok_committed();
1103+
1104+
Ok(())
1105+
}

linera-service/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,6 @@ native-fungible.workspace = true
154154
non-fungible.workspace = true
155155
prometheus.workspace = true
156156
proptest.workspace = true
157-
publish-read-data-blob.workspace = true
158157
reqwest = { workspace = true, features = ["json"] }
159158
social.workspace = true
160159
test-case.workspace = true

linera-service/tests/linera_net_tests.rs

Lines changed: 0 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -4657,78 +4657,3 @@ async fn test_end_to_end_repeated_transfers(config: impl LineraNetConfig) -> Res
46574657

46584658
Ok(())
46594659
}
4660-
4661-
#[cfg_attr(feature = "storage-service", test_case(LocalNetConfig::new_test(Database::Service, Network::Grpc) ; "storage_test_service_grpc"))]
4662-
#[cfg_attr(feature = "scylladb", test_case(LocalNetConfig::new_test(Database::ScyllaDb, Network::Grpc) ; "scylladb_grpc"))]
4663-
#[cfg_attr(feature = "dynamodb", test_case(LocalNetConfig::new_test(Database::DynamoDb, Network::Grpc) ; "aws_grpc"))]
4664-
#[cfg_attr(feature = "kubernetes", test_case(SharedLocalKubernetesNetTestingConfig::new(Network::Grpc, BuildArg::Build) ; "kubernetes_grpc"))]
4665-
#[cfg_attr(feature = "remote-net", test_case(RemoteNetTestingConfig::new(None) ; "remote_net_grpc"))]
4666-
#[test_log::test(tokio::test)]
4667-
async fn test_wasm_end_to_end_publish_read_data_blob(config: impl LineraNetConfig) -> Result<()> {
4668-
use publish_read_data_blob::{PublishReadDataBlobAbi, ServiceQuery};
4669-
4670-
let _guard = INTEGRATION_TEST_GUARD.lock().await;
4671-
tracing::info!("Starting test {}", test_name!());
4672-
4673-
let (mut net, client) = config.instantiate().await?;
4674-
4675-
let chain = client.load_wallet()?.default_chain().unwrap();
4676-
let (contract, service) = client.build_example("publish-read-data-blob").await?;
4677-
4678-
let application_id = client
4679-
.publish_and_create::<PublishReadDataBlobAbi, (), ()>(
4680-
contract,
4681-
service,
4682-
VmRuntime::Wasm,
4683-
&(),
4684-
&(),
4685-
&[],
4686-
None,
4687-
)
4688-
.await?;
4689-
4690-
let port = get_node_port().await;
4691-
let mut node_service = client.run_node_service(port, ProcessInbox::Skip).await?;
4692-
4693-
let application = node_service
4694-
.make_application(&chain, &application_id)
4695-
.await?;
4696-
4697-
// Method 1: Publishing and reading in different blocks.
4698-
4699-
let test_data = b"This is test data for method 1.".to_vec();
4700-
4701-
// publishing the data.
4702-
let mutation = ServiceQuery::PublishDataBlob(test_data.clone());
4703-
application.run_json_query(&mutation).await?;
4704-
4705-
// getting the hash
4706-
let content = BlobContent::new_data(test_data.clone());
4707-
let hash = DataBlobHash(CryptoHash::new(&content));
4708-
4709-
// reading and checking
4710-
let mutation = ServiceQuery::ReadDataBlob(hash, test_data);
4711-
application.run_json_query(&mutation).await?;
4712-
4713-
// Method 2: Publishing and reading in the same transaction
4714-
4715-
let test_data = b"This is test data for method 2.".to_vec();
4716-
4717-
let mutation = ServiceQuery::PublishAndCreateOneOperation(test_data);
4718-
application.run_json_query(&mutation).await?;
4719-
4720-
// Method 3: Publishing and reading in the same block but different transactions
4721-
4722-
let test_data = b"This is test data for method 3.".to_vec();
4723-
4724-
let mutation = ServiceQuery::PublishAndCreateTwoOperations(test_data);
4725-
application.run_json_query(&mutation).await?;
4726-
4727-
// Winding down
4728-
4729-
node_service.ensure_is_running()?;
4730-
net.ensure_is_running().await?;
4731-
net.terminate().await?;
4732-
4733-
Ok(())
4734-
}

0 commit comments

Comments
 (0)