Skip to content

Commit

Permalink
Adding method to interface and test it
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerson2102 committed Sep 29, 2024
1 parent 0b018b7 commit 5253044
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
11 changes: 11 additions & 0 deletions crates/contracts/src/kakarot_core/eth_rpc.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,11 @@ fn is_view(self: @KakarotCore::ContractState) -> bool {
mod tests {
use crate::kakarot_core::KakarotCore;
use crate::kakarot_core::eth_rpc::IEthRPC;
use crate::kakarot_core::interface::IExtendedKakarotCoreDispatcherTrait;
use crate::test_utils::{setup_contracts_for_testing, deploy_eoa};
use snforge_std::{start_cheat_chain_id_global, stop_cheat_chain_id_global};
use utils::constants::POW_2_53;
use evm::test_utils::evm_address;

fn set_up() -> KakarotCore::ContractState {
// Define the kakarot state to access contract functions
Expand All @@ -236,6 +239,14 @@ mod tests {
stop_cheat_chain_id_global();
}

#[test]
fn test_eth_get_transaction_count() {
let (_, kakarot_core) = setup_contracts_for_testing();
let _ = deploy_eoa(kakarot_core, evm_address());
// Deployed eoa should return a zero nonce
assert_eq!(kakarot_core.eth_get_transaction_count(evm_address()), 0);
}


#[test]
fn test_eth_chain_id_returns_input_when_less_than_pow_2_53() {
Expand Down
3 changes: 3 additions & 0 deletions crates/contracts/src/kakarot_core/interface.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ pub trait IExtendedKakarotCore<TContractState> {
/// Executes an EVM transaction and possibly modifies the state
fn eth_send_transaction(ref self: TContractState, tx: Transaction) -> (bool, Span<u8>, u64);

// Returns the transaction count (nonce) of the specified address
fn eth_get_transaction_count(self: @TContractState, address: EthAddress) -> u64;

/// Upgrade the KakarotCore smart contract
/// Using replace_class_syscall
fn upgrade(ref self: TContractState, new_class_hash: ClassHash);
Expand Down

0 comments on commit 5253044

Please sign in to comment.