Skip to content

Commit 923b805

Browse files
committed
tiny rfk in tests
1 parent 2030b33 commit 923b805

File tree

2 files changed

+11
-27
lines changed

2 files changed

+11
-27
lines changed

src/handlers/pingpong.rs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,14 @@ mod tests {
8585
use super::PingpongPayload;
8686

8787
#[test]
88-
fn test_heartbeat_payload() {
88+
fn test_pingpong_payload() {
8989
let pk = PublicKey::parse_compressed(&hex_literal::hex!(
9090
"0208ef5e65a9c656a6f92fb2c770d5d5e2ecffe02a6aade19207f75110be6ae658"
9191
))
9292
.expect("Should parse public key");
9393
let message = DKNMessage {
9494
payload: "Y2RmODcyNDlhY2U3YzQ2MDIzYzNkMzBhOTc4ZWY3NjViMWVhZDlmNWJhMDUyY2MxMmY0NzIzMjQyYjc0YmYyODFjMDA1MTdmMGYzM2VkNTgzMzk1YWUzMTY1ODQ3NWQyNDRlODAxYzAxZDE5MjYwMDM1MTRkNzEwMThmYTJkNjEwMXsidXVpZCI6ICI4MWE2M2EzNC05NmM2LTRlNWEtOTliNS02YjI3NGQ5ZGUxNzUiLCAiZGVhZGxpbmUiOiAxNzE0MTI4NzkyfQ==".to_string(),
95-
topic: "heartbeat".to_string(),
95+
topic: "pingpong".to_string(),
9696
version: "0.0.0".to_string(),
9797
timestamp: 1714129073557846272,
9898
};
@@ -106,22 +106,21 @@ mod tests {
106106
assert_eq!(obj.deadline, 1714128792);
107107
}
108108

109-
/// This test demonstrates the process of heartbeat & task assignment.
109+
/// This test demonstrates the process of pingpong & task assignment.
110110
///
111111
/// A heart-beat message is sent over the network by Admin Node, and compute node responds with a signature.
112112
#[test]
113-
fn test_heartbeat_and_task_assignment() {
113+
fn test_pingpong_and_task_assignment() {
114114
let config = DriaComputeNodeConfig::default();
115115

116-
// a heartbeat message is signed and sent to Admin Node over the p2p network
117-
let heartbeat_message = Message::parse(&sha256hash(b"sign-me"));
118-
let (heartbeat_signature, heartbeat_recid) =
119-
libsecp256k1::sign(&heartbeat_message, &config.secret_key);
116+
// a pingpong message is signed and sent to Admin Node over the p2p network
117+
let pingpong_message = Message::parse(&sha256hash(b"sign-me"));
118+
let (pingpong_signature, pingpong_recid) =
119+
libsecp256k1::sign(&pingpong_message, &config.secret_key);
120120

121121
// admin recovers the address from the signature
122-
let recovered_public_key =
123-
recover(&heartbeat_message, &heartbeat_signature, &heartbeat_recid)
124-
.expect("Could not recover");
122+
let recovered_public_key = recover(&pingpong_message, &pingpong_signature, &pingpong_recid)
123+
.expect("Could not recover");
125124
assert_eq!(
126125
config.public_key, recovered_public_key,
127126
"Public key mismatch"

src/payloads/request.rs

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
use crate::utils::{filter::TaskFilter, get_current_time_nanos};
2-
use fastbloom_rs::BloomFilter;
1+
use crate::utils::filter::TaskFilter;
32
use serde::{Deserialize, Serialize};
4-
use uuid::Uuid;
53

64
/// A generic task request, given by Dria.
75
#[derive(Debug, Clone, Serialize, Deserialize)]
@@ -18,16 +16,3 @@ pub struct TaskRequestPayload<T> {
1816
/// The public key of the requester, in hexadecimals.
1917
pub(crate) public_key: String,
2018
}
21-
22-
impl<T> TaskRequestPayload<T> {
23-
#[allow(unused)]
24-
pub fn new(input: T, filter: BloomFilter, time_ns: u128, public_key: Option<String>) -> Self {
25-
Self {
26-
task_id: Uuid::new_v4().into(),
27-
deadline: get_current_time_nanos() + time_ns,
28-
input,
29-
filter: filter.into(),
30-
public_key: public_key.unwrap_or_default(),
31-
}
32-
}
33-
}

0 commit comments

Comments
 (0)