Skip to content

Commit

Permalink
removed SingleAddressWallet for a proper Lucid implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
nhenin committed Jan 9, 2024
1 parent 54683d4 commit 2756164
Show file tree
Hide file tree
Showing 52 changed files with 1,370 additions and 939 deletions.
12 changes: 10 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,18 @@
{
"type": "node",
"request": "launch",
"name": "Debug Tests",
"name": "Debug Unit Tests",
"program": "${workspaceRoot}/node_modules/.bin/jest",
"cwd": "${workspaceRoot}",
"args": ["--i", "--config", "jest.config.js"],
"args": ["--i", "--config", "jest.unit.config.js"],
},
{
"type": "node",
"request": "launch",
"name": "Debug E2E Tests",
"program": "${workspaceRoot}/node_modules/.bin/jest",
"cwd": "${workspaceRoot}",
"args": ["--i", "--config", "jest.e2e.config.js"],
},
{
"name": "Launch Extension (development)",
Expand Down
136 changes: 118 additions & 18 deletions doc/howToDevelop.md
Original file line number Diff line number Diff line change
@@ -1,53 +1,153 @@
# Development

## Build
# Build

In order to start develop the SDK you need to install the dependencies and build the packages.

```
```bash
$ npm i
$ npm run build
```

If you want to build a single package you can use the `-w` flag or execute the build command from the package folder.

```
```bash
# From the root folder
$ npm run build -w @marlowe.io/language-core-v1
# Or you can enter the package and build
$ cd packages/language/core/v1
$ npm run build
```

# Clean

In order to clean the build artifacts you can use the `clean` command.

```
```bash
$ npm run clean
```

To run the unit test you can execute the `test` command.
# Tests

N.B : It is recommended to clean and build the packages before you run the tests to be sure you are playing with the most up to date version of the codebase.

```bash
$ npm run clean && npm
```

## Unit Tests

To run the unit tests for all the packages, from the root folder you can execute the `test` command :

```bash
$ npm run test
```

If you want to run tests for a single package you can use the `-w` flag or execute the build command from the package folder.

```bash
# From the root folder
$ npm run clean && npm run build && npm run test -w @marlowe.io/language-core-v1
# Or you can enter the package folder and test. You will have to clean and build properly the local package
# dependencies of this current package if you modify one of them
# e.g : `packages/language/core/v1` depends on `packages/adapter`. Be sure you have build correctly this package before runnning your test that way.
$ cd packages/language/core/v1
$ npm run test
```

## E2E tests
## Integration/E2E Tests

### Setting up the env Configuration File

1. Create a `./env/.env.test` at the root of the project
2. Copy/Paste the following, and provide the necessary parameter

```bash
####################################################
## Provide a Runtime Instance URL (>= v0.0.5) #
####################################################
## to create an instance of a local Marlowe runtime, follow the instructions in
## the Marlowe starter kit : https://github.com/input-output-hk/ marlowe-starter-kit/blob/main/docs/preliminaries.md
MARLOWE_WEB_SERVER_URL="http://<path-to-a-runtime-instance>:<a-port>"
####################################################

#####################################################
## Provide Wallet Dependencies (Necessary for Lucid Library)
#####################################################
## Blockfrost Account : If you haven't done it before, go to https://blockfrost.io/ and create a free-tier account.
## Then, create a project and copy the project ID
BLOCKFROST_PROJECT_ID="<your-blockfrost-project-id>"
BLOCKFROST_URL="<your-blockfrost-id>"
## Network used by Blockfrost : private | preview | preprod | mainnet
NETWORK_NAME=preprod
## Bank Seed Phrase : The bank is a wallet where you provision enough tAda (>= 100 tAda) to run all
## the e2e tests without running out of money. This is your responsability to create this wallet and
## add tAda using a Faucet.
BANK_SEED_PHRASE='[
"deal",
"place",
"depart",
"sound",
"kick",
"daughter",
"diamond",
"rebel",
"update",
"shoe",
"benefit",
"useful",
"travel",
"fringe",
"culture",
"dog",
"lawsuit",
"combine",
"run",
"vanish",
"warm",
"rubber",
"quit",
"system"
]'
#####################################################

#####################################################
## Logging
#####################################################
## set to true or false if you want to log Debug Info
LOG_DEBUG_LEVEL=false
```
#### How to Generate a new Seed Phrase for a Bank Wallet ?

1. At the root of the project :
```bash
npm run -w @marlowe.io/testing-kit genSeedPhrase
```
2. Copy/paste the words within quotes in the env file.

In order to run the E2E tests you need to create a `./env/.env.test` file that points to a working version of the Marlowe runtime and a working Blockfrost instance and a faucet PK.
#### How to add tAda to the Bank Wallet via a faucet ?

If you haven't done it before, go to https://blockfrost.io/ and create a free-tier account. Then, create a project and copy the project ID. Blockfrost is a Lucid dependency, eventually when
we migrate to a different library this wont be necessary.
1. Retrieve your Bank Wallet payment address
2. Go to https://docs.cardano.org/cardano-testnet/tools/faucet ask for test Ada on this address.
3. Wait a moment till the transaction is confirmed and you should be able to run the tests.

To create an instance of a local Marlowe runtime, follow the instructions in the [Marlowe starter kit](https://github.com/input-output-hk/marlowe-starter-kit/blob/main/docs/preliminaries.md)
### Running the E2E Tests

TODO: explain how to get the Faucet PK
To run the e2e tests for all the packages, from the root folder you can execute the `test:e2e` command :

```bash
$ npm run test:e2e
```
MARLOWE_WEB_SERVER_URL="http://<path-to-runtime>:33294/"
BLOCKFROST_PROJECT_ID="<blockfrost-id>"
BLOCKFROST_URL="https://cardano-preprod.blockfrost.io/api/v0"
NETWORK_ID=Preprod
BANK_PK_HEX='<pk>'

If you want to run tests for a single package you can use the `-w` flag or execute the build command from the package folder.

```bash
# From the root folder
$ npm run clean && npm run build && npm run test:e2e -w @marlowe.io/runtime-lifecycle
# Or you can enter the package folder and test. You will have to clean and build properly the local package
# dependencies of this current package if you modify one of them
$ cd packages/runtime/client/rest
$ npm run test:e2e
```

## Documentation
Expand All @@ -56,7 +156,7 @@ BANK_PK_HEX='<pk>'
To compile all documentation

```
```bash
$ npm run docs
```

Expand Down Expand Up @@ -89,7 +189,7 @@ This project manages its changelog with [scriv](https://github.com/nedbat/scriv)

Create a new changelog entry template with

```
```s
$ scriv create
```

Expand Down
7 changes: 7 additions & 0 deletions jest.e2e.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
testEnvironment: "node",
projects: [
"<rootDir>/packages/runtime/client/rest/test/jest.e2e.config.mjs",
"<rootDir>/packages/runtime/lifecycle/test/jest.e2e.config.mjs",
],
};
2 changes: 1 addition & 1 deletion jest.config.js → jest.unit.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ module.exports = {
projects: [
"<rootDir>/packages/language/core/v1/test/jest.unit.config.mjs",
"<rootDir>/packages/language/examples/test/jest.unit.config.mjs",
"<rootDir>/packages/wallet/test/jest.unit.config.mjs",
"<rootDir>/packages/wallet/test/jest.unit.config.mjs"
],
};
121 changes: 43 additions & 78 deletions jsdelivr-npm-importmap.js

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

Loading

0 comments on commit 2756164

Please sign in to comment.