PDC Testing ongoing

This commit is contained in:
Fernando Garzon 2023-02-21 17:08:41 -08:00
parent 2d940bcdc6
commit e1169e061e
2 changed files with 18 additions and 5 deletions

View file

@ -850,9 +850,10 @@ func (s *SmartContract) WriteSchemaToPDC(ctx contractapi.TransactionContextInter
}
type transientInput struct {
JsonSchemaContent map[string]interface{} `json:"JsonSchemaContent"`
SchemaId string `json:"SchemaId"`
Project string `json:"Project`
//JsonSchemaContent map[string]interface{} `json:"JsonSchemaContent"`
JsonSchemaContent string `json:"JsonSchemaContent"`
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
@ -861,7 +862,10 @@ func (s *SmartContract) WriteSchemaToPDC(ctx contractapi.TransactionContextInter
if err != nil {
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
assetAsBytes, err := ctx.GetStub().GetPrivateData(PDC1, assetInput.SchemaId)
if err != nil {
@ -887,7 +891,7 @@ func (s *SmartContract) WriteSchemaToPDC(ctx contractapi.TransactionContextInter
// Make submitting client the owner
Schema := PrivateSchemaContent{
JsonSchemaContent: assetInput.JsonSchemaContent,
JsonSchemaContent: jsonFileContent,
SchemaId: assetInput.SchemaId,
Project: assetInput.Project,
}

View file

@ -210,3 +210,12 @@ peer chaincode invoke -o localhost:7050 --ordererTLSHostnameOverride orderer.exa
echo "========= CC Query: Get all DataSamples ==========="
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\" }"]}'