Skip to content

Commit

Permalink
Fix auth tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sisuresh committed Jun 8, 2023
1 parent 076589f commit 88a058c
Showing 1 changed file with 21 additions and 20 deletions.
41 changes: 21 additions & 20 deletions tests/auth/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ mod test_a {
Address as _, AuthorizedFunction, AuthorizedInvocation, MockAuth, MockAuthInvoke,
},
xdr::{
ScAddress, ScVal, SorobanAddressCredentials, SorobanAuthorizationEntry,
SorobanAuthorizedContractFunction, SorobanAuthorizedFunction,
SorobanAuthorizedInvocation, SorobanCredentials, StringM, VecM,
ScAddress, ScError, ScErrorCode, ScErrorType, ScVal, SorobanAddressCredentials,
SorobanAuthorizationEntry, SorobanAuthorizedContractFunction,
SorobanAuthorizedFunction, SorobanAuthorizedInvocation, SorobanCredentials, StringM,
VecM,
},
Address, Env, Error, RawVal, Symbol,
};
Expand Down Expand Up @@ -170,13 +171,13 @@ mod test_a {
}])
.try_fn1(&a);

// TODO: Update this test to assert that a general panic/trap occurred
// once https://github.com/stellar/rs-soroban-env/issues/771 is fixed.
// The ContractError(1) being captured here is from the
// auth_decline::Contract defined at the bottom of this file. The auth
// contract's error is leaking into the contract being called and
// propogating as its own contract, which should not be happening.
assert_eq!(r, Err(Ok(Error::from_contract_error(1))));
assert_eq!(
r,
Err(Ok(Error::from_scerror(ScError {
type_: ScErrorType::Auth,
code: ScErrorCode::InvalidAction
})))
);

assert_eq!(e.auths(), []);
}
Expand Down Expand Up @@ -244,9 +245,9 @@ mod test_b {
Address as _, AuthorizedFunction, AuthorizedInvocation, MockAuth, MockAuthInvoke,
},
xdr::{
ScAddress, ScVal, SorobanAddressCredentials, SorobanAuthorizationEntry,
SorobanAuthorizedContractFunction, SorobanAuthorizedFunction,
SorobanAuthorizedInvocation, SorobanCredentials, StringM,
ScAddress, ScError, ScErrorCode, ScErrorType, ScVal, SorobanAddressCredentials,
SorobanAuthorizationEntry, SorobanAuthorizedContractFunction,
SorobanAuthorizedFunction, SorobanAuthorizedInvocation, SorobanCredentials, StringM,
},
Address, Env, Error, RawVal, Symbol,
};
Expand Down Expand Up @@ -446,13 +447,13 @@ mod test_b {
}])
.try_fn2(&a, &contract_a_id);

// TODO: Update this test to assert that a general panic/trap occurred
// once https://github.com/stellar/rs-soroban-env/issues/771 is fixed.
// The ContractError(1) being captured here is from the
// auth_decline::Contract defined at the bottom of this file. The auth
// contract's error is leaking into the contract being called and
// propogating as its own contract, which should not be happening.
assert_eq!(r, Err(Ok(Error::from_contract_error(1))));
assert_eq!(
r,
Err(Ok(Error::from_scerror(ScError {
type_: ScErrorType::Auth,
code: ScErrorCode::InvalidAction
})))
);

assert_eq!(e.auths(), []);
}
Expand Down

0 comments on commit 88a058c

Please sign in to comment.