-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: testing added DeployKind to allow deploys to return various data
- Loading branch information
1 parent
0437ac6
commit a9996a5
Showing
2 changed files
with
46 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,40 @@ | ||
use soroban_cli::commands::tx; | ||
use soroban_sdk::xdr::{Limits, ReadXdr, TransactionEnvelope, TransactionV1Envelope, WriteXdr}; | ||
use soroban_sdk::xdr::{ | ||
Limits, ReadXdr, TransactionEnvelope, TransactionV1Envelope, VecM, WriteXdr, | ||
}; | ||
use soroban_test::{AssertExt, TestEnv}; | ||
|
||
use crate::integration::util::{deploy_contract, HELLO_WORLD}; | ||
use crate::integration::util::{deploy_contract, DeployKind, HELLO_WORLD}; | ||
|
||
#[tokio::test] | ||
async fn txn_simulate() { | ||
let sandbox = &TestEnv::new(); | ||
let xdr_base64 = deploy_contract(sandbox, HELLO_WORLD, true).await; | ||
println!("{xdr_base64}"); | ||
let xdr_base64_build_only = deploy_contract(sandbox, HELLO_WORLD, DeployKind::BuildOnly).await; | ||
let xdr_base64_sim_only = deploy_contract(sandbox, HELLO_WORLD, DeployKind::SimOnly).await; | ||
println!("{xdr_base64_build_only}"); | ||
let cmd = tx::simulate::Cmd::default(); | ||
let tx_env = TransactionEnvelope::from_xdr_base64(&xdr_base64, Limits::none()).unwrap(); | ||
let tx_env = | ||
TransactionEnvelope::from_xdr_base64(&xdr_base64_build_only, Limits::none()).unwrap(); | ||
let TransactionEnvelope::Tx(TransactionV1Envelope { tx, .. }) = &tx_env else { | ||
panic!("Only transaction v1 is supported") | ||
}; | ||
let assembled = cmd.simulate(tx, &sandbox.client()).await.unwrap(); | ||
let assembled_str = sandbox | ||
.new_assert_cmd("tx") | ||
.arg("simulate") | ||
.write_stdin(xdr_base64.as_bytes()) | ||
.write_stdin(xdr_base64_build_only.as_bytes()) | ||
.assert() | ||
.success() | ||
.stdout_as_str(); | ||
println!("{assembled_str}"); | ||
assert_eq!(xdr_base64_sim_only, assembled_str); | ||
let txn_env = TransactionEnvelope::Tx(TransactionV1Envelope { | ||
tx: assembled.transaction().clone(), | ||
signatures: VecM::default(), | ||
}); | ||
|
||
assert_eq!( | ||
assembled | ||
.transaction() | ||
.to_xdr_base64(Limits::none()) | ||
.unwrap(), | ||
txn_env.to_xdr_base64(Limits::none()).unwrap(), | ||
assembled_str | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters