Skip to content

Commit

Permalink
Make schema an optional pointer so that it's omitted when empty
Browse files Browse the repository at this point in the history
  • Loading branch information
Shaptic committed Sep 14, 2023
1 parent d3664b5 commit 50a3225
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ endif
# Both cases should fallback to default of getting the version from git tag.
ifeq ($(strip $(REPOSITORY_VERSION)),)
override REPOSITORY_VERSION = "$(shell git describe --tags --always --abbrev=0 --match='v[0-9]*.[0-9]*.[0-9]*' 2> /dev/null | sed 's/^.//')"
endif
endif
REPOSITORY_BRANCH := "$(shell git rev-parse --abbrev-ref HEAD)"
BUILD_TIMESTAMP ?= $(shell date '+%Y-%m-%dT%H:%M:%S')
GOLDFLAGS := -X 'github.com/stellar/soroban-tools/cmd/soroban-rpc/internal/config.Version=${REPOSITORY_VERSION}' \
Expand Down Expand Up @@ -62,12 +62,12 @@ build-libpreflight: Cargo.lock
cd cmd/soroban-rpc/lib/preflight && cargo build --target $(CARGO_BUILD_TARGET) --profile release-with-panic-unwind

build-test-wasms: Cargo.lock
cargo build --package 'test_*' --profile test-wasms --target wasm32-unknown-unknown
cargo build --package 'test_*' --profile test-wasms --target wasm32-unknown-unknown --jobs 4

build-test: build-test-wasms install_rust

test: build-test
cargo test
cargo test

e2e-test:
cargo test --test it -- --ignored
Expand All @@ -88,7 +88,7 @@ clean:
publish:
cargo workspaces publish --all --force '*' --from-git --yes

# the build-soroban-rpc build target is an optimized build target used by
# the build-soroban-rpc build target is an optimized build target used by
# https://github.com/stellar/pipelines/stellar-horizon/Jenkinsfile-soroban-rpc-package-builder
# as part of the package building.
build-soroban-rpc: build-libpreflight
Expand All @@ -101,7 +101,7 @@ lint:
golangci-lint run ./...

typescript-bindings-fixtures: build-test-wasms
cargo run -- contract bindings typescript \
cargo run --jobs 4 -- contract bindings typescript \
--wasm ./target/wasm32-unknown-unknown/test-wasms/test_custom_types.wasm \
--contract-id CBYMYMSDF6FBDNCFJCRC7KMO4REYFPOH2U4N7FXI3GJO6YXNCQ43CDSK \
--network futurenet \
Expand Down
8 changes: 4 additions & 4 deletions cmd/soroban-rpc/internal/methods/simulate_transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ type SimulateTransactionResponse struct {
Events []string `json:"events,omitempty"` // DiagnosticEvent XDR in base64
Results []SimulateHostFunctionResult `json:"results,omitempty"` // an array of the individual host function call results
Cost SimulateTransactionCost `json:"cost,omitempty"` // the effective cpu and memory cost of the invoked transaction execution.
RestorePreamble RestorePreamble `json:"restorePreamble,omitempty"` // If present, it indicates that a prior RestoreFootprint is required
RestorePreamble *RestorePreamble `json:"restorePreamble,omitempty"` // If present, it indicates that a prior RestoreFootprint is required
LatestLedger int64 `json:"latestLedger,string"`
}

Expand Down Expand Up @@ -136,9 +136,9 @@ func NewSimulateTransactionHandler(logger *log.Entry, ledgerEntryReader db.Ledge
Auth: base64EncodeSlice(result.Auth),
})
}
restorePreable := RestorePreamble{}
var restorePreamble *RestorePreamble = nil
if len(result.PreRestoreTransactionData) != 0 {
restorePreable = RestorePreamble{
restorePreamble = &RestorePreamble{
TransactionData: base64.StdEncoding.EncodeToString(result.PreRestoreTransactionData),
MinResourceFee: result.PreRestoreMinFee,
}
Expand All @@ -155,7 +155,7 @@ func NewSimulateTransactionHandler(logger *log.Entry, ledgerEntryReader db.Ledge
MemoryBytes: result.MemoryBytes,
},
LatestLedger: int64(latestLedger),
RestorePreamble: restorePreable,
RestorePreamble: restorePreamble,
}
})
}
Expand Down
3 changes: 2 additions & 1 deletion cmd/soroban-rpc/internal/test/simulate_transaction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ func preflightTransactionParamsLocally(t *testing.T, params txnbuild.Transaction
func preflightTransactionParams(t *testing.T, client *jrpc2.Client, params txnbuild.TransactionParams) txnbuild.TransactionParams {
response := simulateTransactionFromTxParams(t, client, params)
// The preamble should be zero except for the special restore case
assert.Zero(t, response.RestorePreamble)
assert.Nil(t, response.RestorePreamble)
return preflightTransactionParamsLocally(t, params, response)
}

Expand Down Expand Up @@ -858,6 +858,7 @@ func TestSimulateTransactionBumpAndRestoreFootprint(t *testing.T) {
waitForExpiration()

simulationResult := simulateTransactionFromTxParams(t, client, invokeIncPresistentEntryParams)
require.NotNil(t, simulationResult.RestorePreamble)
assert.NotZero(t, simulationResult.RestorePreamble)

params = preflightTransactionParamsLocally(t,
Expand Down

0 comments on commit 50a3225

Please sign in to comment.