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

feat: try invoking CLI from go test #927

Merged
merged 11 commits into from
Sep 7, 2023
7 changes: 4 additions & 3 deletions .github/workflows/soroban-rpc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,10 @@ jobs:

- name: Build soroban contract fixtures
run: |
rustup update
rustup target add wasm32-unknown-unknown
make build-test-wasms
rustup update
rustup target add wasm32-unknown-unknown
make build_rust
make build-test-wasms

- name: Install Captive Core
run: |
Expand Down
35 changes: 35 additions & 0 deletions cmd/soroban-rpc/internal/test/simulate_transaction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"crypto/sha256"
"fmt"
"os"
"os/exec"
"path"
"runtime"
"testing"
Expand Down Expand Up @@ -836,3 +837,37 @@ func TestSimulateTransactionBumpAndRestoreFootprint(t *testing.T) {
assert.NoError(t, err)
sendSuccessfulTransaction(t, client, sourceAccount, tx)
}

func TestInstallContractWithCLI(t *testing.T) {
test := NewTest(t)
ch := jhttp.NewChannel(test.sorobanRPCURL(), nil)
client := jrpc2.NewClient(ch, nil)

sourceAccount := keypair.Root(StandaloneNetworkPassphrase)

tx, err := txnbuild.NewTransaction(txnbuild.TransactionParams{
SourceAccount: &txnbuild.SimpleAccount{
AccountID: keypair.Root(StandaloneNetworkPassphrase).Address(),
Sequence: 1,
tsachiherman marked this conversation as resolved.
Show resolved Hide resolved
},
IncrementSequenceNum: false,
Operations: []txnbuild.Operation{&txnbuild.CreateAccount{
Destination: "GDIY6AQQ75WMD4W46EYB7O6UYMHOCGQHLAQGQTKHDX4J2DYQCHVCR4W4",
Amount: "100000",
}},
BaseFee: txnbuild.MinBaseFee,
Memo: nil,
Preconditions: txnbuild.Preconditions{
TimeBounds: txnbuild.NewInfiniteTimeout(),
},
})
require.NoError(t, err)
sendSuccessfulTransaction(t, client, sourceAccount, tx)
cmd := exec.Command("cargo", "run", "--", "--vv", "contract", "install", "--wasm", "../../../../target/wasm32-unknown-unknown/test-wasms/test_hello_world.wasm", "--rpc-url", "http://localhost:8000/", "--network-passphrase", "Standalone Network ; February 2017")
require.NoError(t, err)
res, err := cmd.Output()
require.NoError(t, err)
wasm := getHelloWorldContract(t)
contractHash := xdr.Hash(sha256.Sum256(wasm))
require.Contains(t, string(res), contractHash.HexString())
}