Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

passing e2e tests #855

Merged
merged 41 commits into from
Sep 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
5ae83d0
use latest core version in e2e tests
sreuland Aug 10, 2023
4d48086
updated system test git ref
sreuland Aug 12, 2023
556c173
include bump on the soroban client git ref
sreuland Aug 12, 2023
c7f9259
changed gh ref for js-soroban-client on e2e.yml
sreuland Aug 13, 2023
8e64042
reference new version of system test that has soroban-client local fi…
sreuland Aug 13, 2023
aff6624
fix gha run/uses in step def
sreuland Aug 13, 2023
434e3e2
fixed gha parsing error on env variable
sreuland Aug 13, 2023
29e5b73
use gha run multiline syntax
sreuland Aug 13, 2023
b69c2fb
fixing gha line continuation on if statement
sreuland Aug 13, 2023
262fdfb
include line continuation on make command still
sreuland Aug 13, 2023
09952ab
fix multiline command pipe syntax on gha step
sreuland Aug 13, 2023
a44f159
fix multiline if statement to have line ending semicolons
sreuland Aug 13, 2023
c362141
Merge branch 'main' into bump_e2e
tsachiherman Aug 15, 2023
9e0298c
Merge remote-tracking branch 'upstream/main' into bump_e2e
sreuland Aug 20, 2023
7741db4
use a version of soroban-examples that has latest sdk ref for latest …
sreuland Aug 20, 2023
bd02fea
Merge remote-tracking branch 'origin/bump_e2e' into bump_e2e
sreuland Aug 20, 2023
6b8c08b
include soroban examples repo url in test run command
sreuland Aug 21, 2023
0024b9a
Merge remote-tracking branch 'upstream/main' into bump_e2e
sreuland Aug 21, 2023
3f88242
use soroban-examples:testnet tag for latest contract source
sreuland Aug 21, 2023
5526e0d
Merge remote-tracking branch 'upstream/main' into bump_e2e
sreuland Aug 21, 2023
074d24a
update the system-test repo reference
sreuland Aug 21, 2023
fcebcb0
Merge remote-tracking branch 'upstream/main' into bump_e2e
sreuland Aug 21, 2023
27d8a5e
Merge remote-tracking branch 'upstream/main' into bump_e2e
sreuland Aug 22, 2023
e6afa30
fix(CLI): update to new RPC for simulation response
willemneal Aug 22, 2023
7e7d409
Merge pull request #1 from AhaLabs/fix/cli_sim_rpc
sreuland Aug 22, 2023
08df831
Merge remote-tracking branch 'upstream/main' into bump_e2e
sreuland Aug 22, 2023
6852ddb
Merge remote-tracking branch 'upstream/main' into bump_e2e
sreuland Aug 22, 2023
50ae299
updated js-soroban-client to latest with xdr
sreuland Aug 23, 2023
f044a70
Merge remote-tracking branch 'upstream/main' into bump_e2e
sreuland Aug 23, 2023
f8c94aa
fix: skip serializing events if there are none
willemneal Aug 22, 2023
622a04a
fix: make all omitable fields use a default; fix Cost type to use u64s
willemneal Aug 24, 2023
916772e
Merge pull request #2 from AhaLabs/bump_e2e
sreuland Aug 24, 2023
14e6ee4
Merge remote-tracking branch 'upstream/main' into bump_e2e
sreuland Aug 24, 2023
f81b235
Merge remote-tracking branch 'origin/bump_e2e' into bump_e2e
sreuland Aug 24, 2023
218867a
Merge remote-tracking branch 'upstream/main' into bump_e2e
sreuland Aug 28, 2023
3974ac7
Merge remote-tracking branch 'upstream/main' into bump_e2e
sreuland Aug 29, 2023
2c24750
updated core git ref for preview 10
sreuland Aug 29, 2023
49f72be
Merge remote-tracking branch 'upstream/main' into bump_e2e
sreuland Aug 30, 2023
7fa1611
Merge remote-tracking branch 'upstream/main' into bump_e2e
sreuland Sep 1, 2023
f8444d6
updated core git and js refs
sreuland Sep 1, 2023
2f796c3
Merge remote-tracking branch 'upstream/main' into bump_e2e
sreuland Sep 2, 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
59 changes: 42 additions & 17 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ jobs:
runs-on: ubuntu-latest-4-cores
env:
# the gh tag of system-test repo version to run
SYSTEM_TEST_GIT_REF: "a27c4941564dea24518d26111ecb5a29e5e8ff79"
SYSTEM_TEST_GIT_REF: 1e39ad9fe1e0852ba286e7668aee1f899dd0b96d

# the soroban tools source code to compile and run from system test
# refers to checked out source of current git hub ref context
SYSTEM_TEST_SOROBAN_TOOLS_REF: ${{ github.workspace }}/soroban-tools

# core git ref should be latest commit for stable soroban functionality
# the core bin can either be compiled in-line here as part of ci,
SYSTEM_TEST_CORE_GIT_REF: https:/stellar/stellar-core.git#875f47e247cefc25c8a4b3982ee65610e6a620e3
SYSTEM_TEST_CORE_GIT_REF: https:/stellar/stellar-core.git#22b9bb38416e5ce058eb9c1fadfdd414a4661833
SYSTEM_TEST_CORE_COMPILE_CONFIGURE_FLAGS: "--disable-tests --enable-next-protocol-version-unsafe-for-production"
# or can use option to pull a pre-compiled image instead
# SYSTEM_TEST_CORE_IMAGE:
Expand All @@ -31,45 +31,70 @@ jobs:
# test runtime environment, tests invoke rustc/cargo
SYSTEM_TEST_RUST_TOOLCHAIN_VERSION: stable

# sets the version of soroban-js-client used by tests
SYSTEM_TEST_JS_SOROBAN_CLIENT_NPM_VERSION: "0.9.2"
# set the version of js-soroban-client to use, need to choose one of either
# resolution options, using npm release or a gh ref:
#
# option #1, set the version of soroban-js-client based on a npm release version
SYSTEM_TEST_JS_SOROBAN_CLIENT_NPM_VERSION:
# option #2, set the version of soroban-js-client used as a ref to a gh repo
# if this value is present it takes precedence over any SYSTEM_TEST_JS_SOROBAN_CLIENT_NPM_VERSION
SYSTEM_TEST_JS_SOROBAN_CLIENT_GH_REPO: stellar/js-soroban-client
SYSTEM_TEST_JS_SOROBAN_CLIENT_GH_REF: refs/pull/132/head

# system test will build quickstart image internally to use for running the service stack
# configured in standalone network mode(core, rpc)
SYSTEM_TEST_QUICKSTART_GIT_REF: https:/stellar/quickstart.git#df8303380d5869272852ddb45c39abfeb7d4c938
SYSTEM_TEST_QUICKSTART_GIT_REF: https:/stellar/quickstart.git#c8826f5d8f80d54e819d1aca310cec3005f89175

# triggers system test to log out details from quickstart's logs and test steps
SYSTEM_TEST_VERBOSE_OUTPUT: "true"

# the soroban test cases will compile various contracts from the examples repo
SYSTEM_TEST_SOROBAN_EXAMPLES_GIT_HASH: "main"
SYSTEM_TEST_SOROBAN_EXAMPLES_GIT_HASH: "testnet"
SYSTEM_TEST_SOROBAN_EXAMPLES_GIT_REPO: "https:/stellar/soroban-examples.git"
steps:
- uses: actions/checkout@v3
name: checkout system-test
with:
repository: stellar/system-test
ref: ${{ env.SYSTEM_TEST_GIT_REF }}
path: system-test
- uses: actions/checkout@v3
name: checkout soroban-tools
with:
path: soroban-tools
- if: ${{ env.SYSTEM_TEST_JS_SOROBAN_CLIENT_GH_REPO }}
name: prepare local js-soroban-client
run: |
rm -rf $GITHUB_WORKSPACE/system-test/js-soroban-client;
- if: ${{ env.SYSTEM_TEST_JS_SOROBAN_CLIENT_GH_REPO }}
uses: actions/checkout@v3
with:
repository: ${{ env.SYSTEM_TEST_JS_SOROBAN_CLIENT_GH_REPO }}
ref: ${{ env.SYSTEM_TEST_JS_SOROBAN_CLIENT_GH_REF }}
path: system-test/js-soroban-client
- uses: stellar/actions/rust-cache@main
- name: Build system test with component versions
run: |
cd $GITHUB_WORKSPACE/system-test; \
cd $GITHUB_WORKSPACE/system-test
if [ -z "$SYSTEM_TEST_JS_SOROBAN_CLIENT_GH_REPO" ]; then \
JS_SOROBAN_CLIENT_REF="$SYSTEM_TEST_JS_SOROBAN_CLIENT_NPM_VERSION"; \
else \
JS_SOROBAN_CLIENT_REF="file:/home/tester/js-soroban-client"; \
fi
make \
CORE_GIT_REF=$SYSTEM_TEST_CORE_GIT_REF \
CORE_COMPILE_CONFIGURE_FLAGS="$SYSTEM_TEST_CORE_COMPILE_CONFIGURE_FLAGS" \
CORE_IMAGE=$SYSTEM_TEST_CORE_IMAGE \
SOROBAN_RPC_GIT_REF=$SYSTEM_TEST_SOROBAN_TOOLS_REF \
SOROBAN_CLI_GIT_REF=$SYSTEM_TEST_SOROBAN_TOOLS_REF \
RUST_TOOLCHAIN_VERSION=$SYSTEM_TEST_RUST_TOOLCHAIN_VERSION \
QUICKSTART_GIT_REF=$SYSTEM_TEST_QUICKSTART_GIT_REF \
JS_SOROBAN_CLIENT_NPM_VERSION=$SYSTEM_TEST_JS_SOROBAN_CLIENT_NPM_VERSION \
build
CORE_GIT_REF=$SYSTEM_TEST_CORE_GIT_REF \
CORE_COMPILE_CONFIGURE_FLAGS="$SYSTEM_TEST_CORE_COMPILE_CONFIGURE_FLAGS" \
CORE_IMAGE=$SYSTEM_TEST_CORE_IMAGE \
SOROBAN_RPC_GIT_REF=$SYSTEM_TEST_SOROBAN_TOOLS_REF \
SOROBAN_CLI_GIT_REF=$SYSTEM_TEST_SOROBAN_TOOLS_REF \
RUST_TOOLCHAIN_VERSION=$SYSTEM_TEST_RUST_TOOLCHAIN_VERSION \
QUICKSTART_GIT_REF=$SYSTEM_TEST_QUICKSTART_GIT_REF \
JS_SOROBAN_CLIENT_NPM_VERSION=$JS_SOROBAN_CLIENT_REF \
build
- name: Run system test scenarios
run: |
docker run --rm -t --name e2e_test stellar/system-test:dev \
--VerboseOutput $SYSTEM_TEST_VERBOSE_OUTPUT \
--TestFilter "${{ matrix.scenario-filter }}" \
--SorobanExamplesGitHash $SYSTEM_TEST_SOROBAN_EXAMPLES_GIT_HASH
--SorobanExamplesGitHash $SYSTEM_TEST_SOROBAN_EXAMPLES_GIT_HASH \
--SorobanExamplesRepoURL $SYSTEM_TEST_SOROBAN_EXAMPLES_GIT_REPO
76 changes: 62 additions & 14 deletions cmd/soroban-cli/src/rpc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ pub enum Error {
Spec(#[from] soroban_spec::read::FromWasmError),
#[error(transparent)]
SpecBase64(#[from] soroban_spec::read::ParseSpecBase64Error),
#[error("Fee was too large {0}")]
LargeFee(u64),
}

#[derive(serde::Deserialize, serde::Serialize, Debug)]
Expand Down Expand Up @@ -178,18 +180,18 @@ pub struct GetLatestLedgerResponse {
pub sequence: u32,
}

#[derive(serde::Deserialize, serde::Serialize, Debug)]
#[derive(serde::Deserialize, serde::Serialize, Debug, Default)]
pub struct Cost {
#[serde(
rename = "cpuInsns",
deserialize_with = "deserialize_number_from_string"
)]
pub cpu_insns: String,
pub cpu_insns: u64,
#[serde(
rename = "memBytes",
deserialize_with = "deserialize_number_from_string"
)]
pub mem_bytes: String,
pub mem_bytes: u64,
}

#[derive(serde::Deserialize, serde::Serialize, Debug)]
Expand All @@ -199,27 +201,50 @@ pub struct SimulateHostFunctionResult {
pub xdr: String,
}

#[derive(serde::Deserialize, serde::Serialize, Debug)]
#[derive(serde::Deserialize, serde::Serialize, Debug, Default)]
pub struct SimulateTransactionResponse {
#[serde(skip_serializing_if = "Option::is_none", default)]
pub error: Option<String>,
#[serde(rename = "transactionData")]
pub transaction_data: String,
#[serde(deserialize_with = "deserialize_default_from_null")]
pub events: Vec<String>,
#[serde(
rename = "minResourceFee",
deserialize_with = "deserialize_number_from_string"
deserialize_with = "deserialize_number_from_string",
default
)]
pub min_resource_fee: u32,
pub min_resource_fee: u64,
#[serde(default)]
pub cost: Cost,
#[serde(skip_serializing_if = "Vec::is_empty", default)]
pub results: Vec<SimulateHostFunctionResult>,
pub cost: Cost,
#[serde(rename = "transactionData", default)]
pub transaction_data: String,
#[serde(
deserialize_with = "deserialize_default_from_null",
skip_serializing_if = "Vec::is_empty",
default
)]
pub events: Vec<String>,
#[serde(
rename = "restorePreamble",
skip_serializing_if = "Option::is_none",
default
)]
pub restore_preamble: Option<RestorePreamble>,
#[serde(
rename = "latestLedger",
deserialize_with = "deserialize_number_from_string"
)]
pub latest_ledger: u32,
pub latest_ledger: u64,
#[serde(skip_serializing_if = "Option::is_none", default)]
pub error: Option<String>,
}

#[derive(serde::Deserialize, serde::Serialize, Debug)]
pub struct RestorePreamble {
#[serde(rename = "transactionData")]
pub transaction_data: String,
#[serde(
rename = "minResourceFee",
deserialize_with = "deserialize_number_from_string"
)]
pub min_resource_fee: u64,
}

#[derive(serde::Deserialize, serde::Serialize, Debug)]
Expand Down Expand Up @@ -850,6 +875,29 @@ pub fn parse_cursor(c: &str) -> Result<(u64, i32), Error> {
mod tests {
use super::*;

#[test]
fn simulation_transaction_response_parsing() {
let s = r#"{
"minResourceFee": "100000000",
"cost": { "cpuInsns": "1000", "memBytes": "1000" },
"transactionData": "",
"latestLedger": "1234"
}"#;

let resp: SimulateTransactionResponse = serde_json::from_str(s).unwrap();
assert_eq!(resp.min_resource_fee, 100_000_000);
}

#[test]
fn simulation_transaction_response_parsing_mostly_empty() {
let s = r#"{
"latestLedger": "1234"
}"#;

let resp: SimulateTransactionResponse = serde_json::from_str(s).unwrap();
assert_eq!(resp.latest_ledger, 1_234);
}

#[test]
fn test_rpc_url_default_ports() {
// Default ports are added.
Expand Down
42 changes: 13 additions & 29 deletions cmd/soroban-cli/src/rpc/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,11 @@ pub fn assemble(
// update the fees of the actual transaction to meet the minimum resource fees.
let classic_transaction_fees = crate::fee::Args::default().fee;
// Pad the fees up by 15% for a bit of wiggle room.
tx.fee = (tx
.fee
.max(classic_transaction_fees + simulation.min_resource_fee)
* 115)
tx.fee = (tx.fee.max(
classic_transaction_fees
+ u32::try_from(simulation.min_resource_fee)
.map_err(|_| Error::LargeFee(simulation.min_resource_fee))?,
) * 115)
/ 100;

tx.operations = vec![op].try_into()?;
Expand Down Expand Up @@ -216,7 +217,7 @@ pub fn sign_soroban_authorization_entry(
mod tests {
use super::*;

use super::super::{Cost, SimulateHostFunctionResult};
use super::super::SimulateHostFunctionResult;
use soroban_env_host::xdr::{
self, AccountId, ChangeTrustAsset, ChangeTrustOp, ExtensionPoint, Hash, HostFunction,
InvokeContractArgs, InvokeHostFunctionOp, LedgerFootprint, Memo, MuxedAccount, Operation,
Expand Down Expand Up @@ -266,19 +267,14 @@ mod tests {
};

SimulateTransactionResponse {
error: None,
transaction_data: transaction_data().to_xdr_base64().unwrap(),
events: Vec::default(),
min_resource_fee: 115,
latest_ledger: 3,
results: vec![SimulateHostFunctionResult {
auth: vec![fn_auth.to_xdr_base64().unwrap()],
xdr: ScVal::U32(0).to_xdr_base64().unwrap(),
}],
cost: Cost {
cpu_insns: "0".to_string(),
mem_bytes: "0".to_string(),
},
latest_ledger: 3,
transaction_data: transaction_data().to_xdr_base64().unwrap(),
..Default::default()
}
}

Expand Down Expand Up @@ -386,16 +382,10 @@ mod tests {
let result = assemble(
&txn,
&SimulateTransactionResponse {
error: None,
transaction_data: transaction_data().to_xdr_base64().unwrap(),
events: Vec::default(),
min_resource_fee: 115,
results: vec![],
cost: Cost {
cpu_insns: "0".to_string(),
mem_bytes: "0".to_string(),
},
transaction_data: transaction_data().to_xdr_base64().unwrap(),
latest_ledger: 3,
..Default::default()
},
);

Expand All @@ -412,16 +402,10 @@ mod tests {
let result = assemble(
&txn,
&SimulateTransactionResponse {
error: None,
transaction_data: transaction_data().to_xdr_base64().unwrap(),
events: Vec::default(),
min_resource_fee: 115,
results: vec![],
cost: Cost {
cpu_insns: "0".to_string(),
mem_bytes: "0".to_string(),
},
transaction_data: transaction_data().to_xdr_base64().unwrap(),
latest_ledger: 3,
..Default::default()
},
);

Expand Down
Loading