Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update test scripts for multiuser/multiasset wallets
Browse files Browse the repository at this point in the history
Update the test scripts for multiuser wallets. The tests reflect the
steps necessary to use the widgets interface in the wallet notebook.
In addition, a new test 08.mutiple_user_wallet.md describes a test
that creates two wallets and transfers assets between them.

Signed-off-by: Mic Bowman <mic.bowman@intel.com>
cmickeyb committed May 14, 2024
1 parent 8cc427d commit ddc0cd1
Showing 3 changed files with 260 additions and 26 deletions.
8 changes: 4 additions & 4 deletions exchange-contract/docs/tests/06.single_issuer_wallet.md
Original file line number Diff line number Diff line change
@@ -100,10 +100,10 @@ To verify that the issuer was successfully imported, click the
"Refresh" button in the "Account Balance" section. The table should
show that asset handle "my_blue_marbles" has a balance of 50.

**Container_1: Verify Asset Transfer.** Scroll down to the "Transfer
Assets" section of the wallet. Click on the "Refresh" button to reset
the widget with the imported contract. With the widget perform the
following steps:
**Container_1: Perform and verify asset transfer.** Scroll down to the
"Transfer Assets" section of the wallet. Click on the "Refresh" button
to reset the widget with the imported contract. With the widget
perform the following steps:

* Select "my_blue_marbles" as the Source Handle
* Set the Amount slider to 20
72 changes: 50 additions & 22 deletions exchange-contract/docs/tests/07.multiple_issuer_wallet.md
Original file line number Diff line number Diff line change
@@ -74,10 +74,9 @@ In the "Share Contract" section, change `%%skip True` to `%%skip
False` and run the cell. This should create a "Download Contract"
button. Click the button and save the contract collection file.

**Container_2: Create the green issuer and issue assets.** From the
launcher open the notebook in
`exchange/factories/issuer.ipynb`. Run all cells. Respond to the
prompts as follows:
**Container_2: Create the green issuer and issue assets.** Open the
issuer factory notebook again (select the issuer tab), restart the
kernel, and run all cells. Respond to the prompts as follows:

* Identity: `green_issuer`
* Name of the asset class: `green_marble`
@@ -100,24 +99,53 @@ In the "Share Contract" section, change `%%skip True` to `%%skip
False` and run the cell. This should create a "Download Contract"
button. Click the button and save the contract collection file.

**Shell: Move the contract collection files.** Move the contract
collection files that were downloaded in the previous step into the
`docker/xfer/client` directory where you are running to contracts
docker containers. The name of the file will be something like
`blue_marble_<ID>.zip` and `green_marble_<ID>.zip` where ID is a
unique identifier for the contract.

**Container_1: Import the issuer contract and create a wallet.** From the launcher
open the notebook in `exchange/factories/wallet.ipynb`. Run all
cells. Repond to the prompts as follows:
**Container_1: Import the issuer contract and create a wallet.** From
the launcher open the notebook in `exchange/factories/wallet.ipynb`.
Run all cells. Repond to the prompts as follows:

* Identity: `alice`
* Name of the asset: `blue_marble`
* Name of the issuer import file: `/project/pdo/xfer/client/blue_marble_<ID>.zip`
* Wallet Owner: `alice`
* Wallet Name: `marbles`

This will create a link to the wallet notebook. Click on the link to
open the notebook. Run all cells. To verify that the notebook is
correct, get the balance of the current issuance. This can be done in
the "Get the Account Balance" section by changing the `%%skip True` to
`%%skip False`. When run, the output should say that the balance is
currently 50 blue marbles.
open the notebook. Run all cells.

Scroll down to the "Import Asset Issuers" section. With the widget,
perform the following steps:

* Select "alice" as the identity
* Use the "contract file" button to select the contract file
downloaded earlier; the file should have a name like
`blue_marble_<ID>.zip`
* Specify the Asset Handle as "my_blue_marbles"
* Click on the "Import Contract" button

Repeat the process with the `green_issuer` contract:

* Select "alice" as the identity
* Use the "contract file" button to select the contract file
downloaded earlier; the file should have a name like
`green_marble_<ID>.zip`
* Specify the Asset Handle as "my_green_marbles"
* Click on the "Import Contract" button

To verify that the issuer was successfully imported, click the
"Refresh" button in the "Account Balance" section. The table should
show that asset handles "my_blue_marbles" and "my_green_marbles" have
a balance of 50 .

**Container_1: Verify Asset Transfer.** Scroll down to the "Transfer
Assets" section of the wallet. Click on the "Refresh" button to reset
the widget with the imported contract. With the widget perform the
following steps:

* Select "my_blue_marbles" as the Source Handle
* Set the Amount slider to 20
* Set the New Owner to `user1`
* Click on the "Transfer" button

To verify that the transfer occurred, scroll up to the "Account
Balance" section and click on the "Refresh" button. The balance of
`my_blue_marbles` should be 30.

Repeat the process to transfer 20 assets from `my_red_marbles` to
`user1`.
206 changes: 206 additions & 0 deletions exchange-contract/docs/tests/08.multiple_user_wallet.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,206 @@
<!---
Licensed under Creative Commons Attribution 4.0 International License
https://creativecommons.org/licenses/by/4.0/
--->

# Multiple User/Multiple Issuer Wallet #

## Goal ##

This scenarios tests wallets that contain assets from more than
one issuer. And that those assets can be transferred to another
identity running in a separate container.

## Setup ##

**Prepare the multiuser Jupyter docker test.** To start the services,
run `make -C docker test_multiuser_jupyter` from the PDO contracts
root directory. When the services start, the two Jupyter containers
(`container_1` and `container_2`) will show the access URLs. Open each
URL in a separate browser window. For the rest of this discussion, we
will refer to the windows as `container_1` (for the user) and
`container_2` (for the issuer).

**Container_1: Create the keys for "alice".** Open the notebook
`documents/getting_started.ipynb` and run all cells. Navigate to
"Create Keys" and create a new key pair for the identity
"alice". Refresh the list of public keys and click on the "alice" key
file to download the "alice" public key.

**Container_2: Create the keys for "bob".** Open the notebook
`documents/getting_started.ipynb` and run all cells. Navigate to
"Create Keys" and create a new key pair for the identity
"alice". Refresh the list of public keys and click on the "alice" key
file to download the "bob" public key.

**Container_1: Import "bob" public key.** Navigate to the "Create
Keys" section and import the the "bob" public key that was downloaded
earlier. Refresh the public key list to verify that the key was
uploaded successfully.

**Container_2: Import "alice" public key.** Navigate to the "Create
Keys" section and import the the "alice" public key that was
downloaded earlier. Refresh the public key list to verify that the key
was uploaded successfully.

**Container_3: Create the keys for the issuer.** Open the notebook
`documents/getting_started.ipynb` and run all cells. Navigate to
"Create Keys" and create a new key pair for the identity
"blue_issuer". Using the same steps, create a new key pair for the
identity "green_issuer". Refresh the public and private key lists to
verify that the keys have been created.

**Container_3: Import the "alice" and "bob" public keys into the
issuer.** Navigate to the "Create Keys" section and import the the
"alice" and "bob" public keys that were downloaded earlier. Refresh
the public key list to verify that the keys were uploaded
successfully.

**Container_3: Create the service group.** Navigate to "Create Service
Group" and create a new three new service groups, one each for the
enclave, provisioning and storage services (select each of the tabs
separately). Select the first three services of each type for each
group. Call each of the groups "issuer_group". For the storage
service group, set the required duration to 3600. Refresh each of the
group lists to verify that the groups have been created.

## Test ##

**Container_3: Create the blue issuer and issue assets.** From the
launcher open the notebook in
`exchange/factories/issuer.ipynb`. Run all cells. Respond to the
prompts as follows:

* Identity: `blue_issuer`
* Name of the asset class: `blue_marble`
* Asset description: `blue marbles`
* Link to more information: `http://`
* Service group: `issuer_group`

This will create a link to a issuer notebook. Click on the link to
open the issuer notebook. Run all cells. You can verify that the
issuer was created successfully by looking in the "Approve Authority
Chain" section; the output should say that the issuer was successfully
initialized.

In the "Issue Assets" section of the issuer contract, change `%%skip
True` to `%%skip False` and change `user1` to `alice`. Run the
cell. The output should indicate that 50 assets were issued to
`alice`. Change `alice` to `bob` and run the cell again. The output
should indicate that 50 assets were issued to `bob`.

In the "Share Contract" section, change `%%skip True` to `%%skip
False` and run the cell. This should create a "Download Contract"
button. Click the button and save the contract collection file.

**Container_3: Create the green issuer and issue assets.** Open the
issuer factory notebook again (select the issuer tab), restart the
kernel, and run all cells. Respond to the prompts as follows:

* Identity: `green_issuer`
* Name of the asset class: `green_marble`
* Asset description: `green marbles`
* Link to more information: `http://`
* Service group: `issuer_group`

This will create a link to a issuer notebook. Click on the link to
open the issuer notebook. Run all cells. You can verify that the
issuer was created successfully by looking in the "Approve Authority
Chain" section; the output should say that the issuer was successfully
initialized.

In the "Issue Assets" section of the issuer contract, change `%%skip
True` to `%%skip False` and change `user1` to `alice`. Run the
cell. The output should indicate that 50 assets were issued to
`alice`. Change `alice` to `bob` and run the cell again. The output
should indicate that 50 assets were issued to `bob`.

In the "Share Contract" section, change `%%skip True` to `%%skip
False` and run the cell. This should create a "Download Contract"
button. Click the button and save the contract collection file.

**Container_1: Import the issuer contract and create a wallet.** From
the launcher open the notebook in `exchange/factories/wallet.ipynb`.
Run all cells. Repond to the prompts as follows:

* Wallet Owner: `alice`
* Wallet Name: `marbles`

This will create a link to the wallet notebook. Click on the link to
open the notebook. Run all cells.

Scroll down to the "Import Asset Issuers" section. With the widget,
perform the following steps:

* Select "alice" as the identity
* Use the "contract file" button to select the contract file
downloaded earlier; the file should have a name like
`blue_marble_<ID>.zip`
* Specify the Asset Handle as "my_blue_marbles"
* Click on the "Import Contract" button

Repeat the process with the `green_issuer` contract:

* Select "alice" as the identity
* Use the "contract file" button to select the contract file
downloaded earlier; the file should have a name like
`green_marble_<ID>.zip`
* Specify the Asset Handle as "my_green_marbles"
* Click on the "Import Contract" button

To verify that the issuer was successfully imported, click the
"Refresh" button in the "Account Balance" section. The table should
show that asset handles "my_blue_marbles" and "my_green_marbles" have
a balance of 50 .

**Container_2: Import the issuer contract and create a wallet.** From
the launcher open the notebook in `exchange/factories/wallet.ipynb`.
Run all cells. Repond to the prompts as follows:

* Wallet Owner: `bob`
* Wallet Name: `marbles`

This will create a link to the wallet notebook. Click on the link to
open the notebook. Run all cells.

Scroll down to the "Import Asset Issuers" section. With the widget,
perform the following steps:

* Select "bob" as the identity
* Use the "contract file" button to select the contract file
downloaded earlier; the file should have a name like
`blue_marble_<ID>.zip`
* Specify the Asset Handle as "my_blue_marbles"
* Click on the "Import Contract" button

Repeat the process with the `green_issuer` contract:

* Select "bob" as the identity
* Use the "contract file" button to select the contract file
downloaded earlier; the file should have a name like
`green_marble_<ID>.zip`
* Specify the Asset Handle as "my_green_marbles"
* Click on the "Import Contract" button

To verify that the issuer was successfully imported, click the
"Refresh" button in the "Account Balance" section. The table should
show that asset handles "my_blue_marbles" and "my_green_marbles" have
a balance of 50 .

**Container_1: Perform and verify asset transfer.** Scroll down to the
"Transfer Assets" section of the wallet. Click on the "Refresh" button
to reset the widget with the imported contract. With the widget
perform the following steps:

* Select "my_blue_marbles" as the Source Handle
* Set the Amount slider to 20
* Set the New Owner to `bob`
* Click on the "Transfer" button

To verify that the transfer occurred, scroll up to the "Account
Balance" section and click on the "Refresh" button. The balance of
`my_blue_marbles` should be 30.

**Container_2: Verify asset transfer.** To verify that the transfer
occured, refresh the Asset Balance widget and verify that
`my_blue_marbles` balance is now 70 assets.

0 comments on commit ddc0cd1

Please sign in to comment.