diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 7a82136cd..c6d452150 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -10,6 +10,9 @@ concurrency: group: ${{ github.workflow }}-${{ github.ref_protected == 'true' && github.sha || github.ref }}-{{ github.event_name }} cancel-in-progress: true +env: + ARTIFACT_RETENTION_DAYS_FOR_TEST_WASMS: 7 + defaults: run: shell: bash @@ -18,7 +21,7 @@ jobs: complete: if: always() - needs: [fmt, check-git-rev-deps, semver-checks, build-and-test, build-fuzz, docs, readme, migration-docs] + needs: [fmt, check-git-rev-deps, semver-checks, build, test, build-fuzz, docs, readme, migration-docs] runs-on: ubuntu-latest steps: - if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') @@ -57,7 +60,7 @@ jobs: steps: - uses: actions/checkout@v3 - run: rustup update - - uses: stellar/binaries@v41 + - uses: stellar/binaries@v45 with: name: cargo-semver-checks version: 0.44.0 @@ -67,7 +70,7 @@ jobs: --exclude soroban-token-spec --exclude stellar-asset-spec - build-and-test: + build: strategy: fail-fast: false matrix: @@ -75,18 +78,60 @@ jobs: sys: - os: ubuntu-latest target: x86_64-unknown-linux-gnu + - os: ubuntu-24.04-arm + target: aarch64-unknown-linux-gnu + - os: macos-15-intel + target: x86_64-apple-darwin + - os: macos-latest + target: aarch64-apple-darwin + - os: windows-latest + target: x86_64-pc-windows-msvc + runs-on: ${{ matrix.sys.os }} + steps: + - uses: actions/checkout@v3 + - uses: stellar/actions/rust-cache@main + - name: Use the minimum supported Rust version + if: matrix.rust == 'msrv' + run: | + msrv="$(cargo metadata --format-version 1 --no-deps | jq -r '.packages | map(.rust_version) | map(values) | min')" + rustup override set $msrv + rustup component add clippy rustfmt + - name: Error on warnings only for msrv + if: matrix.rust == 'msrv' + run: echo RUSTFLAGS='-Dwarnings' >> $GITHUB_ENV + - run: rustup update + - run: cargo version + - run: rustup target add ${{ matrix.sys.target }} + - run: rustup target add wasm32v1-none + - run: echo CARGO_BUILD_TARGET='${{ matrix.sys.target }}' >> $GITHUB_ENV + - uses: stellar/binaries@v45 + with: + name: cargo-hack + version: 0.5.28 + - run: make build-libs + - run: make build-test-wasms TEST_CRATES_RUSTUP_TOOLCHAIN= + - name: Upload test wasms + uses: actions/upload-artifact@v4 + with: + name: test-wasms-${{ matrix.rust }}-${{ matrix.sys.target }} + path: target/wasm32v1-none/release/test_*.wasm + retention-days: ${{ env.ARTIFACT_RETENTION_DAYS_FOR_TEST_WASMS }} + + test: + needs: build + strategy: + fail-fast: false + matrix: + rust: [msrv, latest] + sys: - os: ubuntu-latest + target: x86_64-unknown-linux-gnu + - os: ubuntu-24.04-arm target: aarch64-unknown-linux-gnu - # Fix #1011 by avoiding the use of crate-type = ["cdylib"] in native - # builds that cross-compile. It causes linker errors. The root cause - # is rust-lang/cargo#4133. This workaround uses rustc to build for a - # specific crate-type, lib, such that the Cargo.toml crate-type is - # ignored. - cdylib-cross-compile-workaround: true -# - os: macos-latest -# target: x86_64-apple-darwin -# - os: macos-latest -# target: aarch64-apple-darwin + - os: macos-15-intel + target: x86_64-apple-darwin + - os: macos-latest + target: aarch64-apple-darwin - os: windows-latest target: x86_64-pc-windows-msvc runs-on: ${{ matrix.sys.os }} @@ -98,42 +143,28 @@ jobs: run: | msrv="$(cargo metadata --format-version 1 --no-deps | jq -r '.packages | map(.rust_version) | map(values) | min')" rustup override set $msrv - rustup component add clippy --toolchain $msrv - - name: Error on warnings and clippy checks - # Only error on warnings and checks for the msrv, because new versions of - # Rust will frequently add new warnings and checks. + rustup component add clippy rustfmt + - name: Error on warnings only for msrv if: matrix.rust == 'msrv' run: echo RUSTFLAGS='-Dwarnings' >> $GITHUB_ENV - run: rustup update - run: cargo version - run: rustup target add ${{ matrix.sys.target }} - run: rustup target add wasm32v1-none - - uses: stellar/binaries@v37 + - run: echo CARGO_BUILD_TARGET='${{ matrix.sys.target }}' >> $GITHUB_ENV + - uses: stellar/binaries@v45 with: name: cargo-hack version: 0.5.28 - - if: startsWith(matrix.sys.target, 'x86_64') - name: Clear test snapshots for checking no diffs exists after test run + - name: Restore test wasms for tests from one of the msrv builds + uses: actions/download-artifact@v5 + with: + name: test-wasms-msrv-x86_64-unknown-linux-gnu + path: target/wasm32v1-none/release/ + - name: Clear test snapshots for checking no diffs exists after test run run: rm -fr **/test_snapshots - - name: Build for wasm - run: cargo-hack hack build --target wasm32v1-none --profile release --workspace --exclude soroban-meta --exclude soroban-spec --exclude soroban-spec-rust --exclude soroban-ledger-snapshot - - name: Wasm Size - run: | - cd target/wasm32v1-none/release/ && \ - for i in *.wasm ; do \ - ls -l "$i"; \ - done - - if: "!matrix.sys.cdylib-cross-compile-workaround" - name: Build for native - run: cargo-hack hack --feature-powerset --exclude-features docs build --target ${{ matrix.sys.target }} - - if: "matrix.sys.cdylib-cross-compile-workaround" - name: Build for native - run: cargo-hack hack --feature-powerset --exclude-features docs rustc --workspace --exclude soroban-sdk-macros --exclude proc_macros --crate-type lib --target ${{ matrix.sys.target }} - - if: startsWith(matrix.sys.target, 'x86_64') - name: Run tests - run: cargo-hack hack --feature-powerset --ignore-unknown-features --features testutils --exclude-features docs test --target ${{ matrix.sys.target }} - - if: startsWith(matrix.sys.target, 'x86_64') - name: Check no diffs exist + - run: make test + - name: Check no diffs exist run: git add -N . && git diff HEAD --exit-code build-fuzz: @@ -142,10 +173,10 @@ jobs: - uses: actions/checkout@v3 - uses: stellar/actions/rust-cache@main - run: rustup install nightly - - uses: stellar/binaries@v37 + - uses: stellar/binaries@v45 with: name: cargo-fuzz - version: 0.12.0 + version: 0.13.1 - run: make build-fuzz - name: Check no diffs exist run: git add -N . && git diff HEAD --exit-code diff --git a/Makefile b/Makefile index 6c6a81045..1fca66cf2 100644 --- a/Makefile +++ b/Makefile @@ -1,31 +1,38 @@ +LIB_CRATES = $(shell cargo metadata --no-deps --format-version 1 | jq -r '.packages[] | select(.name | startswith("test_") | not) | .name' | tr '\n' ' ') +TEST_CRATES = $(shell cargo metadata --no-deps --format-version 1 | jq -r '.packages[] | select(.name | startswith("test_")) | .name' | tr '\n' ' ') + +MSRV = $(shell cargo metadata --no-deps --format-version 1 | jq -r '.packages[] | select(.name == "soroban-sdk") | .rust_version') +TEST_CRATES_RUSTUP_TOOLCHAIN?=$(MSRV) + all: check test export RUSTFLAGS=-Dwarnings CARGO_DOC_ARGS?=--open -NATIVE_ONLY_CRATES:=soroban-meta soroban-spec soroban-spec-rust soroban-ledger-snapshot -NATIVE_PACKAGE_ARGS:=$(foreach i,$(NATIVE_ONLY_CRATES), --package $(i)) -WASM_EXCLUDE_ARGS:=$(foreach i,$(NATIVE_ONLY_CRATES), --exclude $(i)) doc: fmt - cargo test --doc -p soroban-sdk -p soroban-sdk-macros --features testutils,hazmat - cargo +nightly doc -p soroban-sdk --no-deps --all-features $(CARGO_DOC_ARGS) + cargo test --doc $(foreach c,$(LIB_CRATES),--package $(c)) --features testutils,alloc,hazmat + cargo +nightly doc --no-deps $(foreach c,$(LIB_CRATES),--package $(c)) --all-features $(CARGO_DOC_ARGS) -test: fmt build +test: fmt build-test-wasms cargo hack --feature-powerset --ignore-unknown-features --features testutils --exclude-features docs test -build: fmt - cargo hack build --release $(NATIVE_PACKAGE_ARGS) - cargo hack build --target wasm32v1-none --release --workspace $(WASM_EXCLUDE_ARGS) +build: build-libs build-test-wasms + +build-libs: fmt + cargo hack build --release $(foreach c,$(LIB_CRATES),--package $(c)) + +build-test-wasms: fmt + # Build the test wasms with MSRV by default, with some meta disabled for + # binary stability for tests. + RUSTUP_TOOLCHAIN=$(TEST_CRATES_RUSTUP_TOOLCHAIN) \ + RUSTFLAGS='--cfg soroban_sdk_internal_no_rssdkver_meta' \ + cargo hack build --release --target wasm32v1-none $(foreach c,$(TEST_CRATES),--package $(c)) ; \ cd target/wasm32v1-none/release/ && \ for i in *.wasm ; do \ ls -l "$$i"; \ done -check: build fmt - cargo hack --feature-powerset --exclude-features docs check - cargo hack check --release --target wasm32v1-none --workspace $(WASM_EXCLUDE_ARGS) - build-fuzz: cd tests/fuzz/fuzz && cargo +nightly fuzz check diff --git a/soroban-meta/src/tests.rs b/soroban-meta/src/tests.rs index fa66d992e..15053f0c9 100644 --- a/soroban-meta/src/tests.rs +++ b/soroban-meta/src/tests.rs @@ -12,7 +12,7 @@ fn test_from_wasm() { ScMetaEntry::ScMetaV0(v0) => v0.key.to_string(), }) .collect::>(); - assert_eq!(keys, ["rsver", "rssdkver"]); + assert_eq!(keys, ["rsver"]); } #[test] @@ -58,5 +58,5 @@ fn test_multiple_metadata_sections() { ScMetaEntry::ScMetaV0(v0) => v0.key.to_string(), }) .collect::>(); - assert_eq!(keys, ["rsver", "rssdkver", "mykey"]); + assert_eq!(keys, ["rsver", "mykey"]); } diff --git a/soroban-sdk/build.rs b/soroban-sdk/build.rs index cb933a8ba..7d003ee81 100644 --- a/soroban-sdk/build.rs +++ b/soroban-sdk/build.rs @@ -1,4 +1,10 @@ pub fn main() { + // Inform the compiler that the soroban_sdk_internal_no_rssdkver_meta cfg is valid. + // The cfg is used when building the test vectors in this repository, to disable the embedding + // of the rssdkver meta to increase the stability of the build wasms and therefore their wasm + // hash. + println!("cargo::rustc-check-cfg=cfg(soroban_sdk_internal_no_rssdkver_meta)"); + #[cfg(all(target_family = "wasm", target_os = "unknown"))] if let Ok(version) = rustc_version::version() { if version.major == 1 && version.minor >= 82 { diff --git a/soroban-sdk/src/lib.rs b/soroban-sdk/src/lib.rs index cd160c201..741e56931 100644 --- a/soroban-sdk/src/lib.rs +++ b/soroban-sdk/src/lib.rs @@ -103,7 +103,12 @@ const _: () = { // Rustc version. contractmeta!(key = "rsver", val = env!("RUSTC_VERSION"),); - // Rust Soroban SDK version. + // Rust Soroban SDK version. Don't emit when the cfg is set. The cfg is set when building test + // wasms in this repository, so that every commit in this repo does not cause the test wasms in + // this repo to have a new hash due to the revision being embedded. The wasm hash gets embedded + // into a few places, such as test snapshots, or get used in test themselves where if they are + // constantly changing creates repetitive diffs. + #[cfg(not(soroban_sdk_internal_no_rssdkver_meta))] contractmeta!( key = "rssdkver", val = concat!(env!("CARGO_PKG_VERSION"), "#", env!("GIT_REVISION")), diff --git a/soroban-sdk/src/tests/address.rs b/soroban-sdk/src/tests/address.rs index 7336639c7..c7ac3db60 100644 --- a/soroban-sdk/src/tests/address.rs +++ b/soroban-sdk/src/tests/address.rs @@ -1,8 +1,8 @@ use crate::{self as soroban_sdk}; use sha2::{Digest, Sha256}; use soroban_sdk::{ - address::Executable, contract, env::EnvTestConfig, testutils::Address as _, Address, Bytes, - BytesN, Env, String, TryIntoVal, + address::Executable, contract, testutils::Address as _, Address, Bytes, BytesN, Env, String, + TryIntoVal, }; #[contract] @@ -86,12 +86,7 @@ fn test_get_existing_contract_address_executable_wasm() { const EXAMPLE_WASM: &[u8] = include_bytes!("../../../target/wasm32v1-none/release/test_udt.wasm"); - let env = Env::new_with_config(EnvTestConfig { - // Disable test snapshots because the tests in this repo will run across - // multiple hosts, and this test uses a wasm file that won't build consistently - // across different hosts. - capture_snapshot_at_drop: false, - }); + let env = Env::default(); let contract_address = env.register(EXAMPLE_WASM, ()); let contract_executable = contract_address.executable(); diff --git a/soroban-sdk/src/tests/crypto_bls12_381.rs b/soroban-sdk/src/tests/crypto_bls12_381.rs index f136ecea0..8a3b09d32 100644 --- a/soroban-sdk/src/tests/crypto_bls12_381.rs +++ b/soroban-sdk/src/tests/crypto_bls12_381.rs @@ -2,7 +2,6 @@ use crate::{self as soroban_sdk}; use soroban_sdk::{ bytes, bytesn, contract, contractimpl, crypto::bls12_381::{Bls12_381, Fp, Fp2, Fr, G1Affine, G2Affine}, - env::EnvTestConfig, vec, Address, Bytes, BytesN, Env, Vec, U256, }; @@ -254,12 +253,7 @@ impl Contract { #[test] fn test_invoke_contract() { - let e = Env::new_with_config(EnvTestConfig { - // Disable test snapshots because the tests in this repo will run across - // multiple hosts, and this test uses a wasm file that won't build consistently - // across different hosts. - capture_snapshot_at_drop: false, - }); + let e = Env::default(); let bls_contract_id = e.register(blscontract::WASM, ()); diff --git a/soroban-sdk/test_snapshots/tests/address/test_get_existing_contract_address_executable_wasm.1.json b/soroban-sdk/test_snapshots/tests/address/test_get_existing_contract_address_executable_wasm.1.json new file mode 100644 index 000000000..94ac5f14a --- /dev/null +++ b/soroban-sdk/test_snapshots/tests/address/test_get_existing_contract_address_executable_wasm.1.json @@ -0,0 +1,124 @@ +{ + "generators": { + "address": 1, + "nonce": 0, + "mux_id": 0 + }, + "auth": [], + "ledger": { + "protocol_version": 23, + "sequence_number": 0, + "timestamp": 0, + "network_id": "0000000000000000000000000000000000000000000000000000000000000000", + "base_reserve": 0, + "min_persistent_entry_ttl": 4096, + "min_temp_entry_ttl": 16, + "max_entry_ttl": 6312000, + "ledger_entries": [ + [ + { + "contract_data": { + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "ledger_key_nonce": { + "nonce": "801925984706572462" + } + }, + "durability": "temporary" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "ledger_key_nonce": { + "nonce": "801925984706572462" + } + }, + "durability": "temporary", + "val": "void" + } + }, + "ext": "v0" + }, + 6311999 + ] + ], + [ + { + "contract_data": { + "contract": "CBKMUZNFQIAL775XBB2W2GP5CNHBM5YGH6C3XB7AY6SUVO2IBU3VYK2V", + "key": "ledger_key_contract_instance", + "durability": "persistent" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CBKMUZNFQIAL775XBB2W2GP5CNHBM5YGH6C3XB7AY6SUVO2IBU3VYK2V", + "key": "ledger_key_contract_instance", + "durability": "persistent", + "val": { + "contract_instance": { + "executable": { + "wasm": "14946e6baa1c4606f0bc4fbbde0640071e698393f220e0b7e437337dad0ed994" + }, + "storage": null + } + } + } + }, + "ext": "v0" + }, + 4095 + ] + ], + [ + { + "contract_code": { + "hash": "14946e6baa1c4606f0bc4fbbde0640071e698393f220e0b7e437337dad0ed994" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_code": { + "ext": { + "v1": { + "ext": "v0", + "cost_inputs": { + "ext": "v0", + "n_instructions": 838, + "n_functions": 9, + "n_globals": 4, + "n_table_entries": 0, + "n_types": 9, + "n_data_segments": 1, + "n_elem_segments": 0, + "n_imports": 7, + "n_exports": 5, + "n_data_segment_bytes": 76 + } + } + }, + "hash": "14946e6baa1c4606f0bc4fbbde0640071e698393f220e0b7e437337dad0ed994", + "code": "0061736d0100000001320960017e017e60037e7e7e017e60047e7e7e7e017e60027e7e017e60027f7e0060027f7f0060027f7f017f60000060017f00022b070176013300000162016d0001016d01610002017601680001016901320000017601310003016901310000030a0904050604050703080705030100110621047f01418080c0000b7f0041cc80c0000b7f0041cc80c0000b7f0041d080c0000b072f05066d656d6f7279020003616464000d015f03010a5f5f646174615f656e6403020b5f5f686561705f6261736503030aa80e09d00604017f017e027f017e23808080800041c0006b220224808080800002400240024002400240200142ff018342cb00520d00200110808080800021032002410036021020022001370308200220034220883e0214200241186a200241086a1088808080000240200229031822014202510d002001a74101710d00024020022903202201a741ff0171220441ca00460d002004410e470d010b02400240024002402001419080c08000ad4220864204844284808080c000108180808000422088a70e0400010203060b200228021020022802141089808080000d05410021050c060b2002280210200228021410898080800041014b0d04200241186a200241086a108880808000200229031822014202510d042001a74101710d0420022903202101410021040240034020044118460d01200241186a20046a4202370300200441086a21040c000b0b200142ff018342cc00520d04200141b480c08000ad422086420484200241186aad4220864204844284808080301082808080001a200241306a2002290318108a8080800020022802300d0420022903382103200241306a2002290320108a8080800020022802300d042002290328220642ff018342cb00520d0420022903382101410121050c050b2002280210200228021410898080800041014b0d03200241186a200241086a108880808000200229031822014202510d032001a74101710d032002290320220142ff01834204520d03410a410f41092001422088a72204410f461b2004410a461b22044109460d03410221050c050b2002280210200228021410898080800041014b0d02200241186a200241086a108880808000200229031822014202510d022001a74101710d022002290320220142ff018342cb00520d02410021040240034020044110460d01200241306a20046a4202370300200441086a21040c000b0b2001200241306aad4220864204844284808080201083808080001a200241186a2002290330108a8080800020022802180d022002290338220142ff018342cb00520d0220022903202103410321050c030b200041043a00000c040b200041043a00000c030b200041043a00000c020b0b200020063703182000200137031020002003370308200020043a0001200020053a00000b200241c0006a2480808080000b4a02017e017f42022102024020012802082203200128020c4f0d00200020012903002003ad4220864204841085808080003703082001200341016a360208420021020b200020023703000b1900024020012000490d00200120006b0f0b108c80808000000b5d02017f017e024002402001a741ff0171220241c100460d00024020024107460d00420121034283908080800121010c020b20014208872101420021030c010b42002103200110848080800021010b20002003370300200020013703080b910102027f017e23808080800041106b22022480808080000240024020012802082203200128020c490d00200042023703000c010b200220012903002003ad422086420484108580808000108a808080000240200341016a2203450d00200229030021042000200229030837030820002004370300200120033602080c010b108c80808000000b200241106a2480808080000b0900108f80808000000be50404027f027e017f057e23808080800041c0006b2202248080808000200241086a2000108780808000024002400240024020022d000822034104460d00200229031821002002290310210420023100092105200241086a200110878080800020022d000822064104460d002002290318210720022903102108200231000921094200210a4200210b024002400240024020030e0406020100060b200010808080800021012002410036023020022000370328200220014220883e0234420021000340200241086a200241286a108b80808000200229030822014202510d032001a74101710d0520022903102201420053200020017c2201200053470d07200121000c000b0b2005210b0c040b2000420053200420007c220b20045373450d030c040b2000420053200420007c220b20045373450d020c030b000b200241386a108e80808000000b02400240024002400240024020060e0405020100050b200710808080800021002002410036023020022007370328200220004220883e0234420021000340200241086a200241286a108b80808000200229030822014202510d032001a74101710d0420022903102201420053200020017c2201200053470d06200121000c000b0b2009210a0c030b2007420053200820077c220a200853730d030c020b2000420053200820007c220a200853730d020c010b200241386a108e80808000000b200a420053200b200a7c2200200b53730d000240024020004280808080808080c0007c42ffffffffffffffff00560d00200042088642078421000c010b200010868080800021000b200241c0006a24808080800020000f0b108c80808000000b0900108f80808000000b0300000b0b550100418080c0000b4c556474415564744255647443556474440000100004000000040010000400000008001000040000000c001000040000006162630030001000010000003100100001000000320010000100000000cf030e636f6e747261637473706563763000000003000000000000000000000008556474456e756d32000000020000000000000001410000000000000a0000000000000001420000000000000f00000002000000000000000000000007556474456e756d0000000004000000000000000000000004556474410000000100000000000000045564744200000001000007d0000000095564745374727563740000000000000100000000000000045564744300000001000007d000000008556474456e756d320000000100000000000000045564744400000001000007d0000000085564745475706c65000000010000000000000000000000085564745475706c650000000200000000000000013000000000000007000000000000000131000000000003ea0000000700000001000000000000000000000009556474537472756374000000000000030000000000000001610000000000000700000000000000016200000000000007000000000000000163000000000003ea000000070000000000000000000000036164640000000002000000000000000161000000000007d000000007556474456e756d00000000000000000162000000000007d000000007556474456e756d000000000100000007001e11636f6e7472616374656e766d6574617630000000000000001700000000002b0e636f6e74726163746d65746176300000000000000005727376657200000000000006312e38342e300000" + } + }, + "ext": "v0" + }, + 4095 + ] + ] + ] + }, + "events": [] +} \ No newline at end of file diff --git a/soroban-sdk/test_snapshots/tests/crypto_bls12_381/test_invoke_contract.1.json b/soroban-sdk/test_snapshots/tests/crypto_bls12_381/test_invoke_contract.1.json new file mode 100644 index 000000000..79ce1aa3c --- /dev/null +++ b/soroban-sdk/test_snapshots/tests/crypto_bls12_381/test_invoke_contract.1.json @@ -0,0 +1,181 @@ +{ + "generators": { + "address": 2, + "nonce": 0, + "mux_id": 0 + }, + "auth": [ + [], + [], + [] + ], + "ledger": { + "protocol_version": 23, + "sequence_number": 0, + "timestamp": 0, + "network_id": "0000000000000000000000000000000000000000000000000000000000000000", + "base_reserve": 0, + "min_persistent_entry_ttl": 4096, + "min_temp_entry_ttl": 16, + "max_entry_ttl": 6312000, + "ledger_entries": [ + [ + { + "contract_data": { + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "ledger_key_nonce": { + "nonce": "801925984706572462" + } + }, + "durability": "temporary" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "ledger_key_nonce": { + "nonce": "801925984706572462" + } + }, + "durability": "temporary", + "val": "void" + } + }, + "ext": "v0" + }, + 6311999 + ] + ], + [ + { + "contract_data": { + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + "key": "ledger_key_contract_instance", + "durability": "persistent" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + "key": "ledger_key_contract_instance", + "durability": "persistent", + "val": { + "contract_instance": { + "executable": { + "wasm": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "storage": null + } + } + } + }, + "ext": "v0" + }, + 4095 + ] + ], + [ + { + "contract_data": { + "contract": "CBKMUZNFQIAL775XBB2W2GP5CNHBM5YGH6C3XB7AY6SUVO2IBU3VYK2V", + "key": "ledger_key_contract_instance", + "durability": "persistent" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CBKMUZNFQIAL775XBB2W2GP5CNHBM5YGH6C3XB7AY6SUVO2IBU3VYK2V", + "key": "ledger_key_contract_instance", + "durability": "persistent", + "val": { + "contract_instance": { + "executable": { + "wasm": "a654fd691c9395f5480486e18ebc75f56d7021e109c242b10ad5aa4bbd9a040c" + }, + "storage": null + } + } + } + }, + "ext": "v0" + }, + 4095 + ] + ], + [ + { + "contract_code": { + "hash": "a654fd691c9395f5480486e18ebc75f56d7021e109c242b10ad5aa4bbd9a040c" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_code": { + "ext": { + "v1": { + "ext": "v0", + "cost_inputs": { + "ext": "v0", + "n_instructions": 379, + "n_functions": 7, + "n_globals": 4, + "n_table_entries": 0, + "n_types": 5, + "n_data_segments": 1, + "n_elem_segments": 0, + "n_imports": 10, + "n_exports": 7, + "n_data_segment_bytes": 52 + } + } + }, + "hash": "a654fd691c9395f5480486e18ebc75f56d7021e109c242b10ad5aa4bbd9a040c", + "code": "0061736d01000000011e0560027e7e017e60047e7e7e7e017e60017e017e60027f7e0060017f017e023d0a016301360000016301630000016d016100010162013800020163013800020163013400020163016500020163016100020163016700000176016700000308070003000302030405030100110621047f01418080c0000b7f0041b480c0000b7f0041b480c0000b7f0041c080c0000b074a07066d656d6f727902000667315f6d756c000a0667325f6d756c000c0c64756d6d795f766572696679000e015f03010a5f5f646174615f656e6403020b5f5f686561705f6261736503030a9807076701027f23808080800041106b220224808080800020022000108b80808000024020022802004101460d002002290308210002402001a741ff01712203410c460d00200341c600470d010b200020011080808080002101200241106a24808080800020010f0b000b4d01017f23808080800041106b220224808080800020022001108f8080800042012101024020022802000d0020002002290308370308420021010b20002001370300200241106a2480808080000b6701027f23808080800041106b220224808080800020022000108d80808000024020022802004101460d002002290308210002402001a741ff01712203410c460d00200341c600470d010b200020011081808080002101200241106a24808080800020010f0b000b4201017e420121020240200142ff018342c800520d0020011083808080004280808080708342808080808018520d0020002001370308420021020b200020023703000bd90303027f047e017f23808080800041c0006b2201248080808000410021020240034020024128460d01200141086a20026a4202370300200241086a21020c000b0b0240200042ff018342cc00520d002000418c80c08000ad422086420484200141086aad4220864204844284808080d0001082808080001a2001290308220042ff018342c800520d0020001083808080004280808080708342808080808006520d00200141306a2001290310108f8080800020012802300d0020012903382103024020012903182204a741ff01712202410c460d00200241c600470d010b200141306a2001290320108b8080800020012802300d0020012903382105200141306a2001290328108d8080800020012802300d002001290338210620001084808080001085808080001a20031086808080001087808080001a200520041080808080002103200620041081808080002104420221004101210203402000210520024101712107410021022003210020070d000b20012005370308200141086a1090808080002105420221004101210203402000210320024101712107410021022004210020070d000b200120033703082005200141086a1090808080001088808080002100200141c0006a2480808080002000420151ad0f0b000b4201017e420121020240200142ff018342c800520d002001108380808000428080808070834280808080800c520d0020002001370308420021020b200020023703000b17002000ad4220864204844284808080101089808080000b0b3d0100418080c0000b346670667032667267316732000000100002000000020010000300000005001000020000000700100002000000090010000200000000e7020e636f6e74726163747370656376300000000100000000000000000000000a44756d6d7950726f6f66000000000005000000000000000266700000000003ee00000030000000000000000366703200000003ee000000600000000000000002667200000000000c000000000000000267310000000003ee00000060000000000000000267320000000003ee000000c000000000000000000000000667315f6d756c000000000002000000000000000170000000000003ee000000600000000000000001730000000000000c00000001000003ee0000006000000000000000000000000667325f6d756c000000000002000000000000000170000000000003ee000000c00000000000000001730000000000000c00000001000003ee000000c000000000000000000000000c64756d6d795f76657269667900000001000000000000000570726f6f66000000000007d00000000a44756d6d7950726f6f6600000000000100000001001e11636f6e7472616374656e766d6574617630000000000000001700000000002b0e636f6e74726163746d65746176300000000000000005727376657200000000000006312e38342e300000" + } + }, + "ext": "v0" + }, + 4095 + ] + ], + [ + { + "contract_code": { + "hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_code": { + "ext": "v0", + "hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "code": "" + } + }, + "ext": "v0" + }, + 4095 + ] + ] + ] + }, + "events": [] +} \ No newline at end of file diff --git a/tests/alloc/src/test.rs b/tests/alloc/src/test.rs index 52177afbe..12ea65aaf 100644 --- a/tests/alloc/src/test.rs +++ b/tests/alloc/src/test.rs @@ -1,5 +1,5 @@ #![cfg(test)] -use soroban_sdk::{testutils::EnvTestConfig, vec, Env}; +use soroban_sdk::{vec, Env}; use crate::{Contract, ContractClient}; @@ -14,12 +14,7 @@ macro_rules! tests { #[test] fn test() { - let e = Env::new_with_config(EnvTestConfig { - // Disable test snapshots because the tests in this repo will run across - // multiple hosts, and this test uses a wasm file that won't build consistently - // across different hosts. - capture_snapshot_at_drop: false, - }); + let e = Env::default(); let contract_id = e.register($contract, ()); let client = ContractClient::new(&e, &contract_id); diff --git a/tests/alloc/test_snapshots/test/native/test.1.json b/tests/alloc/test_snapshots/test/native/test.1.json new file mode 100644 index 000000000..6a19fbf66 --- /dev/null +++ b/tests/alloc/test_snapshots/test/native/test.1.json @@ -0,0 +1,77 @@ +{ + "generators": { + "address": 1, + "nonce": 0, + "mux_id": 0 + }, + "auth": [ + [], + [] + ], + "ledger": { + "protocol_version": 23, + "sequence_number": 0, + "timestamp": 0, + "network_id": "0000000000000000000000000000000000000000000000000000000000000000", + "base_reserve": 0, + "min_persistent_entry_ttl": 4096, + "min_temp_entry_ttl": 16, + "max_entry_ttl": 6312000, + "ledger_entries": [ + [ + { + "contract_data": { + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent", + "val": { + "contract_instance": { + "executable": { + "wasm": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "storage": null + } + } + } + }, + "ext": "v0" + }, + 4095 + ] + ], + [ + { + "contract_code": { + "hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_code": { + "ext": "v0", + "hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "code": "" + } + }, + "ext": "v0" + }, + 4095 + ] + ] + ] + }, + "events": [] +} \ No newline at end of file diff --git a/tests/alloc/test_snapshots/test/wasm/test.1.json b/tests/alloc/test_snapshots/test/wasm/test.1.json new file mode 100644 index 000000000..119486814 --- /dev/null +++ b/tests/alloc/test_snapshots/test/wasm/test.1.json @@ -0,0 +1,126 @@ +{ + "generators": { + "address": 1, + "nonce": 0, + "mux_id": 0 + }, + "auth": [ + [] + ], + "ledger": { + "protocol_version": 23, + "sequence_number": 0, + "timestamp": 0, + "network_id": "0000000000000000000000000000000000000000000000000000000000000000", + "base_reserve": 0, + "min_persistent_entry_ttl": 4096, + "min_temp_entry_ttl": 16, + "max_entry_ttl": 6312000, + "ledger_entries": [ + [ + { + "contract_data": { + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "ledger_key_nonce": { + "nonce": "801925984706572462" + } + }, + "durability": "temporary" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "ledger_key_nonce": { + "nonce": "801925984706572462" + } + }, + "durability": "temporary", + "val": "void" + } + }, + "ext": "v0" + }, + 6311999 + ] + ], + [ + { + "contract_data": { + "contract": "CBKMUZNFQIAL775XBB2W2GP5CNHBM5YGH6C3XB7AY6SUVO2IBU3VYK2V", + "key": "ledger_key_contract_instance", + "durability": "persistent" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CBKMUZNFQIAL775XBB2W2GP5CNHBM5YGH6C3XB7AY6SUVO2IBU3VYK2V", + "key": "ledger_key_contract_instance", + "durability": "persistent", + "val": { + "contract_instance": { + "executable": { + "wasm": "fa62607adbe4d9123fca96fcea8cd6203653f5020029d201f1d747cb468c40db" + }, + "storage": null + } + } + } + }, + "ext": "v0" + }, + 4095 + ] + ], + [ + { + "contract_code": { + "hash": "fa62607adbe4d9123fca96fcea8cd6203653f5020029d201f1d747cb468c40db" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_code": { + "ext": { + "v1": { + "ext": "v0", + "cost_inputs": { + "ext": "v0", + "n_instructions": 873, + "n_functions": 15, + "n_globals": 4, + "n_table_entries": 0, + "n_types": 9, + "n_data_segments": 1, + "n_elem_segments": 0, + "n_imports": 2, + "n_exports": 5, + "n_data_segment_bytes": 0 + } + } + }, + "hash": "fa62607adbe4d9123fca96fcea8cd6203653f5020029d201f1d747cb468c40db", + "code": "0061736d01000000012e096000017e60027e7e017e60027f7f0060000060017f017f60037f7f7f0060017f0060017e017e60037f7f7f017f020d020176015f000001760136000103100f02030403050602070606030603030805030100110621047f01418080c0000b7f00418080c0000b7f00418c80c0000b7f00419080c0000b073405066d656d6f72790200086e756d5f6c6973740009015f03010a5f5f646174615f656e6403020b5f5f686561705f6261736503030ad80e0f850101027f0240024020010d00410421020c010b41002d008080c080001a1083808080000240410028028480c08000220241036a22032002490d0002402003417c71220220016a2203410028028880c080004d0d00200110848080800021020c020b4100200336028480c080000c010b108580808000000b20002001360204200020023602000b4301017f02400240410028028880c080000d003f00220041ffff034b0d0141002000411074220036028880c080004100200036028480c080000b0f0b108580808000000b910101047f200041ffff036a22014180807c7121022001411076210302400240034020034000417f460d014100410028028880c0800020026a36028880c08000108380808000410028028480c08000220141036a22042001490d022004417c71220120006a2204410028028880c080004b0d000b4100200436028480c0800020010f0b108f80808000000b108580808000000b0900108e80808000000b940201047f23808080800041106b22032480808080000240024002402002280204450d000240200228020822040d00200341086a2001108280808000200328020c2104200328020821020c020b20022802002105108380808000410028028480c08000220241036a22062002490d02024002402006417c71220220016a2206410028028880c080004d0d00200110848080800021020c010b4100200636028480c080000b0240024020020d00410021020c010b2002200520041090808080001a0b200121040c010b2003200110828080800020032802042104200328020021020b20002002410420021b360204200020024536020020002004200120021b360208200341106a2480808080000f0b108580808000000bec0101067f23808080800041206b220124808080800041002102024002400240024020002802002203417f460d002003410174200341016a200341004a1b220441ffffffff034d0d010b0c010b20044104200441044b1b2205410274220441fcffffff074b0d000240024020030d00410021030c010b2001200341027436021c20012000280204360214410421030b20012003360218200141086a2004200141146a10868080800020012802084101470d0120012802102106200128020c21020b20022006108880808000000b200128020c21032000200536020020002003360204200141206a2480808080000b1900024020000d00108c80808000000b2001108d80808000000bee0101067f23808080800041106b220124808080800002400240200042ff01834204520d002000422088a72102410021032001410036020c20014280808080c00037020441012104410421054100210602400340200620024f0d0102402004417f6a2001280204470d00200141046a108780808000200128020821050b200520036a2006360200200341046a21032001200436020c200441016a2104200620062002496a21060c000b0b108080808000210003402003450d022003417c6a2103200020053502004220864204841081808080002100200541046a21050c000b0b000b200141106a24808080800020000b0b002000108b80808000000b0900108e80808000000b0900108e80808000000b0b002000108a80808000000b0300000b0900108580808000000ba50501087f02400240200241104f0d00200021030c010b02402000410020006b41037122046a220520004d0d002004417f6a2106200021032001210702402004450d002004210820002103200121070340200320072d00003a0000200741016a2107200341016a21032008417f6a22080d000b0b20064107490d000340200320072d00003a0000200341016a200741016a2d00003a0000200341026a200741026a2d00003a0000200341036a200741036a2d00003a0000200341046a200741046a2d00003a0000200341056a200741056a2d00003a0000200341066a200741066a2d00003a0000200341076a200741076a2d00003a0000200741086a2107200341086a22032005470d000b0b2005200220046b2208417c7122066a210302400240200120046a22074103710d00200520034f0d0120072101034020052001280200360200200141046a2101200541046a22052003490d000c020b0b200520034f0d002007410374220241187121042007417c71220941046a2101410020026b411871210a2009280200210203402005200220047620012802002202200a7472360200200141046a2101200541046a22052003490d000b0b20084103712102200720066a21010b02402003200320026a22054f0d002002417f6a2108024020024107712207450d000340200320012d00003a0000200141016a2101200341016a21032007417f6a22070d000b0b20084107490d000340200320012d00003a0000200341016a200141016a2d00003a0000200341026a200141026a2d00003a0000200341036a200141036a2d00003a0000200341046a200141046a2d00003a0000200341056a200141056a2d00003a0000200341066a200141066a2d00003a0000200341076a200141076a2d00003a0000200141086a2101200341086a22032005470d000b0b20000b0b090100418080c0000b0000470e636f6e74726163747370656376300000000000000000000000086e756d5f6c697374000000010000000000000005636f756e740000000000000400000001000003ea00000004001e11636f6e7472616374656e766d6574617630000000000000001700000000002b0e636f6e74726163746d65746176300000000000000005727376657200000000000006312e38342e300000" + } + }, + "ext": "v0" + }, + 4095 + ] + ] + ] + }, + "events": [] +} \ No newline at end of file diff --git a/tests/fuzz/Cargo.toml b/tests/fuzz/Cargo.toml index bf7b00090..10680981c 100644 --- a/tests/fuzz/Cargo.toml +++ b/tests/fuzz/Cargo.toml @@ -15,9 +15,6 @@ rust-version.workspace = true crate-type = ["cdylib", "rlib"] doctest = false -[features] -testutils = ["soroban-sdk/testutils"] - [dependencies] soroban-sdk = {path = "../../soroban-sdk"} diff --git a/tests/fuzz/fuzz/Cargo.toml b/tests/fuzz/fuzz/Cargo.toml index ab7af11e3..b911295c1 100644 --- a/tests/fuzz/fuzz/Cargo.toml +++ b/tests/fuzz/fuzz/Cargo.toml @@ -10,7 +10,7 @@ cargo-fuzz = true [dependencies] libfuzzer-sys = "0.4" soroban-sdk = { path = "../../../soroban-sdk", features = [ "testutils" ]} -test_fuzz = { path = "..", features = [ "testutils" ] } +test_fuzz = { path = ".." } # Prevent this from interfering with workspaces [workspace] diff --git a/tests/workspace_contract/Cargo.toml b/tests/workspace_contract/Cargo.toml index d9cbd13bb..de95b4278 100644 --- a/tests/workspace_contract/Cargo.toml +++ b/tests/workspace_contract/Cargo.toml @@ -17,4 +17,4 @@ test_workspace_lib = {path = "../workspace_lib"} [dev-dependencies] soroban-sdk = {path = "../../soroban-sdk", features = ["testutils"]} -test_workspace_lib = {path = "../workspace_lib", features = ["testutils"]} +test_workspace_lib = {path = "../workspace_lib"} diff --git a/tests/workspace_lib/Cargo.toml b/tests/workspace_lib/Cargo.toml index 03f0fc7f1..ad9c72bf7 100644 --- a/tests/workspace_lib/Cargo.toml +++ b/tests/workspace_lib/Cargo.toml @@ -11,9 +11,6 @@ rust-version.workspace = true crate-type = ["rlib"] doctest = false -[features] -testutils = [] - [dependencies] soroban-sdk = {path = "../../soroban-sdk"}