mirror of
https://github.com/tappollo/quorum-examples.git
synced 2026-01-12 22:45:20 +08:00
More example contracts and tmux for testing. (#112)
This commit is contained in:
30
examples/7nodes/contracts/README.md
Normal file
30
examples/7nodes/contracts/README.md
Normal 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
@@ -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
@@ -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]});
|
||||
}
|
||||
13
examples/7nodes/contracts/tmux_connect_to_nodes.sh
Executable file
13
examples/7nodes/contracts/tmux_connect_to_nodes.sh
Executable 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
|
||||
Reference in New Issue
Block a user