Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
staffik committed Dec 16, 2024
1 parent ed8f37d commit 029cd6c
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 91 deletions.
20 changes: 13 additions & 7 deletions integration-tests/src/test_loop/tests/max_receipt_size.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ fn slow_test_max_receipt_size() {

let account0: AccountId = "account0".parse().unwrap();
let account0_signer = &create_user_test_signer(&account0).into();
let rpc_id = "account4".parse().unwrap();

// We can't test receipt limit by submitting large transactions because we hit the transaction size limit
// before hitting the receipt size limit.
Expand All @@ -33,7 +34,7 @@ fn slow_test_max_receipt_size() {
get_shared_block_hash(&env.datas, &env.test_loop),
);
let large_tx_exec_res =
execute_tx(&mut env.test_loop, large_tx, &env.datas, Duration::seconds(5));
execute_tx(&mut env.test_loop, &rpc_id, large_tx, &env.datas, Duration::seconds(5));
assert_matches!(large_tx_exec_res, Err(InvalidTxError::TransactionSizeExceeded { .. }));

// Let's test it by running a contract that generates a large receipt.
Expand All @@ -44,7 +45,7 @@ fn slow_test_max_receipt_size() {
&account0_signer,
get_shared_block_hash(&env.datas, &env.test_loop),
);
run_tx(&mut env.test_loop, deploy_contract_tx, &env.datas, Duration::seconds(5));
run_tx(&mut env.test_loop, &rpc_id, deploy_contract_tx, &env.datas, Duration::seconds(5));

// Calling generate_large_receipt({"account_id": "account0", "method_name": "noop", "total_args_size": 3000000})
// will generate a receipt that has ~3_000_000 bytes. It'll be a single receipt with multiple FunctionCall actions.
Expand All @@ -60,7 +61,7 @@ fn slow_test_max_receipt_size() {
300 * TGAS,
get_shared_block_hash(&env.datas, &env.test_loop),
);
run_tx(&mut env.test_loop, large_receipt_tx, &env.datas, Duration::seconds(5));
run_tx(&mut env.test_loop, &rpc_id, large_receipt_tx, &env.datas, Duration::seconds(5));

// Generating a receipt that is 5 MB should fail, it's above the receipt size limit.
let too_large_receipt_tx = SignedTransaction::call(
Expand All @@ -74,9 +75,14 @@ fn slow_test_max_receipt_size() {
300 * TGAS,
get_shared_block_hash(&env.datas, &env.test_loop),
);
let too_large_receipt_tx_exec_res =
execute_tx(&mut env.test_loop, too_large_receipt_tx, &env.datas, Duration::seconds(5))
.unwrap();
let too_large_receipt_tx_exec_res = execute_tx(
&mut env.test_loop,
&rpc_id,
too_large_receipt_tx,
&env.datas,
Duration::seconds(5),
)
.unwrap();

match too_large_receipt_tx_exec_res.status {
FinalExecutionStatus::Failure(TxExecutionError::ActionError(action_error)) => {
Expand Down Expand Up @@ -111,7 +117,7 @@ fn slow_test_max_receipt_size() {
300 * TGAS,
get_shared_block_hash(&env.datas, &env.test_loop),
);
let sum_4_res = run_tx(&mut env.test_loop, sum_4_tx, &env.datas, Duration::seconds(5));
let sum_4_res = run_tx(&mut env.test_loop, &rpc_id, sum_4_tx, &env.datas, Duration::seconds(5));
assert_eq!(sum_4_res, 10u64.to_le_bytes().to_vec());

env.shutdown_and_drain_remaining_events(Duration::seconds(20));
Expand Down
Loading

0 comments on commit 029cd6c

Please sign in to comment.