Step 1: Build sample-actor and Run Unit Test
Build sample-actor
The output of the build process is a Webassembly binary called sample-actor.wasm
. This binary executable code will be loaded into the TEA-runtime which we'll talk about more in future steps. Now let's focus on how to build it.
Please make sure you've cloned the code and installed all dependencies as instructed in the previous step. In particular, make sure the following items have been installed correctly:
rust nightly
wasm32-unknown-unknown target
protobuf
Now cd sample-actor
and run ./build.sh
to build the actor.
Once built successfully, you can find the wasm file sample_actor.wasm
in the sample-actor/target/wasm32-unknown-unknown/release
folder. Note that in this step of the tutorial, we won't deploy to the TEA Project testnet, nor run in local single node development environment. We'll describe them more in later steps. In this initial step, we'll only run the unit test.
The build.sh script will also try to copy the sample-actor.wasm file to the ~/local/b-node
folder of the dev-runner
repo. You'll get an error because you don't have that folder yet, but you'll create that folder in the next step of "running local development environment" tutorial.
If you get another error message, it's most likely due to some missing pieces in your development environment. Please go back and check for missing steps.
Run sample-actor unit test
In this step, we won't run the sample-actor in your local development environment (called dev-runner). Instead, we'll just run a unit test.
You can run cargo test
to run all the unit tests. You should see the test results as follows:
When you want to test a request handler and expect it to return an error, you can use the following example:
You should see that the tests have passed.
We highly recommend to write and run a unit test whenever you add / modify code. Building and deploying onto the testnet usually will take much longer than simply running a local unit test.
Run sample-front-end
First from the root of the code repo, cd sample-front-end
. If your backend has a different IP or port number other than the default localhost:8000, please edit the .env.test
file to edit in your customized values:
This address will be your backend service address.
Run the following to install dependencies: npm install
Then start the frontend local web server by running: npm start
If you can see the following:
then your frontend is up and running.
At this moment, you cannot send requests to the backend and get a "hello world" message yet. We'll get into the local development environment in the next step.
You can send Ctrl + C
to stop the frontend now.
Last updated