Skip to main content

nym_node_tester_utils/
error.rs

1// Copyright 2023 - Nym Technologies SA <contact@nymtech.net>
2// SPDX-License-Identifier: Apache-2.0
3
4use crate::NodeId;
5use nym_sphinx::chunking::ChunkingError;
6use nym_sphinx::receiver::MessageRecoveryError;
7use nym_topology::NymTopologyError;
8use thiserror::Error;
9
10#[derive(Debug, Error)]
11pub enum NetworkTestingError {
12    #[error(transparent)]
13    SerializationFailure(#[from] serde_json::Error),
14
15    #[error("could not recover received test message: {source}")]
16    MalformedTestMessageReceived { source: serde_json::Error },
17
18    #[error(transparent)]
19    InvalidTopology(#[from] NymTopologyError),
20
21    #[error("The specified mixnode (id: {mix_id}) doesn't exist")]
22    NonExistentMixnode { mix_id: NodeId },
23
24    #[error("The specified mixnode (identity: {mix_identity}) doesn't exist")]
25    NonExistentMixnodeIdentity { mix_identity: String },
26
27    #[error("The specified gateway (id: {gateway_identity}) doesn't exist")]
28    NonExistentGateway { gateway_identity: String },
29
30    #[error("The provided test message is too long to fit in a single sphinx packet")]
31    TestMessageTooLong,
32
33    #[error(
34        "could not recover underlying data from the received packet since it was malformed: {source}"
35    )]
36    MalformedPacketReceived {
37        #[from]
38        source: MessageRecoveryError,
39    },
40
41    #[error("Received ack packet could not be recovered")]
42    UnrecoverableAck,
43
44    #[error("could not recover ack FragmentIdentifier: {source}")]
45    MalformedAckIdentifier { source: ChunkingError },
46
47    #[error("received a packet that could not be reconstructed into a full message with a single fragment")]
48    NonReconstructablePacket,
49
50    #[error("the recipient of the test packet was never specified")]
51    UnknownPacketRecipient,
52}