The public repository for this project can be found here. You may want to clone it to your local computer for practice.
We created a Docker container with the included Dockerfile
:
$ docker build . -t exercise-w2
We created this repository with Ignite CLI v0.22.1 and the following command:
$ docker run --rm -it -v $(pwd):/exercise -w /exercise exercise-w2 ignite scaffold chain github.com/b9lab/other-world
The idea behind it is that this is the blockchain backing a future metaverse. The blockchain will account for anything of value in it.
We have added:
-
One file that duplicates what accessing the storage looks like:
x/otherworld/keeper/world_params_duplicate.go
. -
And 2 test files:
x/otherworld/types/world_params_student_test.go
x/otherworld/keeper/world_params_student_test.go
All 3 files cannot compile before you have done as per below.
You need to run a Ignite command to create a new Protobuf type and its associated keeper functions that follows this description:
- The name is
WorldParams
. - It has 3 params exactly, no more, no less:
- A
string
for the world'sname
. - A
uint
for the world'sgravity
. - A
uint
for the world'slandSupply
.
- A
- It is unique in the blockchain store. At what key it is stored does not matter, but you should keep the naming conventions of keeper functions chosen by Ignite.
- It should not have any associated messages.
Make these tests pass:
-
x/otherworld/types/world_params_student_test.go
: It needs to pass with:$ docker run --rm -it -v $(pwd):/exercise -w /exercise exercise-w2 go test github.com/b9lab/other-world/x/otherworld/types
Or:
$ go test github.com/b9lab/other-world/x/otherworld/types
-
x/otherworld/keeper/world_params_student_test.go
: It needs to pass with:$ docker run --rm -it -v $(pwd):/exercise -w /exercise exercise-w2 go test github.com/b9lab/other-world/x/otherworld/keeper
Or:
$ go test github.com/b9lab/other-world/x/otherworld/keeper
To run them both at the same time, run:
$ docker run --rm -it -v $(pwd):/exercise -w /exercise exercise-w2 /exercise/score.sh
Or:
$ ./score.sh
In fact, score.sh
is what we run in the Hackerrank environment.
The HackerRank environment presents an online IDE to you, which already contains all the project files. We have also already installed all packages and modules for you. You can start a new Terminal windows by selecting Terminal -> New Terminal in the top menu.
You can run all tests to check your code by clicking on the Run Tests button at the bottom right corner of the IDE.