Nano-node: how to create a testnet?

Created on 8 Jan 2018  Â·  7Comments  Â·  Source: nanocurrency/nano-node

Couldn't find any info on how to create a testnet to test integration with other services, how could this be done? And while at it, how the current acceptance tests work?

question

Most helpful comment

Well, here is my way:

  1. Configure ACTIVE_NETWORK to rai_test_network with cmake gui tool and then rebuild the source.

  2. Run rai_node with the following command:
    ./rai_node --daemon --data_path data-dir

  3. Edit config.json in data-dir:
    set rpc_enable and enable_control to true

4.restart rai_node with the command in step 2

5.install raiblocks rpc library for python with the following command:
python -m pip install raiblocks

6.Test with the python code below:

from raiblocks import RPCClient
rpc = RPCClient('http://localhost:55000')
w = rpc.wallet_create()
print('wallet id:',w)

test_private_key = '34F0A37AAD20F4A260F0A5B3CB3D7FB50673212263E58A380BC10474BB039CE4'
test_account = rpc.wallet_add(w, test_private_key)
print('test genesis account:', test_account)

r = rpc.account_balance(test_account)
print('test_account balance:', r)

new_account = rpc.account_create(w)

r = rpc.account_balance(new_account)
print('balance of %s after account created:%s'%(new_account,r))

block_hash = rpc.send(w, test_account, new_account, 10000)
r = rpc.account_balance(new_account)
print('balance of %s after sent:%s'%(new_account,r))

rpc.receive(w, new_account, block_hash)
r = rpc.account_balance(new_account)
print('balance of %s after received:%s'%(new_account,r))

You will be able to see the following output:

wallet id: BBF38FB45A91B8AB43EBEEE1A59B598280FE0F0EC357070A9FA6793C30CDD250
test genesis account: xrb_3e3j5tkog48pnny9dmfzj1r16pg8t1e76dz5tmac6iq689wyjfpiij4txtdo
test_account balance: {'balance': 340282366920938463463374607431768201455, 'pending': 0}
balance of xrb_151qb7uc6u5sn4tqgdqxr3kfsscnbqfdmx1ph1ffzaw7nbzpiyp7qtrxy7i8 after created account:{'balance': 0, 'pending': 0}
balance of xrb_151qb7uc6u5sn4tqgdqxr3kfsscnbqfdmx1ph1ffzaw7nbzpiyp7qtrxy7i8 after sent:{'balance': 0, 'pending': 10000}
balance of xrb_151qb7uc6u5sn4tqgdqxr3kfsscnbqfdmx1ph1ffzaw7nbzpiyp7qtrxy7i8 after received:{'balance': 10000, 'pending': 0}

7.Happy coding!

On 20 Jan 2018, at 8:31 PM, Paulo Cesar notifications@github.com wrote:

yeah, because sending useless 1 raw transactions to yourself in the mainnet for the sake of testing isn't a nice way to test heh

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub https://github.com/clemahieu/raiblocks/issues/443#issuecomment-359168130, or mute the thread https://github.com/notifications/unsubscribe-auth/Ad6ZPijSysJFWBqK1CNMKMYDgDjIIpp3ks5tMdy8gaJpZM4RV7C5.

All 7 comments

Not completely answering your question as to HOW to create a test net, but search through the code base for "rai_test_network" should turn up some answers.

yeah, because sending useless 1 raw transactions to yourself in the mainnet for the sake of testing isn't a nice way to test heh

Well, here is my way:

  1. Configure ACTIVE_NETWORK to rai_test_network with cmake gui tool and then rebuild the source.

  2. Run rai_node with the following command:
    ./rai_node --daemon --data_path data-dir

  3. Edit config.json in data-dir:
    set rpc_enable and enable_control to true

4.restart rai_node with the command in step 2

5.install raiblocks rpc library for python with the following command:
python -m pip install raiblocks

6.Test with the python code below:

from raiblocks import RPCClient
rpc = RPCClient('http://localhost:55000')
w = rpc.wallet_create()
print('wallet id:',w)

test_private_key = '34F0A37AAD20F4A260F0A5B3CB3D7FB50673212263E58A380BC10474BB039CE4'
test_account = rpc.wallet_add(w, test_private_key)
print('test genesis account:', test_account)

r = rpc.account_balance(test_account)
print('test_account balance:', r)

new_account = rpc.account_create(w)

r = rpc.account_balance(new_account)
print('balance of %s after account created:%s'%(new_account,r))

block_hash = rpc.send(w, test_account, new_account, 10000)
r = rpc.account_balance(new_account)
print('balance of %s after sent:%s'%(new_account,r))

rpc.receive(w, new_account, block_hash)
r = rpc.account_balance(new_account)
print('balance of %s after received:%s'%(new_account,r))

You will be able to see the following output:

wallet id: BBF38FB45A91B8AB43EBEEE1A59B598280FE0F0EC357070A9FA6793C30CDD250
test genesis account: xrb_3e3j5tkog48pnny9dmfzj1r16pg8t1e76dz5tmac6iq689wyjfpiij4txtdo
test_account balance: {'balance': 340282366920938463463374607431768201455, 'pending': 0}
balance of xrb_151qb7uc6u5sn4tqgdqxr3kfsscnbqfdmx1ph1ffzaw7nbzpiyp7qtrxy7i8 after created account:{'balance': 0, 'pending': 0}
balance of xrb_151qb7uc6u5sn4tqgdqxr3kfsscnbqfdmx1ph1ffzaw7nbzpiyp7qtrxy7i8 after sent:{'balance': 0, 'pending': 10000}
balance of xrb_151qb7uc6u5sn4tqgdqxr3kfsscnbqfdmx1ph1ffzaw7nbzpiyp7qtrxy7i8 after received:{'balance': 10000, 'pending': 0}

7.Happy coding!

On 20 Jan 2018, at 8:31 PM, Paulo Cesar notifications@github.com wrote:

yeah, because sending useless 1 raw transactions to yourself in the mainnet for the sake of testing isn't a nice way to test heh

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub https://github.com/clemahieu/raiblocks/issues/443#issuecomment-359168130, or mute the thread https://github.com/notifications/unsubscribe-auth/Ad6ZPijSysJFWBqK1CNMKMYDgDjIIpp3ks5tMdy8gaJpZM4RV7C5.

Thank @learnforpractice.

We can run testnet easily with Docker.

  1. Build Docker image using testnet
./docker/node/build.sh -n test 
  1. Start nano testnet
docker run -d \
    --name nano-testnet \
    -p 7075:7075/udp \
    -p 7075:7075 \
    -p 127.0.0.1:7076:7076 \
    -v RaiBlocksTest:/root/RaiBlocksTest \
    raiblocks-node-test
  1. Test with Python code like above.
    https://github.com/dourvaris/nano-python
from nano import RPCClient


rpc = RPCClient('http://localhost:7076')

w = rpc.wallet_create()
print('wallet id:', w)

test_private_key = '34F0A37AAD20F4A260F0A5B3CB3D7FB50673212263E58A380BC10474BB039CE4'
test_account = rpc.wallet_add(w, test_private_key)
print('test genesis account:', test_account)

r = rpc.account_balance(test_account)
print('test_account balance:', r)

new_account = rpc.account_create(w)

r = rpc.account_balance(new_account)
print('balance of %s after account created:%s' % (new_account, r))


block_hash = rpc.send(w, test_account, new_account, 10000)
r = rpc.account_balance(new_account)
print('balance of %s after sent:%s' % (new_account, r))


rpc.receive(w, new_account, block_hash)
r = rpc.account_balance(new_account)
print('balance of %s after received:%s' % (new_account, r))

Another option is to use the Nano beta network, if a global network is needed.

I'm going to close this ticket since there appears to have been a response that is useful and no further follow-up from the requester.

If I want to build a testnet with a few peers, how can i do?
I have already run two single nodes in docker by the instruction given by @cuongtransc, but they cannot connect to each other even I have called ''work_peer_add" RPC.
Many thanks in advance!

How can i connect two single nodes to make them sync with each other in this testnet?
I have run two nodes with the code given by @cuongtransc, but they are not connected even I have called 'work_peer_add' with RPC.
and I got the log:
`[2018-10-22 06:01:40.532523]: 0x7fa7b0004920 {"action": "account_create","wallet": "B3E4BC10D934B66F54038B91168453361337AF089DEEC70ABE079AD3AC4FBDF0"}
Any suggestions? Thanks in advance!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

paulmelis picture paulmelis  Â·  6Comments

androm3da picture androm3da  Â·  3Comments

sacreman picture sacreman  Â·  6Comments

bbedward picture bbedward  Â·  3Comments

liuhailin picture liuhailin  Â·  5Comments