Skip to content

Commit

Permalink
update existing tests and snapshots
Browse files Browse the repository at this point in the history
  • Loading branch information
piotr-iohk committed Nov 29, 2024
1 parent e50c77d commit 6101d20
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 27 deletions.
52 changes: 41 additions & 11 deletions tests/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ async fn test_error_properties() {
use MinaMeshError::*;

let cases = vec![
(Sql("SQL syntax error".to_string()), 1, "An SQL error occurred.", false, StatusCode::INTERNAL_SERVER_ERROR),
(Sql("SQL syntax error".to_string()), 1, "We encountered a SQL failure.", false, StatusCode::INTERNAL_SERVER_ERROR),
(
JsonParse(Some("Missing field".to_string())),
2,
Expand Down Expand Up @@ -66,34 +66,64 @@ async fn test_error_properties() {
),
(BlockMissing("Block ID".to_string()), 9, "The specified block could not be found.", true, StatusCode::NOT_FOUND),
(MalformedPublicKey, 10, "The provided public key is malformed.", false, StatusCode::BAD_REQUEST),
(OperationsNotValid(vec![]), 11, "The provided operations are not valid.", false, StatusCode::BAD_REQUEST),
(
OperationsNotValid(vec![]),
11,
"We could not convert those operations to a valid transaction.",
false,
StatusCode::BAD_REQUEST,
),
(
UnsupportedOperationForConstruction,
12,
"The operation is not supported for transaction construction.",
false,
StatusCode::BAD_REQUEST,
),
(SignatureMissing, 13, "A signature is missing.", false, StatusCode::BAD_REQUEST),
(PublicKeyFormatNotValid, 14, "The public key format is not valid.", false, StatusCode::BAD_REQUEST),
(NoOptionsProvided, 15, "No options were provided.", false, StatusCode::BAD_REQUEST),
(SignatureMissing, 13, "Your request is missing a signature.", false, StatusCode::BAD_REQUEST),
(PublicKeyFormatNotValid, 14, "The public key you provided had an invalid format.", false, StatusCode::BAD_REQUEST),
(NoOptionsProvided, 15, "Your request is missing options.", false, StatusCode::BAD_REQUEST),
(
Exception("Unexpected error".to_string()),
16,
"An internal exception occurred.",
false,
StatusCode::INTERNAL_SERVER_ERROR,
),
(SignatureInvalid, 17, "The signature is invalid.", false, StatusCode::BAD_REQUEST),
(MemoInvalid, 18, "The memo is invalid.", false, StatusCode::BAD_REQUEST),
(SignatureInvalid, 17, "Your request has an invalid signature.", false, StatusCode::BAD_REQUEST),
(MemoInvalid, 18, "Your request has an invalid memo.", false, StatusCode::BAD_REQUEST),
(GraphqlUriNotSet, 19, "No GraphQL URI has been set.", false, StatusCode::INTERNAL_SERVER_ERROR),
(TransactionSubmitNoSender, 20, "No sender was found in the ledger.", true, StatusCode::BAD_REQUEST),
(
TransactionSubmitNoSender,
20,
"This could occur because the node isn't fully synced or the account doesn't actually exist in the ledger yet.",
true,
StatusCode::BAD_REQUEST,
),
(TransactionSubmitDuplicate, 21, "A duplicate transaction was detected.", false, StatusCode::CONFLICT),
(TransactionSubmitBadNonce, 22, "The nonce is invalid.", false, StatusCode::BAD_REQUEST),
(TransactionSubmitFeeSmall, 23, "The transaction fee is too small.", false, StatusCode::BAD_REQUEST),
(TransactionSubmitInvalidSignature, 24, "The transaction signature is invalid.", false, StatusCode::BAD_REQUEST),
(TransactionSubmitInsufficientBalance, 25, "The account has insufficient balance.", false, StatusCode::BAD_REQUEST),
(TransactionSubmitExpired, 26, "The transaction has expired.", false, StatusCode::BAD_REQUEST),
(
TransactionSubmitInvalidSignature,
24,
"An invalid signature is attached to this transaction.",
false,
StatusCode::BAD_REQUEST,
),
(
TransactionSubmitInsufficientBalance,
25,
"This account do not have sufficient balance perform the requested transaction.",
false,
StatusCode::BAD_REQUEST,
),
(
TransactionSubmitExpired,
26,
"This transaction is expired. Please try again with a larger valid_until.",
false,
StatusCode::BAD_REQUEST,
),
];

for (error, code, description, retriable, status) in cases {
Expand Down
32 changes: 16 additions & 16 deletions tests/snapshots/network_options__network_options.snap
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,11 @@ Allow {
"fee_receiver_inc",
"coinbase_inc",
"account_creation_fee_via_payment",
"account_creation_fee_via_fee_payer",
"account_creation_fee_via_fee_receiver",
"payment_source_dec",
"payment_receiver_inc",
"fee_payment",
"delegate_change",
"create_token",
"mint_tokens",
"zkapp_fee_payer_dec",
"zkapp_balance_update",
],
Expand All @@ -34,7 +31,7 @@ Allow {
code: 1,
message: "SQL failure: SQL syntax error",
description: Some(
"An SQL error occurred.",
"We encountered a SQL failure.",
),
retriable: false,
details: Some(
Expand Down Expand Up @@ -123,13 +120,16 @@ Allow {
},
Error {
code: 8,
message: "Transaction not found",
message: "Transaction not found: Transaction ID",
description: Some(
"The specified transaction could not be found.",
),
retriable: true,
details: Some(
String(""),
Object {
"error": String("You attempted to lookup transaction Transaction ID, but it is missing from the mempool. This may be due to its inclusion in a block -- try looking for this transaction in a recent block. It also could be due to the transaction being evicted from the mempool."),
"transaction": String("Transaction ID"),
},
),
},
Error {
Expand Down Expand Up @@ -158,7 +158,7 @@ Allow {
code: 11,
message: "Cannot convert operations to valid transaction",
description: Some(
"The provided operations are not valid.",
"We could not convert those operations to a valid transaction.",
),
retriable: false,
details: Some(
Expand All @@ -180,7 +180,7 @@ Allow {
code: 13,
message: "Signature missing",
description: Some(
"A signature is missing.",
"Your request is missing a signature.",
),
retriable: false,
details: Some(
Expand All @@ -191,7 +191,7 @@ Allow {
code: 14,
message: "Invalid public key format",
description: Some(
"The public key format is not valid.",
"The public key you provided had an invalid format.",
),
retriable: false,
details: Some(
Expand All @@ -202,7 +202,7 @@ Allow {
code: 15,
message: "No options provided",
description: Some(
"No options were provided.",
"Your request is missing options.",
),
retriable: false,
details: Some(
Expand All @@ -226,7 +226,7 @@ Allow {
code: 17,
message: "Invalid signature",
description: Some(
"The signature is invalid.",
"Your request has an invalid signature.",
),
retriable: false,
details: Some(
Expand All @@ -237,7 +237,7 @@ Allow {
code: 18,
message: "Invalid memo",
description: Some(
"The memo is invalid.",
"Your request has an invalid memo.",
),
retriable: false,
details: Some(
Expand All @@ -259,7 +259,7 @@ Allow {
code: 20,
message: "Can't send transaction: No sender found in ledger",
description: Some(
"No sender was found in the ledger.",
"This could occur because the node isn't fully synced or the account doesn't actually exist in the ledger yet.",
),
retriable: true,
details: Some(
Expand Down Expand Up @@ -303,7 +303,7 @@ Allow {
code: 24,
message: "Can't send transaction: Invalid signature",
description: Some(
"The transaction signature is invalid.",
"An invalid signature is attached to this transaction.",
),
retriable: false,
details: Some(
Expand All @@ -314,7 +314,7 @@ Allow {
code: 25,
message: "Can't send transaction: Insufficient balance",
description: Some(
"The account has insufficient balance.",
"This account do not have sufficient balance perform the requested transaction.",
),
retriable: false,
details: Some(
Expand All @@ -325,7 +325,7 @@ Allow {
code: 26,
message: "Can't send transaction: Expired",
description: Some(
"The transaction has expired.",
"This transaction is expired. Please try again with a larger valid_until.",
),
retriable: false,
details: Some(
Expand Down

0 comments on commit 6101d20

Please sign in to comment.