Skip to content

Commit

Permalink
Small breakthrough
Browse files Browse the repository at this point in the history
  • Loading branch information
rpatel-figure committed Nov 13, 2024
1 parent 8960307 commit 3e29b23
Showing 1 changed file with 39 additions and 6 deletions.
45 changes: 39 additions & 6 deletions tests/integration_tests.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
use std::str::FromStr;

use asset_classification_smart_contract::core::{
msg::{ExecuteMsg, InitMsg},
msg::{ExecuteMsg, InitMsg, QueryMsg},
types::{
asset_definition::AssetDefinitionInputV3, fee_destination::FeeDestinationV2,
serialized_enum::SerializedEnum, verifier_detail::VerifierDetailV2,
asset_definition::AssetDefinitionInputV3, asset_scope_attribute::AssetScopeAttribute,
fee_destination::FeeDestinationV2, serialized_enum::SerializedEnum,
verifier_detail::VerifierDetailV2,
},
};
use cosmwasm_std::{coin, Uint128};
Expand All @@ -16,7 +17,7 @@ use provwasm_std::{
MsgWriteScopeSpecificationRequest, Party, PartyType, Scope, ScopeSpecification,
},
};
use provwasm_test_tube::{wasm::Wasm, Account, Module, ProvwasmTestApp};
use provwasm_test_tube::{wasm::Wasm, Account, FeeSetting, Module, ProvwasmTestApp};
use uuid::Uuid;

const OPTIMIZED_CONTRACT_WASM_PATH: &str = "./artifacts/asset_classification_smart_contract.wasm";
Expand All @@ -28,11 +29,17 @@ fn happy_path_onboard_and_verify_asset() {
// to create a meaningfully reusable function for setting up the test environment
let app = ProvwasmTestApp::default();
let accs = app
.init_accounts(&[coin(100_000_000_000_000, "nhash")], 3)
.init_accounts(&[coin(100_000_000_000_000, "nhash")], 2)
.expect("initializing accounts should succeed");
let admin = &accs[0];
let verifier = &accs[1];
let originator = &accs[2];
let originator = app
.init_account(&[coin(100_000_000_000_000, "nhash")])
.unwrap();
let originator = originator.with_fee_setting(FeeSetting::Custom {
amount: coin(500_000_000_000, "nhash"),
gas_limit: 200000000,
});

let wasm = Wasm::new(&app);
let wasm_byte_code = std::fs::read(OPTIMIZED_CONTRACT_WASM_PATH).unwrap();
Expand Down Expand Up @@ -165,4 +172,30 @@ fn happy_path_onboard_and_verify_asset() {
&originator,
)
.expect("onboarding an asset should succeed");

let contract_query_for_scope = wasm
.query::<QueryMsg, Option<Vec<AssetScopeAttribute>>>(
&contract_addr,
&QueryMsg::QueryAssetScopeAttributes {
identifier: SerializedEnum {
r#type: String::from("asset_uuid"),
value: scope_uuid.to_string(),
},
},
)
.expect("querying the contract should succeed");

if let Some(scope_attributes) = contract_query_for_scope {
assert_eq!(
1,
scope_attributes.len(),
"Exactly one attribute from the contract should exist on the scope"
);
let scope_attribute = scope_attributes.first().unwrap();
assert_eq!(scope_uuid, scope_attribute.asset_uuid.as_str(),);
assert_eq!(scope_address.bech32, scope_attribute.scope_address);
assert_eq!("mortgage", scope_attribute.asset_type.as_str(),);
} else {
panic!("Querying the contract for scope attributes after onboarding returned no results when one result was expected")
}
}

0 comments on commit 3e29b23

Please sign in to comment.