Skip to content

Commit

Permalink
build: remove CI for now
Browse files Browse the repository at this point in the history
  • Loading branch information
chadoh committed Oct 9, 2023
1 parent 0677f8f commit 170a796
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 187 deletions.
50 changes: 0 additions & 50 deletions .github/workflows/bindings-ts.yml

This file was deleted.

82 changes: 4 additions & 78 deletions .github/workflows/soroban-rpc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ jobs:
CGO_ENABLED: 1
GOARCH: ${{ matrix.go_arch }}

cli:
name: CLI integration tests
integration:
name: Integration tests
strategy:
matrix:
os: [ubuntu-20.04]
Expand Down Expand Up @@ -170,80 +170,6 @@ jobs:
- name: Build libpreflight
run: make build-libpreflight

- name: Run CLI tests
- name: Run Soroban RPC Integration Tests
run: |
go test -race -run '.*CLI.*' -timeout 60m -v ./cmd/soroban-rpc/internal/test/...
non-cli:
name: TypeScript Bindings
strategy:
matrix:
os: [ubuntu-20.04]
go: [1.20.1]
env:
SOROBAN_RPC_INTEGRATION_TESTS_ENABLED: true
SOROBAN_RPC_INTEGRATION_TESTS_CAPTIVE_CORE_BIN: /usr/bin/stellar-core
PROTOCOL_20_CORE_DEBIAN_PKG_VERSION: 19.13.1-1481.3acf6dd26.focal
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
with:
# For pull requests, build and test the PR head not a merge of the PR with the destination.
ref: ${{ github.event.pull_request.head.sha || github.ref }}
# We need to full history for git-restore-mtime to know what modification dates to use.
# Otherwise, the Go test cache will fail (due to the modification time of fixtures changing).
fetch-depth: "0"

- uses: ./.github/actions/setup-go
with:
go-version: ${{ matrix.go }}
- uses: stellar/actions/rust-cache@main
- name: Build soroban contract fixtures
run: |
rustup update
rustup target add wasm32-unknown-unknown
make build_rust
make build-test-wasms
- name: Install Captive Core
run: |
# Workaround for https://github.com/actions/virtual-environments/issues/5245,
# libc++1-8 won't be installed if another version is installed (but apt won't give you a helpful
# message about why the installation fails)
sudo apt-get remove -y libc++1-10 libc++abi1-10 || true
sudo wget -qO - https://apt.stellar.org/SDF.asc | APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=true sudo apt-key add -
sudo bash -c 'echo "deb https://apt.stellar.org focal unstable" > /etc/apt/sources.list.d/SDF-unstable.list'
sudo apt-get update && sudo apt-get install -y stellar-core="$PROTOCOL_20_CORE_DEBIAN_PKG_VERSION"
echo "Using stellar core version $(stellar-core version)"
# Docker-compose's remote contexts on Ubuntu 20 started failing with an OpenSSL versioning error.
# See https://stackoverflow.com/questions/66579446/error-executing-docker-compose-building-webserver-unable-to-prepare-context-un
- name: Work around Docker Compose problem
run: |
sudo apt-get update
sudo apt-get install -y ca-certificates curl gnupg
# Install docker apt repo
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg
echo \
"deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
"$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
# Install docker-compose v2 from apt repo
sudo apt-get update
sudo apt-get remove -y moby-compose
sudo apt-get install -y docker-compose-plugin
echo "Docker Compose Version:"
docker-compose version
- name: Build libpreflight
run: make build-libpreflight

- name: Run non-CLI tests (including TypeScript Bindings)
run: |
go test -race -run '^Test(([^C])|(C[^L])|(CL[^I])).*$' -timeout 60m -v ./cmd/soroban-rpc/internal/test/...
go test -race -timeout 25m -v ./cmd/soroban-rpc/internal/test/...
92 changes: 33 additions & 59 deletions cmd/soroban-rpc/internal/test/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,55 +47,40 @@ func TestCLICargoTest(t *testing.T) {
func TestCLIWrapCustom(t *testing.T) {
NewCLITest(t)
testAccount := getCLIDefaultAccount(t)
strkeyContractID := runSuccessfulSorobanCmd(t, fmt.Sprintf("lab token wrap --asset=deadbeef:%s", testAccount))
require.Equal(t, "true", runSuccessfulSorobanCmd(t, fmt.Sprintf("contract invoke --id=%s -- authorized --id=%s", strkeyContractID, testAccount)))
runSuccessfulSorobanCmd(t, fmt.Sprintf("contract invoke --id=%s -- mint --to=%s --amount 1", strkeyContractID, testAccount))
}

func TestTypeScriptBindings(t *testing.T) {
NewCLITest(t)
testDir := "../../../crates/soroban-spec-typescript/ts-tests"
rpcUrl := fmt.Sprintf("SOROBAN_RPC_URL=http://localhost:%d/", sorobanRPCPort)
networkPassphrase := fmt.Sprintf("SOROBAN_NETWORK_PASSPHRASE=%s", StandaloneNetworkPassphrase)
install := newCommand(t, "npm i")
test := newCommand(t, "npm run test")
install.Dir = testDir
test.Dir = testDir
install.Env = append(os.Environ(), rpcUrl, networkPassphrase)
test.Env = append(os.Environ(), rpcUrl, networkPassphrase)
runSuccessfulCmd(t, install)
runSuccessfulCmd(t, test)
strkeyContractID := runSuccessfulCLICmd(t, fmt.Sprintf("lab token wrap --asset=deadbeef:%s", testAccount))
require.Equal(t, "true", runSuccessfulCLICmd(t, fmt.Sprintf("contract invoke --id=%s -- authorized --id=%s", strkeyContractID, testAccount)))
runSuccessfulCLICmd(t, fmt.Sprintf("contract invoke --id=%s -- mint --to=%s --amount 1", strkeyContractID, testAccount))
}

func TestCLIWrapNative(t *testing.T) {
NewCLITest(t)
testAccount := getCLIDefaultAccount(t)
strkeyContractID := runSuccessfulSorobanCmd(t, fmt.Sprintf("lab token wrap --asset=native:%s", testAccount))
strkeyContractID := runSuccessfulCLICmd(t, fmt.Sprintf("lab token wrap --asset=native:%s", testAccount))
require.Equal(t, "CAMTHSPKXZJIRTUXQP5QWJIFH3XIDMKLFAWVQOFOXPTKAW5GKV37ZC4N", strkeyContractID)
require.Equal(t, "true", runSuccessfulSorobanCmd(t, fmt.Sprintf("contract invoke --id=%s -- authorized --id=%s", strkeyContractID, testAccount)))
require.Equal(t, "\"9223372036854775807\"", runSuccessfulSorobanCmd(t, fmt.Sprintf("contract invoke --id=%s -- balance --id %s", strkeyContractID, testAccount)))
require.Equal(t, "true", runSuccessfulCLICmd(t, fmt.Sprintf("contract invoke --id=%s -- authorized --id=%s", strkeyContractID, testAccount)))
require.Equal(t, "\"9223372036854775807\"", runSuccessfulCLICmd(t, fmt.Sprintf("contract invoke --id=%s -- balance --id %s", strkeyContractID, testAccount)))
}

func TestCLIContractInstall(t *testing.T) {
NewCLITest(t)
output := runSuccessfulSorobanCmd(t, "contract install --wasm "+helloWorldContractPath)
output := runSuccessfulCLICmd(t, "contract install --wasm "+helloWorldContractPath)
wasm := getHelloWorldContract(t)
contractHash := xdr.Hash(sha256.Sum256(wasm))
require.Contains(t, output, contractHash.HexString())
}

func TestCLIContractInstallAndDeploy(t *testing.T) {
NewCLITest(t)
runSuccessfulSorobanCmd(t, "contract install --wasm "+helloWorldContractPath)
runSuccessfulCLICmd(t, "contract install --wasm "+helloWorldContractPath)
wasm := getHelloWorldContract(t)
contractHash := xdr.Hash(sha256.Sum256(wasm))
output := runSuccessfulSorobanCmd(t, fmt.Sprintf("contract deploy --salt %s --wasm-hash %s", hex.EncodeToString(testSalt[:]), contractHash.HexString()))
output := runSuccessfulCLICmd(t, fmt.Sprintf("contract deploy --salt %s --wasm-hash %s", hex.EncodeToString(testSalt[:]), contractHash.HexString()))
outputsContractIDInLastLine(t, output)
}

func TestCLIContractDeploy(t *testing.T) {
NewCLITest(t)
output := runSuccessfulSorobanCmd(t, fmt.Sprintf("contract deploy --salt %s --wasm %s", hex.EncodeToString(testSalt[:]), helloWorldContractPath))
output := runSuccessfulCLICmd(t, fmt.Sprintf("contract deploy --salt %s --wasm %s", hex.EncodeToString(testSalt[:]), helloWorldContractPath))
outputsContractIDInLastLine(t, output)
}

Expand All @@ -115,17 +100,17 @@ func outputsContractIDInLastLine(t *testing.T, output string) {

func TestCLIContractDeployAndInvoke(t *testing.T) {
NewCLITest(t)
contractID := runSuccessfulSorobanCmd(t, fmt.Sprintf("contract deploy --salt=%s --wasm %s", hex.EncodeToString(testSalt[:]), helloWorldContractPath))
output := runSuccessfulSorobanCmd(t, fmt.Sprintf("contract invoke --id %s -- hello --world=world", contractID))
contractID := runSuccessfulCLICmd(t, fmt.Sprintf("contract deploy --salt=%s --wasm %s", hex.EncodeToString(testSalt[:]), helloWorldContractPath))
output := runSuccessfulCLICmd(t, fmt.Sprintf("contract invoke --id %s -- hello --world=world", contractID))
require.Contains(t, output, `["Hello","world"]`)
}

func TestCLIRestorePreamble(t *testing.T) {
test := NewCLITest(t)
strkeyContractID := runSuccessfulSorobanCmd(t, fmt.Sprintf("contract deploy --salt=%s --wasm %s", hex.EncodeToString(testSalt[:]), helloWorldContractPath))
count := runSuccessfulSorobanCmd(t, fmt.Sprintf("contract invoke --id %s -- inc", strkeyContractID))
strkeyContractID := runSuccessfulCLICmd(t, fmt.Sprintf("contract deploy --salt=%s --wasm %s", hex.EncodeToString(testSalt[:]), helloWorldContractPath))
count := runSuccessfulCLICmd(t, fmt.Sprintf("contract invoke --id %s -- inc", strkeyContractID))
require.Equal(t, "1", count)
count = runSuccessfulSorobanCmd(t, fmt.Sprintf("contract invoke --id %s -- inc", strkeyContractID))
count = runSuccessfulCLICmd(t, fmt.Sprintf("contract invoke --id %s -- inc", strkeyContractID))
require.Equal(t, "2", count)

// Wait for the counter ledger entry to expire and successfully invoke the `inc` contract function again
Expand All @@ -134,14 +119,14 @@ func TestCLIRestorePreamble(t *testing.T) {
client := jrpc2.NewClient(ch, nil)
waitForLedgerEntryToExpire(t, client, getExpirationKeyForCounterLedgerEntry(t, strkeyContractID))

count = runSuccessfulSorobanCmd(t, fmt.Sprintf("contract invoke --id %s -- inc", strkeyContractID))
count = runSuccessfulCLICmd(t, fmt.Sprintf("contract invoke --id %s -- inc", strkeyContractID))
require.Equal(t, "3", count)
}

func TestCLIBump(t *testing.T) {
test := NewCLITest(t)
strkeyContractID := runSuccessfulSorobanCmd(t, fmt.Sprintf("contract deploy --salt=%s --wasm %s", hex.EncodeToString(testSalt[:]), helloWorldContractPath))
count := runSuccessfulSorobanCmd(t, fmt.Sprintf("contract invoke --id %s -- inc", strkeyContractID))
strkeyContractID := runSuccessfulCLICmd(t, fmt.Sprintf("contract deploy --salt=%s --wasm %s", hex.EncodeToString(testSalt[:]), helloWorldContractPath))
count := runSuccessfulCLICmd(t, fmt.Sprintf("contract invoke --id %s -- inc", strkeyContractID))
require.Equal(t, "1", count)

ch := jhttp.NewChannel(test.sorobanRPCURL(), nil)
Expand All @@ -150,7 +135,7 @@ func TestCLIBump(t *testing.T) {
expirationKey := getExpirationKeyForCounterLedgerEntry(t, strkeyContractID)
initialExpirationSeq := getExpirationForLedgerEntry(t, client, expirationKey)

bumpOutput := runSuccessfulSorobanCmd(
bumpOutput := runSuccessfulCLICmd(
t,
fmt.Sprintf(
"contract bump --id %s --key COUNTER --durability persistent --ledgers-to-expire 20",
Expand All @@ -164,8 +149,8 @@ func TestCLIBump(t *testing.T) {
}
func TestCLIBumpTooLow(t *testing.T) {
test := NewCLITest(t)
strkeyContractID := runSuccessfulSorobanCmd(t, fmt.Sprintf("contract deploy --salt=%s --wasm %s", hex.EncodeToString(testSalt[:]), helloWorldContractPath))
count := runSuccessfulSorobanCmd(t, fmt.Sprintf("contract invoke --id %s -- inc", strkeyContractID))
strkeyContractID := runSuccessfulCLICmd(t, fmt.Sprintf("contract deploy --salt=%s --wasm %s", hex.EncodeToString(testSalt[:]), helloWorldContractPath))
count := runSuccessfulCLICmd(t, fmt.Sprintf("contract invoke --id %s -- inc", strkeyContractID))
require.Equal(t, "1", count)

ch := jhttp.NewChannel(test.sorobanRPCURL(), nil)
Expand All @@ -186,8 +171,8 @@ func TestCLIBumpTooLow(t *testing.T) {

func TestCLIBumpTooHigh(t *testing.T) {
test := NewCLITest(t)
strkeyContractID := runSuccessfulSorobanCmd(t, fmt.Sprintf("contract deploy --salt=%s --wasm %s", hex.EncodeToString(testSalt[:]), helloWorldContractPath))
count := runSuccessfulSorobanCmd(t, fmt.Sprintf("contract invoke --id %s -- inc", strkeyContractID))
strkeyContractID := runSuccessfulCLICmd(t, fmt.Sprintf("contract deploy --salt=%s --wasm %s", hex.EncodeToString(testSalt[:]), helloWorldContractPath))
count := runSuccessfulCLICmd(t, fmt.Sprintf("contract invoke --id %s -- inc", strkeyContractID))
require.Equal(t, "1", count)

ch := jhttp.NewChannel(test.sorobanRPCURL(), nil)
Expand All @@ -205,8 +190,8 @@ func TestCLIBumpTooHigh(t *testing.T) {

func TestCLIRestore(t *testing.T) {
test := NewCLITest(t)
strkeyContractID := runSuccessfulSorobanCmd(t, fmt.Sprintf("contract deploy --salt=%s --wasm %s", hex.EncodeToString(testSalt[:]), helloWorldContractPath))
count := runSuccessfulSorobanCmd(t, fmt.Sprintf("contract invoke --id %s -- inc", strkeyContractID))
strkeyContractID := runSuccessfulCLICmd(t, fmt.Sprintf("contract deploy --salt=%s --wasm %s", hex.EncodeToString(testSalt[:]), helloWorldContractPath))
count := runSuccessfulCLICmd(t, fmt.Sprintf("contract invoke --id %s -- inc", strkeyContractID))
require.Equal(t, "1", count)

ch := jhttp.NewChannel(test.sorobanRPCURL(), nil)
Expand All @@ -218,7 +203,7 @@ func TestCLIRestore(t *testing.T) {
// This ensures that the CLI restores the entry (using the RestorePreamble in the simulateTransaction response)
waitForLedgerEntryToExpire(t, client, expirationKey)

restoreOutput := runSuccessfulSorobanCmd(
restoreOutput := runSuccessfulCLICmd(
t,
fmt.Sprintf(
"contract restore --id %s --key COUNTER --durability persistent",
Expand All @@ -243,21 +228,16 @@ func parseContractStrKey(t *testing.T, strkeyContractID string) [32]byte {
return contractID
}

func runSuccessfulSorobanCmd(t *testing.T, cmdStr string) string {
cmd := newSorobanCommand(t, cmdStr)
return runSuccessfulCmd(t, cmd)
}

func runSuccessfulCmd(t *testing.T, cmd icmd.Cmd) string {
res := icmd.RunCmd(cmd)
func runSuccessfulCLICmd(t *testing.T, cmd string) string {
res := runCLICommand(t, cmd)
stdout, stderr := res.Stdout(), res.Stderr()
outputs := fmt.Sprintf("stderr:\n%s\nstdout:\n%s\n", stderr, stdout)
require.NoError(t, res.Error, outputs)
fmt.Print(outputs)
return strings.TrimSpace(stdout)
}

func newSorobanCommand(t *testing.T, cmd string) icmd.Cmd {
func runCLICommand(t *testing.T, cmd string) *icmd.Result {
args := []string{"run", "-q", "--", "--vv"}
parsedArgs, err := shlex.Split(cmd)
require.NoError(t, err, cmd)
Expand All @@ -267,22 +247,16 @@ func newSorobanCommand(t *testing.T, cmd string) icmd.Cmd {
fmt.Sprintf("SOROBAN_RPC_URL=http://localhost:%d/", sorobanRPCPort),
fmt.Sprintf("SOROBAN_NETWORK_PASSPHRASE=%s", StandaloneNetworkPassphrase),
)
return c
}

func newCommand(t *testing.T, cmd string) icmd.Cmd {
args, err := shlex.Split(cmd)
require.NoError(t, err, cmd)
return icmd.Command(args[0], args[1:]...)
return icmd.RunCmd(c)
}

func getCLIDefaultAccount(t *testing.T) string {
return runSuccessfulSorobanCmd(t, "config identity address --hd-path 0")
return runSuccessfulCLICmd(t, "config identity address --hd-path 0")
}

func NewCLITest(t *testing.T) *Test {
test := NewTest(t)
fundAccount(t, test, getCLIDefaultAccount(t), "10000000000")
fundAccount(t, test, getCLIDefaultAccount(t), "1000000")
return test
}

Expand Down Expand Up @@ -320,7 +294,7 @@ func parseInt(t *testing.T, s string) uint64 {

func bump(t *testing.T, contractId string, amount string, rest string) uint64 {

res := runSuccessfulSorobanCmd(
res := runSuccessfulCLICmd(
t,
fmt.Sprintf(
"contract bump --expiration-ledger-only --id=%s --durability persistent --ledgers-to-expire=%s %s",
Expand Down

0 comments on commit 170a796

Please sign in to comment.