diff --git a/bin/e2e-test-client/src/lib.rs b/bin/e2e-test-client/src/lib.rs index fc763bd4909..36ee3ea5413 100644 --- a/bin/e2e-test-client/src/lib.rs +++ b/bin/e2e-test-client/src/lib.rs @@ -101,11 +101,11 @@ pub fn main_body(config: SuiteConfig, mut args: Arguments) { }), ), Trial::test( - "dry run transaction from `non_specific_tx.raw` file", + "dry run transaction from `arbitrary_tx.raw` file", with_cloned(&config, |config| { async_execute(async { let ctx = TestContext::new(config).await; - tests::script::non_specific_transaction(&ctx).await + tests::script::arbitrary_transaction(&ctx).await })?; Ok(()) }), diff --git a/bin/e2e-test-client/src/tests/script.rs b/bin/e2e-test-client/src/tests/script.rs index cbe12d1dc50..31c35cf63f5 100644 --- a/bin/e2e-test-client/src/tests/script.rs +++ b/bin/e2e-test-client/src/tests/script.rs @@ -142,10 +142,9 @@ pub async fn run_contract_large_state(ctx: &TestContext) -> Result<(), Failed> { _dry_runs(ctx, &[dry_run], 1000, DryRunResult::MayFail).await } -// Send non specific transaction from `non_specific_tx.raw` file -pub async fn non_specific_transaction(ctx: &TestContext) -> Result<(), Failed> { - const RAW_PATH: &str = "src/tests/test_data/non_specific_tx.raw"; - const JSON_PATH: &str = "src/tests/test_data/non_specific_tx.json"; +pub async fn arbitrary_transaction(ctx: &TestContext) -> Result<(), Failed> { + const RAW_PATH: &str = "src/tests/test_data/arbitrary_tx.raw"; + const JSON_PATH: &str = "src/tests/test_data/arbitrary_tx.json"; let dry_run_raw = std::fs::read_to_string(RAW_PATH).expect("Should read the raw transaction"); @@ -153,26 +152,27 @@ pub async fn non_specific_transaction(ctx: &TestContext) -> Result<(), Failed> { std::fs::read_to_string(JSON_PATH).expect("Should read the json transaction"); let bytes = dry_run_raw.replace("0x", ""); let hex_tx = hex::decode(bytes).expect("Expected hex string"); - let dry_run_raw: Transaction = Transaction::from_bytes(hex_tx.as_ref()) + let dry_run_tx_from_raw: Transaction = Transaction::from_bytes(hex_tx.as_ref()) .expect("Should be able do decode the Transaction from canonical representation"); - let dry_run_json: Transaction = serde_json::from_str(dry_run_json.as_ref()) - .expect("Should be able do decode the Transaction from json representation"); + let mut dry_run_tx_from_json: Transaction = + serde_json::from_str(dry_run_json.as_ref()) + .expect("Should be able do decode the Transaction from json representation"); - // Overrides the raw tx with a json tx. if std::env::var_os("OVERRIDE_RAW_WITH_JSON").is_some() { - let bytes = dry_run_json.to_bytes(); + let bytes = dry_run_tx_from_json.to_bytes(); std::fs::write(RAW_PATH, hex::encode(bytes)) .expect("Should write the raw transaction"); } else if std::env::var_os("OVERRIDE_JSON_WITH_RAW").is_some() { - let bytes = serde_json::to_string_pretty(&dry_run_raw) + let bytes = serde_json::to_string_pretty(&dry_run_tx_from_raw) .expect("Should be able to encode the Transaction"); + dry_run_tx_from_json = dry_run_tx_from_raw.clone(); std::fs::write(JSON_PATH, bytes.as_bytes()) .expect("Should write the json transaction"); - } else { - assert_eq!(dry_run_raw, dry_run_json); } - _dry_runs(ctx, &[dry_run_json], 1000, DryRunResult::MayFail).await + assert_eq!(dry_run_tx_from_raw, dry_run_tx_from_json); + + _dry_runs(ctx, &[dry_run_tx_from_json], 1000, DryRunResult::MayFail).await } async fn _dry_runs( diff --git a/bin/e2e-test-client/src/tests/test_data/non_specific_tx.json b/bin/e2e-test-client/src/tests/test_data/arbitrary_tx.json similarity index 100% rename from bin/e2e-test-client/src/tests/test_data/non_specific_tx.json rename to bin/e2e-test-client/src/tests/test_data/arbitrary_tx.json diff --git a/bin/e2e-test-client/src/tests/test_data/non_specific_tx.raw b/bin/e2e-test-client/src/tests/test_data/arbitrary_tx.raw similarity index 100% rename from bin/e2e-test-client/src/tests/test_data/non_specific_tx.raw rename to bin/e2e-test-client/src/tests/test_data/arbitrary_tx.raw