Skip to content

Commit

Permalink
fix: fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alenmestrov committed Feb 7, 2025
1 parent a44013d commit 0ba5565
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 32 deletions.
35 changes: 17 additions & 18 deletions contracts/stellar/context-proxy/tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ use alloc::vec::Vec as StdVec;
use std::fs;

use calimero_context_config::stellar::{
StellarProposal, StellarProposalAction, StellarProposalApprovalWithSigner,
StellarProposalWithApprovals, StellarProxyMutateRequest,
StellarProposal, StellarProposalAction, StellarProposalApprovalWithSigner, StellarProposalWithApprovals, StellarProxyError, StellarProxyMutateRequest
};
// Local imports
use calimero_context_proxy_stellar::ContextProxyContractClient;
Expand All @@ -31,18 +30,18 @@ mod mock_external {
file = "../context-proxy/mock_external/res/calimero_mock_external_stellar.wasm"
);
}

// For proxy contract operations (like creating proposals), use calimero_context_config types:
use calimero_context_config::stellar::stellar_types::{
StellarSignedRequest as ProxySignedRequest,
StellarSignedRequestPayload as ProxySignedRequestPayload,
};
// For context contract operations (like adding members), use context_contract types:
// These come from the contractimport! macro
// use context_contract::{
// StellarSignedRequest as ContextSignedRequest,
// StellarSignedRequestPayload as ContextSignedRequestPayload,
// };
use context_contract::{
StellarSignedRequest as ContextSignedRequest,
StellarSignedRequestPayload as ContextSignedRequestPayload,
};

/// Test context structure holding all necessary components for proxy contract tests
struct ProxyTestContext<'a> {
Expand Down Expand Up @@ -894,17 +893,17 @@ fn test_proposal_limits_and_deletion() {
&context_author_sk,
ProxySignedRequestPayload::Proxy(request),
);
// let result = client.try_mutate(&signed_request);
// match result {
// Ok(_) => panic!("Expected error for exceeding proposal limit"),
// Err(e) => match e {
// Ok(StellarProxyError::TooManyActiveProposals) => {
// // This is what we expect
// log!(&env, "Got expected TooManyActiveProposals error");
// }
// other => panic!("Got unexpected error: {:?}", other),
// },
// }
let result = client.try_mutate(&signed_request);
match result {
Ok(_) => panic!("Expected error for exceeding proposal limit"),
Err(e) => match e {
Ok(StellarProxyError::TooManyActiveProposals) => {
// This is what we expect
log!(&env, "Got expected TooManyActiveProposals error");
}
other => panic!("Got unexpected error: {:?}", other),
},
}

// Delete first proposal to free up space
let (_, delete_proposal) = create_test_proposal(
Expand Down
14 changes: 0 additions & 14 deletions crates/context/config/src/stellar/stellar_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,6 @@ use crate::repr::{Repr, ReprBytes, ReprError, ReprTransmute};
use crate::types::{Application, ApplicationMetadata, ApplicationSource, Capability};
use crate::{ContextRequest, ContextRequestKind, RequestKind};

#[derive(Clone, Debug, Copy)]
#[contracterror]
pub enum StellarProxyError {
AlreadyInitialized = 1,
Unauthorized = 2,
ProposalNotFound = 3,
ProposalAlreadyApproved = 4,
TooManyActiveProposals = 5,
InvalidAction = 6,
ExecutionFailed = 7,
InsufficientBalance = 8,
TransferFailed = 9,
}

// Trait for environment-aware conversion
pub trait FromWithEnv<T> {
fn from_with_env(value: T, env: &Env) -> Self;
Expand Down

0 comments on commit 0ba5565

Please sign in to comment.