More example contracts and tmux for testing. (#112)

This commit is contained in:
libby kent
2018-09-10 16:34:17 -04:00
committed by fixanoid
parent 4a1edd2d84
commit 930b8a5bb0
6 changed files with 132 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
## Testing Contract Playground
## Connecting to multiple nodes
* run tmux script which by default connects to nodes 1, 2, and 7.
```
$> ./tmux_connect_to_nodes.sh
# to kill the tmux session run
$> tmux kill-session -t quorum
```
# Creating Contracts
```
$> cd quorum-examples/examples/7nodes
$> ./runscript.sh contracts/simple-event/private-contract-events.js
```
# Testing Multiple Transactions
* Obtain the address of the contract that was deployed.
* set that address in the test scripts
`var address="0x1932c48b2bf8102ba33b4a6b545c32236e342f34"`
```
$> cd quorum-examples/examples/7nodes
$> ./runscript.sh contracts/simple-event/private-generate-events.js
```

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,12 @@
// From the console test nodes 1 & 7 to see if the events were recorded
// seth is a cool cli tool that can be used see: https://github.com/dapphub/dapptools
// $> seth events 0x1932c48b2bf8102ba33b4a6b545c32236e342f34 | wc -l
var address="0x1932c48b2bf8102ba33b4a6b545c32236e342f34"
// simple contract
var abi = [{"constant":true,"inputs":[],"name":"storedData","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"x","type":"uint256"}],"name":"set","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"get","outputs":[{"name":"retVal","type":"uint256"}],"payable":false,"type":"function"},{"inputs":[{"name":"initVal","type":"uint256"}],"payable":false,"type":"constructor"}];
var contract = eth.contract(abi).at(address)
for ( i = 0; i < 20; i++) {
contract.set(4,{from:eth.accounts[0], privateFor:["ROAZBWtSacxXQrOe3FGAqJDyJjFePR5ce4TSIzmJ0Bc="]});
}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,15 @@
// From console test node 1 & 7 to see if the events were recorded
// seth is a cool CLI (but you can use whatever you'd like): https://github.com/dapphub/dapptools
// $> seth events 0x1932c48b2bf8102ba33b4a6b545c32236e342f34 | wc -l
// NOTE: replace this with the address of the contract you wish to generate
// events for.
var address="0x1932c48b2bf8102ba33b4a6b545c32236e342f34"
// simple contract
var abi = [{"constant":true,"inputs":[],"name":"storedData","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"x","type":"uint256"}],"name":"set","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"get","outputs":[{"name":"retVal","type":"uint256"}],"payable":false,"type":"function"},{"inputs":[{"name":"initVal","type":"uint256"}],"payable":false,"type":"constructor"}];
var contract = eth.contract(abi).at(address)
for ( i = 0; i < 20; i++) {
contract.set(4,{from:eth.accounts[0]});
}

View File

@@ -0,0 +1,13 @@
#!/bin/bash
set -x
# example usage:
# $> ./tmux_connect_to_nodes.sh
tmux new -s quorum 'geth attach ../qdata/dd1/geth.ipc' \; \
splitw -h -p 50 "geth attach ../qdata/dd7/geth.ipc; bash" \; \
splitw -v -p 50 "geth attach ../qdata/dd2/geth.ipc; bash" \;
# To stop the session run:
# $> tmux kill-session -t quorum