Skip to content

Commit

Permalink
✅ pass metadata update test
Browse files Browse the repository at this point in the history
  • Loading branch information
tekkac committed Sep 17, 2024
1 parent 5021caf commit d262951
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion tests/test_project.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use carbon_v3::components::vintage::interface::{
};
use carbon_v3::components::minter::interface::{IMint, IMintDispatcher, IMintDispatcherTrait};
use carbon_v3::components::metadata::{IMetadataHandlerDispatcher, IMetadataHandlerDispatcherTrait};
use erc4906::erc4906_component::ERC4906Component::{Event, MetadataUpdate, BatchMetadataUpdate};
use erc4906::erc4906_component::ERC4906Component;

// Contracts

Expand Down Expand Up @@ -679,3 +679,26 @@ fn test_set_approval_for_all() {
);
spy.assert_emitted(@array![(project_address, expected_event)]);
}

#[test]
fn test_project_metadata_update() {
let owner_address: ContractAddress = contract_address_const::<'OWNER'>();
let project_address = default_setup_and_deploy();
let metadata_class = snf::declare("TestMetadata").expect('Declaration failed');
let project = IProjectDispatcher { contract_address: project_address };
let vintages = IVintageDispatcher { contract_address: project_address };
let num_vintages = vintages.get_num_vintages();

let mut spy = spy_events();

start_cheat_caller_address(project_address, owner_address);
project.set_uri(metadata_class.class_hash);
let uri_result = project.uri(token_id: 1);
assert!(uri_result.at(0) == @'http://imgur.com/', "Cannot get the URI");
assert!(uri_result.at(1) == @'01', "Cannot get the URI");
assert!(uri_result.at(2) == @'.png', "Cannot get the URI");
let expected_batch_metadata_update = ERC4906Component::Event::BatchMetadataUpdate(
ERC4906Component::BatchMetadataUpdate { from_token_id: 1, to_token_id: num_vintages.into() }
);
spy.assert_emitted(@array![(project_address, expected_batch_metadata_update)]);
}

0 comments on commit d262951

Please sign in to comment.