keep-starknet-strange / satoru

Synthetics platform for Starknet, inspired by GMX v2 design.
https://book.satoru.run/
MIT License
110 stars 73 forks source link

Implementing StrictBank functions and tests #426

Closed VictorONN closed 1 year ago

VictorONN commented 1 year ago

Related to https://github.com/keep-starknet-strange/satoru/issues/272

Implemented functions to the best of my understanding of the GMX contracts. The implementation I think I did well the tests are the issue. The functions are: record_transfer_in sync_token_balance record_transfer_in_internal after_transfer_out_infernal

PASSING TESTS The ones which are passing and am comfy with the logic: fn test_initialize() fn given_normal_conditions_when_transfer_out_then_works() fn given_caller_has_no_controller_role_when_transfer_out_then_fails() fn given_caller_has_no_controller_role_when_record_transfer_in_then_fails() fn given_caller_has_no_controller_role_when_sync_token_balance_then_fails()

fn given_normal_conditions_when_sync_token_balance_passes() - this passes but am unsure if I have to play around with token balance first to at least test it or I just call it directly.

FAILING TESTS

fn given_receiver_is_contract_when_transfer_out_then_fails() - Error: (u256_sub Overflow) I think am having the logic correct, am minting to Bank contract address, and passing the bank contract address to transfer out function to make it panic with the assert reason.

fn given_normal_conditions_when_record_transfer_in_works() 'ERC20: transfer from 0' error. It seems it is not minting to caller address successfully. That is why for this test I have I tried to mint to the strict bank address, and transfer out, then transfer in again to register the change. Still getting 'ERC20: transfer from 0'

tevrat-aksoy commented 1 year ago

hello, you implemented _afterTransferOut but didnt used anywhere. Since it is override function I think you need to use it after you called IBank::transfer_out() function. https://github.com/VictorONN/satoru/blob/6711409640ff7e19fdfe26b7856370734cbc70ad/src/bank/strict_bank.cairo#L129C13-L129C32

sparqet commented 1 year ago

@VictorONN Can you fix your coding style pls ?

sparqet commented 1 year ago

@VictorONN do you have any news ? If I don't receive a response within 24 hours, I will have to proceed with redoing the issue

VictorONN commented 1 year ago

Hello, fixed style and fixed the tests too.