• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Neptune-Crypto / neptune-core / 14919393916

09 May 2025 01:23AM UTC coverage: 71.653% (-3.3%) from 74.963%
14919393916

push

github

dan-da
style: address review comments

Addresses review comments for #583:

+ use #[cfg(not(test))] instead of bool param to disable initial sleep
  in mining loop for unit tests
+ improve comment in mining loop when checking composer_task error
+ rename RpcError::Error to RpcError::WalletError
+ remove redundant copy_dir_recursive() in src/tests/shared.rs

0 of 4 new or added lines in 2 files covered. (0.0%)

172 existing lines in 18 files now uncovered.

19870 of 27731 relevant lines covered (71.65%)

367043.22 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

33.33
/src/api/tx_initiation/error.rs
1
//! provides error types related to initiating transactions.
2

3
use tasm_lib::prelude::Digest;
4

5
use crate::api::export::BlockHeight;
6
use crate::api::export::NativeCurrencyAmount;
7
use crate::api::export::WitnessValidationError;
8
use crate::job_queue::errors::AddJobError;
9
use crate::job_queue::errors::JobHandleError;
10
use crate::job_queue::errors::JobHandleErrorSync;
11
use crate::models::blockchain::transaction::transaction_proof::TransactionProofType;
12
use crate::models::proof_abstractions::tasm::prover_job::ProverJobError;
13
use crate::models::state::tx_proving_capability::TxProvingCapability;
14

15
/// enumerates possible transaction send errors
16
#[derive(Debug, Clone, thiserror::Error)]
17
#[non_exhaustive]
18
pub enum CreateTxError {
19
    #[error("missing required data to build transaction")]
20
    MissingRequirement,
21

22
    #[error("Transaction with negative fees not allowed")]
23
    NegativeFee,
24

25
    #[error("total spend amount is too large")]
26
    TotalSpendTooLarge,
27

28
    #[error(
29
        "insufficient funds. requested: {}, available: {}",
30
        requested,
31
        available
32
    )]
33
    InsufficientFunds {
34
        requested: NativeCurrencyAmount,
35
        available: NativeCurrencyAmount,
36
    },
37

38
    #[error("ChangePolicy = ExactChange, but input amount exceeds output amount")]
39
    NotExactChange,
40

41
    #[error("provided key_type cannot be used for receiving change.")]
42
    InvalidKeyForChange,
43

44
    #[error("cannot generate change key for immutable wallet.")]
45
    CantGenChangeKeyForImmutableWallet,
46

47
    #[error("witness validation failed")]
48
    WitnessValidationFailed(#[from] WitnessValidationError),
49

50
    // catch-all error, eg for anyhow errors
51
    #[error("transaction could not be created.  reason: {0}")]
52
    Failed(String),
53
}
54

55
#[derive(Debug, Clone, thiserror::Error, strum::Display)]
56
#[non_exhaustive]
57
pub enum ProofRequirement {
58
    Program,
59
    Claim,
60
    NonDeterminism,
61
    ProofJobOptions,
62
    TransactionProofInput,
63
}
64

65
/// enumerates possible proof generation errors
66
#[derive(Debug, thiserror::Error)]
67
#[non_exhaustive]
68
pub enum CreateProofError {
69
    #[error("missing required data to build proof: {0}")]
70
    MissingRequirement(#[from] ProofRequirement),
71

72
    #[error(
73
        "machine capability {capability} is insufficient to generate proof of type: {proof_type}"
74
    )]
75
    TooWeak {
76
        proof_type: TransactionProofType,
77
        capability: TxProvingCapability,
78
    },
79

80
    #[error("target proof type {0} is not a triton-vm proof.")]
81
    NotVmProof(TransactionProofType),
82

83
    #[error(transparent)]
84
    AddJobError(#[from] AddJobError),
85

86
    #[error(transparent)]
87
    ProverJobError(#[from] ProverJobError),
88

89
    #[error(transparent)]
90
    JobHandleError(#[from] JobHandleErrorSync),
91

92
    #[error("Could not forward job cancellation msg to proving job. {0}")]
93
    JobCancelSendError(#[from] tokio::sync::watch::error::SendError<()>),
94
}
95

96
/// enumerates possible upgrade-proof errors
97
#[derive(Debug, Clone, thiserror::Error)]
98
#[non_exhaustive]
99
pub enum UpgradeProofError {
100
    #[error("transaction is not found in mempool")]
101
    TxNotInMempool,
102

103
    #[error("input proof is not an upgrade.  ignoring.")]
104
    ProofNotAnUpgrade,
105

106
    #[error("provided proof is not valid for specified transaction.")]
107
    InvalidProof,
108
}
109

110
/// enumerates possible transaction send errors
111
#[derive(Debug, thiserror::Error)]
112
#[non_exhaustive]
113
pub enum SendError {
114
    #[error("send() is not supported by this node")]
115
    Unsupported,
116

117
    #[error("transaction could not be broadcast.")]
118
    NotBroadcast,
119

120
    #[error(transparent)]
121
    Tx(#[from] CreateTxError),
122

123
    #[error(transparent)]
124
    Proof(#[from] CreateProofError),
125

126
    // catch-all error, eg for anyhow errors
127
    #[error("transaction could not be sent.  reason: {0}")]
128
    Failed(String),
129

130
    #[error("Send rate limit reached for block height {height} ({digest}). A maximum of {max} tx may be sent per block.", digest = tip_digest.to_hex())]
131
    RateLimit {
132
        height: BlockHeight,
133
        tip_digest: Digest,
134
        max: usize,
135
    },
136
}
137

138
impl From<JobHandleError> for CreateProofError {
139
    fn from(e: JobHandleError) -> Self {
3✔
140
        e.into_sync().into()
3✔
141
    }
3✔
142
}
143

144
// convert anyhow::Error to a CreateTxError::Failed.
145
// note that anyhow Error is not serializable.
146
impl From<anyhow::Error> for CreateTxError {
147
    fn from(e: anyhow::Error) -> Self {
×
148
        Self::Failed(e.to_string())
×
149
    }
×
150
}
151

152
// convert anyhow::Error to a SendError::Failed.
153
// note that anyhow Error is not serializable.
154
impl From<anyhow::Error> for SendError {
UNCOV
155
    fn from(e: anyhow::Error) -> Self {
×
UNCOV
156
        Self::Failed(e.to_string())
×
UNCOV
157
    }
×
158
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc