Skip to content
This repository was archived by the owner on Jul 22, 2024. It is now read-only.

Add a test calling a contract that uses keccak in testnet submodule #1110

Merged
Merged
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
9e6104f
Updated submodule to latest commit
Oct 30, 2023
2e6122f
wip
Nov 2, 2023
ddc74fb
Added a usage target to makefile (#1069)
igaray Oct 30, 2023
c73ef20
Implement `NativeSyscallHandler::deploy` (#1106)
fmoletta Oct 30, 2023
d2651a2
update cairo native to use gas consumed (#1102)
edg-l Oct 30, 2023
9eea072
Save `SierraProgram` + `ContractEntryPoints` instead of `SierraContra…
fmoletta Oct 31, 2023
ce20184
`get_execution_info`test (#1067)
ElFantasma Oct 31, 2023
422d985
Cairo native: Implement library_call syscall (#1074)
edg-l Oct 31, 2023
ea7b47a
Replace class native (#1105)
Oct 31, 2023
5b266b3
`get_block_hash` syscall native (#1048)
igaray Oct 31, 2023
bb5dc90
Add logging to syscalls (#1111)
juanbono Oct 31, 2023
6943453
Add error handling to `RpcState` (#1107)
fmoletta Nov 1, 2023
2533375
Merge branch 'main' into rpc_state_reader-add-test-calling-contract-u…
Nov 6, 2023
b484a18
Convert my_contract/target from a submodule to a regular directory
Nov 9, 2023
5a438c5
Add my_contract/target files
Nov 9, 2023
6149268
Merge branch 'temp-branch-name' into rpc_state_reader-add-test-callin…
Nov 9, 2023
84f87e0
Merge branch 'main' into rpc_state_reader-add-test-calling-contract-u…
Nov 9, 2023
31ac60d
added test that check fees and return data
Nov 9, 2023
e230052
Add Keccak_contract folder
Nov 10, 2023
99989c9
add test price and retdata
Nov 10, 2023
8972655
Merge branch 'main' into rpc_state_reader-add-test-calling-contract-u…
Nov 10, 2023
fe46180
wip
Nov 13, 2023
3f21395
add test to check retdata and fee
Nov 16, 2023
c0bb5ba
Merge branch 'main' into rpc_state_reader-add-test-calling-contract-u…
Nov 16, 2023
6c9d487
wip
Nov 16, 2023
9d21e05
wip
Nov 16, 2023
0fbda6c
wip
Nov 17, 2023
2599461
Merge branch 'main' into rpc_state_reader-add-test-calling-contract-u…
Nov 17, 2023
4d9b99f
wip
Nov 17, 2023
06a3454
wip
Nov 17, 2023
1cd3b82
corrected format
Nov 17, 2023
777d970
Merge branch 'main' into rpc_state_reader-add-test-calling-contract-u…
fguthmann Nov 17, 2023
f603da8
removed unused files
Nov 17, 2023
6575b15
Merge branch 'main' into rpc_state_reader-add-test-calling-contract-u…
fguthmann Nov 17, 2023
dacbd24
Merge remote-tracking branch 'origin/rpc_state_reader-add-test-callin…
Nov 17, 2023
e2b5e4e
Merge branch 'main' into rpc_state_reader-add-test-calling-contract-u…
pefontana Nov 17, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 44 additions & 1 deletion rpc_state_reader/tests/sir_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,6 @@ fn starknet_in_rust_test_case_declare_tx(hash: &str, block_number: u64, chain: R
fn starknet_in_rust_test_case_tx_skip_nonce_check(hash: &str, block_number: u64, chain: RpcChain) {
let (tx_info, trace, receipt) =
execute_tx_configurable(hash, chain, BlockNumber(block_number), false, true);

let TransactionExecutionInfo {
call_info,
actual_fee,
Expand Down Expand Up @@ -621,3 +620,47 @@ fn starknet_in_rust_test_case_tx_skip_nonce_check(hash: &str, block_number: u64,
}
}
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test is great! But we need to remove the corelib files and the scarb related files.

#[test_case(
"0x037e199c9560666d810862bc0cf62a67aae33af6b65823068143640cdeecd8ab",
895707, // real block 895708
RpcChain::TestNet
)]
#[test_case(
"0x048ffc49f04504710e984923980fb63c4f17fb3022467251329adc75aae93c4b",
900795, // real block 900796
RpcChain::TestNet
)]
fn starknet_in_rust_check_fee_and_retdata(hash: &str, block_number: u64, chain: RpcChain) {
let (tx_info, trace, receipt) = execute_tx(hash, chain, BlockNumber(block_number));

let TransactionExecutionInfo {
call_info,
actual_fee,
..
} = tx_info;
let CallInfo { retdata, .. } = call_info.unwrap();

// check actual fee calculation
if receipt.actual_fee != actual_fee {
let diff = 100 * receipt.actual_fee.abs_diff(actual_fee) / receipt.actual_fee;

if diff >= 5 {
assert_eq!(
actual_fee, receipt.actual_fee,
"actual_fee mismatch differs from the baseline by more than 5% ({diff}%)",
);
}
}

let rpc_retdata: Vec<Felt252> = trace
.function_invocation
.unwrap()
.retdata
.unwrap()
.into_iter()
.map(|sf| Felt252::from_bytes_be(sf.bytes()))
.collect();

assert_eq!(retdata, rpc_retdata);
}