Skip to content

Commit

Permalink
more progress?
Browse files Browse the repository at this point in the history
  • Loading branch information
rpatel-figure committed Oct 30, 2024
1 parent e191f68 commit cb2d8e0
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 22 deletions.
4 changes: 2 additions & 2 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"recommendations": [
"recommendations": [
"fill-labs.dependi",
"rust-lang.rust-analyzer"
]
]
}
37 changes: 18 additions & 19 deletions src/execute/onboard_asset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,15 +283,16 @@ where
#[cfg(test)]
mod tests {
use cosmwasm_std::testing::{mock_env, MOCK_CONTRACT_ADDR};
use cosmwasm_std::{coins, from_json, Addr, Response, StdError, Uint128};
use cosmwasm_std::{coins, from_json, Addr, Response, Uint128};
use os_gateway_contract_attributes::{OS_GATEWAY_EVENT_TYPES, OS_GATEWAY_KEYS};
use provwasm_mocks::mock_provenance_dependencies;
use provwasm_std::types::provenance::attribute::v1::{
AttributeType, MsgAddAttributeRequest, MsgUpdateAttributeRequest,
};
use provwasm_std::types::provenance::metadata::v1::process::ProcessId;
use provwasm_std::types::provenance::metadata::v1::{
Process, Record, RecordWrapper, ScopeRequest, ScopeResponse, ScopeWrapper,
Process, Record, RecordWrapper, RecordsRequest, RecordsResponse, ScopeRequest,
ScopeResponse, ScopeWrapper,
};
use provwasm_std::types::provenance::msgfees::v1::MsgAssessCustomMsgFeeRequest;

Expand Down Expand Up @@ -639,6 +640,15 @@ mod tests {
request: None,
},
);
RecordsRequest::mock_response(
&mut deps.querier,
RecordsResponse {
scope: None,
sessions: vec![],
records: vec![],
request: None,
},
);
let err = onboard_asset(
AssetMetaService::new(deps.as_mut()),
mock_env(),
Expand All @@ -653,24 +663,13 @@ mod tests {
)
.unwrap_err();
match err {
ContractError::Std(e) => match e {
StdError::GenericErr { msg, .. } => {
assert!(
msg.contains("Querier system error"),
"the message should denote that the querier failed",
);
assert!(
msg.contains("metadata not found"),
"the message should denote that the issue was related to metadata",
);
assert!(
msg.contains("get_records"),
"the message should denote that the issue was related to records",
);
},
_ => panic!("unexpected StdError encountered when onboarding a scope with no records: {:?}", e),
ContractError::InvalidScope { explanation } => {
assert!(
explanation.contains("scope must have at least one non-empty record"),
"the message should denote that the issue was related to the scope not having any records",
);
},
_ => panic!("expected the provenance querier to return an error when no records are present for the scope, but got error: {:?}", err),
_ => panic!("unexpected ContractError encountered when onboarding a scope with no records: {:?}", err),
};
}

Expand Down
3 changes: 2 additions & 1 deletion src/execute/update_access_routes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,8 @@ mod tests {
use cosmwasm_std::{coin, from_json, Addr};
use provwasm_mocks::mock_provenance_dependencies;
use provwasm_std::types::provenance::attribute::v1::{
AttributeType, MsgUpdateAttributeRequest,
AttributeType, MsgUpdateAttributeRequest, QueryAttributeRequest, QueryAttributeResponse,
QueryAttributesRequest, QueryAttributesResponse,
};

#[test]
Expand Down
18 changes: 18 additions & 0 deletions src/testutil/test_utilities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,24 @@ pub fn setup_test_suite(deps: &mut MockOwnedDeps, args: &InstArgs) {
},
);
RecordsRequest::mock_response(&mut deps.querier, get_default_records());
// TODO: May be incorrect to put these here
QueryAttributeRequest::mock_response(
&mut deps.querier,
QueryAttributeResponse {
account: args.env.contract.address.to_string(),
attributes: vec![],
pagination: None,
},
);
QueryAttributesRequest::mock_response(
&mut deps.querier,
QueryAttributesResponse {
account: args.env.contract.address.to_string(),
attributes: vec![],
pagination: None,
},
);
// END TODO
}

pub fn test_instantiate_success(deps: DepsMut, args: &InstArgs) -> Response {
Expand Down

0 comments on commit cb2d8e0

Please sign in to comment.