Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ on:
- ".github/workflows/shared-build-wasm.yml"
- ".github/actions/**"
- "**.rs"
- "*.move"
- "**.toml"
- "**.lock"
- "bindings/**"
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ on:
- "**.ts"
- "**.js"
- "**.json"
- "**.move"

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand Down
3 changes: 2 additions & 1 deletion hierarchies-move/sources/accreditation.move
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ public(package) fun is_property_allowed(
let accreditation = &self.accreditations[idx_properties_to_attest];
let maybe_property = accreditation.properties.try_get(property_name);

idx_properties_to_attest = idx_properties_to_attest + 1;

if (maybe_property.is_none()) {
continue
};
Expand All @@ -78,7 +80,6 @@ public(package) fun is_property_allowed(
) {
return true
};
idx_properties_to_attest = idx_properties_to_attest + 1;
};
return false
}
Expand Down
74 changes: 73 additions & 1 deletion hierarchies-move/tests/hierarchies_tests.move
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ use hierarchies::{
add_root_authority,
revoke_root_authority,
is_root_authority,
revoke_property
revoke_property,
validate_property
},
property,
property_name::new_property_name,
Expand Down Expand Up @@ -1296,3 +1297,74 @@ fun test_validate_properties_fails_for_revoked_property() {
clock.destroy_for_testing();
let _ = scenario.end();
}

#[test]
fun test_validate_property_returns_false_when_attester_has_different_property() {
let alice = @0x1;
let mut scenario = test_scenario::begin(alice);
let mut clock = clock::create_for_testing(scenario.ctx());
clock.set_for_testing(1000);

// Create a new federation
new_federation(scenario.ctx());
scenario.next_tx(alice);

let mut fed: Federation = scenario.take_shared();
let root_cap: RootAuthorityCap = scenario.take_from_address(alice);
let accredit_cap: AccreditCap = scenario.take_from_address(alice);

// Step 1: Add two properties to the federation: "role" and "foo"
let property_name_role = new_property_name(utf8(b"role"));
let property_value_example = new_property_value_number(1);
let mut allowed_values_role = vec_set::empty();
allowed_values_role.insert(property_value_example);

let property_name_foo = new_property_name(utf8(b"foo"));
let property_value_bar = new_property_value_number(2);
let mut allowed_values_foo = vec_set::empty();
allowed_values_foo.insert(property_value_bar);

let property_role = property::new_property(
property_name_role,
allowed_values_role,
false,
option::none(),
);
let property_foo = property::new_property(
property_name_foo,
allowed_values_foo,
false,
option::none(),
);

fed.add_property(&root_cap, property_role, scenario.ctx());
fed.add_property(&root_cap, property_foo, scenario.ctx());
scenario.next_tx(alice);

let bob_id = @0x2.to_id();
let property_for_bob = property::new_property(
property_name_foo,
allowed_values_foo,
false,
option::none(),
);

fed.create_accreditation_to_attest(
&accredit_cap,
bob_id,
vector[property_for_bob],
&clock,
scenario.ctx(),
);

assert!(fed.validate_property(&bob_id, property_name_foo, property_value_bar, &clock), 0);

assert!(!fed.validate_property(&bob_id, property_name_role, property_value_example, &clock), 1);

// Cleanup
test_scenario::return_shared(fed);
test_scenario::return_to_address(alice, root_cap);
test_scenario::return_to_address(alice, accredit_cap);
clock.destroy_for_testing();
let _ = scenario.end();
}
2 changes: 0 additions & 2 deletions hierarchies-rs/hierarchies/src/core/operations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,9 +266,7 @@ pub(crate) trait HierarchiesOperations {

let fed_ref = HierarchiesImpl::get_fed_ref(client, federation_id).await?;
let fed_ref = ptb.obj(fed_ref)?;
println!("✅ REACHED HERE 001");
let property = new_property(client.package_id(), &mut ptb, property)?;
println!("✅ REACHED HERE 002");

ptb.programmable_move_call(
client.package_id(),
Expand Down
Loading