Skip to content

Commit bbff0d0

Browse files
authored
chore: Update response (#37)
* chore: Update response * chore: Update expected responses
1 parent cffb046 commit bbff0d0

File tree

6 files changed

+33
-12
lines changed

6 files changed

+33
-12
lines changed

fixture/Cargo.lock

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

fixture/coordinator1/src/lib.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,22 @@
11
use hdk::prelude::*;
22
use integrity::*;
3-
use serde::Deserialize;
3+
use serde::{Serialize, Deserialize};
4+
5+
#[derive(Debug, Serialize, Deserialize)]
6+
pub struct CreateResponse {
7+
pub created: ActionHashB64,
8+
}
49

510
#[hdk_extern]
6-
pub fn create_1() -> ExternResult<ActionHash> {
11+
pub fn create_1() -> ExternResult<CreateResponse> {
712
let time = sys_time()?;
813
let created = create_entry(EntryTypes::TestType(TestType {
914
value: format!("create_1_{time}"),
1015
}))?;
1116

1217
create_link(base(), created.clone(), LinkTypes::Link, ())?;
1318

14-
Ok(created)
19+
Ok(CreateResponse { created: created.into() })
1520
}
1621

1722
#[hdk_extern]

fixture/coordinator2/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,6 @@ name = "coordinator2"
99

1010
[dependencies]
1111
hdk = { workspace = true }
12+
serde = { workspace = true }
13+
1214
integrity = { workspace = true }

fixture/coordinator2/src/lib.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
11
use hdk::prelude::*;
22
use integrity::*;
3+
use serde::{Serialize, Deserialize};
4+
5+
#[derive(Debug, Serialize, Deserialize)]
6+
pub struct CreateResponse {
7+
pub created: ActionHashB64,
8+
}
39

410
#[hdk_extern]
5-
pub fn create_2() -> ExternResult<ActionHash> {
11+
pub fn create_2() -> ExternResult<CreateResponse> {
612
let time = sys_time()?;
713
let created = create_entry(EntryTypes::TestType(TestType {
814
value: format!("create_2_{time}"),
915
}))?;
1016

1117
create_link(base(), created.clone(), LinkTypes::Link, ())?;
1218

13-
Ok(created)
19+
Ok(CreateResponse { created: created.into() })
1420
}
1521

1622
#[hdk_extern]

tests/sweet/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,19 @@ use std::path::PathBuf;
99
use std::sync::Arc;
1010
// TODO `SerializedBytes` has an unclean macro reference to `holochain_serial!`
1111
use holochain_serialized_bytes::prelude::*;
12+
use holochain_types::prelude::ActionHashB64;
1213
use serde::{Deserialize, Serialize};
1314

1415
#[derive(Debug, Serialize, Deserialize, SerializedBytes)]
1516
pub struct TestType {
1617
pub value: String,
1718
}
1819

20+
#[derive(Debug, Serialize, Deserialize)]
21+
pub struct CreateResponse {
22+
pub created: ActionHashB64,
23+
}
24+
1925
#[derive(Debug, Serialize, Deserialize)]
2026
pub struct GetWithLimitRequest {
2127
pub limit: usize,

tests/zome_call.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
use crate::sweet::{init_zome, install_fixture1, install_fixture2, GetWithLimitRequest, TestType};
1+
use crate::sweet::{
2+
init_zome, install_fixture1, install_fixture2, CreateResponse, GetWithLimitRequest, TestType,
3+
};
24
use base64::Engine;
3-
use holochain::core::ActionHash;
45
use holochain::prelude::{CellId, DnaHash};
56
use holochain::sweettest::SweetConductor;
67
use holochain_conductor_api::CellInfo;
@@ -57,7 +58,7 @@ async fn respond_with_data() {
5758
// Create some data
5859
for _ in 0..3 {
5960
sweet_conductor
60-
.easy_call_zome::<_, ActionHash, _>(
61+
.easy_call_zome::<_, CreateResponse, _>(
6162
&app.agent_key,
6263
None,
6364
cell_id.clone(),
@@ -100,7 +101,7 @@ async fn get_data_with_agent_key_payload() {
100101
// Create some data
101102
for _ in 0..3 {
102103
sweet_conductor
103-
.easy_call_zome::<_, ActionHash, _>(
104+
.easy_call_zome::<_, CreateResponse, _>(
104105
&app.agent_key,
105106
None,
106107
cell_id.clone(),
@@ -143,7 +144,7 @@ async fn get_data_with_object_payload() {
143144
// Create some data
144145
for _ in 0..3 {
145146
sweet_conductor
146-
.easy_call_zome::<_, ActionHash, _>(
147+
.easy_call_zome::<_, CreateResponse, _>(
147148
&app.agent_key,
148149
None,
149150
cell_id.clone(),
@@ -186,7 +187,7 @@ async fn get_data_from_multiple_apps() {
186187
// Create some data
187188
for _ in 0..2 {
188189
sweet_conductor
189-
.easy_call_zome::<_, ActionHash, _>(
190+
.easy_call_zome::<_, CreateResponse, _>(
190191
&app_1.agent_key,
191192
None,
192193
cell_id_1.clone(),
@@ -206,7 +207,7 @@ async fn get_data_from_multiple_apps() {
206207
// Create some data
207208
for _ in 0..3 {
208209
sweet_conductor
209-
.easy_call_zome::<_, ActionHash, _>(
210+
.easy_call_zome::<_, CreateResponse, _>(
210211
&app_2.agent_key,
211212
None,
212213
cell_id_2.clone(),

0 commit comments

Comments
 (0)