Skip to content

Commit 1b80f9e

Browse files
committed
change version back
1 parent 52d83fa commit 1b80f9e

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
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.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "dkn-compute"
3-
version = "0.3.0"
3+
version = "0.2.6"
44
edition = "2021"
55
license = "Apache-2.0"
66
readme = "README.md"

src/utils/message.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use crate::utils::{
22
crypto::{sha256hash, sign_bytes_recoverable},
33
get_current_time_nanos,
44
};
5+
use crate::DRIA_COMPUTE_NODE_VERSION;
56
use base64::{prelude::BASE64_STANDARD, Engine};
67
use core::fmt;
78
use ecies::PublicKey;
@@ -12,7 +13,7 @@ use serde::{Deserialize, Serialize};
1213
/// A message within Dria Knowledge Network.
1314
#[derive(Serialize, Deserialize, Debug, Clone)]
1415
pub struct DKNMessage {
15-
/// Base64 encoded data
16+
/// Base64 encoded payload, stores the main result.
1617
pub(crate) payload: String,
1718
/// The topic of the message, derived from `TopicHash`
1819
///
@@ -44,7 +45,7 @@ impl DKNMessage {
4445
Self {
4546
payload: BASE64_STANDARD.encode(payload),
4647
topic: topic.to_string(),
47-
version: crate::DRIA_COMPUTE_NODE_VERSION.to_string(),
48+
version: DRIA_COMPUTE_NODE_VERSION.to_string(),
4849
timestamp: get_current_time_nanos(),
4950
}
5051
}
@@ -133,8 +134,7 @@ mod tests {
133134
use crate::payloads::TaskResponsePayload;
134135
use crate::{utils::crypto::sha256hash, DriaComputeNodeConfig};
135136
use ecies::decrypt;
136-
use libsecp256k1::SecretKey;
137-
use libsecp256k1::{verify, Message, PublicKey, RecoveryId, Signature};
137+
use libsecp256k1::{verify, Message, PublicKey, RecoveryId, SecretKey, Signature};
138138
use rand::thread_rng;
139139
use serde_json::json;
140140

@@ -155,7 +155,7 @@ mod tests {
155155

156156
#[test]
157157
fn test_display_message() {
158-
let message = DKNMessage::new(b"hello world", "test-topic");
158+
let message = DKNMessage::new(b"hello world", TOPIC);
159159
println!("{}", message);
160160
}
161161

@@ -173,10 +173,11 @@ mod tests {
173173
serde_json::to_string(&body).expect("Should stringify"),
174174
"{\"hello\":\"world\"}"
175175
);
176-
assert_eq!(message.topic, "test-topic");
177-
assert_eq!(message.version, crate::DRIA_COMPUTE_NODE_VERSION);
176+
assert_eq!(message.topic, TOPIC);
177+
assert_eq!(message.version, DRIA_COMPUTE_NODE_VERSION);
178178
assert!(message.timestamp > 0);
179179

180+
// decode payload without signature
180181
let parsed_body = message.parse_payload(false).expect("Should decode");
181182
assert_eq!(body, parsed_body);
182183
}
@@ -200,8 +201,8 @@ mod tests {
200201
serde_json::to_string(&body).expect("Should stringify"),
201202
"{\"hello\":\"world\"}"
202203
);
203-
assert_eq!(message.topic, "test-topic");
204-
assert_eq!(message.version, crate::DRIA_COMPUTE_NODE_VERSION);
204+
assert_eq!(message.topic, TOPIC);
205+
assert_eq!(message.version, DRIA_COMPUTE_NODE_VERSION);
205206
assert!(message.timestamp > 0);
206207

207208
assert!(message.is_signed(&pk).expect("Should check signature"));

0 commit comments

Comments
 (0)