This is an automated email from the ASF dual-hosted git repository.
cmorris pushed a commit to branch splitroles-blockchain
in repository https://gitbox.apache.org/repos/asf/incubator-milagro-dta.git
The following commit(s) were added to refs/heads/splitroles-blockchain by this
push:
new 1eda2c0 Update tests - not working yet
1eda2c0 is described below
commit 1eda2c09b50965d1abb2e25348517ad29650522d
Author: Christopher Morris <[email protected]>
AuthorDate: Tue Oct 1 13:23:58 2019 +0100
Update tests - not working yet
---
cmd/servicetester/Manual_Tests.txt | 18 +++++++
cmd/servicetester/e2e_test.sh | 24 +++++-----
cmd/servicetester/go.mod | 8 ++++
cmd/servicetester/main | Bin 0 -> 23390004 bytes
cmd/servicetester/main.go | 93 +++++++++++++++++++++++++++++++++++++
p | 6 +++
6 files changed, 137 insertions(+), 12 deletions(-)
diff --git a/cmd/servicetester/Manual_Tests.txt
b/cmd/servicetester/Manual_Tests.txt
new file mode 100644
index 0000000..61c172a
--- /dev/null
+++ b/cmd/servicetester/Manual_Tests.txt
@@ -0,0 +1,18 @@
+Run
+ service: safeguardsecret
+
+
+beneficiaryIDDocumentCID="QmNpPp9wbBFUfBYCABrmKcaxd3eVxd2bGHfVQsEhRJPHjD"
+curl -s -X POST http://localhost:5556/v1/order1 -H "accept: */*"" -H
Content-Type: application/json -d
"{\"beneficiaryIDDocumentCID\":\"$beneficiaryIDDocumentCID\",\"extension\":{\"plainText\":\"This
is some random test text 1234567890\"}}"
+curl -s -X POST http://localhost:5556/v1/order/secret1 -H "accept: */*"" -H
Content-Type: application/json -d
"{\"orderReference\":\"05aca4ec-e43d-11e9-b3d3-acde48001122\",\"beneficiaryIDDocumentCID\":\"\",\"extension\":{\"cypherText\":\"e4cbcbd24933ae36bb0be94d:04c9ac09595636acc109910634e632e278ba44ad752d4792d4b22a43a6ed9aa95b378878e803511dfc76d9a9b746488faab07d601befa25a58ea1323bc0d53e2fb:0dc02c50c8fbfafa27ddcdf469c191c2ff7e20f0e04edc815b79418d2ed366234c90c303cf7122b7210fc81b3ce9bbf4\"}}"
+
+
+Run:
+service : bitcoinwallet
+curl -s -X POST "127.0.0.1:5556/v1/order1" -H "accept: */*" -H "Content-Type:
application/json" -d
"{\"beneficiaryIDDocumentCID\":\"\",\"extension\":{\"coin\":\"0\"}}"
+curl -X POST "127.0.0.1:5556/v1/order/secret1" -H "accept: */*" -H
"Content-Type: application/json" -d
"{\"orderReference\":\"0cbdf024-e442-11e9-90cc-acde48001122\",\"beneficiaryIDDocumentCID\":\"QmNpPp9wbBFUfBYCABrmKcaxd3eVxd2bGHfVQsEhRJPHjD\"}"
+
+
+service: Milagro
+curl -s -X POST http://localhost:5556/v1/order1 -H "accept: */*" -H
Content-Type: application/json -d
"{\"beneficiaryIDDocumentCID\":\"$beneficiaryIDDocumentCID\"}"
+curl -s -X POST http://localhost:5556/v1/order/secret1 -H "accept: */*" -H
Content-Type: application/json -d
"{\"orderReference\":\"380b8704-e443-11e9-969f-acde48001122\",\"beneficiaryIDDocumentCID\":\"QmNpPp9wbBFUfBYCABrmKcaxd3eVxd2bGHfVQsEhRJPHjD\"}"
diff --git a/cmd/servicetester/e2e_test.sh b/cmd/servicetester/e2e_test.sh
index 678b364..93eb2fd 100755
--- a/cmd/servicetester/e2e_test.sh
+++ b/cmd/servicetester/e2e_test.sh
@@ -28,12 +28,12 @@ echo "$apiURL/$apiVersion/status"
execute_bitcoin () {
# #Run 4 Tests against the Bitcoin Extension
echo "Bitcoin Plugin Tests [4 Tests]"
- output1=$(curl -s -X POST "$apiURL/$apiVersion/order" -H "accept: */*" -H
"Content-Type: application/json" -d
"{\"beneficiaryIDDocumentCID\":\"\",\"extension\":{\"coin\":\"0\"}}")
+ output1=$(curl -s -X POST "$apiURL/$apiVersion/order1" -H "accept: */*" -H
"Content-Type: application/json" -d
"{\"beneficiaryIDDocumentCID\":\"\",\"extension\":{\"coin\":\"0\"}}")
#echo $output1
op1=$(echo $output1 | jq .orderReference)
commitment1=$(echo $output1 | jq .commitment)
address1=$(echo $output1 | jq .extension.address)
- output2=$(curl -s -X POST "$apiURL/$apiVersion/order/secret" -H "accept:
*/*" -H "Content-Type: application/json" -d
"{\"orderReference\":$op1,\"beneficiaryIDDocumentCID\":$identity}")
+ output2=$(curl -s -X POST "$apiURL/$apiVersion/order/secret1" -H "accept:
*/*" -H "Content-Type: application/json" -d
"{\"orderReference\":$op1,\"beneficiaryIDDocumentCID\":$identity}")
address2=$(echo $output2 | jq .extension.address)
commitment2=$(echo $output2 | jq .commitment)
@@ -52,12 +52,12 @@ execute_bitcoin () {
exit 1
fi
- output3=$(curl -s -X POST "$apiURL/$apiVersion/order" -H "accept: */*" -H
"Content-Type: application/json" -d
"{\"beneficiaryIDDocumentCID\":$identity,\"extension\":{\"coin\":\"0\"}}")
+ output3=$(curl -s -X POST "$apiURL/$apiVersion/order1" -H "accept: */*" -H
"Content-Type: application/json" -d
"{\"beneficiaryIDDocumentCID\":$identity,\"extension\":{\"coin\":\"0\"}}")
op3=$(echo $output3 | jq .orderReference)
commitment3=$(echo $output3 | jq .commitment)
address3=$(echo $output3 | jq .extension.address)
- output4=$(curl -s -X POST "$apiURL/$apiVersion/order/secret" -H "accept:
*/*" -H "Content-Type: application/json" -d "{\"orderReference\":$op3}")
+ output4=$(curl -s -X POST "$apiURL/$apiVersion/order/secret1" -H "accept:
*/*" -H "Content-Type: application/json" -d "{\"orderReference\":$op3}")
commitment4=$(echo $output4 | jq .commitment)
address4=$(echo $output4 | jq .extension.address)
orderReference=$(echo $output4 | jq .orderReference)
@@ -86,13 +86,13 @@ execute_bitcoin () {
#Tests against the Bitcoin Extension - different befificary
- output6=$(curl -s -X POST "http://localhost:5556/$apiVersion/order" -H
"accept: */*" -H "Content-Type: application/json" -d
"{\"beneficiaryIDDocumentCID\":\"\",\"extension\":{\"coin\":\"0\"}}")
+ output6=$(curl -s -X POST "http://localhost:5556/$apiVersion/order1" -H
"accept: */*" -H "Content-Type: application/json" -d
"{\"beneficiaryIDDocumentCID\":\"\",\"extension\":{\"coin\":\"0\"}}")
#echo $output6
op6=$(echo $output6 | jq .orderReference)
commitment6=$(echo $output6 | jq .commitment)
address6=$(echo $output6 | jq .extension.address)
- output7=$(curl -s -X POST "http://localhost:5556/$apiVersion/order/secret"
-H "accept: */*" -H "Content-Type: application/json" -d
"{\"orderReference\":$op6,\"beneficiaryIDDocumentCID\":\"$benid\"}")
+ output7=$(curl -s -X POST "http://localhost:5556/$apiVersion/order/secret1"
-H "accept: */*" -H "Content-Type: application/json" -d
"{\"orderReference\":$op6,\"beneficiaryIDDocumentCID\":\"$benid\"}")
address7=$(echo $output7 | jq .extension.address)
commitment7=$(echo $output7 | jq .commitment)
@@ -111,13 +111,13 @@ execute_bitcoin () {
exit 1
fi
- output8=$(curl -s -X POST "http://localhost:5556/$apiVersion/order" -H
"accept: */*" -H "Content-Type: application/json" -d
"{\"beneficiaryIDDocumentCID\":\"$benid\",\"extension\":{\"coin\":\"0\"}}")
+ output8=$(curl -s -X POST "http://localhost:5556/$apiVersion/order1" -H
"accept: */*" -H "Content-Type: application/json" -d
"{\"beneficiaryIDDocumentCID\":\"$benid\",\"extension\":{\"coin\":\"0\"}}")
op8=$(echo $output8 | jq .orderReference)
commitment8=$(echo $output8 | jq .commitment)
address8=$(echo $output8 | jq .extension.address)
- output9=$(curl -s -X POST "http://localhost:5556/$apiVersion/order/secret"
-H "accept: */*" -H "Content-Type: application/json" -d
"{\"orderReference\":$op8}")
+ output9=$(curl -s -X POST "http://localhost:5556/$apiVersion/order/secret1"
-H "accept: */*" -H "Content-Type: application/json" -d
"{\"orderReference\":$op8}")
commitment9=$(echo $output9 | jq .commitment)
address9=$(echo $output9 | jq .extension.address)
orderReference=$(echo $output9 | jq .orderReference)
@@ -147,14 +147,14 @@ execute_safeguardsecret () {
inputString="This is some random test text 1234567890!"
echo "Encrypt a String [1 Test]"
echo $output1
- output1=$(curl -s -X POST "$apiURL/$apiVersion/order" -H "accept: */*" -H
"Content-Type: application/json" -d
"{\"beneficiaryIDDocumentCID\":$identity,\"extension\":{\"plainText\":\"$inputString\"}}")
+ output1=$(curl -s -X POST "$apiURL/$apiVersion/order1" -H "accept: */*" -H
"Content-Type: application/json" -d
"{\"beneficiaryIDDocumentCID\":$identity,\"extension\":{\"plainText\":\"$inputString\"}}")
echo $output1
op1=$(echo $output1 | jq .orderReference)
cipherText=$(echo $output1 | jq .extension.cypherText)
tvalue=$(echo $output1 | jq .extension.t)
vvalue=$(echo $output1 | jq .extension.v)
commitment1=$(echo $output1 | jq .commitment)
- output2=$(curl -s -X POST "$apiURL/$apiVersion/order/secret" -H "accept:
*/*" -H "Content-Type: application/json" -d
"{\"orderReference\":$op1,\"beneficiaryIDDocumentCID\":$identity,\"extension\":{\"cypherText\":$cipherText,\"t\":$tvalue,\"v\":$vvalue}}")
+ output2=$(curl -s -X POST "$apiURL/$apiVersion/order/secret1" -H "accept:
*/*" -H "Content-Type: application/json" -d
"{\"orderReference\":$op1,\"beneficiaryIDDocumentCID\":$identity,\"extension\":{\"cypherText\":$cipherText,\"t\":$tvalue,\"v\":$vvalue}}")
result=$(echo $output2 | jq -r .extension.plainText)
orderReference=$(echo $output2 | jq .orderReference)
@@ -174,13 +174,13 @@ execute_safeguardsecret () {
execute_milagro () {
echo "Milagro Tests [1 Test]"
- output1=$(curl -s -X POST "$apiURL/$apiVersion/order" -H "accept: */*" -H
"Content-Type: application/json" -d "{\"beneficiaryIDDocumentCID\":$identity}")
+ output1=$(curl -s -X POST "$apiURL/$apiVersion/order1" -H "accept: */*" -H
"Content-Type: application/json" -d "{\"beneficiaryIDDocumentCID\":$identity}")
echo $output1
op1=$(echo $output1 | jq .orderReference)
commitment1=$(echo $output1 | jq .commitment)
- output2=$(curl -s -X POST "$apiURL/$apiVersion/order/secret" -H "accept:
*/*" -H "Content-Type: application/json" -d
"{\"orderReference\":$op1,\"beneficiaryIDDocumentCID\":$identity}")
+ output2=$(curl -s -X POST "$apiURL/$apiVersion/order/secret1" -H "accept:
*/*" -H "Content-Type: application/json" -d
"{\"orderReference\":$op1,\"beneficiaryIDDocumentCID\":$identity}")
commitment2=$(echo $output2 | jq .commitment)
orderReference=$(echo $output2 | jq .orderReference)
diff --git a/cmd/servicetester/go.mod b/cmd/servicetester/go.mod
new file mode 100644
index 0000000..0a4bd6f
--- /dev/null
+++ b/cmd/servicetester/go.mod
@@ -0,0 +1,8 @@
+module github.com/apache/incubator-milagro-dta/cmd/servicetester
+
+go 1.13
+
+require (
+ github.com/apache/incubator-milagro-dta
v0.0.0-20191001084144-6bc9bc4c9a45
+ github.com/tendermint/tendermint v0.32.4
+)
diff --git a/cmd/servicetester/main b/cmd/servicetester/main
new file mode 100755
index 0000000..3f84e01
Binary files /dev/null and b/cmd/servicetester/main differ
diff --git a/cmd/servicetester/main.go b/cmd/servicetester/main.go
new file mode 100644
index 0000000..fc55432
--- /dev/null
+++ b/cmd/servicetester/main.go
@@ -0,0 +1,93 @@
+package main
+
+import (
+ "context"
+ "encoding/json"
+ "os"
+
+ tmclient "github.com/tendermint/tendermint/rpc/client"
+ tmtypes "github.com/tendermint/tendermint/types"
+)
+
+type BlockChainTX struct {
+ Processor string
+ SenderID string
+ RecipientID string
+ AdditionalRecipientIDs []string
+ Payload []byte
+ TXhash []byte
+ Tags map[string]string
+}
+
+func main() {
+
+ subscribe(3)
+}
+
+//Subscribe to Websocket and add to queue
+func subscribe(ignore int) error {
+ client := tmclient.NewHTTP("tcp://34.246.173.153:26657", "/websocket")
+ err := client.Start()
+ if err != nil {
+ print("Failed to start Tendermint HTTP client %s", err)
+ return err
+ }
+ defer client.Stop()
+ query :=
"tag.recipient='QmNpPp9wbBFUfBYCABrmKcaxd3eVxd2bGHfVQsEhRJPHjD'"
+ //query := "tm.event = 'Tx'"
+
+ out, err := client.Subscribe(context.Background(), "test", query, 1000)
+ if err != nil {
+ print("Failed to subscribe to query %s %s", query, err)
+ return err
+ }
+
+ print("Tendermint: Connected")
+
+ for {
+ select {
+ case result := <-out:
+ tx := result.Data.(tmtypes.EventDataTx).Tx
+ payload := BlockChainTX{}
+ err := json.Unmarshal(tx, &payload)
+ if err != nil {
+ print("******** Invalid TX - ignored")
+ break
+ }
+ print(".")
+ ignore--
+ if ignore == 0 {
+ print("Complete")
+ os.Exit(0)
+ }
+ }
+
+ }
+ return nil
+}
+
+
+
+//Dump - used for debugging purpose, print the entire Encrypted Transaction
+func Dump(tx *BlockChainTX) error {
+ nodeID := s.NodeID()
+ txHashString := hex.EncodeToString(tx.TXhash)
+
+ localIDDoc, err := common.RetrieveIDDocFromIPFS(s.Ipfs, nodeID)
+ if err != nil {
+ return err
+ }
+
+ _, _, _, sikeSK, err := common.RetrieveIdentitySecrets(s.Store, nodeID)
+ if err != nil {
+ return err
+ }
+
+ order := &documents.OrderDoc{}
+ err = documents.DecodeOrderDocument(tx.Payload, txHashString, order,
sikeSK, nodeID, localIDDoc.BLSPublicKey)
+
+ pp, _ := prettyjson.Marshal(order)
+ fmt.Println(string(pp))
+
+ return nil
+}
\ No newline at end of file
diff --git a/p b/p
new file mode 100755
index 0000000..4d94421
--- /dev/null
+++ b/p
@@ -0,0 +1,6 @@
+#!/bin/bash
+export ref=$(curl -s -X POST "127.0.0.1:5556/v1/order1" -H "accept: */*" -H
"Content-Type: application/json" -d
"{\"beneficiaryIDDocumentCID\":\"\",\"extension\":{\"coin\":\"0\"}}")
+sleep 4
+curl -X POST "127.0.0.1:5556/v1/order/secret1" -H "accept: */*" -H
"Content-Type: application/json" -d
"{\"orderReference\":$ref,\"beneficiaryIDDocumentCID\":\"$1\"}"
+
+