mirror of
https://github.com/hyperledger/fabric-samples.git
synced 2026-06-25 19:15:10 +00:00
PDC Testing ongoing
This commit is contained in:
parent
2d940bcdc6
commit
e1169e061e
2 changed files with 18 additions and 5 deletions
|
|
@ -850,9 +850,10 @@ func (s *SmartContract) WriteSchemaToPDC(ctx contractapi.TransactionContextInter
|
||||||
}
|
}
|
||||||
|
|
||||||
type transientInput struct {
|
type transientInput struct {
|
||||||
JsonSchemaContent map[string]interface{} `json:"JsonSchemaContent"`
|
//JsonSchemaContent map[string]interface{} `json:"JsonSchemaContent"`
|
||||||
SchemaId string `json:"SchemaId"`
|
JsonSchemaContent string `json:"JsonSchemaContent"`
|
||||||
Project string `json:"Project`
|
SchemaId string `json:"SchemaId"`
|
||||||
|
Project string `json:"Project`
|
||||||
}
|
}
|
||||||
|
|
||||||
// So far, we've taken what's on the transient dictionary and unmarshal it into the transientInput Struct
|
// So far, we've taken what's on the transient dictionary and unmarshal it into the transientInput Struct
|
||||||
|
|
@ -861,7 +862,10 @@ func (s *SmartContract) WriteSchemaToPDC(ctx contractapi.TransactionContextInter
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to unmarshal JSON: %v", err)
|
return fmt.Errorf("failed to unmarshal JSON: %v", err)
|
||||||
}
|
}
|
||||||
|
jsonFileContent, err := s.JsonReader(ctx, assetInput.JsonSchemaContent)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
// Check if Schema already exists
|
// Check if Schema already exists
|
||||||
assetAsBytes, err := ctx.GetStub().GetPrivateData(PDC1, assetInput.SchemaId)
|
assetAsBytes, err := ctx.GetStub().GetPrivateData(PDC1, assetInput.SchemaId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -887,7 +891,7 @@ func (s *SmartContract) WriteSchemaToPDC(ctx contractapi.TransactionContextInter
|
||||||
|
|
||||||
// Make submitting client the owner
|
// Make submitting client the owner
|
||||||
Schema := PrivateSchemaContent{
|
Schema := PrivateSchemaContent{
|
||||||
JsonSchemaContent: assetInput.JsonSchemaContent,
|
JsonSchemaContent: jsonFileContent,
|
||||||
SchemaId: assetInput.SchemaId,
|
SchemaId: assetInput.SchemaId,
|
||||||
Project: assetInput.Project,
|
Project: assetInput.Project,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -210,3 +210,12 @@ peer chaincode invoke -o localhost:7050 --ordererTLSHostnameOverride orderer.exa
|
||||||
echo "========= CC Query: Get all DataSamples ==========="
|
echo "========= CC Query: Get all DataSamples ==========="
|
||||||
|
|
||||||
peer chaincode query -C mychannel -n basic -c '{"Args":["GetAllAssets"]}'
|
peer chaincode query -C mychannel -n basic -c '{"Args":["GetAllAssets"]}'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
echo "========= CC Invoke: Creation of Schema in PDC ==========="
|
||||||
|
|
||||||
|
export ASSET_PROPERTIES=$(echo -n "{\"SchemaId\":\"Project1.Schema1\",\"Project\":\"Project1\",\"JsonSchemaContent\":"{\"type\": \"object\", \"properties\": { \"number\": { \"type\": \"number\" }, \"street_name\": { \"type\": \"string\" }, \"street_type\": { \"enum\": [\"Street\", \"Avenue\",\"Boulevard\"] }}, \"additionalProperties\": false, \"required\": [ \"number\", \"street_name\"]}", "{ \"number\": 1600, \"street_name\": \"Pennsylvania\", \"street_type\": \"Avenue\" }"]}"}" | base64 | tr -d \\n)
|
||||||
|
peer chaincode invoke -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls --cafile "${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem" -C mychannel -n private -c '{"function":"WriteSchemaToPDC","Args":[]}' --transient "{\"asset_properties\":\"$ASSET_PROPERTIES\"}"
|
||||||
|
|
||||||
|
'{\"type\": \"object\", \"properties\": { \"number\": { \"type\": \"number\" }, \"street_name\": { \"type\": \"string\" }, \"street_type\": { \"enum\": [\"Street\", \"Avenue\",\"Boulevard\"] }}, \"additionalProperties\": false, \"required\": [ \"number\", \"street_name\"]}", "{ \"number\": 1600, \"street_name\": \"Pennsylvania\", \"street_type\": \"Avenue\" }"]}'
|
||||||
Loading…
Reference in a new issue