Skip to content

Commit

Permalink
minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
0xChqrles committed Oct 3, 2024
1 parent d0ed05a commit 4f9b35a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
2 changes: 1 addition & 1 deletion contracts/src/contracts/ramps/revolut/interface.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use zkramp::components::registry::interface::OffchainId;
// Structs
//

#[derive(Drop, Serde)]
#[derive(Drop, Copy, Serde)]
pub struct Proof {
pub foo: felt252
}
Expand Down
23 changes: 13 additions & 10 deletions contracts/src/contracts/ramps/revolut/revolut_test.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use snforge_std::{
EventSpyAssertionsTrait, spy_events, declare, DeclareResultTrait, ContractClassTrait, start_cheat_caller_address,
stop_cheat_caller_address, test_address, start_cheat_block_timestamp_global
};
use zkramp::contracts::ramps::revolut::interface::{ZKRampABIDispatcher, ZKRampABIDispatcherTrait, LiquidityKey, Proof};
use zkramp::contracts::ramps::revolut::interface::{ZKRampABIDispatcher, ZKRampABIDispatcherTrait, LiquidityKey};
use zkramp::contracts::ramps::revolut::revolut::RevolutRamp::{
Event, LiquidityAdded, LiquidityRetrieved, LiquidityLocked, LiquidityShareRequested, LiquidityShareWithdrawn,
MINIMUM_LOCK_DURATION
Expand Down Expand Up @@ -929,7 +929,7 @@ fn test_withdraw_liquidity_without_request() {
let withdrawer = constants::OTHER();
let withdrawer_offchain_id = constants::REVOLUT_ID2();
let liquidity_key = LiquidityKey { owner: liquidity_owner, offchain_id };
let proof = Proof { foo: 0 };
let proof = constants::PROOF();

// fund the account
fund_and_approve(token: erc20, recipient: liquidity_owner, spender: revolut_ramp.contract_address, amount: amount);
Expand Down Expand Up @@ -961,7 +961,7 @@ fn test_withdraw_liquidity_after_expiration() {
let withdrawer = constants::OTHER();
let withdrawer_offchain_id = constants::REVOLUT_ID2();
let liquidity_key = LiquidityKey { owner: liquidity_owner, offchain_id };
let proof = Proof { foo: 0 };
let proof = constants::PROOF();

// fund the account
fund_and_approve(token: erc20, recipient: liquidity_owner, spender: revolut_ramp.contract_address, amount: amount);
Expand Down Expand Up @@ -998,12 +998,13 @@ fn test_withdraw_liquidity_from_another_caller() {
// on-ramper
let withdrawer = constants::OTHER();
let withdrawer_offchain_id = constants::REVOLUT_ID2();
let liquidity_key = LiquidityKey { owner: liquidity_owner, offchain_id };
let proof = Proof { foo: 0 };

// other on-ramper
let other_withdrawer = constants::OTHER2();

let liquidity_key = LiquidityKey { owner: liquidity_owner, offchain_id };
let proof = constants::PROOF();

// fund the account
fund_and_approve(token: erc20, recipient: liquidity_owner, spender: revolut_ramp.contract_address, amount: amount);

Expand Down Expand Up @@ -1038,7 +1039,7 @@ fn test_withdraw_liquidity_from_another_offchain_id() {
let withdrawer = constants::OTHER();
let withdrawer_offchain_id = constants::REVOLUT_ID2();
let liquidity_key = LiquidityKey { owner: liquidity_owner, offchain_id };
let proof = Proof { foo: 0 };
let proof = constants::PROOF();

// other on-ramper
let other_withdrawer_offchain_id = constants::REVOLUT_ID3();
Expand All @@ -1060,7 +1061,6 @@ fn test_withdraw_liquidity_from_another_offchain_id() {

// other offchain-id tries to withdraw
revolut_ramp.withdraw_liquidity(:liquidity_key, offchain_id: other_withdrawer_offchain_id, :proof);
panic!("Not implemented yet");
}

#[test]
Expand All @@ -1076,8 +1076,9 @@ fn test_withdraw_liquidity() {
// on-ramper
let withdrawer = constants::OTHER();
let withdrawer_offchain_id = constants::REVOLUT_ID2();

let liquidity_key = LiquidityKey { owner: liquidity_owner, offchain_id };
let proof = Proof { foo: 0 };
let proof = constants::PROOF();

// fund the account
fund_and_approve(token: erc20, recipient: liquidity_owner, spender: revolut_ramp.contract_address, amount: amount);
Expand Down Expand Up @@ -1136,6 +1137,8 @@ fn test_withdraw_liquidity_twice() {
// on-ramper
let withdrawer = constants::OTHER();
let withdrawer_offchain_id = constants::REVOLUT_ID2();

let proof = constants::PROOF();
let liquidity_key = LiquidityKey { owner: liquidity_owner, offchain_id };

// fund the account
Expand All @@ -1154,10 +1157,10 @@ fn test_withdraw_liquidity_twice() {
revolut_ramp.initiate_liquidity_withdrawal(:liquidity_key, :amount, offchain_id: withdrawer_offchain_id);

// withdrawer withdraws
revolut_ramp.withdraw_liquidity(:liquidity_key, offchain_id: withdrawer_offchain_id, proof: Proof { foo: 0 });
revolut_ramp.withdraw_liquidity(:liquidity_key, offchain_id: withdrawer_offchain_id, :proof);

// withdrawer withdraws again
revolut_ramp.withdraw_liquidity(:liquidity_key, offchain_id: withdrawer_offchain_id, proof: Proof { foo: 0 });
revolut_ramp.withdraw_liquidity(:liquidity_key, offchain_id: withdrawer_offchain_id, :proof);
}

//
Expand Down
5 changes: 5 additions & 0 deletions contracts/src/tests/constants.cairo
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use core::starknet::{ContractAddress, contract_address_const};
use zkramp::components::registry::interface::OffchainId;
use zkramp::contracts::ramps::revolut::interface::Proof;

const REVTAG: felt252 = 'just a random revtag hash';

Expand Down Expand Up @@ -53,3 +54,7 @@ pub fn NAME() -> ByteArray {
pub fn SYMBOL() -> ByteArray {
"SYMBOL"
}

pub fn PROOF() -> Proof {
Proof { foo: 0 }
}

0 comments on commit 4f9b35a

Please sign in to comment.