diff --git a/packages/ledger-plugin/sawtooth/validator/unit-test/.gitignore b/packages/ledger-plugin/sawtooth/validator/unit-test/.gitignore deleted file mode 100644 index b8ffe08f2c..0000000000 --- a/packages/ledger-plugin/sawtooth/validator/unit-test/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -node_modules/ -package-lock.json - diff --git a/packages/ledger-plugin/sawtooth/validator/unit-test/README.md b/packages/ledger-plugin/sawtooth/validator/unit-test/README.md deleted file mode 100644 index 05c3a99607..0000000000 --- a/packages/ledger-plugin/sawtooth/validator/unit-test/README.md +++ /dev/null @@ -1,58 +0,0 @@ - -# BIF-trial(Validator Driver) - -## Assumption -- Validator1 (for Ethereum) is running -- geth1(geth-docker) is running -- Specify the validator URL to connect to with "validatorUrl" in "config/default.js" - -## a) Get balance -### Target source: validatorDriver_getNumericBalance.js - -1) Specify the parameters in the target source - - - referedAddress: Account ID to be displayed - -2) Run -
-node validatorDriver_getNumericBalance.js -- -## b) Asset transfer -### Target source: validatorDriver_transferNumericAsset.js - -1) Specify the parameters in the target source - - - fromAddress: Transfer source account ID - - toAddress: Destination account ID - - amount: the value of the asset to be transferred - -2) Run -
-node validatorDriver_transferNumericAsset.js -- -## c) Raw Transaction execution (Asset transfer) -### Target source: validatorDriver_sendRawTransaction.js - -1) Specify the parameters in the target source - - - fromAddress: Transfer source account ID - - fromAddressPkey: private key of Transfer source account - - toAddress: Destination account ID - - amount: the value of the asset to be transferred - -2) Run -
-node validatorDriver_sendRawTransaction.js -- - -**NOTE** - -* You can check the balance with "validatorDriver_getNumericBalance.js". diff --git a/packages/ledger-plugin/sawtooth/validator/unit-test/config/default.js b/packages/ledger-plugin/sawtooth/validator/unit-test/config/default.js deleted file mode 100644 index e5ce005fea..0000000000 --- a/packages/ledger-plugin/sawtooth/validator/unit-test/config/default.js +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright 2021 Hyperledger Cactus Contributors - * SPDX-License-Identifier: Apache-2.0 - * - * default.js - */ - -module.exports = { - // URL to validator - "validatorUrl" : 'https://localhost:5050', - "gethUrl" : 'http://localhost:8545', - - // forCustomChain - "chainName": 'geth1', - "networkId": 10, - "chainId": 10 - -}; diff --git a/packages/ledger-plugin/sawtooth/validator/unit-test/copyStaticAssets.ts b/packages/ledger-plugin/sawtooth/validator/unit-test/copyStaticAssets.ts deleted file mode 100644 index c4885fe49c..0000000000 --- a/packages/ledger-plugin/sawtooth/validator/unit-test/copyStaticAssets.ts +++ /dev/null @@ -1,4 +0,0 @@ -# Copyright 2021 Hyperledger Cactus Contributors -# SPDX-License-Identifier: Apache-2.0 -import * as shell from 'shelljs'; -shell.cp('config/default.js', './dist/config'); diff --git a/packages/ledger-plugin/sawtooth/validator/unit-test/geth-docker/.gitignore b/packages/ledger-plugin/sawtooth/validator/unit-test/geth-docker/.gitignore deleted file mode 100644 index 53a9595130..0000000000 --- a/packages/ledger-plugin/sawtooth/validator/unit-test/geth-docker/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -data-ec1 -data-ec2 -genesis/genesis-ec1.json -genesis/genesis-ec2.json - diff --git a/packages/ledger-plugin/sawtooth/validator/unit-test/geth-docker/README.md b/packages/ledger-plugin/sawtooth/validator/unit-test/geth-docker/README.md deleted file mode 100644 index 0ea91daa10..0000000000 --- a/packages/ledger-plugin/sawtooth/validator/unit-test/geth-docker/README.md +++ /dev/null @@ -1,102 +0,0 @@ - -# BIF-trial(geth-docker) - -## Explanation -- "geth-docker" is a module required to run "Validator" -- Immediately after applying -geth-docker, it is necessary to perform "a) initialization" -- How to start/stop will be explained follow - -## a) Initialization -### 1) Account creation -
-./init-account.sh -- -Please keep in your memo the addresses (ec1-accounts[0],[1],..,[4] and ec2-accounts[0],[1],..,[4]), - -* Sample output -
- make-account-ec1-accounts[0] - Creating network "ecenv_default" with the default driver - INFO [05-29|08:33:35.658] Maximum peer count ETH=25 LES=0 total=25 - Address: {782646267c64d536983a64af9d9a5ab80e036989} - - make-account-ec1-accounts[1] - INFO [05-29|08:33:42.143] Maximum peer count ETH=25 LES=0 total=25 - Address: {38f6d41b35d1af26865a0c13d41e8aa342e62e61} - - make-account-ec1-accounts[2] - INFO [05-29|08:33:48.534] Maximum peer count ETH=25 LES=0 total=25 - Address: {895b383457a714e051357dfc36bb3b6ddf84f01f} - - make-account-ec1-accounts[3] - INFO [05-29|08:33:54.731] Maximum peer count ETH=25 LES=0 total=25 - Address: {caf99b30857e0d29cd866e27fb39b2e7d2b2dc17} - - make-account-ec1-accounts[4] - INFO [05-29|08:34:01.282] Maximum peer count ETH=25 LES=0 total=25 - Address: {1b75166f65a852216306af320783e4b22986d3e3} - - make-account-ec2-accounts[0] - INFO [05-29|08:34:08.021] Maximum peer count ETH=25 LES=0 total=25 - Address: {8f2244f75a4c53684c5827ec19615dc89c2ad21c} - - make-account-ec2-accounts[1] - INFO [05-29|08:34:14.414] Maximum peer count ETH=25 LES=0 total=25 - Address: {add19019ee1ea604b3fcb55a11b97d0fc81cc221} - - make-account-ec2-accounts[2] - INFO [05-29|08:34:21.292] Maximum peer count ETH=25 LES=0 total=25 - Address: {ab66982e4eb732f0e17c56586e530f94ee9411ce} - - make-account-ec2-accounts[3] - INFO [05-29|08:34:27.947] Maximum peer count ETH=25 LES=0 total=25 - Address: {4809b6329ef15bcd1b5b730e0f148ae751cfd9f6} - - make-account-ec2-accounts[4] - INFO [05-29|08:34:34.360] Maximum peer count ETH=25 LES=0 total=25 - Address: {421c9db39b64575c511f94990acfd4394dd5f1c3} -- -### 2) Editing initial block information -* Change the "ADDRESS" in genesis/genesis-ec1.json(and genesis-ec2.json) to the address for ec1-accounts[0]. - - * Specify ec1-accounts [0] account for "genesis / genesis-ec1.json" - * Specify ec2-accounts [0] account for "genesis / genesis-ec2.json" - -* Sample output - -
- "alloc" : { - "ADDRESS": - {"balance":"100000000000000000000000000"} - }, - | - v - "alloc" : { - "782646267c64d536983a64af9d9a5ab80e036989": - {"balance":"100000000000000000000000000"} - }, -- -### 3) Initializing end-chains: -
-./init-chain.sh -- -## b) Launching geth-containers -
-./up.sh -- - -## c) Stop geth-containers -
-./down.sh -- diff --git a/packages/ledger-plugin/sawtooth/validator/unit-test/geth-docker/delete.sh b/packages/ledger-plugin/sawtooth/validator/unit-test/geth-docker/delete.sh deleted file mode 100644 index 6d788a6b91..0000000000 --- a/packages/ledger-plugin/sawtooth/validator/unit-test/geth-docker/delete.sh +++ /dev/null @@ -1,7 +0,0 @@ -# Copyright 2021 Hyperledger Cactus Contributors -# SPDX-License-Identifier: Apache-2.0 -docker-compose -f docker-init.yml down -docker-compose down -sudo rm -r ./data* -docker network rm ec1net -docker network rm ec2net diff --git a/packages/ledger-plugin/sawtooth/validator/unit-test/geth-docker/docker-compose.yml b/packages/ledger-plugin/sawtooth/validator/unit-test/geth-docker/docker-compose.yml deleted file mode 100644 index adbe0bf0e5..0000000000 --- a/packages/ledger-plugin/sawtooth/validator/unit-test/geth-docker/docker-compose.yml +++ /dev/null @@ -1,77 +0,0 @@ -# Copyright 2021 Hyperledger Cactus Contributors -# SPDX-License-Identifier: Apache-2.0 -version: '3' -services: - geth1: - container_name: geth1 - image: ethereum/client-go:v1.8.27 - volumes: - - "$PWD/data-ec1:/root/data" - - "$PWD/genesis/genesis-ec1.json:/root/data/genesis.json" # mount genesis.js from host - working_dir: /root - ports: - - "8545:8545" #uncomment this line to enable JSON-RPC access from outside of network - # - "30303:30303" - expose: - - "8545" # enable JSON-RPC access fron only inside of network - networks: - - ec1net - logging: - driver: "json-file" - options: - max-size: "10m" - max-file: "3" - # following parameters are given to geth - command: > - --rpc - --networkid 10 - --nodiscover - --datadir=/root/data - --rpcaddr "0.0.0.0" - --rpcport "8545" - --rpccorsdomain "*" - --rpcvhosts "*" - --rpcapi "eth,web3" - --unlock 0,1,2,3,4 - --password "/dev/null" - --gasprice 0 - --mine --minerthreads=1 - geth2: - container_name: geth2 - image: ethereum/client-go:v1.8.27 - volumes: - - "$PWD/data-ec2:/root/data" - - "$PWD/genesis/genesis-ec2.json:/root/data/genesis.json" # mount genesis.js from host - working_dir: /root - ports: - - "8546:8545" #uncomment this line to enable JSON-RPC access from outside of network - # - "30303:30303" - expose: - - "8545" # enable JSON-RPC access fron only inside of network - networks: - - ec2net - logging: - driver: "json-file" - options: - max-size: "10m" - max-file: "3" - # following parameters are given to geth - command: > - --rpc - --networkid 10 - --nodiscover - --datadir=/root/data - --rpcaddr "0.0.0.0" - --rpcport "8545" - --rpccorsdomain "*" - --rpcvhosts "*" - --rpcapi "eth,web3" - --unlock 0,1,2,3,4 - --password "/dev/null" - --gasprice 0 - --mine --minerthreads=1 -networks: - ec1net: - external: true - ec2net: - external: true diff --git a/packages/ledger-plugin/sawtooth/validator/unit-test/geth-docker/docker-init.yml b/packages/ledger-plugin/sawtooth/validator/unit-test/geth-docker/docker-init.yml deleted file mode 100644 index 51b6de5493..0000000000 --- a/packages/ledger-plugin/sawtooth/validator/unit-test/geth-docker/docker-init.yml +++ /dev/null @@ -1,44 +0,0 @@ -# Copyright 2021 Hyperledger Cactus Contributors -# SPDX-License-Identifier: Apache-2.0 -version: '3' -services: - # ec1 - make-account-ec1: - container_name: make-account-ec1 - image: ethereum/client-go:v1.8.27 - tty: true - volumes: - - "$PWD/data-ec1:/root/data" - command: > - --datadir "/root/data" - account new --password /dev/null > /root/data/log.txt - init-chain-ec1: - container_name: init-chain-ec1 - image: ethereum/client-go:v1.8.27 - tty: true - volumes: - - "$PWD/data-ec1:/root/data" - - "$PWD/genesis/genesis-ec1.json:/root/data/genesis.json" - command: > - --datadir "/root/data" - init /root/data/genesis.json - # ec2 - make-account-ec2: - container_name: make-account-ec2 - image: ethereum/client-go:v1.8.27 - tty: true - volumes: - - "$PWD/data-ec2:/root/data" - command: > - --datadir "/root/data" - account new --password /dev/null > /root/data/log.txt - init-chain-ec2: - container_name: init-chain-ec2 - image: ethereum/client-go:v1.8.27 - tty: true - volumes: - - "$PWD/data-ec2:/root/data" - - "$PWD/genesis/genesis-ec2.json:/root/data/genesis.json" - command: > - --datadir "/root/data" - init /root/data/genesis.json diff --git a/packages/ledger-plugin/sawtooth/validator/unit-test/geth-docker/down.sh b/packages/ledger-plugin/sawtooth/validator/unit-test/geth-docker/down.sh deleted file mode 100644 index 5d4067f077..0000000000 --- a/packages/ledger-plugin/sawtooth/validator/unit-test/geth-docker/down.sh +++ /dev/null @@ -1,4 +0,0 @@ -# Copyright 2021 Hyperledger Cactus Contributors -# SPDX-License-Identifier: Apache-2.0 -docker-compose -f docker-init.yml down -docker-compose down diff --git a/packages/ledger-plugin/sawtooth/validator/unit-test/geth-docker/genesis/template/genesis-template.json b/packages/ledger-plugin/sawtooth/validator/unit-test/geth-docker/genesis/template/genesis-template.json deleted file mode 100644 index 1d3401b722..0000000000 --- a/packages/ledger-plugin/sawtooth/validator/unit-test/geth-docker/genesis/template/genesis-template.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "config": { - "chainId": 10, - "homesteadBlock": 0, - "eip155Block": 0, - "eip158Block": 0 - }, - "alloc" : { - "ADDRESS": - {"balance":"100000000000000000000000000"} - }, - "coinbase" : "0x3333333333333333333333333333333333333333", - "difficulty" : "0x4000", - "extraData" : "", - "gasLimit" : "0x8000000", - "nonce" : "0x0000000000000042", - "mixhash" : "0x0000000000000000000000000000000000000000000000000000000000000000", - "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", - "timestamp" : "0x00" -} diff --git a/packages/ledger-plugin/sawtooth/validator/unit-test/geth-docker/init-account.sh b/packages/ledger-plugin/sawtooth/validator/unit-test/geth-docker/init-account.sh deleted file mode 100644 index 40356541b0..0000000000 --- a/packages/ledger-plugin/sawtooth/validator/unit-test/geth-docker/init-account.sh +++ /dev/null @@ -1,34 +0,0 @@ -# Copyright 2021 Hyperledger Cactus Contributors -# SPDX-License-Identifier: Apache-2.0 -echo "make-account-ec1-accounts[0]" -docker-compose -f docker-init.yml run make-account-ec1 -cp ./genesis/template/genesis-template.json ./genesis/genesis-ec1.json -echo " " -echo "make-account-ec1-accounts[1]" -docker-compose -f docker-init.yml run make-account-ec1 -echo " " -echo "make-account-ec1-accounts[2]" -docker-compose -f docker-init.yml run make-account-ec1 -echo " " -echo "make-account-ec1-accounts[3]" -docker-compose -f docker-init.yml run make-account-ec1 -echo " " -echo "make-account-ec1-accounts[4]" -docker-compose -f docker-init.yml run make-account-ec1 -echo " " -echo "make-account-ec2-accounts[0]" -docker-compose -f docker-init.yml run make-account-ec2 -cp ./genesis/template/genesis-template.json ./genesis/genesis-ec2.json -echo " " -echo "make-account-ec2-accounts[1]" -docker-compose -f docker-init.yml run make-account-ec2 -echo " " -echo "make-account-ec2-accounts[2]" -docker-compose -f docker-init.yml run make-account-ec2 -echo " " -echo "make-account-ec2-accounts[3]" -docker-compose -f docker-init.yml run make-account-ec2 -echo " " -echo "make-account-ec2-accounts[4]" -docker-compose -f docker-init.yml run make-account-ec2 -echo " " diff --git a/packages/ledger-plugin/sawtooth/validator/unit-test/geth-docker/init-chain.sh b/packages/ledger-plugin/sawtooth/validator/unit-test/geth-docker/init-chain.sh deleted file mode 100644 index eed80e47e8..0000000000 --- a/packages/ledger-plugin/sawtooth/validator/unit-test/geth-docker/init-chain.sh +++ /dev/null @@ -1,4 +0,0 @@ -# Copyright 2021 Hyperledger Cactus Contributors -# SPDX-License-Identifier: Apache-2.0 -docker-compose -f docker-init.yml run init-chain-ec1 -docker-compose -f docker-init.yml run init-chain-ec2 diff --git a/packages/ledger-plugin/sawtooth/validator/unit-test/geth-docker/logview.sh b/packages/ledger-plugin/sawtooth/validator/unit-test/geth-docker/logview.sh deleted file mode 100644 index 6f8cdd2024..0000000000 --- a/packages/ledger-plugin/sawtooth/validator/unit-test/geth-docker/logview.sh +++ /dev/null @@ -1,3 +0,0 @@ -# Copyright 2021 Hyperledger Cactus Contributors -# SPDX-License-Identifier: Apache-2.0 -docker-compose logs -f diff --git a/packages/ledger-plugin/sawtooth/validator/unit-test/geth-docker/up.sh b/packages/ledger-plugin/sawtooth/validator/unit-test/geth-docker/up.sh deleted file mode 100644 index 4b82ede74d..0000000000 --- a/packages/ledger-plugin/sawtooth/validator/unit-test/geth-docker/up.sh +++ /dev/null @@ -1,5 +0,0 @@ -# Copyright 2021 Hyperledger Cactus Contributors -# SPDX-License-Identifier: Apache-2.0 -docker network create ec1net -docker network create ec2net -docker-compose up -d diff --git a/packages/ledger-plugin/sawtooth/validator/unit-test/package.json b/packages/ledger-plugin/sawtooth/validator/unit-test/package.json deleted file mode 100644 index 2bb031ce4d..0000000000 --- a/packages/ledger-plugin/sawtooth/validator/unit-test/package.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "name": "validatorDriver", - "version": "0.0.0", - "private": true, - "scripts": { - "build": "npm run build-ts && npm run copy-static-assets", - "build-ts": "tsc", - "tslint": "tslint -c tslint.json -p tsconfig.json", - "copy-static-assets": "ts-node copyStaticAssets.ts" - }, - "dependencies": { - "@types/node": "^14.14.5", - "config": "^1.26.1", - "ethereumjs-common": "^1.5.1", - "ethereumjs-tx": "^2.1.2", - "ts-node": "^9.0.0", - "web3": "^1.2.9", - "socket.io": "^2.0.4" - }, - "devDependencies": { - "typescript": "^3.9.3" - } -} diff --git a/packages/ledger-plugin/sawtooth/validator/unit-test/tsconfig.json b/packages/ledger-plugin/sawtooth/validator/unit-test/tsconfig.json deleted file mode 100644 index 928b357062..0000000000 --- a/packages/ledger-plugin/sawtooth/validator/unit-test/tsconfig.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "compileOnSave": false, - "compilerOptions": { - "outDir": "./dist", - "sourceMap": false, - "declaration": false, - "moduleResolution": "node", - "emitDecoratorMetadata": true, - "experimentalDecorators": true, - "target": "ES2017", - "module": "CommonJS", - "typeRoots": [ - "node_modules/@types", - "./typings" - ], - "lib": [ - "es2017", - "dom" - ] - }, -} diff --git a/packages/ledger-plugin/sawtooth/validator/unit-test/validatorDriver_getNumericBalance.ts b/packages/ledger-plugin/sawtooth/validator/unit-test/validatorDriver_getNumericBalance.ts deleted file mode 100644 index 38fd265f86..0000000000 --- a/packages/ledger-plugin/sawtooth/validator/unit-test/validatorDriver_getNumericBalance.ts +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright 2021 Hyperledger Cactus Contributors - * SPDX-License-Identifier: Apache-2.0 - * - * validatorDriver_getNumericBalance.js - */ - -//////// -// Usage -// 1) Set parameter to parameter variable -// [parameter variables of getNumericBalance] referredAddress -// 2) Specify the function to execute with "requestData" -// 3) execute -// -//////// - -{ - -// Validator test program.(socket.io client) -var io = require('socket.io-client'); -var config = require('config'); - -// Specify the server (Validator) of the communication destination -var validatorUrl = config.validatorUrl; -console.log('validatorUrl: ' + validatorUrl); -var options = { - rejectUnauthorized: false, // temporary avoidance since self-signed certificates are used - reconnection : false, - timeout : 20000 -}; -var socket = io(validatorUrl, options); - -// for test -// ec1-accounts[0] Address: {ec709e1774f0ce4aba47b52a499f9abaaa159f71} -// ec1-accounts[1] Address: {36e146d5afab61ab125ee671708eeb380aea05b6} -// ec1-accounts[2] Address: {06fc56347d91c6ad2dae0c3ba38eb12ab0d72e97} -// ec1-accounts[3] Address: {9d624f7995e8bd70251f8265f2f9f2b49f169c55} -// ec1-accounts[4] Address: {2666a32bf7594ab5395d766dcfbf03d557dab538} - -// ## Request for "getNumericBalance" -var referedAddress = "36e146d5afab61ab125ee671708eeb380aea05b6"; -var reqID = "reqID_001"; - -// function param -const requestData = { - contract: {}, // NOTE: Since contract does not need to be specified, specify an empty object. - method: {type: "web3Eth", command: "getBalance"}, - args: {"args": [referedAddress]}, - reqID: reqID -}; - - -const json2str = (jsonObj) => { - try { - return JSON.stringify(jsonObj); - } - catch (error) { - return null; - } -} - - -socket.on('connect_error', (err) => { - console.log('####connect_error:', err); - // end communication - socket.disconnect(); - process.exit(0); -}); - -socket.on('connect_timeout', (err) => { - console.log('####Error:', err); - // end communication - socket.disconnect(); - process.exit(0); -}); - -socket.on('error', (err) => { - console.log('####Error:', err); -}); - -socket.on('eventReceived', function (res) { - // output the data received from the client - console.log('#[recv]eventReceived, res: ' + json2str(res)); -}); - - -const requestStopMonitor = () => { - console.log('##exec requestStopMonitor()'); - socket.emit('stopMonitor'); - - setTimeout(function(){ - // end communication - socket.disconnect(); - process.exit(0); - },5000); -} - -// request StartMonitor -const requestStartMonitor = () => { - console.log('##exec requestStartMonitor()'); - socket.emit('startMonitor'); - - setTimeout(requestStopMonitor,15000); -} - - -const sendRequest = () => { - // - console.log('exec sendRequest()'); - console.log('#[send]requestData: ' + json2str(requestData)); - // socket.emit('request', requestData); - socket.emit('request2', requestData); -} - -setTimeout(requestStartMonitor, 2000); -setTimeout(sendRequest, 4000); - -} diff --git a/packages/ledger-plugin/sawtooth/validator/unit-test/validatorDriver_sendRawTransaction.ts b/packages/ledger-plugin/sawtooth/validator/unit-test/validatorDriver_sendRawTransaction.ts deleted file mode 100644 index b5e5bc7372..0000000000 --- a/packages/ledger-plugin/sawtooth/validator/unit-test/validatorDriver_sendRawTransaction.ts +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Copyright 2021 Hyperledger Cactus Contributors - * SPDX-License-Identifier: Apache-2.0 - * - * validatorDriver_sendRawTransaction.js - */ - -//////// -// Usage -// 1) Set parameter to parameter variable -// [parameter variables of sendRawTransaction] fromAddress,fromAddressPkey,toAddress,amount,amount -// 2) execute -// -//////// - -{ - -// Validator test program.(socket.io client) -var io = require('socket.io-client'); -var config = require('config'); - -// Specify the server (Validator) of the communication destination -var validatorUrl = config.validatorUrl; -console.log('validatorUrl: ' + validatorUrl); -var options = { - rejectUnauthorized: false, // temporary avoidance since self-signed certificates are used - reconnection : false, - timeout : 20000 -}; -var socket = io(validatorUrl, options); - -// for signing -var Common = require('ethereumjs-common').default; -var Tx = require('ethereumjs-tx').Transaction; -const Web3 = require('web3'); -var gethUrl = config.gethUrl; -console.log('gethUrl: ' + gethUrl); -const provider = new Web3.providers.HttpProvider(gethUrl); -const web3 = new Web3(provider); - -//ethereumjs-tx2.1.2_support -const customCommon = Common.forCustomChain( - 'mainnet', - { - name: config.chainName, - networkId: config.networkId, - chainId: config.chainId, - }, - 'petersburg', -) - -// for test -// ec1-accounts[0] Address: {ec709e1774f0ce4aba47b52a499f9abaaa159f71}, pkey: 40d7e5931a6e0807d3ebd70518f635dbf575975d3bb564ff34c99be416067c89 -// ec1-accounts[1] Address: {36e146d5afab61ab125ee671708eeb380aea05b6}, pkey: 13a45756bc314465c4ae2ff0eb9ab58cf72453c04604d8fa14393eb25ce96d06 -// ec1-accounts[2] Address: {06fc56347d91c6ad2dae0c3ba38eb12ab0d72e97}, pkey: cb5d48d371916a4ea1627189d8af4f642a5d72746a06b559780c3f5932658207 -// ec1-accounts[3] Address: {9d624f7995e8bd70251f8265f2f9f2b49f169c55}, pkey: 3d966c433eb650f40287debacd92afb9c390024e359f9f719b2ca6c0ab07339a -// ec1-accounts[4] Address: {2666a32bf7594ab5395d766dcfbf03d557dab538}, pkey: 918b9b842a633c04e7e97b917d091736334dab6dd71fdc1dcbf0c763014caaf4 - -// ## Request Params -var fromAddress = "36e146d5afab61ab125ee671708eeb380aea05b6"; -var fromAddressPkey = "13a45756bc314465c4ae2ff0eb9ab58cf72453c04604d8fa14393eb25ce96d06"; -var toAddress = "06fc56347d91c6ad2dae0c3ba38eb12ab0d72e97"; -var amount = 100; - -var gas = 21000; - -const json2str = (jsonObj) => { - try { - return JSON.stringify(jsonObj); - } - catch (error) { - return null; - } -} - -const makeTxTransferNumericAsset = () => { - //web3_v1.2.9_support - web3.eth.getTransactionCount('0x' + fromAddress).then(_nance => { - var txnCount = _nance; - // NOTE: No need to count up. - - var gasPrice = web3.eth.gasPrice; - - var privKey = Buffer.from(fromAddressPkey, 'hex'); - console.log('##privKey=' + fromAddressPkey); - var rawTx = { - "nonce": web3.utils.toHex(txnCount), - "to": '0x' + toAddress, - "value": amount, - "gas": gas, - - } - console.log('txnCount=' + web3.utils.toHex(txnCount)); - console.log('##rawTx=' + json2str(rawTx)); - var tx = new Tx(rawTx, { common: customCommon },); - tx.sign(privKey); - var serializedTx = tx.serialize(); - var serializedTxHex = '0x' + serializedTx.toString('hex'); - console.log('##serializedTxHex=' + serializedTxHex); - - var func = "sendRawTransaction"; - - var args = { - serializedTx: serializedTxHex - }; - // function param - const requestData = { - contract: {}, // NOTE: Since contract does not need to be specified, specify an empty object. - method: {type: "web3Eth", command: "sendRawTransaction"}, - args: {"args": [serializedTxHex]} - }; - - console.log('exec sendRequest()'); - console.log('#[send]requestData: ' + json2str(requestData)); - socket.emit('request2', requestData); - }) -} - - -socket.on('connect_error', (err) => { - console.log('####connect_error:', err); - // end communication - socket.disconnect(); - process.exit(0); -}); - -socket.on('connect_timeout', (err) => { - console.log('####Error:', err); - // end communication - socket.disconnect(); - process.exit(0); -}); - -socket.on('error', (err) => { - console.log('####Error:', err); -}); - -socket.on('eventReceived', function (res) { - // output the data received from the client - console.log('#[recv]eventReceived, res: ' + json2str(res)); -}); - - -const requestStopMonitor = () => { - console.log('##exec requestStopMonitor()'); - socket.emit('stopMonitor'); - - setTimeout(function(){ - // end communication - socket.disconnect(); - process.exit(0); - },5000); -} - -// request StartMonitor -const requestStartMonitor = () => { - console.log('##exec requestStartMonitor()'); - socket.emit('startMonitor'); - - setTimeout(requestStopMonitor,15000); -} - - -setTimeout(requestStartMonitor, 2000); -setTimeout(makeTxTransferNumericAsset, 4000); - -} diff --git a/packages/ledger-plugin/sawtooth/validator/unit-test/validatorDriver_transferNumericAsset.ts b/packages/ledger-plugin/sawtooth/validator/unit-test/validatorDriver_transferNumericAsset.ts deleted file mode 100644 index f43a4bf674..0000000000 --- a/packages/ledger-plugin/sawtooth/validator/unit-test/validatorDriver_transferNumericAsset.ts +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Copyright 2021 Hyperledger Cactus Contributors - * SPDX-License-Identifier: Apache-2.0 - * - * validatorDriver_transferNumericAsset.js - */ - -//////// -// Usage -// 1) Set parameter to parameter variable -// [parameter variables of transferNumericAsset] fromAddress,toAddress,amount -// 2) Specify the function to execute with "requestData" -// 3) execute -// -//////// - -{ - -// Validator test program.(socket.io client) -var io = require('socket.io-client'); -var config = require('config'); - -// Specify the server (Validator) of the communication destination -var validatorUrl = config.validatorUrl; -console.log('validatorUrl: ' + validatorUrl); -var options = { - rejectUnauthorized: false, // temporary avoidance since self-signed certificates are used - reconnection : false, - timeout : 20000 -}; -var socket = io(validatorUrl, options); - -// for test -// ec1-accounts[0] Address: {ec709e1774f0ce4aba47b52a499f9abaaa159f71} -// ec1-accounts[1] Address: {36e146d5afab61ab125ee671708eeb380aea05b6} -// ec1-accounts[2] Address: {06fc56347d91c6ad2dae0c3ba38eb12ab0d72e97} -// ec1-accounts[3] Address: {9d624f7995e8bd70251f8265f2f9f2b49f169c55} -// ec1-accounts[4] Address: {2666a32bf7594ab5395d766dcfbf03d557dab538} - - -// ## Request for "transferNumericAsset" -var fromAddress = "36e146d5afab61ab125ee671708eeb380aea05b6"; -var toAddress = "06fc56347d91c6ad2dae0c3ba38eb12ab0d72e97"; -var amount = 50; -var func2 = "transferNumericAsset"; -var args2 = { - fromAddress : fromAddress, - toAddress : toAddress, - amount : amount -}; -const reqID = "reqID_002"; - - -// function param -//var requestData = { -// contract: {}, -// method: {"method": func2}, -// args: {"args": [args2]} -//}; -const requestData = { - contract: {}, // NOTE: Since contract does not need to be specified, specify an empty object. - method: {type: "web3Eth", command: "sendTransaction"}, - args: {"args": [ - { - "from" : fromAddress, - "to" : toAddress, - "value" : amount - } - ]}, - reqID: reqID -}; - - -const json2str = (jsonObj) => { - try { - return JSON.stringify(jsonObj); - } - catch (error) { - return null; - } -} - - -socket.on('connect_error', (err) => { - console.log('####connect_error:', err); - // end communication - socket.disconnect(); - process.exit(0); -}); - -socket.on('connect_timeout', (err) => { - console.log('####Error:', err); - // end communication - socket.disconnect(); - process.exit(0); -}); - -socket.on('error', (err) => { - console.log('####Error:', err); -}); - -socket.on('eventReceived', function (res) { - // output the data received from the client - console.log('#[recv]eventReceived, res: ' + json2str(res)); -}); - - -const requestStopMonitor = () => { - console.log('##exec requestStopMonitor()'); - socket.emit('stopMonitor'); - - setTimeout(function(){ - // end communication - socket.disconnect(); - process.exit(0); - },5000); -} - -// request StartMonitor -const requestStartMonitor = () => { - console.log('##exec requestStartMonitor()'); - socket.emit('startMonitor'); - - setTimeout(requestStopMonitor,15000); -} - - -const sendRequest = () => { - // - console.log('exec sendRequest()'); - console.log('#[send]requestData: ' + json2str(requestData)); - socket.emit('request2', requestData); -} - -setTimeout(requestStartMonitor, 2000); -setTimeout(sendRequest, 4000); - -}