Skip to content

Commit

Permalink
Nargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
LogvinovLeon committed May 23, 2024
1 parent 0dc9304 commit 6b9fd38
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 30 deletions.
6 changes: 1 addition & 5 deletions ethereum/circuits/get_transaction/src/main.nr
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ fn main(
block_number: pub u64,
tx_idx: pub Field
) -> pub TransactionWithinBlock<MAX_DATA_LEN_M> {
let transaction_within_block: TransactionWithinBlock<MAX_DATA_LEN_M> = get_transaction::<MAX_DATA_LEN_M, PROOF_LEN, MAX_ENCODED_TX_LENGTH>(
chain_id,
block_number,
tx_idx
);
let transaction_within_block: TransactionWithinBlock<MAX_DATA_LEN_M> = get_transaction::<MAX_DATA_LEN_M, PROOF_LEN, MAX_ENCODED_TX_LENGTH>(chain_id, block_number, tx_idx);
transaction_within_block
}
30 changes: 5 additions & 25 deletions ethereum/circuits/lib/src/transaction_int_test.nr
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,7 @@ fn get_transaction_success() {
let _ = OracleMock::mock("get_header").returns((block_header_partial, block_header_rlp));
let _ = OracleMock::mock("get_transaction").returns((tx_type, foreign_call_transaction, proof));

let transaction_within_block: TransactionWithinBlock<MAX_DATA_LEN> = get_transaction::<MAX_DATA_LEN, PROOF_LEN, MAX_RLP_LEN>(
ETHEREUM_MAINNET_ID,
number,
tx_idx
);
let transaction_within_block: TransactionWithinBlock<MAX_DATA_LEN> = get_transaction::<MAX_DATA_LEN, PROOF_LEN, MAX_RLP_LEN>(ETHEREUM_MAINNET_ID, number, tx_idx);

assert_eq(transaction_within_block.block_hash, block_header_partial.hash);
assert_eq(transaction_within_block.transaction, foreign_call_transaction.into());
Expand All @@ -44,11 +40,7 @@ fn get_transaction_wrong_block_number() {
let _ = OracleMock::mock("get_transaction").returns((tx_type, foreign_call_transaction, proof));

let wrong_number = number + 1;
let _: TransactionWithinBlock<MAX_DATA_LEN> = get_transaction::<MAX_DATA_LEN, PROOF_LEN, MAX_RLP_LEN>(
ETHEREUM_MAINNET_ID,
wrong_number,
tx_idx
);
let _: TransactionWithinBlock<MAX_DATA_LEN> = get_transaction::<MAX_DATA_LEN, PROOF_LEN, MAX_RLP_LEN>(ETHEREUM_MAINNET_ID, wrong_number, tx_idx);
}

#[test(should_fail_with = "Key does not match rlp-encoded transaction index")]
Expand All @@ -57,33 +49,21 @@ fn get_transaction_wrong_tx_idx() {
let _ = OracleMock::mock("get_transaction").returns((tx_type, foreign_call_transaction, proof));

let wrong_tx_idx = tx_idx + 1;
let _: TransactionWithinBlock<MAX_DATA_LEN> = get_transaction::<MAX_DATA_LEN, PROOF_LEN, MAX_RLP_LEN>(
ETHEREUM_MAINNET_ID,
number,
wrong_tx_idx
);
let _: TransactionWithinBlock<MAX_DATA_LEN> = get_transaction::<MAX_DATA_LEN, PROOF_LEN, MAX_RLP_LEN>(ETHEREUM_MAINNET_ID, number, wrong_tx_idx);
}

#[test(should_fail_with = "Internal node hash does not match the hash extracted from the preceding node")]
fn get_transaction_wrong_transaction() {
let _ = OracleMock::mock("get_header").returns((block_header_partial, block_header_rlp));
let _ = OracleMock::mock("get_transaction").returns((another_tx_type, another_foreign_call_transaction, another_proof));

let _: TransactionWithinBlock<MAX_DATA_LEN> = get_transaction::<MAX_DATA_LEN, PROOF_LEN, MAX_RLP_LEN>(
ETHEREUM_MAINNET_ID,
number,
another_tx_idx
);
let _: TransactionWithinBlock<MAX_DATA_LEN> = get_transaction::<MAX_DATA_LEN, PROOF_LEN, MAX_RLP_LEN>(ETHEREUM_MAINNET_ID, number, another_tx_idx);
}

#[test(should_fail_with = "Internal node hash does not match the hash extracted from the preceding node")]
fn get_transaction_wrong_header() {
let _ = OracleMock::mock("get_header").returns((another_block_header_partial, another_block_header_rlp));
let _ = OracleMock::mock("get_transaction").returns((tx_type, foreign_call_transaction, proof));

let _: TransactionWithinBlock<MAX_DATA_LEN> = get_transaction::<MAX_DATA_LEN, PROOF_LEN, MAX_RLP_LEN>(
ETHEREUM_MAINNET_ID,
another_number,
tx_idx
);
let _: TransactionWithinBlock<MAX_DATA_LEN> = get_transaction::<MAX_DATA_LEN, PROOF_LEN, MAX_RLP_LEN>(ETHEREUM_MAINNET_ID, another_number, tx_idx);
}

0 comments on commit 6b9fd38

Please sign in to comment.