Can't use hfc to invoke a transaction?
huhaiqing opened this issue · comments
- execute below test case, it returns OK.
test('Enroll Loan institution', function (t) {
getUser('loanInst', function (err, user) {
if (err) {
fail(t, "enroll loanInst", err);
// Exit the test script after a failure
process.exit(1);
}
loanInst = user;
loanInst.getUserCert(null, function (err, userCert) {
if (err) {
fail(t, "Failed getting Application certificate.");
// Exit the test script after a failure
process.exit(1);
}
loanInstCert = userCert;
pass(t, "enroll loan institution");
})
});
}); - USE loanInst to invoke a transaction, it returns error.
test("register Loan institution", function (t) {
t.plan(1);
console.log("Chaincode ID: %s", testChaincodeID);
var invokeRequest = {
// Name (hash) required for invoke
chaincodeID: testChaincodeID,
// Function to trigger
fcn: "register_loan_institution",
// Parameters for the invoke function
args: ['loanInst', loanInstCert.encode().toString('base64')],
userCert: loanInstCert,
confidential: true
};
console.log("loanInstCert: %s", loanInstCert.encode().toString('base64'));
var tx = loanInst.invoke(invokeRequest);
tx.on('submitted', function (results) {
// Invoke transaction submitted successfully
console.log("Successfully submitted chaincode invoke transaction");
});
tx.on('complete', function (results) {
console.log("invoke completed");
pass(t, "loanInst invoke");
});
tx.on('error', function (err) {
fail(t, "loanInst invoke", err);
// Exit the test script after a failure
process.exit(1);
});
});
//////Response output/////////////
register Loan institution
Chaincode ID: 76b9ae493f70cfdaa20224147ccfd673483130c07d1a1bc99dbc0bab361eea2fdbda1eb52b0ec05d5dc265c1593e5a0cb07c322e5fd337543237849e70bf7571
loanInstCert: MIICQjCCAeigAwIBAgIRAMagV3dGNkUKkHB62sKPqvIwCgYIKoZIzj0EAwMwMTELMAkGA1UEBhMCVVMxFDASBgNVBAoTC0h5cGVybGVkZ2VyMQwwCgYDVQQDEwN0Y2EwHhcNMTYwODExMTI0MjMwWhcNMTYxMTA5MTI0MjMwWjBFMQswCQYDVQQGEwJVUzEUMBIGA1UEChMLSHlwZXJsZWRnZXIxIDAeBgNVBAMTF1RyYW5zYWN0aW9uIENlcnRpZmljYXRlMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEHCRthrPwPJvHn4wWyg1pFagRPvlso6zDxyYVO/94so5q9ASpqU8wlzGeK88f09uIp34wQLENRGsILJA61knaf6OBzDCByTAOBgNVHQ8BAf8EBAMCB4AwDAYDVR0TAQH/BAIwADANBgNVHQ4EBgQEAQIDBDAPBgNVHSMECDAGgAQBAgMEME0GBioDBAUGBwEB/wRAqhPsfrnnL/VslO8L10JePC0U71bvyK9bBvhPVfu1SyJmadmF8wBLLVmDbDG6rDbWF9LppokEmF9+eZeZmmAINzA6BgYqAwQFBggEMF2pvUnRwL6Cfv/uJP76bJa8f/segSX4aPrtZPuc6e60gJFP9NShSprUUaGxQ20fHTAKBggqhkjOPQQDAwNIADBFAiEApmJBAhyHsyMOM75fwJ/vvgWZCYG+05DN6KWlRUAp9LECIDlvt5SCcmU0TeVCKEKRmGgjqGqlEAWm1+CCe+KhE71A
not ok 6 Failure: [loanInst invoke]: [[object Object]]
operator: fail
at: fail (/root/test_p2p.js:97:7)
...
not ok 7 [object Object]
operator: error
expected: |-
undefined
actual: |-
{ error: { msg: <Buffer 43 65 72 74 69 66 69 63 61 74 65 20 68 61 73 20 6e 6f 74 20 62 65 65 6e 20 73 69 67 6e 65 64 20 62 79 20 61 20 74 72 75 73 74 65 64 20 61 75 74 68 6f ... >, status: 'FAILURE' }, msg: 'Certificate has not been signed by a trusted authority. [x509: certificate signed by unknown authority (possibly because of "x509: ECDSA verification failure" while trying to verify candidate authority certificate "eca")]' }
at: fail (/root/test_p2p.js:98:7)
...
not ok 8 plan != count
operator: fail
expected: 1
actual: 2
...
root@peernode:~#
3.Could you help to tell us how to fix this issue ? thanks.
@huhaiqing Thanks for submitting this issue. However, we have transitioned issue tracking to Jira https://jira.hyperledger.org/ Please transfer this issue there and then close this one. Thanks!