Skip to content

Commit

Permalink
build: remove redundant TS tests
Browse files Browse the repository at this point in the history
All tests that are being removed are now duplicates of tests that are in
stellar-sdk. So are the test-custom-types tests, but those ones actually
caught some edge cases, so maybe they're worth keeping.
  • Loading branch information
chadoh committed Mar 13, 2024
1 parent 45e5d95 commit 406f906
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 244 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 2 additions & 34 deletions cmd/crates/soroban-spec-typescript/ts-tests/initialize.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,52 +28,20 @@ exe() { echo"${@/eval/}" ; "$@" ; }
function fund_all() {
exe eval "./soroban keys generate root"
exe eval "./soroban keys fund root"
exe eval "./soroban keys generate alice"
exe eval "./soroban keys fund alice"
exe eval "./soroban keys generate bob"
exe eval "./soroban keys fund bob"
}
function upload() {
exe eval "(./soroban contract $1 --source root --wasm $2 --ignore-checks) > $3"
}
function deploy() {
exe eval "(./soroban contract deploy --source root --wasm-hash $(cat $1) --ignore-checks) > $2"
exe eval "(./soroban contract deploy --source root --wasm $1 --ignore-checks) > $2"
}
function deploy_all() {
upload deploy ../../../../target/wasm32-unknown-unknown/test-wasms/test_custom_types.wasm contract-id-custom-types.txt
upload deploy ../../../../target/wasm32-unknown-unknown/test-wasms/test_hello_world.wasm contract-id-hello-world.txt
upload deploy ../../../../target/wasm32-unknown-unknown/test-wasms/test_swap.wasm contract-id-swap.txt
upload install ../../../../target/wasm32-unknown-unknown/test-wasms/test_token.wasm contract-token-hash.txt
deploy contract-token-hash.txt contract-id-token-a.txt
deploy contract-token-hash.txt contract-id-token-b.txt
}
function initialize() {
exe eval "./soroban contract invoke --source root --id $(cat $1) -- initialize --admin $(./soroban keys address root) --decimal 0 --name 'Token $2' --symbol '$2'"
}
function initialize_all() {
initialize contract-id-token-a.txt A
initialize contract-id-token-b.txt B
deploy ../../../../target/wasm32-unknown-unknown/test-wasms/test_custom_types.wasm contract-id-custom-types.txt
}
function bind() {
exe eval "./soroban contract bindings typescript --contract-id $(cat $1) --output-dir ./node_modules/$2 --overwrite"
}
function bind_all() {
bind contract-id-custom-types.txt test-custom-types
bind contract-id-hello-world.txt test-hello-world
bind contract-id-swap.txt test-swap
bind contract-id-token-a.txt token
}

function mint() {
exe eval "./soroban contract invoke --source root --id $(cat $1) -- mint --amount 2000000 --to $(./soroban keys address $2)"
}
function mint_all() {
mint contract-id-token-a.txt alice
mint contract-id-token-b.txt bob
}

fund_all
deploy_all
initialize_all
mint_all
bind_all
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
import test from "ava"
import { rpcUrl, root, signer } from "./util.js"
import { Client, networks } from "test-hello-world"
import { Client, networks } from "test-custom-types"

const contract = new Client({
...networks.standalone,
rpcUrl,
allowHttp: true,
publicKey: root.keypair.publicKey(),
...signer,
...networks.standalone,
})

test("has correctly-typed result", async (t) => {
const initial = await contract.hello({ world: "tests" })
t.is(initial.result[0], "Hello")
t.is(initial.result[1], "tests")
const initial = await contract.hello({ hello: "tests" })
t.is(initial.result, "tests")

const serialized = initial.toJSON()
const deserialized = contract.fromJSON.hello(serialized)
t.is(deserialized.result[0], "Hello") // throws TS error if `result` is of type `unknown`
t.is(deserialized.result[1], "tests") // throws TS error if `result` is of type `unknown`
t.is(deserialized.result, "tests") // throws TS error if `result` is of type `unknown`
});

This file was deleted.

This file was deleted.

140 changes: 0 additions & 140 deletions cmd/crates/soroban-spec-typescript/ts-tests/src/test-swap.ts

This file was deleted.

12 changes: 0 additions & 12 deletions cmd/crates/soroban-spec-typescript/ts-tests/src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,12 @@ import { Address, Keypair } from "@stellar/stellar-sdk";
import { basicNodeSigner } from "@stellar/stellar-sdk/lib/contract_client/index.js";

const rootKeypair = Keypair.fromSecret(spawnSync("./soroban", ["keys", "show", "root"], { shell: true, encoding: "utf8" }).stdout.trim());
const aliceKeypair = Keypair.fromSecret(spawnSync("./soroban", ["keys", "show", "alice"], { shell: true, encoding: "utf8" }).stdout.trim());
const bobKeypair = Keypair.fromSecret(spawnSync("./soroban", ["keys", "show", "bob"], { shell: true, encoding: "utf8" }).stdout.trim());

export const root = {
keypair: rootKeypair,
address: Address.fromString(rootKeypair.publicKey()),
}

export const alice = {
keypair: aliceKeypair,
address: Address.fromString(aliceKeypair.publicKey()),
}

export const bob = {
keypair: bobKeypair,
address: Address.fromString(bobKeypair.publicKey()),
}

export const rpcUrl = process.env.SOROBAN_RPC_URL ?? "http://localhost:8000/";
export const networkPassphrase = process.env.SOROBAN_NETWORK_PASSPHRASE ?? "Standalone Network ; February 2017";

Expand Down

0 comments on commit 406f906

Please sign in to comment.