From 77273fae51d985f4cf07b3970119fcd289eeaeb4 Mon Sep 17 00:00:00 2001 From: Thomas Marchand Date: Mon, 14 Aug 2023 12:07:43 +0100 Subject: [PATCH] wip: testing via starknetid identity --- src/naming/main.cairo | 2 +- src/tests.cairo | 1 + src/tests/test_naming.cairo | 38 +++++++++++++++++++++++-------------- 3 files changed, 26 insertions(+), 15 deletions(-) diff --git a/src/naming/main.cairo b/src/naming/main.cairo index 5bd6b4a..ed3d9b6 100644 --- a/src/naming/main.cairo +++ b/src/naming/main.cairo @@ -185,7 +185,7 @@ mod Naming { ) -> (felt252, u64, u64) { let now = get_block_timestamp(); - // Verify that the starknet.id doesn't already manage a domain + Verify that the starknet.id doesn't already manage a domain self.assert_id_availability(identity, now); // Verify that the domain is not already taken or expired diff --git a/src/tests.cairo b/src/tests.cairo index dc48c93..c86583e 100644 --- a/src/tests.cairo +++ b/src/tests.cairo @@ -1,3 +1,4 @@ +mod erc20; mod utils; mod test_pricing; mod test_naming; diff --git a/src/tests/test_naming.cairo b/src/tests/test_naming.cairo index 9aba022..4a8ec33 100644 --- a/src/tests/test_naming.cairo +++ b/src/tests/test_naming.cairo @@ -2,36 +2,41 @@ use array::ArrayTrait; use debug::PrintTrait; use zeroable::Zeroable; use traits::Into; - -use starknet::ContractAddress; use starknet::testing; +use starknet::ContractAddress; +use starknet::contract_address::ContractAddressZeroable; +use starknet::contract_address_const; +use starknet::testing::set_caller_address; use super::utils; +use identity::identity::main::Identity; use naming::interface::naming::{INamingDispatcher, INamingDispatcherTrait}; use naming::naming::main::Naming; use naming::pricing::Pricing; -use openzeppelin::token::erc20::erc20::ERC20; +use super::erc20::ERC20; #[cfg(test)] fn deploy() -> INamingDispatcher { //erc20 - // let mut calldata = ArrayTrait::::new(); - // calldata.append('ether'); - // calldata.append('ETH'); - // calldata.append(0); - // calldata.append(1024); - // calldata.append(0x123); - // let eth = utils::deploy(ERC20::TEST_CLASS_HASH, calldata); + let mut calldata = ArrayTrait::::new(); + calldata.append('ether'); + calldata.append('ETH'); + calldata.append(0); + calldata.append(1024); + calldata.append(0x123); + let eth = utils::deploy(ERC20::TEST_CLASS_HASH, calldata); // pricing let mut calldata = ArrayTrait::::new(); - calldata.append(0x789); + calldata.append(eth.into()); let pricing = utils::deploy(Pricing::TEST_CLASS_HASH, calldata); + // identity + let identity = utils::deploy(Identity::TEST_CLASS_HASH, ArrayTrait::::new()); + // naming let mut calldata = ArrayTrait::::new(); - let starknetid = 0x456; let admin = 0x123; - calldata.append(starknetid); + calldata.append(identity.into()); calldata.append(pricing.into()); calldata.append(0); calldata.append(admin); @@ -43,6 +48,11 @@ fn deploy() -> INamingDispatcher { #[test] #[available_gas(20000000000)] fn test_deploying() { - deploy(); + let naming = deploy(); + let caller = contract_address_const::<0x123>(); + set_caller_address(caller); + + let th0rgal = 33133781693; + naming.buy(1, th0rgal, 365, ContractAddressZeroable::zero(), ContractAddressZeroable::zero()); }