Skip to content

Commit 43b6914

Browse files
authored
Hyperledger Caliper for Peerplays (#2)
* Caliper v0.4.0, d9f2cc8cf9419d9b7c06c4c91077514d27d3b546 * Peerplays connector * Docker img for private network, connector and workload fixes * Peerplays connector fixes and integration tests * Peerplays integration tests for read-only calls * Peerplays integration tests for transactions * Improvements to support both mainnet and testnet * Develop branch tests
1 parent eb0fafb commit 43b6914

File tree

291 files changed

+14632
-9784
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

291 files changed

+14632
-9784
lines changed

caliper-peerplays-tests/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
**/node_modules/
2+
**/*.log
3+
**/report.html
4+
package-lock.json

caliper-peerplays-tests/README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Hyperledger Caliper tests for Peerplays
2+
3+
## Initializing
4+
To initialize test environment, run
5+
```
6+
npm i
7+
```
8+
Test environment uses packages from ../caliper-peerplays
9+
10+
## Running tests
11+
12+
Run basic-private-net tests.
13+
This test is the same as Hyperledger Caliper integration test
14+
```
15+
BENCHMARK=basic-private-net ./run-tests.sh
16+
```
17+
18+
Run develop-private-net tests.
19+
```
20+
BENCHMARK=develop-private-net ./run-tests.sh
21+
```
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#
2+
# Licensed under the Apache License, Version 2.0 (the "License");
3+
# you may not use this file except in compliance with the License.
4+
# You may obtain a copy of the License at
5+
#
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
#
14+
15+
test:
16+
workers:
17+
type: local
18+
number: 2
19+
rounds:
20+
- label: claim_balance
21+
txNumber: 1
22+
rateControl: { type: 'fixed-rate', opts: { tps: 1 } }
23+
workload:
24+
module: ./claim_balance.js
25+
- label: query
26+
txNumber: 200
27+
rateControl: { type: 'fixed-feedback-rate', opts: { tps: 10, maximum_transaction_load: 5 } }
28+
workload:
29+
module: ./query.js
30+
- label: transfer
31+
txNumber: 100
32+
rateControl: { type: 'linear-rate', opts: { startingTps: 5, finishingTps: 20 } }
33+
workload:
34+
module: ./transfer.js
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#
2+
# Licensed under the Apache License, Version 2.0 (the "License");
3+
# you may not use this file except in compliance with the License.
4+
# You may obtain a copy of the License at
5+
#
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
#
14+
15+
caliper:
16+
benchconfig: benchconfig.yaml
17+
networkconfig: networkconfig.json
18+
txupdatetime: 500
19+
workspace: ./
20+
report:
21+
path: report.html
22+
logging:
23+
template: '%timestamp%%level%%module%%message%%metadata%'
24+
formats:
25+
timestamp: 'YYYY.MM.DD-HH:mm:ss.SSS ZZ'
26+
label: false
27+
json: false
28+
pad: true
29+
align: false
30+
attributeformat:
31+
level: ' %attribute%'
32+
module: ' [%attribute%] '
33+
metadata: ' (%attribute%)'
34+
colorize:
35+
all: true
36+
colors:
37+
info: green
38+
error: red
39+
warn: yellow
40+
debug: grey
41+
targets:
42+
console:
43+
target: console
44+
enabled: true
45+
options:
46+
level: info
47+
file:
48+
target: file
49+
enabled: false
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/*
2+
* Licensed under the Apache License, Version 2.0 (the "License");
3+
* you may not use this file except in compliance with the License.
4+
* You may obtain a copy of the License at
5+
*
6+
* http://www.apache.org/licenses/LICENSE-2.0
7+
*
8+
* Unless required by applicable law or agreed to in writing, software
9+
* distributed under the License is distributed on an "AS IS" BASIS,
10+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
* See the License for the specific language governing permissions and
12+
* limitations under the License.
13+
*/
14+
15+
'use strict';
16+
17+
const {WorkloadModuleBase} = require('@hyperledger/caliper-core');
18+
const {ChainConfig} = require("peerplaysjs-lib");
19+
20+
class PeerplaysClaimBalanceWorkload extends WorkloadModuleBase {
21+
constructor() {
22+
super();
23+
}
24+
25+
async initializeWorkloadModule(workerIndex, totalWorkers, roundIndex, roundArguments, sutAdapter, sutContext) {
26+
await super.initializeWorkloadModule(workerIndex, totalWorkers, roundIndex, roundArguments, sutAdapter, sutContext);
27+
}
28+
29+
async submitTransaction() {
30+
if (this.workerIndex == 0) {
31+
let args = [
32+
{
33+
api_name: null,
34+
method: 'balance_claim',
35+
params: [
36+
{
37+
fee: {
38+
amount: 0,
39+
asset_id: '1.3.0'
40+
},
41+
deposit_to_account: '1.2.18',
42+
balance_to_claim: '1.15.0',
43+
balance_owner_key: 'TEST6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV',
44+
total_claimed: {
45+
amount: 1000000000000000,
46+
asset_id: '1.3.0'
47+
}
48+
}
49+
],
50+
readOnly: false
51+
}
52+
];
53+
await this.sutAdapter.sendRequests(args);
54+
} else {
55+
let args = [
56+
{
57+
api_name: 'database',
58+
method: 'get_account_balances',
59+
params: ['nathan', []],
60+
readOnly: true
61+
}
62+
];
63+
await this.sutAdapter.sendRequests(args);
64+
}
65+
}
66+
67+
async cleanupWorkloadModule() {
68+
//
69+
}
70+
}
71+
72+
function createWorkloadModule() {
73+
return new PeerplaysClaimBalanceWorkload();
74+
}
75+
76+
module.exports.createWorkloadModule = createWorkloadModule;
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#
2+
# Licensed under the Apache License, Version 2.0 (the "License");
3+
# you may not use this file except in compliance with the License.
4+
# You may obtain a copy of the License at
5+
#
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
#
14+
15+
FROM datasecuritynode/peerplays:develop
16+
17+
RUN /usr/local/bin/witness_node --create-genesis-json /peerplays/genesis.json --data-dir=/peerplays/witness_node_data_dir && \
18+
sed -i 's/"initial_timestamp".*/"initial_timestamp": "2020-03-03T03:03:03",/' /peerplays/genesis.json && \
19+
sed -i 's/"maintenance_interval".*/"maintenance_interval": 600,/' /peerplays/genesis.json && \
20+
sed -i 's/"committee_proposal_review_period".*/"committee_proposal_review_period": 600,/' /peerplays/genesis.json && \
21+
sed -i 's/"son_deregister_time".*/"son_deregister_time": 600,/' /peerplays/genesis.json && \
22+
sed -i 's/"son_heartbeat_frequency".*/"son_heartbeat_frequency": 120,/' /peerplays/genesis.json && \
23+
sed -i 's/"son_bitcoin_min_tx_confirmations".*/"son_bitcoin_min_tx_confirmations": 1/' /peerplays/genesis.json && \
24+
sed -i 's/.*p2p-endpoint.*/p2p-endpoint = 0.0.0.0:9777/' /peerplays/witness_node_data_dir/config.ini && \
25+
sed -i 's/.*seed-node[^s].*/\# seed-node = /' /peerplays/witness_node_data_dir/config.ini && \
26+
sed -i 's/.*seed-nodes.*/seed-nodes = \[\]/' /peerplays/witness_node_data_dir/config.ini && \
27+
sed -i 's/.*rpc-endpoint.*/rpc-endpoint = 0.0.0.0:8090/' /peerplays/witness_node_data_dir/config.ini && \
28+
sed -i 's/.*genesis-json.*/genesis-json = genesis.json/' /peerplays/witness_node_data_dir/config.ini && \
29+
sed -i '/^plugins/ s/$/ peerplays_sidechain/' /peerplays/witness_node_data_dir/config.ini && \
30+
sed -i 's/.*enable-stale-production.*/enable-stale-production = true/' /peerplays/witness_node_data_dir/config.ini && \
31+
sed -i 's/.*witness-id[^s].*/# witness-id = /' /peerplays/witness_node_data_dir/config.ini && \
32+
sed -i 's/.*witness-ids.*/witness-ids = \["1.6.1", "1.6.2", "1.6.3", "1.6.4", "1.6.5", "1.6.6", "1.6.7", "1.6.8", "1.6.9", "1.6.10", "1.6.11"\]/' /peerplays/witness_node_data_dir/config.ini && \
33+
sed -i 's/^private-key.*$/private-key = \["TEST6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", "5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3"\]/' /peerplays/witness_node_data_dir/config.ini && \
34+
sed -i 's/^debug-private-key.*$/debug-private-key = \["TEST6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV", "5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3"\]/' /peerplays/witness_node_data_dir/config.ini
35+
36+
EXPOSE 8090
37+
EXPOSE 9777
38+
39+
ENTRYPOINT cd /peerplays && witness_node --data-dir=/peerplays/witness_node_data_dir
Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
# Endpoint for P2P node to listen on
2+
p2p-endpoint = 0.0.0.0:9777
3+
4+
# P2P nodes to connect to on startup (may specify multiple times)
5+
# seed-node =
6+
7+
# JSON array of P2P nodes to connect to on startup
8+
seed-nodes = []
9+
10+
# Pairs of [BLOCK_NUM,BLOCK_ID] that should be enforced as checkpoints.
11+
# checkpoint =
12+
13+
# Endpoint for websocket RPC to listen on
14+
rpc-endpoint = 0.0.0.0:8090
15+
16+
# Endpoint for TLS websocket RPC to listen on
17+
# rpc-tls-endpoint =
18+
19+
# The TLS certificate file for this server
20+
# server-pem =
21+
22+
# Password for this certificate
23+
# server-pem-password =
24+
25+
# File to read Genesis State from
26+
genesis-json = genesis.json
27+
28+
# Block signing key to use for init witnesses, overrides genesis file
29+
# dbg-init-key =
30+
31+
# JSON file specifying API permissions
32+
# api-access =
33+
34+
# Whether to enable tracking of votes of standby witnesses and committee members. Set it to true to provide accurate data to API clients, set to false for slightly better performance.
35+
# enable-standby-votes-tracking =
36+
37+
# Space-separated list of plugins to activate
38+
# plugins =
39+
40+
# Enable block production, even if the chain is stale.
41+
enable-stale-production = true
42+
43+
# Percent of witnesses (0-99) that must be participating in order to produce blocks
44+
required-participation = false
45+
46+
# ID of witness controlled by this node (e.g. "1.6.5", quotes are required, may specify multiple times)
47+
# witness-id =
48+
49+
# IDs of multiple witnesses controlled by this node (e.g. ["1.6.5", "1.6.6"], quotes are required)
50+
witness-ids = ["1.6.1", "1.6.2", "1.6.3", "1.6.4", "1.6.5", "1.6.6", "1.6.7", "1.6.8", "1.6.9", "1.6.10", "1.6.11"]
51+
52+
# Tuple of [PublicKey, WIF private key] (may specify multiple times)
53+
private-key = ["TEST6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV","5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3"]
54+
55+
# Tuple of [PublicKey, WIF private key] (may specify multiple times)
56+
debug-private-key = ["TEST6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV","5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3"]
57+
58+
# Account ID to track history for (may specify multiple times)
59+
# track-account =
60+
61+
# Keep only those operations in memory that are related to account history tracking
62+
partial-operations = 1
63+
64+
# Maximum number of operations per account will be kept in memory
65+
max-ops-per-account = 100
66+
67+
# Elastic Search database node url(http://localhost:9200/)
68+
# elasticsearch-node-url =
69+
70+
# Number of bulk documents to index on replay(10000)
71+
# elasticsearch-bulk-replay =
72+
73+
# Number of bulk documents to index on a syncronied chain(100)
74+
# elasticsearch-bulk-sync =
75+
76+
# Use visitor to index additional data(slows down the replay(false))
77+
# elasticsearch-visitor =
78+
79+
# Pass basic auth to elasticsearch database('')
80+
# elasticsearch-basic-auth =
81+
82+
# Add a prefix to the index(peerplays-)
83+
# elasticsearch-index-prefix =
84+
85+
# Save operation as object(false)
86+
# elasticsearch-operation-object =
87+
88+
# Start doing ES job after block(0)
89+
# elasticsearch-start-es-after-block =
90+
91+
# Save operation as string. Needed to serve history api calls(true)
92+
# elasticsearch-operation-string =
93+
94+
# Mode of operation: only_save(0), only_query(1), all(2) - Default: 0
95+
# elasticsearch-mode =
96+
97+
# Elasticsearch node url(http://localhost:9200/)
98+
# es-objects-elasticsearch-url =
99+
100+
# Basic auth username:password('')
101+
# es-objects-auth =
102+
103+
# Number of bulk documents to index on replay(10000)
104+
# es-objects-bulk-replay =
105+
106+
# Number of bulk documents to index on a synchronized chain(100)
107+
# es-objects-bulk-sync =
108+
109+
# Store proposal objects(true)
110+
# es-objects-proposals =
111+
112+
# Store account objects(true)
113+
# es-objects-accounts =
114+
115+
# Store asset objects(true)
116+
# es-objects-assets =
117+
118+
# Store balances objects(true)
119+
# es-objects-balances =
120+
121+
# Store limit order objects(true)
122+
# es-objects-limit-orders =
123+
124+
# Store feed data(true)
125+
# es-objects-asset-bitasset =
126+
127+
# Add a prefix to the index(ppobjects-)
128+
# es-objects-index-prefix =
129+
130+
# Keep only current state of the objects(true)
131+
# es-objects-keep-only-current =
132+
133+
# Start doing ES job after block(0)
134+
# es-objects-start-es-after-block =
135+
136+
# Track market history by grouping orders into buckets of equal size measured in seconds specified as a JSON array of numbers
137+
bucket-size = [15,60,300,3600,86400]
138+
139+
# How far back in time to track history for each bucket size, measured in the number of buckets (default: 1000)
140+
history-per-size = 1000
141+
142+
# Block number after which to do a snapshot
143+
# snapshot-at-block =
144+
145+
# Block time (ISO format) after which to do a snapshot
146+
# snapshot-at-time =
147+
148+
# Pathname of JSON file where to store the snapshot
149+
# snapshot-to =
150+
151+
152+
# ==============================================================================
153+
# logging options
154+
# ==============================================================================
155+
#
156+
# Logging configuration is loaded from logging.ini by default.
157+
# If logging.ini exists, logging configuration added in this file will be ignored.

0 commit comments

Comments
 (0)