Skip to content

Commit

Permalink
Fix bug loading contract spec in sandbox when not deployed (#745)
Browse files Browse the repository at this point in the history
* Fix check-dependencies typos (#723)

* Add lab token id command (#693)

* Add lab token id command

* fix doc

* Keep only the strkey id

* refactoring

---------

Co-authored-by: Paul Bellamy <[email protected]>

* fix(bindings-ts): don't delete existing dirs (#733)

* fix(bindings-ts): don't delete existing dirs

- Rename `root-dir` to `output-dir` to clarify the intent
- If `output-dir` already exists, use `output-dir/contract-name` instead

* docs: update auto-generated

* Upgrade wasm-opt to 0.113 (#736)

* fix

* fix

* update

* cargo fmt

* Fix bug loading contract spec in sandbox when not deployed

* Make fmt

* No more 'set' type to test

* remove unused import

* Fix sandbox contract invoke

* Make test invoke quiet so it doesn't spit out events

* Set default state expiries in the sandbox

* Add a note about a crappy test

---------

Co-authored-by: Alfonso Acosta <[email protected]>
Co-authored-by: Vincent Amouret <[email protected]>
Co-authored-by: Chad Ostrowski <[email protected]>
Co-authored-by: Brian Anderson <[email protected]>
Co-authored-by: Tsachi Herman <[email protected]>
  • Loading branch information
6 people authored Jul 4, 2023
1 parent 81630b4 commit 910db9a
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 28 deletions.
1 change: 1 addition & 0 deletions cmd/crates/soroban-test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ impl TestEnv {
/// to be the internal `temp_dir`.
pub fn new_assert_cmd(&self, subcommand: &str) -> Command {
let mut this = Command::cargo_bin("soroban").unwrap_or_else(|_| Command::new("soroban"));
this.arg("-q");
this.arg(subcommand);
this.current_dir(&self.temp_dir);
this
Expand Down
14 changes: 0 additions & 14 deletions cmd/crates/soroban-test/tests/it/custom_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,20 +73,6 @@ fn map_help() {
.stdout(predicates::str::contains("Map<u32, bool>"));
}

#[test]
fn set() {
invoke_with_roundtrip("set", json!([0, 1]));
}

#[test]
fn set_help() {
invoke(&TestEnv::default(), "set")
.arg("--help")
.assert()
.success()
.stdout(predicates::str::contains("Set<u32>"));
}

#[test]
fn vec_() {
invoke_with_roundtrip("vec", json!([0, 1]));
Expand Down
3 changes: 3 additions & 0 deletions cmd/crates/soroban-test/tests/it/invoke_sandbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,9 @@ fn handles_kebab_case() {

#[tokio::test]
async fn fetch() {
// TODO: Currently this test fetches a live contract from futurenet. This obviously depends on
// futurenet for the test to work, which is not great. But also means that if we are upgrading
// the XDR ahead of a futurenet upgrade, this test will pass. Oof. :(
let e = TestEnv::default();
let f = e.dir().join("contract.wasm");
let cmd = e.cmd_arr::<fetch::Cmd>(&[
Expand Down
24 changes: 12 additions & 12 deletions cmd/soroban-cli/src/commands/contract/invoke.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ use soroban_env_host::{
events::HostEvent,
storage::Storage,
xdr::{
self, AccountId, Error as XdrError, HostFunction, InvokeHostFunctionOp, LedgerEntryData,
LedgerFootprint, LedgerKey, LedgerKeyAccount, Memo, MuxedAccount, Operation, OperationBody,
Preconditions, PublicKey, ScBytes, ScSpecEntry, ScSpecFunctionV0, ScSpecTypeDef, ScVal,
ScVec, SequenceNumber, SorobanAddressCredentials, SorobanAuthorizationEntry,
SorobanCredentials, Transaction, TransactionExt, Uint256, VecM,
self, AccountId, Error as XdrError, Hash, HostFunction, InvokeHostFunctionOp,
LedgerEntryData, LedgerFootprint, LedgerKey, LedgerKeyAccount, Memo, MuxedAccount,
Operation, OperationBody, Preconditions, PublicKey, ScAddress, ScSpecEntry,
ScSpecFunctionV0, ScSpecTypeDef, ScVal, ScVec, SequenceNumber, SorobanAddressCredentials,
SorobanAuthorizationEntry, SorobanCredentials, Transaction, TransactionExt, Uint256, VecM,
},
DiagnosticLevel, Host, HostError,
};
Expand Down Expand Up @@ -211,7 +211,7 @@ impl Cmd {

// Add the contract ID and the function name to the arguments
let mut complete_args = vec![
ScVal::Bytes(ScBytes(contract_id.try_into().unwrap())),
ScVal::Address(ScAddress::Contract(Hash(contract_id))),
ScVal::Symbol(
function
.try_into()
Expand Down Expand Up @@ -322,12 +322,12 @@ impl Cmd {

let snap = Rc::new(state.clone());
let mut storage = Storage::with_recording_footprint(snap);
let spec_entries = utils::get_contract_spec_from_storage(
&mut storage,
&state.sequence_number,
contract_id,
)
.map_err(Error::CannotParseContractSpec)?;
let spec_entries = if let Some(spec) = self.spec_entries()? {
spec
} else {
utils::get_contract_spec_from_storage(&mut storage, &state.sequence_number, contract_id)
.map_err(Error::CannotParseContractSpec)?
};
let budget = Budget::default();
if self.unlimited_budget {
budget.reset_unlimited();
Expand Down
7 changes: 7 additions & 0 deletions cmd/soroban-cli/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ pub fn ledger_snapshot_read_or_default(
Err(soroban_ledger_snapshot::Error::Io(e)) if e.kind() == ErrorKind::NotFound => {
Ok(LedgerSnapshot {
network_id: sandbox_network_id(),
// These three "defaults" are not part of the actual default definition in
// rs-soroban-sdk, but if we don't have them the sandbox doesn't work right.
// Oof.
// TODO: Remove this hacky workaround.
min_persistent_entry_expiration: 4096,
min_temp_entry_expiration: 16,
max_entry_expiration: 6_312_000,
..Default::default()
})
}
Expand Down
3 changes: 1 addition & 2 deletions cmd/soroban-rpc/lib/preflight/src/fees.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@ use soroban_env_host::fees::{
};
use soroban_env_host::storage::{AccessType, Footprint, Storage, StorageMap};
use soroban_env_host::xdr::{
ConfigSettingEntry, ConfigSettingId, DecoratedSignature, DiagnosticEvent, ExtensionPoint,
self, ConfigSettingEntry, ConfigSettingId, DecoratedSignature, DiagnosticEvent, ExtensionPoint,
InvokeHostFunctionOp, LedgerEntry, LedgerEntryData, LedgerFootprint, LedgerKey,
LedgerKeyConfigSetting, Memo, MuxedAccount, MuxedAccountMed25519, Operation, OperationBody,
Preconditions, SequenceNumber, Signature, SignatureHint, SorobanResources,
SorobanTransactionData, Transaction, TransactionExt, TransactionV1Envelope, Uint256, WriteXdr,
};
use soroban_env_host::{xdr, Env};
use std::cmp::max;
use std::convert::{TryFrom, TryInto};
use std::error;
Expand Down

0 comments on commit 910db9a

Please sign in to comment.