Skip to content

Commit

Permalink
Merge branch 'feature/apply-testnet-configuration' into feature/integ…
Browse files Browse the repository at this point in the history
…ration-tests-forkless-upgrades
  • Loading branch information
xgreenx committed May 16, 2024
2 parents bea5ed1 + d70e312 commit f6fa43d
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions bin/e2e-test-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}),
Expand Down
26 changes: 13 additions & 13 deletions bin/e2e-test-client/src/tests/script.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,37 +142,37 @@ 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");
let dry_run_json =
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(
Expand Down

0 comments on commit f6fa43d

Please sign in to comment.