Skip to content

Commit

Permalink
fix tests, custom cubit branch
Browse files Browse the repository at this point in the history
  • Loading branch information
notV4l committed Feb 18, 2024
1 parent e60afd8 commit 2a0d43d
Show file tree
Hide file tree
Showing 16 changed files with 86 additions and 82 deletions.
2 changes: 1 addition & 1 deletion Scarb.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ dependencies = [
[[package]]
name = "cubit"
version = "1.3.0"
source = "git+https://github.com/influenceth/cubit.git#62756082bf2555d7ab25c69d9c7bc30574ff1ce8"
source = "git+https://github.com/notV4l/cubit.git?rev=5aa99005#5aa99005475012a04421e85c8fa3dc77f53c8ca3"

[[package]]
name = "dojo"
Expand Down
3 changes: 2 additions & 1 deletion Scarb.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ homepage = "https://github.com/dojoengine/origami"
authors = ["bal7hazar@proton.me"]

[workspace.dependencies]
cubit = { git = "https://github.com/influenceth/cubit.git" }
# cubit = { git = "https://github.com/influenceth/cubit.git" }
cubit = { git = "https://github.com/notV4l/cubit.git", rev = "5aa99005" }
dojo = { git = "https://github.com/dojoengine/dojo", tag = "v0.6.0-alpha.0" }
origami = { path = "crates" }
token = { path = "token" }
16 changes: 8 additions & 8 deletions examples/market/src/models/market.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ mod tests {
let market = Market {
item_id: 1, cash_amount: SCALING_FACTOR * 1, item_quantity: 1
}; // pool 1:1
let cost = market.buy(10);
let _cost = market.buy(10);
}

#[test]
Expand Down Expand Up @@ -339,9 +339,9 @@ mod tests {
let expected_quantity = FixedTrait::new_unscaled(expected_quantity, false);

// Get expecteed liquidity
let expected_liquidity = FixedTrait::sqrt(expected_amount * expected_quantity);
let _expected_liquidity = FixedTrait::sqrt(expected_amount * expected_quantity);

let final_liquidity = initial_liquidity + liquidity_add;
let _final_liquidity = initial_liquidity + liquidity_add;
// assert_precise(expected_liquidity, final_liquidity.into(), 'wrong liquidity', Option::None(()));
}

Expand All @@ -353,7 +353,7 @@ mod tests {
}; // pool 1:10
// Adding 20 items requires (SCALING_FACTOR * 2) cash amount to maintain the ratio
// Therefore this should fail
let (amount_add, quantity_add, liquidity_add) = market
let (_amount_add, _quantity_add, _liquidity_add) = market
.add_liquidity(SCALING_FACTOR * 1, 20);
}

Expand Down Expand Up @@ -381,9 +381,9 @@ mod tests {
let expected_quantity = FixedTrait::new_unscaled(expected_quantity, false);

// Get expecteed liquidity
let expected_liquidity = FixedTrait::sqrt(expected_amount * expected_quantity);
let _expected_liquidity = FixedTrait::sqrt(expected_amount * expected_quantity);

let final_liquidity = initial_liquidity - liquidity_remove;
let _final_liquidity = initial_liquidity - liquidity_remove;
// assert_precise(expected_liquidity, final_liquidity.into(), 'wrong liquidity', Option::None(()));
}

Expand All @@ -396,7 +396,7 @@ mod tests {
// Remove liquidity
let one = FixedTrait::new_unscaled(1, false);

let (amount_remove, quantity_remove) = market.remove_liquidity(one);
let (_amount_remove, _quantity_remove) = market.remove_liquidity(one);
}

#[test]
Expand All @@ -412,6 +412,6 @@ mod tests {
let two = FixedTrait::new_unscaled(2, false);
let liquidity_remove = initial_liquidity * two;

let (amount_remove, quantity_remove) = market.remove_liquidity(liquidity_remove);
let (_amount_remove, _quantity_remove) = market.remove_liquidity(liquidity_remove);
}
}
2 changes: 1 addition & 1 deletion examples/market/src/tests/trade.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ use market::tests::{setup, setup::Systems};
#[test]
fn test_market_spawn() {
// [Setup]
let (world, systems) = setup::spawn_market();
let (_world, _systems) = setup::spawn_market();
}
10 changes: 5 additions & 5 deletions token/src/components/tests/introspection/test_src5.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -21,29 +21,29 @@ fn STATE() -> (IWorldDispatcher, SRC5Mock::ContractState) {

#[test]
fn test_src5_default_behavior() {
let (world, mut state) = STATE();
let (_world, mut state) = STATE();
let supports_default_interface = state.supports_interface(ISRC5_ID);
assert(supports_default_interface, 'Should support base interface');
}

#[test]
fn test_src5_not_registered_interface() {
let (world, mut state) = STATE();
let (_world, mut state) = STATE();
let supports_unregistered_interface = state.supports_interface(OTHER_ID);
assert(!supports_unregistered_interface, 'Should not support unregistered');
}

#[test]
fn test_src5_register_interface() {
let (world, mut state) = STATE();
let (_world, mut state) = STATE();
state.src5.register_interface(OTHER_ID);
let supports_new_interface = state.supports_interface(OTHER_ID);
assert(supports_new_interface, 'Should support new interface');
}

#[test]
fn test_src5_deregister_interface() {
let (world, mut state) = STATE();
let (_world, mut state) = STATE();
state.src5.register_interface(OTHER_ID);
state.src5.deregister_interface(OTHER_ID);
let supports_old_interface = state.supports_interface(OTHER_ID);
Expand All @@ -53,6 +53,6 @@ fn test_src5_deregister_interface() {
#[test]
#[should_panic(expected: ('SRC5: invalid id',))]
fn test_src5_deregister_default_interface() {
let (world, mut state) = STATE();
let (_world, mut state) = STATE();
state.src5.deregister_interface(ISRC5_ID);
}
4 changes: 2 additions & 2 deletions token/src/components/tests/security/test_initializable.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ fn STATE() -> (IWorldDispatcher, InitializableMock::ContractState) {

#[test]
fn test_initializable_initialize() {
let (world, mut state) = STATE();
let (_world, mut state) = STATE();
assert(!state.initializable.is_initialized(), 'Should not be initialized');
state.initializable.initialize();
assert(state.initializable.is_initialized(), 'Should be initialized');
Expand All @@ -29,7 +29,7 @@ fn test_initializable_initialize() {
#[test]
#[should_panic(expected: ('Initializable: is initialized',))]
fn test_initializable_initialize_when_initialized() {
let (world, mut state) = STATE();
let (_world, mut state) = STATE();
state.initializable.initialize();
state.initializable.initialize();
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ fn STATE() -> (IWorldDispatcher, erc20_allowance_mock::ContractState) {

#[test]
fn test_erc20_allowance_approve() {
let (world, mut state) = STATE();
let (_world, mut state) = STATE();

testing::set_caller_address(OWNER());

Expand All @@ -73,7 +73,7 @@ fn test_erc20_allowance_approve() {
#[test]
#[should_panic(expected: ('ERC20: approve from 0',))]
fn test_erc20_allowance_approve_from_zero() {
let (world, mut state) = STATE();
let (_world, mut state) = STATE();

testing::set_caller_address(ZERO());
state.erc20_allowance.approve(SPENDER(), VALUE);
Expand All @@ -82,7 +82,7 @@ fn test_erc20_allowance_approve_from_zero() {
#[test]
#[should_panic(expected: ('ERC20: approve to 0',))]
fn test_erc20_allowance_approve_to_zero() {
let (world, mut state) = STATE();
let (_world, mut state) = STATE();

testing::set_caller_address(OWNER());
state.erc20_allowance.approve(ZERO(), VALUE);
Expand All @@ -94,7 +94,7 @@ fn test_erc20_allowance_approve_to_zero() {

#[test]
fn test_erc20_allowance_spend_allowance() {
let (world, mut state) = STATE();
let (_world, mut state) = STATE();

testing::set_caller_address(OWNER());

Expand Down
20 changes: 10 additions & 10 deletions token/src/components/tests/token/erc20/test_erc20_balance.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ fn STATE() -> (IWorldDispatcher, erc20_balance_mock::ContractState) {

#[test]
fn test_erc20_balance_initialize() {
let (world, mut state) = STATE();
let (_world, mut state) = STATE();

assert(state.erc20_balance.balance_of(ADMIN()) == 0, 'Should be 0');
assert(state.erc20_balance.balance_of(OWNER()) == 0, 'Should be 0');
Expand All @@ -82,7 +82,7 @@ fn test_erc20_balance_initialize() {

#[test]
fn test_erc20_balance_update_balance() {
let (world, mut state) = STATE();
let (_world, mut state) = STATE();

state.erc20_balance.update_balance(ZERO(), 0, 420);
assert(state.erc20_balance.balance_of(ZERO()) == 420, 'Should be 420');
Expand All @@ -97,15 +97,15 @@ fn test_erc20_balance_update_balance() {
#[test]
#[should_panic(expected: ('u256_sub Overflow',))]
fn test_erc20_balance_update_balance_sub_overflow() {
let (world, mut state) = STATE();
let (_world, mut state) = STATE();

state.erc20_balance.update_balance(ZERO(), 1, 0);
}

#[test]
#[should_panic(expected: ('u256_add Overflow',))]
fn test_erc20_balance_update_balance_add_overflow() {
let (world, mut state) = STATE();
let (_world, mut state) = STATE();

state.erc20_balance.update_balance(ZERO(), 0, BoundedInt::max());
state.erc20_balance.update_balance(ZERO(), 0, 1);
Expand All @@ -117,7 +117,7 @@ fn test_erc20_balance_update_balance_add_overflow() {

#[test]
fn test_erc20_balance_transfer_internal() {
let (world, mut state) = STATE();
let (_world, mut state) = STATE();

state.erc20_balance.update_balance(ADMIN(), 0, 420);
state.erc20_balance.update_balance(OTHER(), 0, 1000);
Expand All @@ -136,15 +136,15 @@ fn test_erc20_balance_transfer_internal() {
#[test]
#[should_panic(expected: ('ERC20: transfer from 0',))]
fn test_erc20_balance_transfer_internal_from_zero() {
let (world, mut state) = STATE();
let (_world, mut state) = STATE();

state.erc20_balance.transfer_internal(ZERO(), ADMIN(), 420);
}

#[test]
#[should_panic(expected: ('ERC20: transfer to 0',))]
fn test_erc20_balance_transfer_internal_to_zero() {
let (world, mut state) = STATE();
let (_world, mut state) = STATE();

state.erc20_balance.transfer_internal(ADMIN(), ZERO(), 420);
}
Expand Down Expand Up @@ -217,7 +217,7 @@ fn test_transfer_from() {
#[test]
#[should_panic(expected: ('u256_sub Overflow', 'ENTRYPOINT_FAILED'))]
fn test_transfer_from_greater_than_allowance() {
let (world, mut erc20_balance_mock) = setup();
let (_world, mut erc20_balance_mock) = setup();

utils::impersonate(OWNER());
erc20_balance_mock.approve(SPENDER(), VALUE);
Expand All @@ -231,7 +231,7 @@ fn test_transfer_from_greater_than_allowance() {
#[test]
#[should_panic(expected: ('ERC20: transfer to 0', 'ENTRYPOINT_FAILED'))]
fn test_transfer_from_to_zero_address() {
let (world, mut erc20_balance_mock) = setup();
let (_world, mut erc20_balance_mock) = setup();

utils::impersonate(OWNER());
erc20_balance_mock.approve(SPENDER(), VALUE);
Expand All @@ -243,7 +243,7 @@ fn test_transfer_from_to_zero_address() {
#[test]
#[should_panic(expected: ('u256_sub Overflow', 'ENTRYPOINT_FAILED'))]
fn test_transfer_from_from_zero_address() {
let (world, mut erc20_balance_mock) = setup();
let (_world, mut erc20_balance_mock) = setup();

erc20_balance_mock.transfer_from(ZERO(), RECIPIENT(), VALUE);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ fn STATE() -> (IWorldDispatcher, erc20_bridgeable_mock::ContractState) {


fn setup() -> erc20_bridgeable_mock::ContractState {
let (world, mut state) = STATE();
let (_world, mut state) = STATE();
state.initializer(NAME, SYMBOL, SUPPLY, OWNER(), BRIDGE());
state
}
Expand All @@ -63,7 +63,7 @@ fn setup() -> erc20_bridgeable_mock::ContractState {

#[test]
fn test_erc20_bridgeable_initializer() {
let (world, mut state) = STATE();
let (_world, mut state) = STATE();
state.initializer(NAME, SYMBOL, SUPPLY, OWNER(), BRIDGE());

assert(state.l2_bridge_address() == BRIDGE(), 'should be BRIDGE');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ fn STATE() -> (IWorldDispatcher, erc20_metadata_mock::ContractState) {

#[test]
fn test_erc20_metadata_initialize() {
let (world, mut state) = STATE();
let (_world, mut state) = STATE();

state.erc20_metadata.initialize(NAME, SYMBOL, DECIMALS);

Expand All @@ -35,7 +35,7 @@ fn test_erc20_metadata_initialize() {

#[test]
fn test_erc20_metadata_update_total_supply() {
let (world, mut state) = STATE();
let (_world, mut state) = STATE();

state.erc20_metadata.update_total_supply(0, 420);
assert(state.erc20_metadata.total_supply() == 420, 'Should be 420');
Expand All @@ -51,7 +51,7 @@ fn test_erc20_metadata_update_total_supply() {
#[test]
#[should_panic(expected: ('u256_sub Overflow',))]
fn test_erc20_metadata_update_total_supply_sub_overflow() {
let (world, mut state) = STATE();
let (_world, mut state) = STATE();

state.erc20_metadata.update_total_supply(1, 0);
}
Expand All @@ -60,7 +60,7 @@ fn test_erc20_metadata_update_total_supply_sub_overflow() {
#[test]
#[should_panic(expected: ('u256_add Overflow',))]
fn test_erc20_metadata_update_total_supply_add_overflow() {
let (world, mut state) = STATE();
let (_world, mut state) = STATE();

state.erc20_metadata.update_total_supply(0, BoundedInt::max());
state.erc20_metadata.update_total_supply(0, 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ fn STATE() -> (IWorldDispatcher, erc20_mintable_burnable_mock::ContractState) {

#[test]
fn test_erc20_mintable_mint() {
let (world, mut state) = STATE();
let (_world, mut state) = STATE();

let total_supply = state.total_supply();
state.erc20_mintable.mint(RECIPIENT(), VALUE);
Expand All @@ -46,14 +46,14 @@ fn test_erc20_mintable_mint() {
#[test]
#[should_panic(expected: ('ERC20: mint to 0',))]
fn test_erc20_mintable_mint_to_zero() {
let (world, mut state) = STATE();
let (_world, mut state) = STATE();
state.erc20_mintable.mint(ZERO(), VALUE);
}


#[test]
fn test_erc20_burnable_burn() {
let (world, mut state) = STATE();
let (_world, mut state) = STATE();

let total_supply = state.total_supply();
state.erc20_mintable.mint(RECIPIENT(), VALUE);
Expand All @@ -71,7 +71,7 @@ fn test_erc20_burnable_burn() {
#[test]
#[should_panic(expected: ('ERC20: burn from 0',))]
fn test_erc20_burnable_burn_from_zero() {
let (world, mut state) = STATE();
let (_world, mut state) = STATE();
state.erc20_burnable.burn(ZERO(), VALUE);
}

Loading

0 comments on commit 2a0d43d

Please sign in to comment.