Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
enitrat committed Oct 4, 2024
1 parent 94329d9 commit ec20538
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
17 changes: 9 additions & 8 deletions crates/contracts/src/kakarot_core/eth_rpc.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -175,14 +175,6 @@ pub impl EthRPC<
fn eth_send_transaction(
ref self: TContractState, mut tx: Transaction
) -> (bool, Span<u8>, u64) {
panic!("unimplemented")
}

fn eth_send_raw_unsigned_tx(
ref self: TContractState, mut tx_data: Span<u8>
) -> (bool, Span<u8>, u64) {
let tx = TransactionTrait::decode_enveloped(ref tx_data).expect('EOA: could not decode tx');

let mut kakarot_state = KakarotState::get_state();
let intrinsic_gas = validate_eth_tx(@kakarot_state, tx);

Expand All @@ -197,6 +189,15 @@ pub impl EthRPC<
starknet_backend::commit(ref state).expect('Committing state failed');
(success, return_data, gas_used)
}

//TODO: we can't really unit-test this with foundry because we can't generate the RLP-encoding
//in Cairo Find another way - perhaps test-data gen with python?
fn eth_send_raw_unsigned_tx(
ref self: TContractState, mut tx_data: Span<u8>
) -> (bool, Span<u8>, u64) {
let tx = TransactionTrait::decode_enveloped(ref tx_data).expect('EOA: could not decode tx');
Self::eth_send_transaction(ref self, tx)
}
}

trait IEthRPCInternal<T> {
Expand Down
4 changes: 4 additions & 0 deletions crates/contracts/src/kakarot_core/interface.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ 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);

fn eth_send_raw_unsigned_tx(
ref self: TContractState, encoded_tx_data: Span<u8>
) -> (bool, Span<u8>, u64);

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

Expand Down
3 changes: 2 additions & 1 deletion crates/contracts/tests/test_kakarot_core.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,8 @@ fn test_eth_send_transaction_deploy_tx() {
let value = 0;

// When
// Set the contract address to the EOA address, so that the caller of the `eth_send_transaction`
// Set the contract address to the EOA address, so that the caller of the
// `eth_send_transaction`
// is an eoa
let tx = TxLegacy {
chain_id: Option::Some(chain_id()),
Expand Down

0 comments on commit ec20538

Please sign in to comment.