Skip to content

Commit

Permalink
build: remove e2e-specific package.json, depend on root project
Browse files Browse the repository at this point in the history
  • Loading branch information
chadoh committed Dec 13, 2023
1 parent 64987d4 commit d09d8ed
Show file tree
Hide file tree
Showing 13 changed files with 875 additions and 3,748 deletions.
File renamed without changes.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ js-stellar-base/

test/unit/out/

target/
target
.soroban
26 changes: 22 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,21 @@
"build:prod": "cross-env NODE_ENV=production yarn _build",
"build:node": "yarn _babel && yarn build:ts",
"build:ts": "tsc -p ./config/tsconfig.json",
"build:test": "tsc -p ./test/tsconfig.json",
"build:test": "tsc -p ./test/unit/tsconfig.json",
"build:browser": "webpack -c config/webpack.config.browser.js",
"build:docs": "cross-env NODE_ENV=docs yarn _babel",
"clean": "rm -rf lib/ dist/ coverage/ .nyc_output/ jsdoc/",
"build:e2e": "tsc -p ./test/e2e/tsconfig.json && ./test/e2e/initialize.sh",
"clean": "rm -rf lib/ dist/ coverage/ .nyc_output/ jsdoc/ test/e2e/.soroban test/e2e/contract-*.txt",
"docs": "yarn build:docs && jsdoc -c ./config/.jsdoc.json --verbose",
"test": "yarn build:test && yarn test:node && yarn test:integration && yarn test:browser",
"test:e2e": "ava",
"test:node": "yarn _nyc mocha --recursive 'test/unit/**/*.js'",
"test:integration": "yarn _nyc mocha --recursive 'test/integration/**/*.js'",
"test:browser": "karma start config/karma.conf.js",
"fmt": "yarn eslint -c .eslintrc.js src/ --fix && yarn _prettier",
"preversion": "yarn clean && yarn fmt && yarn build:prod && yarn test",
"prepare": "yarn build:prod",
"_build": "yarn build:node && yarn build:test && yarn build:browser",
"_build": "yarn build:node && yarn build:test && yarn build:browser && yarn build:e2e",
"_babel": "babel --extensions '.ts' --out-dir lib/ src/",
"_nyc": "nyc --nycrc-path config/.nycrc",
"_prettier": "prettier --ignore-path config/.prettierignore --write './test/**/*.js'"
Expand Down Expand Up @@ -76,6 +78,9 @@
]
},
"devDependencies": {
"@ava/typescript": "^4.1.0",
"ava": "^5.3.1",
"dotenv": "^16.3.1",
"@babel/cli": "^7.23.0",
"@babel/core": "^7.23.0",
"@babel/eslint-parser": "^7.22.15",
Expand All @@ -96,7 +101,6 @@
"@types/randombytes": "^2.0.1",
"@types/sinon": "^17.0.2",
"@types/urijs": "^1.19.20",
"@typescript-eslint/parser": "^6.9.1",
"axios-mock-adapter": "^1.22.0",
"babel-loader": "^9.1.3",
"babel-plugin-istanbul": "^6.1.1",
Expand Down Expand Up @@ -151,5 +155,19 @@
"randombytes": "^2.1.0",
"toml": "^3.0.0",
"urijs": "^1.19.1"
},
"ava": {
"files": [
"./test/e2e/src/test-*"
],
"typescript": {
"rewritePaths": {
"test/e2e/src/": "test/e2e/build/"
},
"compile": false
},
"require": [
"dotenv/config"
]
}
}
11 changes: 0 additions & 11 deletions test/e2e/.eslintrc.cjs

This file was deleted.

53 changes: 26 additions & 27 deletions test/e2e/initialize.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,15 @@ for l in $(cat .env); do
done
unset IFS

if [[ -f "../../target/bin/soroban" ]]; then
echo "Using soroban binary from ../../target/bin"
# a good-enough implementation of __dirname from https://blog.daveeddy.com/2015/04/13/dirname-case-study-for-bash-and-node/
dirname="$(CDPATH= cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

soroban="$dirname/../../target/bin/soroban"
if [[ -f "$soroban" ]]; then
echo "Using soroban binary from ./target/bin"
else
if [[ $(pwd) =~ "e2e" ]]; then
echo "Building pinned soroban binary"
(cd ../.. && cargo install_soroban)
else
echo "Building pinned soroban binary in $(pwd)"
cargo install_soroban
fi
echo "Building pinned soroban binary"
(cd "$dirname/../.." && cargo install_soroban)
fi

NETWORK_STATUS=$(curl -s -X POST "$SOROBAN_RPC_URL" -H "Content-Type: application/json" -d '{ "jsonrpc": "2.0", "id": 8675309, "method": "getHealth" }' | sed 's/.*"status":"\(.*\)".*/\1/') || { echo "Make sure you're running local RPC network on localhost:8000" && exit 1; }
Expand All @@ -32,35 +31,35 @@ echo " Status: $NETWORK_STATUS"
exe() { echo"${@/eval/}" ; "$@" ; }

function fund_all() {
exe eval "./soroban config identity fund"
exe eval "./soroban config identity generate alice"
exe eval "./soroban config identity fund alice"
exe eval "./soroban config identity generate bob"
exe eval "./soroban config identity fund bob"
exe eval "$soroban config identity fund"
exe eval "$soroban config identity generate alice"
exe eval "$soroban config identity fund alice"
exe eval "$soroban config identity generate bob"
exe eval "$soroban config identity fund bob"
}
function upload() {
exe eval "(./soroban contract $1 --wasm $2 --ignore-checks) > $3"
exe eval "($soroban contract $1 --wasm $dirname/$2 --ignore-checks) > $dirname/$3"
}
function deploy() {
exe eval "(./soroban contract deploy --wasm-hash $(cat $1) --ignore-checks) > $2"
exe eval "($soroban contract deploy --wasm-hash $(cat $dirname/$1) --ignore-checks) > $dirname/$2"
}
function deploy_all() {
upload deploy ./wasms/test_custom_types.wasm contract-id-custom-types.txt
upload deploy ./wasms/test_hello_world.wasm contract-id-hello-world.txt
upload deploy ./wasms/test_swap.wasm contract-id-swap.txt
upload install ./wasms/test_token.wasm contract-token-hash.txt
upload deploy wasms/test_custom_types.wasm contract-id-custom-types.txt
upload deploy wasms/test_hello_world.wasm contract-id-hello-world.txt
upload deploy wasms/test_swap.wasm contract-id-swap.txt
upload install 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 --id $(cat $1) -- initialize --admin $(./soroban config identity address) --decimal 0 --name 'Token $2' --symbol '$2'"
exe eval "$soroban contract invoke --id $(cat $dirname/$1) -- initialize --admin $($soroban config identity address) --decimal 0 --name 'Token $2' --symbol '$2'"
}
function initialize_all() {
initialize contract-id-token-a.txt A
initialize contract-id-token-b.txt B
}
function bind() {
exe eval "./soroban contract bindings typescript --contract-id $(cat $1) --output-dir ./node_modules/$2 --overwrite"
exe eval "$soroban contract bindings typescript --contract-id $(cat $dirname/$1) --output-dir $dirname/../../node_modules/$2 --overwrite"
}
function bind_all() {
bind contract-id-custom-types.txt test-custom-types
Expand All @@ -70,15 +69,15 @@ function bind_all() {
}

function mint() {
exe eval "./soroban contract invoke --id $(cat $1) -- mint --amount 2000000 --to $(./soroban config identity address $2)"
exe eval "$soroban contract invoke --id $(cat $dirname/$1) -- mint --amount 2000000 --to $($soroban config identity 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
fund_all
deploy_all
initialize_all
mint_all
bind_all
Loading

0 comments on commit d09d8ed

Please sign in to comment.