Skip to content

Commit

Permalink
wip: testing via starknetid identity
Browse files Browse the repository at this point in the history
  • Loading branch information
Th0rgal committed Aug 14, 2023
1 parent 9cfcac4 commit 77273fa
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/naming/main.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/tests.cairo
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
mod erc20;
mod utils;
mod test_pricing;
mod test_naming;
38 changes: 24 additions & 14 deletions src/tests/test_naming.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -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::<felt252>::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::<felt252>::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::<felt252>::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::<felt252>::new());

// naming
let mut calldata = ArrayTrait::<felt252>::new();
let starknetid = 0x456;
let admin = 0x123;
calldata.append(starknetid);
calldata.append(identity.into());
calldata.append(pricing.into());
calldata.append(0);
calldata.append(admin);
Expand All @@ -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());
}

0 comments on commit 77273fa

Please sign in to comment.