-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1e40dd6
commit 6235356
Showing
9 changed files
with
436 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package transactions | ||
|
||
import ( | ||
"log" | ||
"testing" | ||
|
||
"github.com/hyperledger/fabric/core/chaincode/shim" | ||
) | ||
|
||
func TestGetDataTypes(t *testing.T) { | ||
stub := shim.NewMockStub("testcc", new(testCC)) | ||
|
||
expectedResponse := map[string]interface{}{ | ||
"boolean": map[string]interface{}{ | ||
"acceptedFormats": []interface{}{ | ||
"boolean", | ||
}, | ||
"DropDownValues": nil, | ||
}, | ||
"cpf": map[string]interface{}{ | ||
"acceptedFormats": nil, | ||
"DropDownValues": nil, | ||
}, | ||
"datetime": map[string]interface{}{ | ||
"acceptedFormats": []interface{}{ | ||
"string", | ||
}, | ||
"DropDownValues": nil, | ||
}, | ||
"integer": map[string]interface{}{ | ||
"acceptedFormats": []interface{}{ | ||
"number", | ||
}, | ||
"DropDownValues": nil, | ||
}, | ||
"number": map[string]interface{}{ | ||
"acceptedFormats": []interface{}{ | ||
"number", | ||
}, | ||
"DropDownValues": nil, | ||
}, | ||
"string": map[string]interface{}{ | ||
"acceptedFormats": []interface{}{ | ||
"string", | ||
}, | ||
"DropDownValues": nil, | ||
}, | ||
} | ||
err := invokeAndVerify(stub, "getDataTypes", nil, expectedResponse, 200) | ||
if err != nil { | ||
log.Println("getDataTypes fail") | ||
t.FailNow() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package transactions | ||
|
||
import ( | ||
"log" | ||
"testing" | ||
|
||
"github.com/hyperledger/fabric/core/chaincode/shim" | ||
) | ||
|
||
func TestGetHeader(t *testing.T) { | ||
stub := shim.NewMockStub("org1MSP", new(testCC)) | ||
|
||
expectedResponse := map[string]interface{}{ | ||
"ccToolsVersion": "v0.7.0-rc.3", | ||
"colors": []interface{}{ | ||
"#4267B2", | ||
"#34495E", | ||
"#ECF0F1", | ||
}, | ||
"name": "CC Tools Test", | ||
"orgMSP": "org1MSP", | ||
"orgTitle": "CC Tools Demo", | ||
"version": "v0.7.0", | ||
} | ||
err := invokeAndVerify(stub, "getHeader", nil, expectedResponse, 200) | ||
if err != nil { | ||
log.Println("getHeader fail") | ||
t.FailNow() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
package transactions | ||
|
||
import ( | ||
"log" | ||
"testing" | ||
|
||
"github.com/hyperledger/fabric/core/chaincode/shim" | ||
) | ||
|
||
func TestGetSchema(t *testing.T) { | ||
stub := shim.NewMockStub("org1MSP", new(testCC)) | ||
|
||
expectedResponse := []interface{}{ | ||
map[string]interface{}{ | ||
"description": "Personal data of someone", | ||
"label": "Person", | ||
"tag": "person", | ||
"writers": nil, | ||
}, | ||
map[string]interface{}{ | ||
"description": "Library as a collection of books", | ||
"label": "Library", | ||
"tag": "library", | ||
"writers": nil, | ||
}, | ||
map[string]interface{}{ | ||
"description": "Book", | ||
"label": "Book", | ||
"tag": "book", | ||
"writers": nil, | ||
}, | ||
map[string]interface{}{ | ||
"description": "Secret between Org2 and Org3", | ||
"label": "Secret", | ||
"readers": []interface{}{ | ||
"org2MSP", | ||
"org3MSP", | ||
}, | ||
"tag": "secret", | ||
"writers": nil, | ||
}, | ||
} | ||
err := invokeAndVerify(stub, "getSchema", nil, expectedResponse, 200) | ||
if err != nil { | ||
log.Println("getSchema fail") | ||
t.FailNow() | ||
} | ||
|
||
req := map[string]interface{}{ | ||
"assetType": "person", | ||
} | ||
expectedPersonSchema := map[string]interface{}{ | ||
"tag": "person", | ||
"label": "Person", | ||
"description": "Personal data of someone", | ||
"props": []interface{}{ | ||
map[string]interface{}{ | ||
"dataType": "cpf", | ||
"description": "", | ||
"isKey": true, | ||
"label": "CPF (Brazilian ID)", | ||
"readOnly": false, | ||
"required": true, | ||
"tag": "id", | ||
"writers": []interface{}{ | ||
"org1MSP", | ||
}, | ||
}, | ||
map[string]interface{}{ | ||
"dataType": "string", | ||
"description": "", | ||
"isKey": false, | ||
"label": "Name of the person", | ||
"readOnly": false, | ||
"required": true, | ||
"tag": "name", | ||
"writers": nil, | ||
}, | ||
map[string]interface{}{ | ||
"dataType": "datetime", | ||
"description": "", | ||
"isKey": false, | ||
"label": "Date of Birth", | ||
"readOnly": false, | ||
"required": false, | ||
"tag": "dateOfBirth", | ||
"writers": nil, | ||
}, | ||
map[string]interface{}{ | ||
"dataType": "number", | ||
"defaultValue": 0.0, | ||
"description": "", | ||
"isKey": false, | ||
"label": "Person's height", | ||
"readOnly": false, | ||
"required": false, | ||
"tag": "height", | ||
"writers": nil, | ||
}, | ||
}, | ||
} | ||
err = invokeAndVerify(stub, "getSchema", req, expectedPersonSchema, 200) | ||
if err != nil { | ||
log.Println("getSchema of person fail") | ||
t.FailNow() | ||
} | ||
} |
Oops, something went wrong.