Skip to content

Commit

Permalink
Fix u256 test refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
EmmanuelAR committed Oct 11, 2024
1 parent 129a5fb commit 245b0cb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
18 changes: 10 additions & 8 deletions contracts/src/fundManager.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use starknet::class_hash::ClassHash;

#[starknet::interface]
pub trait IFundManager<TContractState> {
fn newFund(ref self: TContractState, name: felt252, goal: u64);
fn newFund(ref self: TContractState, name: felt252, goal: u256);
fn getCurrentId(self: @TContractState) -> u128;
fn getFund(self: @TContractState, id: u128) -> ContractAddress;
fn getOwner(self: @TContractState) -> ContractAddress;
Expand All @@ -21,6 +21,8 @@ mod FundManager {
use starknet::syscalls::deploy_syscall;
use starknet::class_hash::ClassHash;
use starknet::get_caller_address;
use openzeppelin::utils::serde::SerializedAppend;


// ***************************************************************************************
// STORAGE
Expand Down Expand Up @@ -48,14 +50,14 @@ mod FundManager {
// ***************************************************************************************
#[abi(embed_v0)]
impl FundManagerImpl of super::IFundManager<ContractState> {
fn newFund(ref self: ContractState, name: felt252, goal: u64) {
let mut calldata = ArrayTrait::<felt252>::new();
calldata.append(self.current_id.read().try_into().unwrap());
calldata.append(get_caller_address().try_into().unwrap());
calldata.append(name);
calldata.append(goal.try_into().unwrap());
fn newFund(ref self: ContractState, name: felt252, goal: u256) {
let mut call_data: Array<felt252> = array![];
Serde::serialize(@self.current_id.read(), ref call_data);
Serde::serialize(@get_caller_address(), ref call_data);
Serde::serialize(@name, ref call_data);
Serde::serialize(@goal, ref call_data);
let (address_0, _) = deploy_syscall(
self.fund_class_hash.read(), 12345, calldata.span(), false
self.fund_class_hash.read(), 12345, call_data.span(), false
)
.unwrap();
self.current_id.write(self.current_id.read() + 1);
Expand Down
2 changes: 1 addition & 1 deletion contracts/tests/test_fund.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ fn NAME() -> felt252 {
fn REASON() -> ByteArray {
"Lorem impsum, Lorem impsum, Lorem impsum, Lorem impsum, Lorem impsum, Lorem impsum, Lorem impsum, Lorem impsum"
}
fn GOAL() -> u64 {
fn GOAL() -> u256 {
1000
}
fn _setup_() -> ContractAddress {
Expand Down
2 changes: 1 addition & 1 deletion contracts/tests/test_fund_manager.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ fn NAME() -> felt252 {
fn REASON() -> ByteArray {
"Lorem impsum, Lorem impsum, Lorem impsum, Lorem impsum, Lorem impsum, Lorem impsum, Lorem impsum, Lorem impsum"
}
fn GOAL() -> u64 {
fn GOAL() -> u256 {
1000
}

Expand Down

0 comments on commit 245b0cb

Please sign in to comment.