Skip to content

Commit

Permalink
Update account & proof oracles tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Pasifaee committed May 27, 2024
1 parent 6f7be70 commit c55220b
Show file tree
Hide file tree
Showing 14 changed files with 1,401 additions and 603 deletions.
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 @@ -27,11 +27,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_input_serialized));

let transaction_within_block: TransactionWithinBlock<MAX_DATA_LEN> = get_transaction(
ETHEREUM_MAINNET_ID,
number,
tx_idx
);
let transaction_within_block: TransactionWithinBlock<MAX_DATA_LEN> = get_transaction(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 @@ -43,11 +39,7 @@ fn get_transaction_wrong_block_number() {
let _ = OracleMock::mock("get_transaction").returns((tx_type, foreign_call_transaction, proof_input_serialized));

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

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

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

#[test(should_fail_with = "Invalid node hash")]
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_input_serialized));

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

#[test(should_fail_with = "Invalid node hash")]
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_input_serialized));

let _: TransactionWithinBlock<MAX_DATA_LEN> = get_transaction(
ETHEREUM_MAINNET_ID,
another_number,
tx_idx
);
let _: TransactionWithinBlock<MAX_DATA_LEN> = get_transaction(ETHEREUM_MAINNET_ID, another_number, tx_idx);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`accountOracle > getAccountOracle 1`] = `
[
"0x00",
"0x00",
"0x00",
"0x00",
"0x00",
"0x00",
"0x00",
"0x00",
"0x00",
"0x00",
"0x00",
"0x00",
"0x00",
"0x00",
"0x00",
"0x00",
"0x00",
"0x00",
"0x00",
"0x00",
"0x00",
"0x00",
"0x00",
"0x00",
"0x00",
"0x00",
"0x00",
"0x00",
"0x00",
"0x00",
"0x00",
"0x00",
"0x00",
"0x00",
"0x06",
"0xe1",
"0x20",
"0xc2",
"0xc3",
"0x54",
"0x7c",
"0x60",
"0xee",
"0x47",
"0xf7",
"0x12",
"0xd3",
"0x2e",
"0x5a",
"0xcf",
"0x38",
"0xb3",
"0x5d",
"0x1c",
"0xc6",
"0x2e",
"0x23",
"0xb0",
"0x55",
"0xa6",
"0x9b",
"0xb8",
"0x82",
"0x84",
"0xc2",
"0x81",
]
`;

exports[`accountOracle > getAccountOracle 2`] = `
[
"0x00",
"0x00",
"0x00",
"0x00",
"0x00",
"0x00",
"0x00",
"0x00",
"0x00",
"0x00",
"0x00",
"0x00",
"0x00",
"0x00",
"0x00",
"0x00",
"0x00",
"0x00",
"0x00",
"0x00",
"0x00",
"0x00",
"0x00",
"0x00",
"0x00",
"0x00",
"0x00",
"0x00",
"0xf8",
"0x50",
"0x82",
"0x02",
"0xcb",
"0x8a",
"0x01",
"0x9c",
"0x54",
"0xc1",
"0xcc",
"0x8b",
"0x1a",
"0xd5",
"0x99",
"0x4d",
"0xa0",
"0x56",
"0xe8",
"0x1f",
"0x17",
"0x1b",
"0xcc",
"0x55",
"0xa6",
"0xff",
"0x83",
"0x45",
"0xe6",
"0x92",
"0xc0",
"0xf8",
"0x6e",
"0x5b",
"0x48",
"0xe0",
"0x1b",
"0x99",
"0x6c",
"0xad",
"0xc0",
"0x01",
"0x62",
"0x2f",
"0xb5",
"0xe3",
"0x63",
"0xb4",
"0x21",
"0xa0",
"0xc5",
"0xd2",
"0x46",
"0x01",
"0x86",
"0xf7",
"0x23",
"0x3c",
"0x92",
"0x7e",
"0x7d",
"0xb2",
"0xdc",
"0xc7",
"0x03",
"0xc0",
"0xe5",
"0x00",
"0xb6",
"0x53",
"0xca",
"0x82",
"0x27",
"0x3b",
"0x7b",
"0xfa",
"0xd8",
"0x04",
"0x5d",
"0x85",
"0xa4",
"0x70",
]
`;
Loading

0 comments on commit c55220b

Please sign in to comment.