From 626d31df924814236f54c1a937443a1160fec152 Mon Sep 17 00:00:00 2001 From: Fishon Amos Date: Tue, 15 Oct 2024 10:37:17 +0100 Subject: [PATCH 1/2] test --- land_registry/src/interface.cairo | 2 +- land_registry/src/land_register.cairo | 16 ++++++++++++---- land_registry/src/lib.cairo | 1 + land_registry/src/tests/test_land_register.cairo | 1 - 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/land_registry/src/interface.cairo b/land_registry/src/interface.cairo index ba342a5c..3b6d2320 100644 --- a/land_registry/src/interface.cairo +++ b/land_registry/src/interface.cairo @@ -17,7 +17,7 @@ struct LandApprovalDetails { timestamp: u64, } -#[derive(Drop, Copy, Clone, Serde, starknet::Store, PartialEq)] +#[derive(Debug, Drop, Copy, Clone, Serde, starknet::Store, PartialEq)] pub enum LandUse { Residential, Commercial, diff --git a/land_registry/src/land_register.cairo b/land_registry/src/land_register.cairo index 3c2cfe21..63731c47 100644 --- a/land_registry/src/land_register.cairo +++ b/land_registry/src/land_register.cairo @@ -6,17 +6,16 @@ pub mod LandRegistryContract { use core::array::SpanTrait; use starknet::storage::{Map, StorageMapWriteAccess}; + #[storage] struct Storage { lands: Map::, - owner_lands: Map::>, + owner_lands: Map::, land_count: u256, } - - //lands - //What are we storing? + //What are we storing?> //lands, owners? @@ -76,6 +75,10 @@ pub mod LandRegistryContract { self.lands.write(land_id, new_land); self.land_count.write(land_id); + self.owner_lands.write(caller, land_id); + + //Write new land to a specific owner.. + self .emit( LandRegistered { @@ -106,3 +109,8 @@ pub mod LandRegistryContract { } } } + +#[cfg(test)] +mod tests { + use starknet::{get_caller_address, get_block_timestamp, ContractAddress}; +} diff --git a/land_registry/src/lib.cairo b/land_registry/src/lib.cairo index 0527250e..1e71d9ec 100644 --- a/land_registry/src/lib.cairo +++ b/land_registry/src/lib.cairo @@ -1,3 +1,4 @@ pub mod interface; pub mod land_register; pub mod utils; +pub mod tests; diff --git a/land_registry/src/tests/test_land_register.cairo b/land_registry/src/tests/test_land_register.cairo index 05e52e1d..a1dea386 100644 --- a/land_registry/src/tests/test_land_register.cairo +++ b/land_registry/src/tests/test_land_register.cairo @@ -6,5 +6,4 @@ use starknet::ContractAddress; // TESTS // ************************************************************************* -//#[test] From 9e4e593526f0662ff4f96c0c1386b795a31e2484 Mon Sep 17 00:00:00 2001 From: Fishon Amos Date: Tue, 15 Oct 2024 11:22:23 +0100 Subject: [PATCH 2/2] test --- land_registry/src/land_register.cairo | 41 +++++++++++++++++++++------ 1 file changed, 32 insertions(+), 9 deletions(-) diff --git a/land_registry/src/land_register.cairo b/land_registry/src/land_register.cairo index 63731c47..098d8734 100644 --- a/land_registry/src/land_register.cairo +++ b/land_registry/src/land_register.cairo @@ -13,11 +13,6 @@ pub mod LandRegistryContract { owner_lands: Map::, land_count: u256, } - //lands - - //What are we storing?> - - //lands, owners? #[event] #[derive(Drop, starknet::Event)] @@ -110,7 +105,35 @@ pub mod LandRegistryContract { } } -#[cfg(test)] -mod tests { - use starknet::{get_caller_address, get_block_timestamp, ContractAddress}; -} +// #[cfg(test)] +// mod tests { +// use starknet::{get_caller_address, get_block_timestamp, ContractAddress}; + +// // Import the interface and dispatcher to be able to interact with the contract. +// use super::{SimpleContract, IContractDispatcher, ISimpleContractDispatcherTrait}; + +// // Import the deploy syscall to be able to deploy the contract. +// use starknet::{SyscallResultTrait, syscalls::deploy_syscall}; +// use starknet::{get_contract_address, contract_address_const}; + +// // Use starknet test utils to fake the contract_address +// use starknet::testing::set_contract_address; + +// // Deploy the contract and return its dispatcher. +// fn deploy(initial_value: u32) -> ISimpleContractDispatcher { +// // Declare and deploy +// let (contract_address, _) = deploy_syscall( +// SimpleContract::TEST_CLASS_HASH.try_into().unwrap(), +// 0, +// array![initial_value.into()].span(), +// false +// ) +// .unwrap_syscall(); + +// // Return the dispatcher. +// // The dispatcher allows to interact with the contract based on its interface. +// ISimpleContractDispatcher { contract_address } +// } + + +// }