Skip to content

Commit

Permalink
Merge pull request #2 from CityOfZion/CU-864ej4a4d
Browse files Browse the repository at this point in the history
Add a setup to execute a local Neo network on the boilerplate template
  • Loading branch information
melanke authored Sep 1, 2023
2 parents e2b4c1c + a6815bb commit 8089e7e
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 19 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,13 @@ recommend creating a virtual environment to isolate your Python environment.
├── README.md
└── requirements.txt - Contains the name of the python packages needed to compile the smart contract and run the unit tests.
```

## How to use NeoExpress to locally test your smart contract

Install [NeoExpress requirements](https://github.com/neo-project/neo-express#requirements) and [NeoExpress](https://github.com/neo-project/neo-express#installation).
This repository already has a `.neo-express` file, with two wallets named `admin` and `user`.

Now, you can either test manually by running NeoExpress directly, or you can write a Python script that imports
`NeoTestRunner`. On the `unit_tests` folder, you'll find that the classes that inherit `TestCase` already
come with a `NeoTestRunner` object implemented. Check out the [Neo3-boa documentation](https://neo3.readthedocs.io/en/latest/sc/quickstart.html#testing)
for more information on how to invoke methods and assert the results using `NeoTestRunner`.
30 changes: 15 additions & 15 deletions default.neo-express
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"magic": 794836317,
"magic": 4166153244,
"address-version": 53,
"consensus-nodes": [
{
Expand All @@ -10,24 +10,24 @@
"name": "node1",
"accounts": [
{
"private-key": "35a0413af7984650c9886f65af75e6089a145d2ef1b3a0ac821736f015e47e71",
"script-hash": "NRE8hRkmQgnp3T32FcAVhdRSy7p2bF5vu8",
"private-key": "e28fcca918492cd87f82cafc7689e8d3d7e811754c7c97c0d4c8c6255429be5e",
"script-hash": "NLHN3gRLQhnkDppc956pdzbCWV9XerCkWd",
"label": null,
"is-default": true,
"contract": {
"script": "0c2102eb865d2739cee1591dfc27e39410f6992b0774298e2068ebfebadb84803b6b4a4156e7b327",
"script": "0c21036fede24b0474eee8b79cc4c7c31c9d5cc4274dfc7a5ee6fe972a96cd3c700a404156e7b327",
"parameters": [
"Signature"
]
}
},
{
"private-key": "35a0413af7984650c9886f65af75e6089a145d2ef1b3a0ac821736f015e47e71",
"script-hash": "NcuzvaCecvsstxu1DptHucr7BCNtnZdXf5",
"private-key": "e28fcca918492cd87f82cafc7689e8d3d7e811754c7c97c0d4c8c6255429be5e",
"script-hash": "NREh5jyjBXFXFY57YJf1UU2BDNaXnb8fWw",
"label": "Consensus MultiSigContract",
"is-default": false,
"contract": {
"script": "110c2102eb865d2739cee1591dfc27e39410f6992b0774298e2068ebfebadb84803b6b4a11419ed0dc3a",
"script": "110c21036fede24b0474eee8b79cc4c7c31c9d5cc4274dfc7a5ee6fe972a96cd3c700a4011419ed0dc3a",
"parameters": [
"Signature"
]
Expand All @@ -39,15 +39,15 @@
],
"wallets": [
{
"name": "testAccount1",
"name": "admin",
"accounts": [
{
"private-key": "d63b5a0e5bcbae91a38ecb2166f4264cd5c637e9b2815b4229e33b6b5edc7e7d",
"script-hash": "Ngj3na4mCrRc3SMSTtW92sbsMDhVqCK9XH",
"private-key": "b1a851cf1542b08202614b2bcd1b74f5e859d345e02bab10de63b95990043860",
"script-hash": "NQQaLK9SKJ3b5ch3LnXhPJ8N93cGCL8GXC",
"label": null,
"is-default": true,
"contract": {
"script": "0c21035bcdd1b178310ea9c21b16360e2a247faaeb544d1077ec10767c8a36960c32c34156e7b327",
"script": "0c2102d0874cbd6a915d5fcf4ca3a5a6d4c35ae688a8bd2c8e116ab0af8e3dcdd1756b4156e7b327",
"parameters": [
"Signature"
]
Expand All @@ -56,15 +56,15 @@
]
},
{
"name": "testAccount2",
"name": "user",
"accounts": [
{
"private-key": "30f840d06d939f1a2319b1b67d975446085fcfdfea250699170aee1800c9a554",
"script-hash": "NhvTVBz56diqxag7hCd36a5j63AjCvrVd9",
"private-key": "1903eabb883c11f8c2f37ca9450bb06ea82cd7b47cedd4468941c423c900513b",
"script-hash": "NcrPRGfJu6aDT7WX3K75wfEtB93UrryozT",
"label": null,
"is-default": true,
"contract": {
"script": "0c2103b5b1f366bb375c1e2806ed1c448f7b9c3b9770aba0bcbd25fdb7a77461e5ea864156e7b327",
"script": "0c21031d928728ccadac4a547a42b9cd6bda9b4adde3ff4ec1e52d405b929e7048e7814156e7b327",
"parameters": [
"Signature"
]
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
neo3-boa==0.13.1
neo3-boa==1.0.2
25 changes: 22 additions & 3 deletions unit_tests/test_hello_world.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,26 @@
from unittest import TestCase
import unittest
import os.path

from boa3.boa3 import Boa3
from boa3_test.test_drive.testrunner.neo_test_runner import NeoTestRunner

class TestHelloWorld(TestCase):
PROJECT_PATH = os.sep.join(os.path.dirname(__file__).split(os.sep)[:-1])

def test_compile(self):
class TestHelloWorld(unittest.TestCase):
neoxp_config_file = PROJECT_PATH + '/default.neo-express'
smart_contract_root_folder = PROJECT_PATH + '/smart_contracts'
smart_contract_path = PROJECT_PATH + '/smart_contracts/hello_world.py'
nef_path = smart_contract_path.replace('.py', '.nef')

runner: NeoTestRunner = None

@classmethod
def setUpClass(cls):
Boa3.compile_and_save(cls.smart_contract_path)
cls.runner = NeoTestRunner(cls.neoxp_config_file)

def test_method(self):
pass

if __name__ == '__main__':
unittest.main()

0 comments on commit 8089e7e

Please sign in to comment.